Catchup to latest Symbian^4 GCC_SURGE
authorWilliam Roberts <williamr@symbian.org>
Thu, 22 Jul 2010 16:30:28 +0100
branchGCC_SURGE
changeset 55 cdd802add233
parent 28 011f79704660 (current diff)
parent 54 997a02608b3a (diff)
Catchup to latest Symbian^4
emailservices/emaildebug/inc/emailtraceconfig.hrh
emailservices/emailserver/inc/fsmailserverconst.h
emailservices/emailserver/inc/fsmailserverconst.hrh
emailservices/emailservermonitor/inc/emailshutdownconst.h
emailservices/emailservermonitor/inc/emailshutdownconst.hrh
emailservices/nmclientapi/inc/nmapicommonheader.h
emailservices/nmclientapi/inc/nmapiprivateheaders.h
emailuis/nmailui/conf/nmeditorview.docml
emailuis/nmailui/conf/nmmessagelistview.docml
emailuis/nmailuiengine/inc/nmmessagesearchlistmodel.h
emailuis/nmailuiengine/src/nmmessagesearchlistmodel.cpp
emailuis/nmframeworkadapter/inc/nmfwacheckoutboxoperation.h
emailuis/nmframeworkadapter/src/nmfwacheckoutboxoperation.cpp
emailuis/nmhswidget/conf/nmhswidgetmail.docml
emailuis/nmhswidget/conf/nmhswidgettitle.docml
inc/emailshutdownconst.h
inc/emailshutdownconst.hrh
inc/nmmessagesearchlistmodel.h
ipsservices/ipssosplugin/inc/ipsplgoperationwait.h
ipsservices/ipssosplugin/src/ipsplgoperationwait.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/email_client_api.metaxml	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<api id="df8c92b67351daff85c808d60deaccd2" dataversion="2.0">
+  <name>email client api</name>
+  <description>Email client api allows listing and accessing mailboxes and  email messages. Messages can be created, replied, forwared and searched. Specific mailbox can be launched in the Email application.</description>
+  <type>c++</type>
+  <collection>email_plat</collection>
+  <libs/>
+  <release category="platform" sinceversion="5.0"/>
+  <attributes>
+    <htmldocprovided>no</htmldocprovided>
+    <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/email_client_api.pri	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,35 @@
+#
+# 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>" \
+            "email_client_api/emailinterfacefactory.h       APP_LAYER_PLATFORM_EXPORT_PATH(emailinterfacefactory.h)" \
+            "email_client_api/emailinterfacefactory.inl     APP_LAYER_PLATFORM_EXPORT_PATH(emailinterfacefactory.inl)" \
+            "email_client_api/emailclientapi.hrh            APP_LAYER_PLATFORM_EXPORT_PATH(emailclientapi.hrh)" \
+            "email_client_api/emailapidefs.h                APP_LAYER_PLATFORM_EXPORT_PATH(emailapidefs.h)" \
+            "email_client_api/emailsorting.h                APP_LAYER_PLATFORM_EXPORT_PATH(emailsorting.h)" \
+            "email_client_api/mmessageiterator.h            APP_LAYER_PLATFORM_EXPORT_PATH(mmessageiterator.h)" \
+            "email_client_api/memailclientapi.h             APP_LAYER_PLATFORM_EXPORT_PATH(memailclientapi.h)" \
+            "email_client_api/memailmailbox.h               APP_LAYER_PLATFORM_EXPORT_PATH(memailmailbox.h)" \
+            "email_client_api/memailmessage.h               APP_LAYER_PLATFORM_EXPORT_PATH(memailmessage.h)" \
+            "email_client_api/memailfolder.h                APP_LAYER_PLATFORM_EXPORT_PATH(memailfolder.h)" \
+            "email_client_api/memailaddress.h               APP_LAYER_PLATFORM_EXPORT_PATH(memailaddress.h)" \
+            "email_client_api/memailcontent.h               APP_LAYER_PLATFORM_EXPORT_PATH(memailcontent.h)" \
+            "email_client_api/memailmessagesearch.h         APP_LAYER_PLATFORM_EXPORT_PATH(memailmessagesearch.h)" \
+            "email_client_api/mmailboxsyncobserver.h        APP_LAYER_PLATFORM_EXPORT_PATH(mmailboxsyncobserver.h)" \
+            "email_client_api/mmailboxcontentobserver.h     APP_LAYER_PLATFORM_EXPORT_PATH(mmailboxcontentobserver.h)"
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/emailapidefs.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,158 @@
+/*
+* 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: Email Client API definitions
+*
+*/
+
+#ifndef __EMAILAPIDEFS
+#define __EMAILAPIDEFS
+
+#include <e32base.h>
+#include <f32file.h>
+
+namespace EmailInterface {
+
+/**
+* Id for message, message part, folder and mailbox entries
+*/
+typedef TUint TEntryId;
+
+/**
+* Interface id. Each implementation of MEmailInterface has unique id value.
+*/
+typedef TInt TEmailTypeId;
+
+const TEntryId KUndefinedEntryId = 0;
+
+/**
+ * base interface for all email interfaces available to clients
+ * @since S60 v5.0
+ */
+class MEmailInterface
+{
+public:
+    /** returns interface id (kind of RTTI) */
+    virtual TEmailTypeId InterfaceId() const = 0;
+
+    /** frees memory allocated by interface impl. */    
+    virtual void Release() = 0;
+};
+
+/**
+ * Defines abstraction for entry ID. Used by message, folder, mailbox etc types.
+ * @since S60 v5.0
+ */
+class TBaseId
+{
+public:
+    inline TBaseId() : iId( KUndefinedEntryId ){}
+    inline TBaseId( TEntryId aId ) : iId( aId ){}
+    
+    TEntryId   iId;
+};
+
+/**
+ * Defines mailbox ID
+ * @since S60 v5.0
+ */
+class TMailboxId : public TBaseId  
+{
+public:
+    inline TMailboxId() : 
+        TBaseId(){}
+    inline TMailboxId( TEntryId aId ) : TBaseId( aId ){}
+    inline TBool operator==( const TMailboxId& aMailboxId ) const {
+        return ( aMailboxId.iId == iId ); }
+};
+
+/**
+ * Defines folder ID which is associated with a mailbox
+ * @since S60 v5.0
+ */
+class TFolderId : public TBaseId
+{
+public:
+    // parent mailbox
+    TMailboxId iMailboxId;
+    inline TFolderId( TEntryId aId, const TMailboxId& aMailboxId ) : 
+        TBaseId( aId ),iMailboxId( aMailboxId.iId ){}
+        
+    inline TFolderId() : TBaseId(), iMailboxId() {}
+    
+    inline TBool operator==( const TFolderId& aFolderId ) const {
+        return ( iMailboxId.iId == aFolderId.iMailboxId.iId &&
+        iId == aFolderId.iId ); }
+        
+    inline TBool operator!=( const TFolderId& aFolderId ) const {
+        return !( aFolderId == *this ); }
+};
+
+/**
+ * Defines email message ID which is associated with a mailbox and folder
+ * @since S60 v5.0
+ */
+class TMessageId : public TBaseId
+{
+public:
+    inline TMessageId() : TBaseId(), iFolderId(){}
+    
+    inline TMessageId( TEntryId aMsgId, TEntryId aFolderId, TMailboxId aMailboxId ) : 
+    TBaseId( aMsgId ), iFolderId( aFolderId, aMailboxId ){}
+
+    inline TBool operator==( const TMessageId& aMessageId ) const {
+        return ( iFolderId == aMessageId.iFolderId &&
+        iId == aMessageId.iId ); }
+        
+    inline TBool operator!=( const TMessageId& aMessageId ) const {
+        return !( aMessageId == *this ); }
+    
+    /**
+    * parent folder id.
+    */
+    TFolderId iFolderId;
+};
+
+
+/**
+ * Message content (part) id
+ * @since S60 v5.0
+ */
+class TMessageContentId : public TBaseId
+{
+public:
+    inline TMessageContentId(): TBaseId(), iMessageId() {}
+    
+    inline TMessageContentId( TEntryId aContentId, TEntryId aMsgId, TEntryId aFolderId, TMailboxId aMailboxId ) : 
+    TBaseId( aContentId ), iMessageId( aMsgId, aFolderId, aMailboxId ){}
+    
+    inline TBool operator==( const TMessageContentId& aContentId ) const {
+        return ( iMessageId == aContentId.iMessageId &&
+        iId == aContentId.iId ); }
+        
+    inline TBool operator!=( const TMessageContentId& aContentId ) const {
+        return !( aContentId == *this ); }
+    
+    // parent message
+    TMessageId iMessageId;
+};
+
+typedef RArray<TMessageId> REmailMessageIdArray;
+
+typedef RArray<TFolderId>  REmailFolderIdArray;
+
+typedef RArray<TMailboxId>     REmailMailboxIdArray;
+
+} // EmailInterface
+
+#endif // __EMAILAPIDEFS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/emailclientapi.hrh	Thu Jul 22 16:30:28 2010 +0100
@@ -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: Interface IDs for sub interfaces
+*
+*/
+
+#ifndef __EMAILCLIENTAPI_HRH
+#define __EMAILCLIENTAPI_HRH
+
+// ECom interface UID for email API
+#define KEmailClientFactoryApiUid 0x20022D62
+
+
+// Interface ids (not ECom) for accessing "sub interfaces" via
+// MEmailInterface* CEmailInterfaceFactory::InterfaceL( const TInt aInterfaceId )
+// to be checked if all should be published to clients (some are not
+// meant to be instantiated via factory method but by other means, e.g. 
+// user never instantiates mailbox from scratch but asks it from MEmailClientApi
+
+#define KEmailClientApiInterface 0x20022D63
+#define KEmailIFUidMailbox 0x20022D64
+#define KEmailIFUidMessage 0x20022D65
+#define KEmailIFUidFolder 0x20022D66
+#define KEmailIFUidAddress 0x20022D67
+#define KEmailIFUidMessageContent 0x20022D68
+#define KEmailIFUidSearch 0x20022D69
+#define KEmailIFUidTextContent 0x20022D6B
+#define KEmailIFUidMessageIterator 0x20022D6C
+#define KEmailIFUidMultipart 0x20022D6D
+#define KEmailIFUidAttachment 0x20022D6E
+
+
+#endif // __EMAILCLIENTAPI_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/emailinterfacefactory.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,119 @@
+/*
+* 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: ECom interface for Email Client API
+*
+*/
+
+
+#ifndef CEMAILINTERFACEFACTORY_H
+#define CEMAILINTERFACEFACTORY_H
+
+#include <e32base.h>
+#include <ecom/ecom.h>
+#include <memailclientapi.h>
+#include <memailcontent.h>
+
+namespace EmailInterface {
+    
+/**
+ * ECom factory class for Email Client API.
+ * @since S60 v5.0
+ * 
+ */
+NONSHARABLE_CLASS( CEmailInterfaceFactory ) : public CBase
+{
+public:       
+        
+    /**
+     * Contructor
+     * @return factory for creating interface instances.
+     */
+    inline static CEmailInterfaceFactory* NewL();
+    
+    /**
+    * destructor
+    */
+    inline ~CEmailInterfaceFactory();
+    
+    /**
+    * Returns email interface pointer by id
+    * @param aInterfaceId interface id, see emailclientapi.hrh for available ids
+    * @return pointer to interface
+    * @exception KErrNotFound if unkown interface id is given
+    *
+    * @code
+    
+     #include <emailinterfacefactory.h>
+    
+     using namespace EmailInterface;
+     
+     CEmailInterfaceFactory* factory = CEmailInterfaceFactory::NewL();
+     CleanupStack::PushL( factory );
+     MEmailInterface* ifPtr = factory->InterfaceL( KEmailClientApiInterface );
+     MEmailClientApi* clientApi = static_cast<MEmailClientApi*>( ifPtr );
+     CleanupReleasePushL( *clientApi );
+     // <do something with clientApi...>
+     CleanupStack::PopAndDestroy( 2 ); // clientApi and factory
+     @endcode
+    * 
+    */
+    virtual EmailInterface::MEmailInterface* InterfaceL(  
+        const TInt aInterfaceId ) = 0;
+
+private:
+    
+        // Unique instance identifier key
+        TUid iDtor_ID_Key;
+};
+
+    
+/**
+ * Cleanup support for pointer arrays with MEmailInterface elements which are 
+ * destroyed with Release() method.
+ * @since S60 v5.0
+   @code
+       using namespace EmailInterface;
+ 
+       RMailboxPtrArray mailboxes; // array of MEmailMailbox pointers
+       // note: PushL can take any pointer array of elements with Release()
+       // method
+       CleanupResetAndRelease<MEmailMailbox>::PushL( mailboxes );
+      // <here some code that might leave>
+       mailClient->GetMailboxesL( mailboxes );
+ 
+       // MEmailMailbox::Release() called for each array element and then
+       // mailboxes.Reset() is called 
+       CleanupStack::PopAndDestroy();  
+   @endcode
+ */
+template<class T>
+NONSHARABLE_CLASS( CleanupResetAndRelease )
+{
+public:
+    /**
+     * Cleanup for elements containing Release() method  
+     */
+    inline static void PushL( RPointerArray<T>& aItem );
+
+    /**
+     * Releases array elements and resets array.
+     */
+    inline static void ResetAndRelease( TAny* aPtr );  
+};
+
+#include "emailinterfacefactory.inl"
+
+} // namespace EmailInterface
+
+#endif // CEMAILINTERFACEFACTORY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/emailinterfacefactory.inl	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,90 @@
+/*
+* 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:  ECom interface for email interface factory inline implementation
+*
+*/
+
+#include "emailclientapi.hrh"
+
+// LOCAL FUNCTIONS
+
+inline void ResetAndDestroyCleanup( TAny* aAny )
+    {
+    RImplInfoPtrArray* ptrArray = reinterpret_cast<RImplInfoPtrArray*>( aAny );
+    ptrArray->ResetAndDestroy();
+    }
+
+inline void CleanupResetAndDestroyPushL( RImplInfoPtrArray& aArray )
+    {
+    TCleanupItem item( &ResetAndDestroyCleanup, &aArray );
+    CleanupStack::PushL( item );
+    }
+
+// ============================= MEMBER FUNCTIONS =============================
+
+// ----------------------------------------------------------------------------
+// CEmailInterfaceFactory::NewL
+// Two-phased constructor
+// ----------------------------------------------------------------------------
+//
+inline CEmailInterfaceFactory* CEmailInterfaceFactory::NewL( )
+    {
+    // Find implementation for our interface.
+    RImplInfoPtrArray implArray;
+    EmailInterface::CleanupResetAndDestroyPushL( implArray );
+    const TUid ifUid = {KEmailClientFactoryApiUid};
+    REComSession::ListImplementationsL(
+                            ifUid,
+                            implArray );
+    // there should be only one impl so take first
+    TAny* interface = NULL;
+    if ( implArray.Count() )
+        {
+        const TUid uid = implArray[0]->ImplementationUid();        
+        interface = REComSession::CreateImplementationL( 
+            uid, _FOFF( CEmailInterfaceFactory, iDtor_ID_Key ) );
+        }
+    CleanupStack::PopAndDestroy(); // implArray
+        
+    return reinterpret_cast<CEmailInterfaceFactory*>( interface );
+    }
+
+// ----------------------------------------------------------------------------
+// CEmailInterfaceFactory::~CEmailInterfaceFactory
+// Destructor
+// ----------------------------------------------------------------------------
+//
+inline CEmailInterfaceFactory::~CEmailInterfaceFactory()
+    {
+    REComSession::DestroyedImplementation( iDtor_ID_Key );
+    }
+
+template<class T>
+inline void CleanupResetAndRelease<T>::PushL( RPointerArray<T>& aItem ) { 
+     TCleanupItem item( &CleanupResetAndRelease<T>::ResetAndRelease, &aItem );
+     CleanupStack::PushL( item );
+ }
+template<class T>
+inline void CleanupResetAndRelease<T>::ResetAndRelease( TAny* aPtr )
+     {
+     RPointerArray<T>* array = reinterpret_cast<RPointerArray<T>* >( aPtr );
+     for ( TInt i = 0; i < array->Count(); i++ )
+         {
+         T* item = (*array)[i];
+         item->Release();
+         }
+     array->Reset();
+     }
+
+// End Of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/emailsorting.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* 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: Email Client sort criteria definition
+*
+*/
+
+#ifndef EMAILSORTING
+#define EMAILSORTING
+
+#include <e32base.h>
+
+namespace EmailInterface {
+
+/**
+* Sort criteria used in searching messages with MEmailMessageSearchAsync 
+* declared in memailmessagesearch.h.
+*/
+class TEmailSortCriteria
+{
+public:
+    /**
+    * Fields for sort criteria
+    */
+    enum TSortField {
+        EDontCare,
+        EByDate,
+        EBySender,
+        EByRecipient,
+        EBySubject,
+        EByPriority,
+        EByFlagStatus,
+        EByUnread,
+        EBySize,
+        EByAttachment,
+    };
+    
+    // is ascending sort order
+    TBool iAscending;
+    
+    // sort by field
+    TSortField iField; 
+
+    inline TEmailSortCriteria() : iAscending( ETrue ), iField( EDontCare ) {}
+};
+
+typedef RArray<TEmailSortCriteria> RSortCriteriaArray;
+
+} // EmailInterface
+
+#endif // EMAILSORTING
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailaddress.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* 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: Email address in Email Client API
+*
+*/
+
+#ifndef MEMAILADDRESS_H
+#define MEMAILADDRESS_H
+
+#include <emailapidefs.h>
+
+namespace EmailInterface {
+
+/**
+ * Email address that is used as recipient or sender in MEmailMessage and
+ * mailbox address in MEmailMailbox.
+ * @since S60 v5.0
+ */
+class MEmailAddress : public MEmailInterface
+{ 
+public:
+    /**
+     * Association role of the address in message/mailbox.
+     */
+    enum TRole { 
+        // role is undefined
+        EUndefined, 
+        // reply-to address in a message
+        EReplyTo, 
+        // sender of a message
+        ESender, 
+        // to-recipient of a message
+        ETo, 
+        // cc-recipient of a message
+        ECc, 
+        // bcc-recipient of a message
+        EBcc };
+    
+    /**
+     * Sets email address
+     * @param email address 
+     */
+    virtual void SetAddressL( const TDesC& aAddress ) = 0;
+    
+    /**
+     * Returns email address
+     * @return email address
+     */
+    virtual TPtrC Address() const = 0;
+    
+    /**
+     * Sets display name for the address
+     * @param display name
+     */
+    virtual void SetDisplayNameL( const TDesC& aDisplayName ) = 0;
+    
+    /**
+     * Returns display name for the address
+     * @return display name
+     */
+    virtual TPtrC DisplayName() const = 0;
+    
+    /**
+     * Returns role associated with the address
+     * @return role
+     */
+    virtual TRole Role() const = 0;
+    
+    /**
+     * Sets role
+     * @param role
+     */
+    virtual void SetRole( const TRole aRole ) = 0;
+};
+
+typedef RPointerArray<MEmailAddress>    REmailAddressArray;
+
+} // namespace EmailInterface {
+
+#endif // MEMAILADDRESS_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailclientapi.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,78 @@
+/*
+* 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: ECom interface for Email Client API
+*
+*/
+
+
+#ifndef MEMAILCLIENTAPI_H
+#define MEMAILCLIENTAPI_H
+
+#include <emailapidefs.h>
+
+namespace EmailInterface {
+
+class MEmailMailbox;
+
+
+typedef RPointerArray<MEmailMailbox> RMailboxPtrArray;
+
+/**
+ * Email client main interface for accessing mailboxes and launching
+ * email editor and viewer.
+ * Use CEmailInterfaceFactory::InterfaceL( KEmailClientApiInterface )
+ * to get instance. Use Release() (from MEmailInterface) when the instance 
+ * is no more needed.
+ * 
+ */
+class MEmailClientApi : public MEmailInterface
+{
+public:
+    
+    /** returns mailbox by id, ownership transferred */
+    virtual MEmailMailbox* MailboxL( const TMailboxId& aId ) = 0;
+    
+    /** 
+     * Conveninence method for accessing mailbox by own addresss.
+     */
+    virtual MEmailMailbox* MailboxL( const TPtrC& aAddress ) = 0;
+        
+    /**
+    * Gets all mailboxes in pointer array. It is recommended to free other
+    * mailboxes besides needed one to optimise memory usage.
+    */    
+    virtual TInt GetMailboxesL( RMailboxPtrArray& aMailboxes ) = 0;
+
+    /**
+    * Launch policy defines behavior when launching email application
+    */
+    enum TLaunchPolicy {
+        // Launch email application as from menu application by the user
+        EDefault,
+        // Shows inbox with unseen messages. If there are no unseen messages
+        // behavior is same as EDefault. This one is not currently supported.
+        EShowLastUnseenMailbox
+    };
+    /**
+     * Launches Email application with defined launch behavior
+     * The method follows "fire and forget" pattern, returns immediately.
+     * @param aPolicy defines behavior for app launch
+     */
+    virtual void LaunchEmailL( const TLaunchPolicy aPolicy ) = 0;
+
+};
+
+}  // namespace EmailInterface
+
+#endif // MEMAILCLIENTAPI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailcontent.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,289 @@
+/*
+* 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: ECom interface for Email Client API
+*
+*/
+
+#ifndef MEMAILCONTENT_H
+#define MEMAILCONTENT_H
+
+#include <emailapidefs.h>
+
+namespace EmailInterface {
+
+_LIT( KContentTypeTextPlain, "text/plain" );
+_LIT( KContentTypeTextHtml, "text/html" );
+
+class MEmailOperationObserver;
+class MEmailAttachment;
+class MEmailMultipart;
+class MEmailTextContent;
+class MEmailMessageContent;
+
+/**
+* Callback interface used for content fetching asynchronously.
+* Object deriving this interface is passed to MEmailMessageContent::FetchL
+* @since S60 v5.0
+*/
+class MEmailFetchObserver
+{
+public:
+    /** Content fetched
+    * @param operation result 
+    */
+    virtual void DataFetchedL( const TInt aResult ) = 0;
+};
+
+typedef RPointerArray<MEmailMessageContent> REmailContentArray;
+
+/**
+* Base interface for mime message parts.
+* @since S60 v5.0
+*/
+class MEmailMessageContent : public MEmailInterface
+{
+public:
+    /** numeric identifier of message content */
+    virtual TMessageContentId Id() const = 0;
+
+// fields as per RFC 2045
+    /**
+     * return sContent-Type field value
+     */
+    virtual TPtrC ContentType() const = 0;
+
+    /**
+     * sets value of Content-Type field
+     * @param content type
+     */
+    virtual void SetContentType( const TDesC& aContentType ) = 0;
+
+    /**
+    /* Returns Content-ID field value.
+     * @return content id
+     */
+    virtual TPtrC ContentId() const = 0;
+
+    /**
+     * Sets value of Content-ID field
+     * @param content id
+     */
+    virtual void SetContentId( const TDesC& aContentId ) = 0;
+
+    /**
+     * Returns value of content-description field
+     * @return content description 
+     */
+    virtual TPtrC ContentDescription() const = 0;
+
+    /**
+     * Sets value of content description field
+     * @param content description 
+     */
+    virtual void SetContentDescription( const TDesC& aContentDescription ) = 0;
+
+    /**
+     * Returns value of content disposition field
+     * @return content disposition
+     */
+    virtual TPtrC ContentDisposition() const = 0;
+
+    /**
+     * Sets value of content-disposition field
+     * @param content disposition
+     */
+    virtual void SetContentDisposition( const TDesC& aContentDisposition ) = 0;
+
+// end of standard  RFC 2045 fields
+
+    /**
+     * returns Content-class field value (non-standard)
+     */
+    virtual TPtrC ContentClass() const = 0;
+
+    /**
+     * Sets value of Content-class field (non-standard)
+     * @param content class
+     */
+    virtual void SetContentClass( const TDesC& aContentClass ) = 0;
+
+    /**
+     * Available (=fetched) size accessor. If this is less than value from
+     * TotalSize(), Fetch() should be used to retrieve more data from
+     * remote mail server.
+     * @return fetched size of the data.
+     */
+    virtual TInt AvailableSize() const = 0;
+
+    /**
+     * Total size accessor
+     * @return total size of message text.
+     */
+    virtual TInt TotalSize( ) const = 0;
+
+    /**
+     * Returns pointer descriptor to content data
+     */
+    virtual TPtrC ContentL() const = 0;
+
+    /**
+     * Sets content data.
+     */
+    virtual void SetContentL( const TDesC& aContent ) = 0;
+
+    /**
+     * Starts fetching rest of content asynchronously.
+     *
+     * If available size after fetch is smaller than total size, next chunk can
+     * be fetched with new invocatin of Fetch method.
+     *
+     * Calling Release() implicitly cancels fetching.
+     * @param aObserver called when when fetch completes.
+     * @exception KErrInUse if fetch is ongoing
+     */
+    virtual void FetchL( MEmailFetchObserver& aObserver ) = 0;
+
+    /**
+     * Cancels fetch operation, observer is not called
+     */
+    virtual void CancelFetch() = 0;
+
+    /**
+     * Stores message content to a file
+     */
+    virtual void SaveToFileL( const TDesC& aPath ) = 0;
+
+    /**
+     * Typesafe multipart accessor for obtaining MEmailMultipart pointer
+     * to this object.
+     * @param content as multipart or NULL if content is not multipart
+     */
+    virtual MEmailMultipart* AsMultipartOrNull() const = 0;
+
+    /**
+     * Typesafe text content accessor for obtaining MEmailTextContent pointer
+     * to this object.
+     * @param content as text content or NULL if content is not text
+     */
+    virtual MEmailTextContent* AsTextContentOrNull() const = 0;
+
+    /**
+     * Typesafe attachment content accessor for obtaining MEmailAttachment pointer
+     * to this object.
+     * @param content as attachment content or NULL if content is not an attachment
+     */
+    virtual MEmailAttachment* AsAttachmentOrNull() const = 0;
+};
+
+/**
+* Convenience abstraction for manipulating plain or html text content. Use
+* CEmailInterfaceFactory::InterfaceL( KEmailIFUidTextContent ) to make new
+* instance of this interface.
+* @since S60 v5.0
+*/
+class MEmailTextContent : public MEmailMessageContent
+{
+public:
+    /**
+     * Text (content) type 
+     */
+    enum TTextType {
+        EPlainText, // text/plain
+        EHtmlText   // text/html
+    };
+
+    /**
+    * Tells if content has specified type of text.
+    */
+    virtual TTextType TextType() const = 0;
+
+    /**
+    * Sets (replaces) text to message content. Possible old content is
+    * deleted. Content type is set to "text/plain" or "text/html" based on
+    * specified text type.
+    * @param aPlainOrHtml sub-type of the text
+    * @param aText content of the message part
+    */
+    virtual void SetTextL(
+        const TTextType aPlainOrHtml,
+        const TDesC& aText ) = 0;
+};
+
+/**
+* Message part with multiple sub parts. If MEmailMessage::ContentL returns
+* content with type "multipart/*" (where '*' is a character sequence) it can
+* safely be casted to MEmailMultipart
+* @since S60 v5.0
+*/
+class MEmailMultipart : public MEmailMessageContent
+{
+public:
+    /**
+    * Returns number of child parts
+    */
+    virtual TInt PartCountL() = 0;
+
+    /**
+    * Returns a child part, ownership is transferred.
+    * @param aIndex part to return, leaves KErrArgument if out of bounds
+    */
+    virtual MEmailMessageContent* PartByIndexL( const TUint aIndex ) const = 0;
+
+    /**
+    * Deletes part by index.
+    * @param aIndex part to delete, leaves KErrArgument if out of bounds
+    */
+    virtual void DeletePartL( const TUint aIndex ) = 0;
+
+    /**
+    * Adds message part, ownership is transferred.
+    * @param aPart any object derived from MEmailMessageContent
+    * @param aPos position among child parts
+    */
+    virtual void AddPartL(
+        const MEmailMessageContent& aPart,
+        const TUint aPos ) = 0;
+};
+
+typedef RPointerArray<MEmailAttachment> REmailAttachmentArray;
+
+/**
+* Email attachment interface
+* Attachment is created with MEmailMessage::AddAttachmentL()
+* @since S60 v5.0
+*/
+class MEmailAttachment : public MEmailMessageContent
+{
+public:
+      /**
+      * Returns file handle of this attachment. If the attachment is
+      * not associated with a file, null file handle is returned.
+      */
+      virtual RFile FileL() const = 0;
+
+      /**
+      * Sets file name field
+      */
+      virtual void SetFileNameL( const TDesC& aFileName ) = 0;
+
+      /**
+      * Returns file name or null pointer descriptor if attachment
+      * is not associated with any file
+      */
+      virtual TPtrC FileNameL() const = 0;
+};
+
+} // namespace EmailInterface
+
+#endif // MEMAILCONTENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailfolder.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,107 @@
+/*
+* 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: Email message API
+*
+*/
+
+#ifndef _M_EMAILFOLDER
+#define _M_EMAILFOLDER
+
+#include <emailapidefs.h>
+#include <emailsorting.h>
+
+namespace EmailInterface {
+
+class MEmailFolder;
+class MMessageIterator;
+
+typedef  RPointerArray<MEmailFolder> RFolderArray;
+
+/**
+* folder types
+*/
+enum TFolderType
+    {
+    EInbox,
+    EOutbox,
+    EDrafts,
+    EDeleted,
+    ESent,
+    EOther
+    };
+
+/**
+* Email folder interface 
+* This is used for accessing folder information and included messages.
+* Operations affecting folder itself are not provided.
+*
+* Use case: for accessing messages in specific folder use MEmailMessageQuery
+* and set folder id with MEmailMessageQuery::SetFolderIdL()
+*
+* @since S60 v5.0
+*/
+class MEmailFolder : public MEmailInterface
+{
+public:
+    /**
+    * Returns folder id.
+    * @return folder type
+    */
+    virtual TFolderId FolderId() const = 0;
+    
+    /**
+    * Returns parent folder id.
+    * @return parent folder id
+    */
+    virtual TFolderId ParentFolderId() const = 0;
+    
+    /**
+    * Returns folder type.
+    * @return folder type
+    */
+    virtual TFolderType FolderType() const = 0;    
+
+    /**
+    * Returns folder name.
+    * @return folder name pointer descriptor
+    */
+    virtual TPtrC Name() const = 0;
+
+    /**
+    * Returns direct children of this folder, i.e. this is not recursive.
+    * @return number of subfolders or an error code
+    */    
+    virtual TInt GetSubfoldersL( 
+        RFolderArray& aSubfolders ) const = 0;
+
+    /**
+    * Returns message iterator for iterating messages in the folder
+    * @param aSortCriteria sort criteria
+    * @return message iterator
+    */
+    virtual EmailInterface::MMessageIterator* MessagesL( 
+        const RSortCriteriaArray& aCriteria ) = 0;
+    
+    /**
+    * Deletes messages in this folder
+    * @param aMessageIds messages to delete. This method is no-op if
+    * array is empty. It is expected that messages in the array are
+    * located in same folder or KErrArgument exception is raised.
+    */
+    virtual void DeleteMessagesL( const REmailMessageIdArray& aMessageIds ) = 0;
+};
+
+} // namespace EmailInterface
+
+#endif // _M_EMAILFOLDER
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailmailbox.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,159 @@
+/*
+* 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: Email message API
+*
+*/
+
+#ifndef MEMAILMAILBOX_H
+#define MEMAILMAILBOX_H
+
+#include <memailfolder.h>
+
+namespace EmailInterface {
+
+class MEmailAddress;
+class MEmailMessage;
+class MMailboxContentObserver;
+class MEmailMessageSearchAsync;
+class MMailboxSyncObserver;
+
+/**
+* Email mailbox interface.
+* MEmailMailbox cannot be instantiated with factory method. Use
+* MEmailClientApi::MailboxL to obtain a configured mailbox.
+* @since S60 v5.0
+*/
+class MEmailMailbox : public MEmailInterface
+{
+public:
+    /**
+    * Returns mailbox identifier
+    * @return mailbox id
+    */
+    virtual TMailboxId MailboxId() const = 0;
+
+    /**
+    * Returns own address of the mailbox. Role is set to ESender
+    * @return address, ownership not transferred
+    */
+    virtual MEmailAddress* AddressL() const = 0;
+
+    /**
+    * Returns mailbox name
+    * @return mailbox name
+    */
+    virtual TPtrC MailboxName() const = 0;
+
+    /** returns root level folders of this mailbox, to get subfolders of specific
+     * folder, use MEmailFolder::GetSubfolders
+     * @param aFolders pointer array of folders, ownership of folders is
+     * transferred
+     * @return number of folders in aFolders or Symbian OS error code
+     */
+    virtual TInt GetFoldersL( RFolderArray& aFolders ) const = 0;
+
+    /**
+    * Returns folder by folder id
+    * @param folder id
+    * @return pointer to folder, ownership is transferred
+    */
+    virtual MEmailFolder* FolderL( const TFolderId& aFolderId ) const = 0;
+
+    /**
+    * Returns folder by type
+    * @param type other than EOther because it is ambiguous
+    * @return pointer to folder, ownership is transferred
+    * @exception KErrNotFound if folder of requested type is not found
+    */
+    virtual MEmailFolder* FolderByTypeL(
+        const TFolderType aFolderType ) const = 0;
+
+    /**
+    * Returns existing message in this mailbox.
+    * @param aMessageId a message id returned by GetMessagesIdsL()
+    * @return new message object, ownership transferred.
+    * @exception
+    */
+    virtual MEmailMessage* MessageL( const TMessageId& aMessageId ) = 0;
+
+    /**
+     * Creates new message in 'drafts' folder. Ownership is transferred
+     * @return new draft message
+     */
+    virtual MEmailMessage* CreateDraftMessageL() const = 0;
+
+    /**
+     * Creates reply message. Ownership is transferred
+     * @param aMessageId original message
+     * @param aReplyToAll If ETrue, all recipients of the original message are
+     *        added to reply message.
+     * @return new draft message
+     */
+    virtual MEmailMessage* CreateReplyMessageL(
+        const TMessageId& aMessageId,
+        const TBool aReplyToAll = ETrue ) const = 0;
+
+    /**
+     * Creates forward message. Ownership is transferred
+     * @param aMessageId original message
+     * @return new draft message
+     */
+    virtual MEmailMessage* CreateForwardMessageL(
+        const TMessageId& aMessageId ) const = 0;
+
+    /**
+     * Starts synchronising this mailbox
+     * @param aObserver observer called back when sync is complete
+     */
+    virtual void SynchroniseL( MMailboxSyncObserver& aObserver ) = 0;
+
+    /**
+     * Cancels mailbox synchronisation.
+     */
+    virtual void CancelSynchronise() = 0;
+
+    /**
+    * Returns interface for searching messages from this mailbox. Ownership
+    * is transferred.
+    * @return message search interface pointer
+    */
+    virtual MEmailMessageSearchAsync* MessageSearchL() = 0;
+
+    /**
+     * Launches Email application and shows inbox.
+     * The method follows "fire and forget" pattern, returns immediately.
+     */
+    virtual void ShowInboxL() = 0;
+
+    /** Launches email editor and returns immediately.
+     * The method follows "fire and forget" pattern, returns immediately.
+     */
+    virtual void EditNewMessageL() = 0;
+    
+    /** Register mailbox observer 
+     * @param aObserver observer called back when changes in mailbox (new message,
+     * messages changes or messages deleted).
+     * */
+    virtual void RegisterObserverL( MMailboxContentObserver& aObserver ) = 0;
+        
+    /** 
+     * Unregister mailbox observe.r 
+     */
+    virtual void UnregisterObserver( MMailboxContentObserver& aObserver ) = 0;
+
+};
+
+} // namespace EmailInterface
+
+#endif // MEMAILMAILBOX_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailmessage.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,262 @@
+/*
+* 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: Email message API
+*
+*/
+
+#ifndef MEMAILMESSAGE_H
+#define MEMAILMESSAGE_H
+
+#include <emailapidefs.h>
+#include <memailaddress.h>
+#include <memailcontent.h>
+
+namespace EmailInterface {
+
+class MEmailMessageContent;
+class MEmailAttachment;
+
+/** message flags */  
+enum TMsgFlag
+    {
+    EFlag_Read = 1,                 // Message is read (or "seen") on the server
+    EFlag_Read_Locally = 2,         // Message is read on the client
+    EFlag_Low = 4,                  // Message has low priority
+    EFlag_Important = 8,            // Message has high priority
+    EFlag_FollowUpComplete = 16,    // The message follow-up is complete
+    EFlag_FollowUp = 32,            // Message is flagged (a flag is showing next to msg in Outlook)
+    EFlag_Attachments = 64,         // Message has attachments
+    EFlag_Multiple = 128,           // Message has more than one recipient
+    EFlag_CalendarMsg = 256,        // Message is a calendar message
+    EFlag_Answered = 512,           // The message was replied to
+    EFlag_Forwarded = 1024,         // The message was forwarded
+    EFlag_OnlyToMe = 2048,          // The message was sent only to this user
+    EFlag_RemoteDeleted = 4096,     // The message has been deleted on the server
+    EFlag_HasMsgSender = 8192,      // The message has one or more senders 
+    };
+/**
+ * MEmailMessage is email message abstraction
+ * @since S60 v5.0
+   @code
+     Create and send a message with attachment:
+ 
+     using namespace EmailInterface;
+     CEmailInterfaceFactory* factory = CEmailInterfaceFactory::NewL();
+     CleanupStack::PushL( factory );
+     MEmailClientApi* emailAPI = factory->InterfaceL( KEmailTypeClientAPI );
+     CleanupReleasePushL( *emailAPI );
+     RMailboxPtrArray mailboxes;
+     // Cleanup for array containing mailbox pointers, 
+     // calls MEmailMailbox::Release() on cleanup.
+     CleanupResetAndRelease<MEmailMailbox>::PushL( mailboxes );
+     if ( emailAPI->GetMailboxesL( mailboxes ) > 0 ) // at least one found
+         {
+         MEmailMailbox* mailbox = mailboxes[0];
+         MEmailMessage* message = mailbox->CreateDraftMessageL();
+         CleanupReleasePushL( *message );
+         message->SetPlainTextBodyL( _L("So say we all!") );
+         message->AddAttachmentL( _L( "BSG.png" ) ); 
+         message->SendL();
+         CleanupStack::PopAndDestroy(); // message
+         }    
+    CleanupStack::PopAndDestroy( 3 ); // mailboxes, emailAPI, factory
+  @endcode
+  *
+  */
+class MEmailMessage : public MEmailInterface
+{
+public:
+    /**
+     * Returns message id
+     * @return message id
+     */
+    virtual const TMessageId& MessageId() const = 0;
+ 
+    /** 
+     * Returns sender address, ownership is not transferred
+     * Setting role to MEmailAddress::EUndefined marks sender field "undefined"
+     */
+    virtual MEmailAddress* SenderAddressL() const = 0;        
+        
+    /**
+     * Returns reply-to address (NULL for newly created draft message).
+     * Ownership is not transferred. Setting role to MEmailAddress::EUndefined 
+     * marks reply-to field "undefined".
+     */    
+    virtual MEmailAddress* ReplyToAddressL() const = 0;
+    
+    /**
+     * Sets reply-to address, note that role of the address is ignored.
+     * Ownership is not transferred.
+     */
+    virtual void SetReplyToAddressL( const MEmailAddress& aSender ) = 0;       
+        
+    /**
+     * Returns recipients. Ownership is transferred.
+     * @param aRole, if EUndefined - returns to,cc and bcc recipients in that order
+     * @return number of recipients returned in array
+     * @exception returns KErrArgument if aRole is EReplyTo or ESender
+     */    
+    virtual TInt GetRecipientsL( const MEmailAddress::TRole aRole,
+        REmailAddressArray& aRecipients ) const = 0;
+    
+    /**
+     * Sets and replaces recipients of specific type.
+     * @param aRole to, cc or bcc, for other types leave KErrArgument
+     * @return recipient added to this message. Ownership is not transferred.
+     */
+    virtual void SetRecipientsL( const MEmailAddress::TRole aRole, REmailAddressArray& aRecipients ) = 0;    
+    
+    /** removes recipient from the message
+     * @param aRecipient that has been obtained by GetRecipients().
+     * Comparison of recipients and aRecipient is done based on 
+     * MEmailAddress::Address() and MEmailAddress::Role().
+     * @exception KErrNotFound if aRecipient doesn't match with existing 
+     * recipients.
+     */
+    virtual void RemoveRecipientL( const MEmailAddress& aRecipient ) = 0;
+    
+    /**
+     * Returns subject
+     * @return subject of the message
+     */
+    virtual TPtrC Subject() const = 0;
+
+    /**
+     * Sets subject
+     * @param subject of the message 
+     */
+    virtual void  SetSubjectL( const TPtrC& aSubject) = 0;    
+    
+    /**
+     * Returns date and time of the message.
+     * @return message date/time 
+     */
+    virtual TTime Date() const = 0;
+
+    /**
+     * Returns message flags
+     * @return message flags
+     */
+    virtual TInt Flags() const = 0;
+    
+    /**
+     * Sets a message flag
+     * @param flag to set
+     */
+    virtual void SetFlag( const TUint aFlag ) = 0;
+    
+    /**
+     * Resets a message flag to zero
+     * @param flag to reset
+     */
+    virtual void ResetFlag( const TUint aFlag ) = 0;
+
+// content
+    /**      
+     * Returns message body
+     * Returns pointer to message content, ownership not transferred.
+     * Actual type is MEmailTextContent, or MEmailMultipart (see memailcontent.h)
+     * @return content of the message or NULL if content has not been set
+     */    
+    virtual MEmailMessageContent* ContentL() const = 0;
+
+    /**
+     * Sets content to this message. First create content object, e.g.
+     * CEmailInterfaceFactory::InterfaceL( KEmailIFUidTextContent ), i.e. text/plain
+     * @param aContent content to set in the message, ownership is transferred.
+     * possible old content is destroyed if setting new content succeeds.
+     */    
+    virtual void SetContentL( const MEmailMessageContent* aContent ) = 0;
+    
+    /**
+     * Convenience method for setting plain text as message body.
+     * @param aPlainText text/plain content of message body. Old content
+     * is destroyed.
+     */
+    virtual void SetPlainTextBodyL( const TDesC& aPlainText ) = 0;
+
+    /**
+     * Adds attachment to message. This may affect previously set content, e.g.
+     * if SetContentL with MEmailTextContent argument was called, a new multipart
+     * content is created with MEmailTextContent and attachment as child parts.
+     * @param aFullpath path to file 
+     * @return created attachment, ownership is not transferred
+     */
+    virtual MEmailAttachment* AddAttachmentL( const TDesC& aFullPath ) = 0;
+        
+    /**
+     * Adds attachment to message. This may affect previously set content, e.g.
+     * if SetContentL with MEmailTextContent argument was called, a new multipart
+     * content is created with MEmailTextContent and attachment as child parts.
+     * @param file handle to file to be attached. Handle remains open.
+     * @return created attachment, ownership is not transferred
+     */
+    virtual MEmailAttachment* AddAttachmentL( RFile& aFile ) = 0;
+    
+    /**
+     * Returns attachments, ownership is transferred    
+     * @return number of attachments in aAttachments 
+     */
+    virtual TInt GetAttachmentsL( REmailAttachmentArray& aAttachments ) = 0;
+    
+    /**
+     * Remove an attachment, ownership is not transferred. 
+     * @param attachment object obtained with GetAttachmentsL
+     */
+    virtual void RemoveAttachmentL( const MEmailAttachment& aAttachment ) = 0;
+
+    /**
+     * Returns id of parent folder of the message
+     * @return parent folder id
+     */
+    virtual const TFolderId& ParentFolderId() const = 0;
+
+    /** 
+     * Saves changes done with any mutator to persistent store. 
+     */
+    virtual void SaveChangesL() = 0;
+
+    /** 
+     * Moves message to outbox, sending may not happen immediately but
+     * after next mailbox synchronization. Changes done to the message
+     * are first saved before sending as if SaveChangesL was called.
+     * For immediate sending use MEmailMailbox::SynchronizeL()
+     */
+    virtual void SendL() = 0;
+
+    /**
+     * Launches Email application and opens message in viewer
+     * The method follows "fire and forget" pattern, returns immediately.
+     */    
+    virtual void ShowMessageViewerL( ) = 0;
+
+    /** 
+     * Launches Email application and new reply message in editor. 
+     * The method follows "fire and forget" pattern, returns immediately.
+     * @param boolean indicating if reply-to message is sent to all recipients.
+     */
+    virtual void ReplyToMessageL( const TBool aReplyToAll = ETrue ) = 0;   
+
+    /** 
+     * Launches Email application and new forward message in editor
+     * The method follows "fire and forget" pattern, returns immediately.
+     */    
+    virtual void ForwardMessageL() = 0;
+
+};
+
+} // namespace EmailInterface
+
+#endif // MEMAILMESSAGE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailmessagesearch.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,133 @@
+/*
+* 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: ECom interface for Email Client API
+*
+*/
+
+#ifndef __MEMAILACTIONS
+#define __MEMAILACTIONS
+
+#include <e32cmn.h>
+#include <memailmessage.h>
+
+namespace EmailInterface {
+
+class MMessageIterator;
+class TEmailSortCriteria;
+
+/**
+* Observer interface for handling email search results.
+*/
+class MEmailSearchObserver
+{
+public:
+    /**
+     * Called when search has next message available.
+     * This callback is called several times until all results
+     * have been delivered.
+     *
+     * @param message found in search, ownership is transferred.
+     *          
+     */ 
+    virtual void HandleResultL( 
+        MEmailMessage* aMessage ) = 0;
+
+    /**
+     * Notifies that the search has completed and no more results are expected.
+     */
+    virtual void SearchCompletedL() = 0;
+};
+
+/**
+ * Search interface for messages. Results are provided asynchronoysly.
+ * By default all found mailboxes are included in search.
+ * @code
+   
+   MEmailMailbox* mailbox = NULL;
+   // obtain mailbox here... 
+   // ...and now get search interface
+   MEmailMessageSearchAsync* search = mailbox->MessageSearchL();
+   CleanupReleasePushL( *search );
+   TEmailSortCriteria criteria;
+   criteria.iAscending = ETrue;
+   criteria.iField = TEmailSortCriteria::EByDate;                 
+   search->SetSortCriteriaL( criteria );
+   search->StartSearchL( *this ); // this implements MEmailSearchObserver
+   search->Cancel(); // cancel search
+   CleanupStack::PopAndDestroy(); // search
+   
+   @endcode
+   
+ * @since S60 v5.0
+ */
+class MEmailMessageSearchAsync : public MEmailInterface
+{
+public:
+        
+    /**
+    * Sets sort order for search results.
+    * Leaves KErrNotReady if search is ongoing.
+    */
+    virtual void SetSortCriteriaL( const TEmailSortCriteria& aCriteria ) = 0;
+    
+    /**
+    * Adds a search key. Leaves KErrNotReady if search is ongoing.
+    */
+    virtual void AddSearchKeyL( const TDesC& aSearchKey ) = 0;
+                                                                  
+    /**
+    * Enables/disables search from remote email server.
+    * Leaves KErrNotReady if search is ongoing.
+    */
+    virtual void SetRemoteSearchL( TBool aRemote ) = 0;                                                                  
+    
+    /**
+    * Indicates whether remote search is enabled.
+    */
+    virtual TBool IsRemoteSearch() const = 0;
+    
+    /**
+     * Starts search, all methods affecting search attribures leave
+     * KErrNotReady while search is ongoing.
+     * @param aObserver called when results are available.
+     */     
+    virtual void StartSearchL( MEmailSearchObserver& aObserver ) = 0;
+
+    /**
+     * Cancels search.
+     */
+    virtual void Cancel() = 0;
+                                             
+    /** returns search status 
+      * @return search status:
+      *     < 0 : Search has failed
+      *     KRequestPending : search is ongoing. note that status may be
+      *         KRequestPending after HandleResultL callback because results 
+      *         may be given in chunks of results. Size of chunk depends on
+      *         implementation and may vary.
+      *     KErrNone : initial state, or search has finished
+      */
+    virtual TInt Status() const = 0;
+    
+    /**
+     * Resets all search attribures. Cancels search if ongoing. 
+     */
+    virtual void Reset() = 0;
+};
+
+} //EmailInterface
+
+#endif // __MEMAILACTIONS
+
+// End of file.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/mmailboxcontentobserver.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* 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: Observer interface for mailbox events.
+*
+*/
+
+#ifndef MMAILBOXCONTENTOBSERVER_H
+#define MMAILBOXCONTENTOBSERVER_H
+
+#include <emailapidefs.h>
+
+namespace EmailInterface {
+
+class MMailboxContentObserver
+{
+public:
+    virtual void NewMessageEventL( const TMailboxId& aMailbox, const REmailMessageIdArray aNewMessages, const TFolderId& aParentFolderId ) = 0; 
+    
+    virtual void MessageChangedEventL( const TMailboxId& aMailbox, const REmailMessageIdArray aChangedMessages, const TFolderId& aParentFolderId ) = 0;
+    
+    virtual void MessageDeletedEventL( const TMailboxId& aMailbox, const REmailMessageIdArray aDeletedMessages, const TFolderId& aParentFolderId ) = 0;
+};
+
+} // namespace EmailInterface
+
+#endif // MMAILBOXCONTENTOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/mmailboxsyncobserver.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,33 @@
+/*
+* 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: Observer interface for mailbox synchronisation.
+*
+*/
+
+#ifndef MEMAILSYNCOBSERVER_H
+#define MEMAILSYNCOBSERVER_H
+
+#include <emailapidefs.h>
+
+namespace EmailInterface {
+
+class MMailboxSyncObserver
+{
+public:
+    virtual void MailboxSynchronisedL( TInt aResult ) = 0; 
+};
+
+} // namespace EmailInterface
+
+#endif // MEMAILSYNCOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/mmessageiterator.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* 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: Message iterator interface
+*
+*/
+
+#ifndef MMESSAGEITERATOR_H
+#define MMESSAGEITERATOR_H
+
+#include <emailapidefs.h>
+
+namespace EmailInterface {
+
+class MEmailMessage;
+
+/**
+ * Iterator for email messages. 
+ * @since S60 v5.0
+ */
+class MMessageIterator : public MEmailInterface
+{
+public:
+    /**
+    * Returns next message. When all messages are iterated, returns NULL
+    * @return next message. Ownership is not transferred.
+    */
+    virtual MEmailMessage* NextL() = 0;
+    
+    /**
+    * Returns previous message. When first message is reached, returns NULL
+    * @return previous message. Ownership not is transferred.
+    */
+    virtual MEmailMessage* PreviousL() = 0;
+    
+    /**
+    * Returns amount of messages accessible from the iterator.
+    * @return message count
+    */
+    virtual TUint Count() const = 0;
+    
+};
+
+} // EmailInterface
+
+#endif // MMESSAGEITERATOR_H
--- a/email_plat/email_plat.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/email_plat/email_plat.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -19,6 +19,7 @@
 
 symbian*: { 
     include(email_services_api/email_services_api.pri)
-
+    include(nmail_settings_api/nmail_settings_api.pri)
     include(nmail_client_api/nmail_client_api.pri)
+    include(email_client_api/email_client_api.pri)
 }
--- a/email_plat/nmail_client_api/nmail_client_api.pri	Fri Jun 11 16:23:29 2010 +0100
+++ b/email_plat/nmail_client_api/nmail_client_api.pri	Thu Jul 22 16:30:28 2010 +0100
@@ -30,5 +30,6 @@
             "nmail_client_api/nmapimailboxlisting.h    APP_LAYER_PLATFORM_EXPORT_PATH(nmapimailboxlisting.h)" \
             "nmail_client_api/nmapimessagebody.h       APP_LAYER_PLATFORM_EXPORT_PATH(nmapimessagebody.h)" \
             "nmail_client_api/nmapimessageenvelope.h   APP_LAYER_PLATFORM_EXPORT_PATH(nmapimessageenvelope.h)" \
-            "nmail_client_api/nmapimessagetask.h       APP_LAYER_PLATFORM_EXPORT_PATH(nmapimessagetask.h)"
+            "nmail_client_api/nmapimessagetask.h       APP_LAYER_PLATFORM_EXPORT_PATH(nmapimessagetask.h)" \
+            "nmail_client_api/nmapimessagemanager.h    APP_LAYER_PLATFORM_EXPORT_PATH(nmapimessagemanager.h)"
 }
--- a/email_plat/nmail_client_api/nmapiemailaddress.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/email_plat/nmail_client_api/nmapiemailaddress.h	Thu Jul 22 16:30:28 2010 +0100
@@ -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"
@@ -20,8 +20,9 @@
 
 #include <QExplicitlySharedDataPointer>
 #include <nmapidef.h>
+
 /*!
-   Email addres
+   Email address
  */
 
 class QString;
@@ -41,7 +42,7 @@
     virtual ~NmApiEmailAddress();
 
     /*!
-       copying constructor for nmmessageenvelope
+       copying constructor for NmApiEmailAddress
      */
     NmApiEmailAddress(const NmApiEmailAddress &addr);
 
--- a/email_plat/nmail_client_api/nmapifolderlisting.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/email_plat/nmail_client_api/nmapifolderlisting.h	Thu Jul 22 16:30:28 2010 +0100
@@ -37,11 +37,11 @@
     Q_OBJECT
 public:
     /*!
-       Constructor of class. It set start values.
+       Constructor of class. 
      */
-    NmApiFolderListing(QObject *parent, const quint64 &nmMailboxId);
+    NmApiFolderListing(QObject *parent, const quint64 &mailboxId);
     /*!
-       Destructor of class. It release engine to be safe if manual releasing won't work.
+       Destructor of class. 
      */
     ~NmApiFolderListing();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/nmail_client_api/nmapimessagemanager.h	Thu Jul 22 16:30:28 2010 +0100
@@ -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:
+ *     Email message related operations
+ */
+
+#ifndef NMAPIMESSAGEMANAGER_H_
+#define NMAPIMESSAGEMANAGER_H_
+
+#include <QObject>
+#include <QList>
+
+#include <nmapidef.h>
+
+struct NmApiMessage;
+class NmApiEmailMessage;
+
+namespace EmailClientApi {
+
+class NmApiFolder;
+class NmApiMessageManagerPrivate;
+
+class NMAPI_EXPORT NmApiMessageManager : public QObject
+{
+    Q_OBJECT
+	
+public:
+    NmApiMessageManager(quint64 mailboxId,QObject *parent = 0);
+
+    virtual ~NmApiMessageManager();
+
+public slots:
+    bool createDraftMessage(const QVariant *initData);
+    
+    bool createForwardMessage(const QVariant *initData);
+    
+    bool createReplyMessage(const QVariant *initData,bool replyAll);
+    
+    bool moveMessages(const QList<quint64> messageIds,
+		quint64 sourceFolderId,quint64 targetFolderId);
+    
+    bool copyMessages(const QList<quint64> messageIds,					
+					quint64 sourceFolder,
+					quint64 targetFolder);
+    
+    bool saveMessage(const ::NmApiMessage &message);
+    
+    bool deleteMessages(const QList<quint64> messageIds);
+    
+    bool fetch(const NmApiMessage &message);
+    
+    bool send(const NmApiMessage &message);
+    
+    bool createAttachment(NmApiEmailMessage &message,const QVariant &attachmenSpec);
+
+    bool removeAttachment(NmApiEmailMessage &message,quint64 attachmentId);
+    
+signals:
+	void messagesCopied(int result);
+
+	void messagesCreated(int result);
+
+	void messagesMoved(int result);
+
+	void messagesDeleted(int result);
+
+private:
+	NmApiMessageManagerPrivate *d;
+};
+
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/nmail_settings_api/nmail_settings_api.pri	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+# 
+# Description:
+#
+#
+
+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)"
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/nmail_settings_api/nmapimailboxsettings.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,55 @@
+/*
+ * 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 NMAPIMAILBOXSETTINGS_H_
+#define NMAPIMAILBOXSETTINGS_H_
+
+#include <QList>
+#include <QObject>
+
+#include <nmapidef.h>
+
+namespace EmailClientApi
+{
+
+class NmApiMailboxSettingsData;
+class NmApiMailboxSettingsPrivate;
+class NMAPI_EXPORT NmApiMailboxSettings : public QObject
+{
+    Q_OBJECT
+public:
+    NmApiMailboxSettings(QObject *parent = 0);
+    ~NmApiMailboxSettings();
+
+    bool listMailboxIds(QList<quint64> &idList);
+    bool loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data);
+    bool saveSettings(const NmApiMailboxSettingsData &data);
+    bool createMailbox(const QString &mailboxType, NmApiMailboxSettingsData &data);
+    bool deleteMailbox(quint64 mailboxId);
+    bool populateDefaultSettings(const QString &mailboxType, NmApiMailboxSettingsData &data);
+
+signals:
+    void mailboxDeleted(int result = 0);
+    
+protected:    
+    NmApiMailboxSettingsPrivate *d;
+ 
+};
+
+}
+
+#endif /* NMAPIMAILBOXSETTINGS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/nmail_settings_api/nmapimailboxsettingsdata.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,129 @@
+/*
+ * 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 NMAPIMAILBOXSETTINGSDATA_H_
+#define NMAPIMAILBOXSETTINGSDATA_H_
+
+#include <QVariant>
+#include <nmapidef.h>
+
+namespace EmailClientApi
+{
+
+const QString NmApiMailboxTypeImap = "imap";
+const QString NmApiMailboxTypePop = "pop";
+
+const QString NmApiAuthNone = "none";
+const QString NmApiAuthSameAsIncoming = "SameAsIncoming";
+const QString NmApiAuthUserAuthentication = "UserAuthentication";
+
+const QString NmApiAutomatic = "automatic";
+const QString NmApiAlways = "always";
+const QString NmApiHomeOnly = "homeOnly";
+const QString NmApiOff = "off";
+
+const QString NmApiStartTls = "StartTls";
+const QString NmApiSSLTls = "SSLTls";
+const QString NmApiSecurityOff = NmApiOff;
+
+const QString NmApiKeepUpToDate = "Keep-Up-To-Date";
+const QString NmApiSaveEnergy = "Save-Energy";
+const QString NmApiFetchManually = "Manual-Fetch";
+const QString NmApiUserDefined = "User-Defined";
+
+enum NmApiWeekDays
+{
+    Mon = 0x01, Tue = 0x02, Wed = 0x04, Thu = 0x08, Fri = 0x10,
+    Sat = 0x20, Sun = 0x40
+};
+
+enum NmApiRefreshPeriods
+{
+    WhenMailboxOpens = 0, Every5minutes = 5, Every15minutes = 15,
+    EveryHour = 60, Every4Hours = 240
+};
+
+enum NmApiMailboxSettingKey
+{
+    IncomingLoginName = 0, // String
+    IncomingPassword, // String
+    MailboxName, // String
+    EmailAddress, // String
+    ReplyAddress, // String
+    EmailAlias, // String
+    MyName, // String    
+    DownloadPictures, // Integer: 0=Off, 1=On
+    MessageDivider, // Integer: 0=Off, 1=On
+    ReceptionActiveProfile, // String: Reception profile
+    ReceptionUserDefinedProfile, // Integer: 0=Disabled, 1=Enabled
+    ReceptionInboxSyncWindow, // Integer: 0=All messages
+    ReceptionGenericSyncWindowInMessages, // Integer: 0=All messages
+    ReceptionWeekDays, // Integer bitmask of weekdays
+    ReceptionDayStartTime, // Integer: 0-23
+    ReceptionDayEndTime, // Integer: 0-23
+    ReceptionRefreshPeriodDayTime, // Integer: 5,15,60,240,0="When open mailbox"
+    ReceptionRefreshPeriodOther, // Integer: 5,15,60,240,0="When open mailbox"
+    UserNameHidden, // Integer: 0=Off, 1=On
+    IncomingMailServer, // String
+    IncomingMailUsesAuthentication, // String    "none", "UserAuthentication"
+    IncomingMailSecurityType, // String  "StartTls", "SSLTls", "none"
+    OutgoingMailServer, // String
+    OutgoingMailUsesAuthentication, // String "none", "SameAsIncoming", "UserAuthentication"
+    OutgoingMailSecurityType, // String 	"StartTls", "SSLTls", "none"
+    IncomingPort, // Integer
+    OutgoingPort, // Integer
+    FolderPath, // String: Empty string means 'Default'
+    AlwaysOnlineState, // string "always", "homeOnly", "off"
+    EmailNotificationState, // string "automatic", "homeOnly", "off"
+    FirstEmnReceived, // Integer: 0=false,1=true
+    EmnReceivedNotSynced, // Integer: 0=false,1=true
+    AoLastSuccessfulUpdate, // QDateTime
+    AoLastUpdateFailed, // Integer: 0=false, 1=true
+    AoUpdateSuccessfulWithCurSettings, // Integer: 0=false, 1=true
+    IncomingSecureSockets, // Boolean
+    IncomingSSLWrapper, // Boolean
+    OutgoingLoginName, // String
+    OutgoingPassword, // String
+    UseOutgoingAuthentication, // Boolean
+    OutgoingSecureSockets, // Boolean
+    OutgoingSSLWrapper // Boolean
+};
+
+class NmApiMailboxSettingsDataPrivate;
+class NMAPI_EXPORT NmApiMailboxSettingsData
+{
+
+public:    
+    NmApiMailboxSettingsData();
+    ~NmApiMailboxSettingsData();
+
+    void setMailboxId(quint64 mailboxId);
+    quint64 mailboxId() const;
+    void setValue(int key, const QVariant &settingValue);
+    bool getValue(int key, QVariant &settingValue) const;
+    bool validateData() const;
+    void clearSettings();
+    QList<int> listSettings() const;
+
+protected:    
+    NmApiMailboxSettingsDataPrivate *d;
+
+};
+
+}//end namespace
+
+#endif /* NMAPIMAILBOXSETTINGSDATA_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/bwins/emailclientapiu.def	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/data/emailclientapi.rss	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* 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:  Declares ECom registration information for email client api
+*     
+*
+*/
+
+#include <ecom/registryinfov2.rh>		//REGISTRY_INFO
+#include "emailclientapiimpl.hrh" 
+
+/** ECom version number to be used in Cmail related ECom registeration
+ *  resource files.
+ *  NOTE: Version number in ECom registeration resource file is saved as one
+ *  byte, so 255 is the maximum version number.
+ */
+#define KEmailEcomVersionNumber 7
+
+RESOURCE REGISTRY_INFO theInfo
+    {    
+    dll_uid = 0x20022D63;
+    resource_format_version = RESOURCE_FORMAT_VERSION_2;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = 0x20022D62;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x20022D61;
+                    version_no = KEmailEcomVersionNumber;
+                    display_name = "email client api";
+                    default_data = "";
+    				opaque_data = "";
+    				rom_only=0;
+                    }
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/eabi/emailclientapiu.def	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/emailclientapi.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,107 @@
+#
+# 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:
+#
+#
+
+TEMPLATE = lib
+TARGET = emailclientapi
+DEPENDPATH += . inc src
+INCLUDEPATH += . \
+			   ../../inc \
+			   ../emailframework/inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+HEADERS += inc/emailclientapiimpl.h \
+            inc/emailinterfacefactoryimpl.h \
+            inc/emailapiutils.h \
+            inc/emailmailbox.h \
+            inc/emailaddress.h \
+            inc/emailfolder.h \
+            inc/emailmessage.h \
+            inc/emailmailboxcache.h \
+            inc/messageiterator.h \
+            inc/emailcontent.h \
+            inc/emailmessagesearch.h \
+            inc/emailattachment.h \
+            inc/emailtextcontent.h \
+            inc/emailmultipart.h   
+
+SOURCES += src/emailclientapiimpl.cpp \
+            src/emailinterfacefactoryimpl.cpp \
+            src/implproxy.cpp \
+            src/emailapiutils.cpp \
+            src/emailmailbox.cpp \
+            src/emailaddress.cpp \
+            src/emailfolder.cpp \
+            src/emailmessage.cpp \
+            src/emailmailboxcache.cpp \
+            src/messageiterator.cpp \
+            src/emailcontent.cpp \
+            src/emailmessagesearch.cpp \
+            src/emailattachment.cpp \
+            src/emailtextcontent.cpp \
+            src/emailmultipart.cpp        
+        
+
+LIBS += -lbafl \
+        -lcone \
+        -leuser \
+        -lECom \
+        -lFSFWCommonLib \
+        -lFSMailFramework \
+        -lefsrv \
+        -lviewcli \
+        -lestor \
+        -lcentralrepository
+
+symbian*: {
+
+	INCLUDEPATH += /sf/mw/qtextensions/qthighway/inc
+	LIBS += -lxqservice 
+
+    TARGET.EPOCALLOWDLLDATA = 1
+    TARGET.CAPABILITY = CAP_ECOM_PLUGIN
+
+    TARGET.UID2 = 0x10009D8D
+    TARGET.UID3 = 0x20022D63
+
+    ecomPluginRegisterationFile = \
+    "SOURCEPATH data" \
+    "START RESOURCE emailclientapi.rss" \
+    "END" 
+
+    MMP_RULES += "SYSTEMINCLUDE /epoc32/include/ecom" 
+    MMP_RULES += ecomPluginRegisterationFile
+    MMP_RULES += "TARGETTYPE PLUGIN"
+
+    defBlock = \
+        "$${LITERAL_HASH}if defined(MARM)" \
+        "DEFFILE  eabi/emailclientapi.def" \
+        "$${LITERAL_HASH}else" \
+        "DEFFILE  bwins/emailclientapi.def" \
+        "$${LITERAL_HASH}endif"
+
+    MMP_RULES += defBlock
+    
+    BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>" \
+    "rom/emailclientapi.iby CORE_APP_LAYER_IBY_EXPORT_PATH(emailclientapi.iby)"    
+    
+    # Prevents C2874W warnings
+    QMAKE_CXXFLAGS.ARMCC += --diag_suppress 2874
+}
+
+win32 {
+	DESTDIR = ../../../../bin
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailaddress.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* 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 address implementation definition
+*
+*/
+
+#ifndef EMAILADDRESS_H
+#define EMAILADDRESS_H
+
+#include <memailaddress.h>
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+NONSHARABLE_CLASS( CEmailAddress ) : public CBase, public MEmailAddress
+    {
+public:
+    static CEmailAddress* NewL( const TRole aRole, const TDataOwner aOwner );
+    static CEmailAddress* NewLC( const TRole aRole, const TDataOwner aOwner );
+    
+    ~CEmailAddress();
+
+public: // from MEmailInterface
+    TEmailTypeId InterfaceId() const;
+    
+    void Release();
+
+public: // from MEmailAddress
+    void SetAddressL( const TDesC& aAddress );
+    TPtrC Address() const;
+    
+    void SetDisplayNameL( const TDesC& aDisplayName );
+    TPtrC DisplayName() const;
+    
+    TRole Role() const;
+    void SetRole( const TRole aRole );
+            
+private:        
+        CEmailAddress( const TRole aRole, const TDataOwner aOwner );
+        
+private:
+        RBuf iAddress;
+        RBuf iDisplayName;
+        TRole iRole;
+        TDataOwner iOwner;
+    };
+
+#endif // EMAILADDRESS_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailapiutils.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,157 @@
+/*
+* 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: This file implements utilities like CPluginData.
+*
+*/
+
+#ifndef EMAILAPIUTILS_H
+#define EMAILAPIUTILS_H
+
+#include <e32base.h>
+#include "cfsmailcommon.h"
+#include <emailapidefs.h>
+
+//using namespace EmailInterface;
+
+class CFSMailPlugin;
+
+enum TDataOwner
+    {
+    EClientOwns,
+    EAPIOwns
+    };
+
+
+/**
+* Helper container class for storing plugin pointer and implementation UID
+* @since S60 v5.2
+*/
+NONSHARABLE_CLASS( TPluginData )
+    {
+    public:
+    
+        inline TPluginData( TUid aUid ) : iPlugin( NULL ), iUid( TUid::Uid( aUid.iUid ) ) {}
+        
+        CFSMailPlugin* iPlugin;
+        
+        const TUid     iUid;
+    };
+    
+/**
+* Plugin data is a utility for protocol plugin creation and book 
+* keeping. Objects using the plugin should access it via this
+* class for optimised reference counting.
+*/
+NONSHARABLE_CLASS( CPluginData ) : public CBase
+{
+public:    
+    /**
+    * returns plugin instance or null if failed to instantiate.
+    * LoadResult() will return error code in instantiation
+    */
+    CFSMailPlugin* ClaimInstance();
+    
+    /**
+    * returns plugin instance or leaves if failed to instantiate.
+    */
+    CFSMailPlugin* ClaimInstanceL();
+
+    /**
+    *  Decreases access count of the plugin and deletes if reaches zero.
+    * Note! this should be called only aftre succesful ClaimInstance or 
+    * ClaimInstanceL.
+    */
+    void ReleaseInstance();
+    
+    /**
+    * Adds cleanup operation calling ReleaseInstance to cleanup stack
+    */                                                 
+    void ReleasePushL();
+    /**
+    * Cleanup operation for CleanupReleasePluginPushL
+    */
+    static void CleanupOperation( TAny* aAny );
+    
+    TUid Uid() const;
+    
+    TInt LoadResult() const;
+
+private: 
+    /* only CEmailClientApi owns instances of this, it should make sure that
+     * no duplicates exist, otherwise reference counting of plugins fail
+     * (this is not singleton class)
+     */
+    friend class CEmailClientApi;
+    friend class CEmailMailboxCache;
+    
+    CPluginData( TUid aUid );
+    ~CPluginData();
+
+private:    
+    // plugin pointer and uid
+    TPluginData iData;
+    
+    TInt iPluginLoadError;
+        
+    // >0 when iPlugin is instantiated
+    TUint          iRefCount;
+    
+    // EFalse if shared from Email Framework (CFSMailClient). If true,
+    // ReleaseInstance() doesn't delete plugin
+    TBool          iOwned;
+};
+
+/**
+* Constructs internal message id type from plugin data and mailbox/folder/message id 
+*/
+TFSMailMsgId FsMsgId( const CPluginData& aPluginData, const EmailInterface::TBaseId& aId );
+
+/**
+* Cleanup support for pointer arrays
+*/
+template<class T>
+class CleanupResetAndDestroy
+{
+public:
+    inline static void PushL( T& aItem );
+
+private:
+    inline static void ResetAndDestroy( TAny *aPtr );
+} ;
+
+template <class T>
+inline void CleanupResetAndDestroyPushL( T& aRef )
+    {
+    CleanupResetAndDestroy<T>::PushL( aRef );
+    }
+
+/**
+* Cleanup support for email interface objects.
+*/
+class CleanupReleasePush
+{
+public:
+    static void PushL( EmailInterface::MEmailInterface& aItem );
+
+private:
+    static void Release( TAny *aPtr );
+} ;
+
+
+#include "emailapiutils.inl"
+
+
+#endif // EMAILAPIUTILS_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailapiutils.inl	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* 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: This file implements class CEmailMailbox.
+*
+*/
+
+template<class T>
+inline void CleanupResetAndDestroy<T>::PushL( T& aItem ) 
+    { 
+    TCleanupItem item( &CleanupResetAndDestroy::ResetAndDestroy, &aItem );
+    CleanupStack::PushL( item );
+    }
+
+template<class T>
+inline void CleanupResetAndDestroy<T>::ResetAndDestroy( TAny *aPtr )
+    {
+    reinterpret_cast<T*>( aPtr )->ResetAndDestroy();
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailattachment.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,162 @@
+/*
+* 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: Definition of Email attachment.
+*
+*/
+
+
+#ifndef EMAILATTACHMENT_H
+#define EMAILATTACHMENT_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+#include "cfsmailclient.h"
+#include <memailcontent.h>
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+class CEmailMessageContent;
+// CLASS DECLARATION
+
+/**
+ *  CEmailAttachment
+ * 
+ */
+
+NONSHARABLE_CLASS(CEmailAttachment) : public CBase, public MEmailAttachment
+    {
+public:
+    // Constructors and destructor
+
+    /**
+     * Destructor.
+     */
+    ~CEmailAttachment();
+
+    /**
+     * Two-phased constructor.
+     */
+    static CEmailAttachment* NewL(
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,
+        CFSMailMessagePart *aAtt,
+        const TDataOwner aOwner );    
+
+    /**
+     * Two-phased constructor.
+     */
+    static CEmailAttachment* NewLC(
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,    
+        CFSMailMessagePart *aAtt,
+        const TDataOwner aOwner );    
+
+public: // from MEmailInterface
+    TEmailTypeId InterfaceId() const;
+    
+    void Release();
+
+public: // from MEmailAttachment
+    /**
+    * Returns file handle of this attachment. If the attachment is
+    * not associated with a file, null file handle is returned.
+    */
+    RFile FileL() const;
+
+    /**
+    * Sets file name field
+    */
+    void SetFileNameL( const TDesC& aFileName );
+
+    /**
+    * Returns file name or null pointer descriptor if attachment
+    * is not associated with any file
+    */
+    TPtrC FileNameL() const;
+    
+    
+public: // from MEmailMessageContent
+    
+    TMessageContentId Id() const;
+
+    TPtrC ContentType() const;
+
+    void SetContentType( const TDesC& aContentType );
+
+    TPtrC ContentId() const;
+
+    void SetContentId( const TDesC& aContentId );
+
+    TPtrC ContentDescription() const;
+
+    void SetContentDescription( const TDesC& aContentDescription );
+
+    TPtrC ContentDisposition() const;
+
+    void SetContentDisposition( const TDesC& aContentDisposition );
+
+    TPtrC ContentClass() const;
+
+    void SetContentClass( const TDesC& aContentClass );
+
+    TInt AvailableSize() const;
+
+    TInt TotalSize() const;
+
+    TPtrC ContentL() const;
+
+    void SetContentL( const TDesC& aContent );
+
+    void FetchL( MEmailFetchObserver& aObserver );
+
+    void CancelFetch();
+
+    void SaveToFileL( const TDesC& aPath );
+
+    MEmailMultipart* AsMultipartOrNull() const;
+    
+    MEmailTextContent* AsTextContentOrNull() const;
+
+    MEmailAttachment* AsAttachmentOrNull() const;
+    
+private:
+
+    /**
+     * Constructor for performing 1st stage construction
+     */
+    CEmailAttachment( const TDataOwner aOwner );
+
+    /**
+     * EPOC default constructor for performing 2nd stage construction
+     */
+    void ConstructL(
+            CPluginData& aPluginData,
+            const TMessageContentId& aMsgContentId );    
+
+    void ConstructL(
+            CPluginData& aPluginData,
+            const TMessageContentId& aMsgContentId,
+            CFSMailMessagePart *aPart);    
+    
+private:        
+    CEmailMessageContent*   iEmailMsgContent;
+    TDataOwner iOwner;
+    };
+
+#endif // EMAILATTACHMENT_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailclientapiimpl.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,232 @@
+/*
+* 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: Definition of Email API main interface.
+*
+*/
+
+#ifndef EMAILCLIENTAPIIMPL_H
+#define EMAILCLIENTAPIIMPL_H
+
+
+#include <implementationinformation.h> 
+#include "emailapiutils.h"
+#include "cfsmailcommon.h"
+#include "mfsmaileventobserver.h"    
+#include <memailclientapi.h>
+#include "emailclientpluginmanager.h"
+
+
+using namespace EmailInterface;
+
+class CFSMailBox;
+class MEmailEventObserver;
+class CVwsSessionWrapper;
+class CFSMailPlugin;
+class TFSMailMsgId;
+class CEmailMailboxCache;
+class CFSMailClient;
+
+/**
+*  "Framework" class including plugin management
+* @since S60 v5.2
+*/
+NONSHARABLE_CLASS( CEmailClientApi ) : public CBase, public MEmailClientApi
+{
+public:
+    /**
+    * Constructor
+    * @return
+    */
+    static CEmailClientApi* NewL();
+    
+    /**
+     *
+     */
+     CEmailClientApi();       
+
+public: // from MEmailInterface
+    TEmailTypeId InterfaceId() const;
+    
+    void Release();
+    
+public: // from MEmailClientApi
+
+    /** @see MEmailClientApi */   
+    MEmailMailbox* MailboxL( const TMailboxId& aId );
+   
+    /** @see MEmailClientApi */   
+    MEmailMailbox* MailboxL( const TPtrC& aAddress );
+           
+    /**
+    * Gets all mailboxes in pointer array. It is recommended to free other
+    * mailboxes besides needed one to optimise memory usage.
+    */    
+    TInt GetMailboxesL( RMailboxPtrArray& aMailboxes );
+    
+    /**
+    */
+    void LaunchEmailL( const TLaunchPolicy aPolicy );
+
+public: // new methods
+
+    /**
+     * Gets array of mailbox ids
+     * @param aMailboxes mailbox ids from all plugins
+     * @return number of mailboxes returned in aMailboxes
+     */
+    TInt GetMailboxIdsL( REmailMailboxIdArray& aMailboxes );
+        
+private:
+
+    /**
+     * Constructor
+     */
+    void ConstructL();
+    
+     /**
+     * Destructor
+     */
+    ~CEmailClientApi();
+
+    /**
+     * Push ECom implementation info to cleanup operation to cleanup stack
+     */
+    void CleanupImplInfoPushL( RPointerArray<CImplementationInformation>& aArray );
+    
+    /**
+     * Cleanup operation for ECom implementation info
+     */
+    static void CleanupImplInfo( TAny* aAny );
+   
+
+    // Group of methods for book keeping of loaded protocol plugins by this object.
+    // In certain situations it is preferable to have a plugin in memory
+    // instead of loading/unloading frequently.
+    
+    /** Increases plugin reference count if CEmailClientApi already doesn't
+     *  have active instance. When plugin is needed internally, this method
+     * should be accessor to a plugin. Counterpart is ReleasePlugin() when
+     * CEmailClientApi doesn't itself need plugin any more.
+     */
+    CFSMailPlugin* UsePlugin( CPluginData& aPluginData );
+    
+    /**
+    * For finding plugin data
+    */
+    TInt IndexOfLoadedPluginData( const TPluginData& aPluginData ) const;
+    
+    /**
+    * Used in comparing plugin data in array (part of find algorithm)
+    */    
+    static TBool PluginDataEquals( const TPluginData& a1, const TPluginData& a2 );
+    
+    /**
+    * This object doesn't need related protocol plugin
+    */
+    void ReleasePlugin( CPluginData& aPluginData );
+    
+    /**
+    * This object doesn't need any protocol plugin
+    */
+    void ReleaseAllPlugins();
+    
+    /**
+    * Return mailbox cache, creates it when called first time
+    */
+    CEmailMailboxCache& MailboxInfoCacheL();
+    
+    /**
+    * Caches mailbox ids and their mapping to related plugin data for quick
+    * lookup. When a mailbox with specific id is next time asked, related
+    * protocol plugin is already known.
+    */
+    void UpdateMailboxInfoCacheL();
+
+    /**
+    * Internal, used from UpdateMailboxInfoCacheL
+    */    
+    TBool CachePluginMailboxesL( 
+        CPluginData& aPluginData, 
+        CFSMailPlugin& aPlugin );
+    
+private:    
+    typedef RPointerArray<CPluginData> RPluginDataArray;
+    
+    /**
+    * Iterator for CPluginData elements in an array
+    */
+    class TPluginIterator
+    {
+    public:
+        // constructor
+        inline TPluginIterator( RPluginDataArray& aArray ) : 
+            iArray( aArray ), iIndex( 0 ) {}
+        
+        /**
+        * return next element
+        */
+        CPluginData* Next();
+    private:
+        // iterator array
+        RPluginDataArray& iArray;
+        // current iterator index
+        TInt iIndex;
+    };
+    
+private:
+    // plugin data array for all protocol plugins
+    RPluginDataArray    iPluginDataArray;
+
+    // singleton instance counter    
+    TInt iInstanceCounter;
+    
+    // book keeping of loaded plugins
+    RArray<TPluginData> iLoadedPluginsArray;
+       
+    // Mailbox ids are cached when first time listed. Related plugin uid
+    // is include in the cache.
+    CEmailMailboxCache* iMailboxCache;
+
+    CFSMailClient* iMailClient;
+    
+};
+
+/**
+* Email application launcher. 
+*/
+NONSHARABLE_CLASS( CEmailLauncher ) : public CBase
+{
+public:
+    static CEmailLauncher* NewL();
+    
+    ~CEmailLauncher();
+                                    
+    /**
+    *
+    */
+     void LaunchL( const TMailboxId& aMailboxId );
+private:
+    
+    CEmailLauncher();
+    
+    void ConstructL();
+    
+    // Owned window server session.
+    CVwsSessionWrapper* iViewSrvSession;
+};
+
+
+#endif // EMAILCLIENTAPIIMPL_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailclientapiimpl.hrh	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,25 @@
+/*
+* 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: email client api internal definitions
+*
+*/
+#ifndef _EMAILCLIENTAPIIMPL_HRH
+#define _EMAILCLIENTAPIIMPL_HRH
+
+#define KEmailClientApiDllUid       0x20022D63
+#define KEmailClientApiImplUid      0x20022D61
+
+#endif // _EMAILCLIENTAPIIMPL_HRH
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailclientapiimpldefs.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,30 @@
+/*
+* 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 _EMAILCLIENTAPIIMPLDEFS_H
+#define _EMAILCLIENTAPIIMPLDEFS_H
+
+enum TEmailImplPanic {
+    EMailPanicPluginNotReleased,
+    EMailPanicSortMapIndexOutOfBounds
+};
+
+void Panic( TEmailImplPanic aPanic );
+
+#endif // _EMAILCLIENTAPIIMPLDEFS_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailclientpluginmanager.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,32 @@
+/*
+* 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: Definition for plugin manager interface
+*
+* Description: 
+*
+*/
+
+#ifndef MEMAILPLUGINMANAGER_H_
+#define MEMAILPLUGINMANAGER_H_
+
+#include "cfsmailcommon.h"
+
+class MEmailClientPluginManager
+    {
+public:
+    virtual CFSMailPlugin* GetPluginByUid(TUid aUid) = 0; 
+    };
+
+#endif // MEMAILPLUGINMANAGER_H_
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailcontent.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,129 @@
+/*
+* 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 content implementation definition
+*
+*/
+
+#ifndef EMAILCONTENT_H
+#define EMAILCONTENT_H
+
+#include <memailcontent.h>
+
+#include "cfsmailclient.h"
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+class CFSMailPlugin;
+class CFSMailRequestObserver;
+
+NONSHARABLE_CLASS( CEmailMessageContent ) : public CBase, 
+                                            public MEmailMessageContent
+{
+public:
+    static CEmailMessageContent* NewL( 
+            CPluginData& aPluginData,
+            const TMessageContentId& aMsgContentId,
+            CFSMailMessagePart* aPart);
+        
+    ~CEmailMessageContent();
+    
+public: // from MEmailInterface
+    TEmailTypeId InterfaceId() const;
+    
+    void Release();
+
+public: // from MEmailMessageContent
+    TMessageContentId Id() const;
+
+    TPtrC ContentType() const;
+
+    void SetContentType( const TDesC& aContentType );
+
+    TPtrC ContentId() const;
+
+    void SetContentId( const TDesC& aContentId );
+
+    TPtrC ContentDescription() const;
+
+    void SetContentDescription( const TDesC& aContentDescription );
+
+    TPtrC ContentDisposition() const;
+
+    void SetContentDisposition( const TDesC& aContentDisposition );
+
+    TPtrC ContentClass() const;
+
+    void SetContentClass( const TDesC& aContentClass );
+
+    TInt AvailableSize() const;
+
+    TInt TotalSize() const;
+
+    TPtrC ContentL() const;
+
+    void SetContentL( const TDesC& aContent );
+
+    void FetchL( MEmailFetchObserver& aObserver );
+
+    void CancelFetch();
+
+    void SaveToFileL( const TDesC& aPath );
+
+    MEmailMultipart* AsMultipartOrNull() const;
+    
+    MEmailTextContent* AsTextContentOrNull() const;
+
+    MEmailAttachment* AsAttachmentOrNull() const;
+    
+public:     
+    CFSMailMessagePart& Part();
+    void SetPart( CFSMailMessagePart *aPart );
+    
+    CPluginData& PluginData();
+        
+protected:
+    CEmailMessageContent( CPluginData& aPluginData, const TMessageContentId& aMsgContentId, CFSMailMessagePart* aPart );
+    
+private:
+    class CContentRequestObserver: public CBase, 
+                                   public MFSMailRequestObserver
+        {
+    public:
+        CContentRequestObserver( CEmailMessageContent &aParent);
+        
+        virtual void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
+        void SetObserverL( MEmailFetchObserver* aObserver );
+    private:
+        MEmailFetchObserver* iObserver;
+        CEmailMessageContent& iParent;
+        };
+
+private:
+    void ConstructL();
+
+private:
+    CPluginData&            iPluginData;
+    CFSMailPlugin*          iPlugin;
+    CFSMailMessagePart*     iPart;
+    TMessageContentId       iMsgContentId;
+    mutable HBufC*          iBuf;
+    mutable TUint           iUsed;
+    CContentRequestObserver *iFetchObserver;
+    TInt                    iRequestId;
+};
+
+#endif // EMAILCONTENT_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailfolder.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,103 @@
+/*
+* 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: CEmailMailbox.
+*
+*/
+
+#ifndef CEMAILFOLDER_H
+#define CEMAILFOLDER_H
+
+#include <emailapidefs.h>
+#include "cfsmailcommon.h"
+#include <memailfolder.h>
+#include "mfsmaileventobserver.h"
+
+using namespace EmailInterface;
+
+class CFSMailPlugin;
+class CPluginData;
+class CFSMailFolder;
+class EmailInterface::MMessageIterator;
+
+NONSHARABLE_CLASS( CEmailFolder ) : 
+    public CBase, 
+    public MEmailFolder
+{
+public:
+    
+    static CEmailFolder* NewLC( 
+        CPluginData& aPluginData,
+        const TFolderId& aFolderId,
+        CFSMailFolder *aFolder );
+    
+    static CEmailFolder* NewL( 
+        CPluginData& aPluginData,
+        const TFolderId& aFolderId,
+        CFSMailFolder *aFolder );
+
+    ~CEmailFolder();           
+
+public: // from MEmailInterface
+    TEmailTypeId InterfaceId() const;
+    
+    void Release();
+    
+public:    // from MEmailFolder
+    TFolderId FolderId() const;
+    
+    TFolderId ParentFolderId() const;
+    
+    TFolderType FolderType() const;    
+
+    TPtrC Name() const;
+
+    /**
+    * Returns direct childs of this folder, i.e. this is not recursive.
+    * @return number of subfolders or an error code
+    */    
+    TInt GetSubfoldersL( 
+        RFolderArray& aSubfolders ) const;
+
+    EmailInterface::MMessageIterator* MessagesL( 
+        const RSortCriteriaArray& aCriteria );
+    
+    void DeleteMessagesL( const REmailMessageIdArray& aMessageIds );
+    
+private: // constructors
+    CEmailFolder( CPluginData& aPluginData, const TFolderId& aFolderId, CFSMailFolder *aFolder );
+    
+    void ConstructL();
+
+private: // Internal methods
+    static void ToFsSortCriteriaL( 
+        const RSortCriteriaArray& aSortCriteria, 
+        RArray<TFSMailSortCriteria>& aFsCriteria );
+
+private:
+    CPluginData&    iPluginData;
+    
+    CFSMailPlugin*  iPlugin;
+
+    TFolderType     iFolderType;
+       
+    TFolderId       iFolderId;
+    
+    TFolderId       iParentId;
+    
+    CFSMailFolder   *iFolder;
+};
+    
+#endif // CEMAILFOLDER_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailinterfacefactoryimpl.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,69 @@
+/*
+* 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: Interface factory implementation class definition
+*
+*/
+
+#ifndef EMAILINTERFACEFACTORY_H
+#define EMAILINTERFACEFACTORY_H
+
+#include <emailinterfacefactory.h>
+
+using namespace EmailInterface;
+
+/**
+* Implements CEmailInterfaceFactory ECom interface
+*
+*/
+NONSHARABLE_CLASS( CEmailInterfaceFactoryImpl ) : public CEmailInterfaceFactory
+{
+public: 
+
+    /**
+    * Creates interface factory
+    * @return interface factory
+    */
+    static CEmailInterfaceFactoryImpl* NewL();
+    
+    // destructor
+    ~CEmailInterfaceFactoryImpl();
+    
+    /** @see CEmailInterfaceFactory::InterfaceL */
+    MEmailInterface* InterfaceL( const TInt aInterfaceId );
+    
+private:
+    enum TEmailUidAppendRemoveMode
+        {
+        EEmailUidModeAppend,
+        EEmailUidModeRemove,
+        };
+    
+    /**
+    * Registers/removes application UID to/from P&S so that the application
+    * can be shutdown during Email IAD update. Update may fail if any
+    * application is using some Email services during the update.
+    * Application UID is removed from the list in destructor.
+    * @param aMode Is the current process UID added or removed from the list
+    */
+    void AppendOrRemoveUidL( const TEmailUidAppendRemoveMode aMode );
+
+private:    
+    // c++ constructor and 2nd phase constructor
+    CEmailInterfaceFactoryImpl();
+    void ConstructL();
+};
+
+#endif // EMAILINTERFACEFACTORY_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailmailbox.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,181 @@
+/*
+* 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: This file implements class CEmailMailbox.
+*
+*/
+
+#ifndef EMAILMAILBOX_H
+#define EMAILMAILBOX_H
+
+#include "cfsmailcommon.h"
+#include <memailmailbox.h>
+#include "mfsmaileventobserver.h"
+#include "mfsmailrequestobserver.h"
+#include "mmailboxcontentobserver.h"
+
+using namespace EmailInterface;
+
+class CFSMailBox;
+class CFSMailAddress;
+class CFSMailPlugin;
+class CPluginData;
+class CEmailAddress;
+
+NONSHARABLE_CLASS( CEmailMailbox ) : 
+    public CBase, 
+    public MEmailMailbox
+{
+public:
+    
+    static CEmailMailbox* NewL( 
+        CPluginData& aPluginData,
+        const TMailboxId& aMailboxId );
+    
+    ~CEmailMailbox();           
+
+public: // from MEmailInterface
+    TEmailTypeId InterfaceId() const;
+    
+    void Release();
+    
+public:    // from MEmailMailbox
+    /**@see MEmailMailbox */
+    TMailboxId MailboxId() const;
+    
+    /**@see MEmailMailbox */
+    MEmailAddress* AddressL() const;
+    
+    /**@see MEmailMailbox */
+    TPtrC MailboxName() const;
+    
+    /**@see MEmailMailbox */
+    TInt GetFoldersL( RFolderArray& aFolders ) const;
+
+    /**@see MEmailMailbox */
+    MEmailFolder* FolderL( const TFolderId& aFolderId ) const;
+    
+    /**@see MEmailMailbox */
+    MEmailFolder* FolderByTypeL( 
+        const TFolderType aFolderType ) const;
+        
+    /**@see MEmailMailbox */
+    MEmailMessage* MessageL( const TMessageId& aMessageId );
+    
+    /**@see MEmailMailbox */
+    MEmailMessage* CreateDraftMessageL() const;
+    
+    /**@see MEmailMailbox */
+    MEmailMessage* CreateReplyMessageL( const TMessageId& aMessageId, const TBool aReplyToAll = ETrue ) const;
+    
+    /**@see MEmailMailbox */
+    MEmailMessage* CreateForwardMessageL( const TMessageId& aMessageId ) const;
+    
+    /**@see MEmailMailbox */
+    void SynchroniseL( MMailboxSyncObserver& aObserver );
+        
+    /**@see MEmailMailbox */
+    void CancelSynchronise();
+    
+    /**@see MEmailMailbox */
+    void RegisterObserverL( MMailboxContentObserver& aObserver );
+        
+    /**@see MEmailMailbox */
+    void UnregisterObserver( MMailboxContentObserver& aObserver );
+    
+    /**@see MEmailMailbox */
+    MEmailMessageSearchAsync* MessageSearchL();
+
+    /**@see MEmailMailbox */
+    void ShowInboxL();
+
+    /**@see MEmailMailbox */
+    void EditNewMessageL();
+    
+
+public: // new methods
+
+private:       
+    TFSMailMsgId FsMailboxId() const;
+    
+private: // constructors
+    CEmailMailbox( CPluginData& aPluginData, const TMailboxId& aPlugin );
+    
+    void ConstructL();
+
+private: // inner class for mailbox event handling
+    class TObserverEventMapper : public MFSMailEventObserver
+    {
+    public:
+        TObserverEventMapper( CFSMailPlugin* aPlugin, TUid aPluginUid, const TMailboxId& aMailboxId );
+        ~TObserverEventMapper();
+        void AddObserverL( MMailboxContentObserver& aObserver );
+        void RemoveObserver( MMailboxContentObserver& aObserver );
+    public: // from MFSMailEventObserver
+        virtual void EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        typedef void ( CEmailMailbox::TObserverEventMapper::*TEventMapFunc)( TMailboxId, TAny*, TAny*, TAny* );
+    private: // mappers, so say we all!
+        void ConvertParamsL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, REmailMessageIdArray& aMessageIds, TFolderId& aFolderId );
+        void IgnoreEventL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        void NewMessageL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        void MessageChangedL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        void MessageDeletedL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        void MessageMoved( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        void MessageCopiedL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        void NewFolderL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        void FolderChangeL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        void FoldersDeletedL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        void FoldersMovedL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+        void ExceptionL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+    
+    private:                                                                                                                         
+        static TBool Equals( const MMailboxContentObserver& a1, const MMailboxContentObserver& a2 );
+    private:
+        CFSMailPlugin*  iPlugin;
+        TFSMailMsgId    iFsMailboxId;
+        RPointerArray<MMailboxContentObserver> iClientObservers;
+    };
+    class CEmailRequestObserver: public CBase,
+                                 public MFSMailRequestObserver                                 
+        {
+    public:
+        CEmailRequestObserver();
+        
+        void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
+        void SetObserverL( MMailboxSyncObserver* aObserver );
+    private:
+        MMailboxSyncObserver* iObserver;
+        };
+        
+private:        
+
+    CPluginData&    iPluginData;
+    
+    CFSMailPlugin*  iPlugin;
+
+    TMailboxId      iMailboxId;
+    
+    TObserverEventMapper* iEventMapper;
+
+    mutable CEmailAddress* iAddress;
+
+    CFSMailBox*     iFsMailbox;
+    
+    CEmailRequestObserver* iSyncObserver;    
+    
+    TInt iRequestId;
+};
+    
+#endif // EMAILMAILBOX_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailmailboxcache.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,138 @@
+/*
+* 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: Definition for mailbox cache
+*
+*/
+
+#ifndef EMAILMAILBOXCACHE_H
+#define EMAILMAILBOXCACHE_H
+
+#include <e32base.h> 
+#include <emailapidefs.h>
+
+using namespace EmailInterface;
+
+class CPluginData;
+
+
+/**
+* Cache associating mailbox with a protocol plugin. Improves performance by
+* removing need to load protocol plugins every time a mailbox needs to be
+* accessed (and keeping plugin loaded when it is not needed)
+* @since s60 v5.2
+*/
+NONSHARABLE_CLASS( CEmailMailboxCache ) : public CBase
+{
+public:
+    /**
+    * Cache entry to access plugin by mailbox id
+    */
+    class TCacheEntry
+    {
+    public:
+        inline TCacheEntry( 
+            CPluginData* aPluginData, 
+            TMailboxId aId ) : 
+            iPluginData( aPluginData ), 
+            iMailboxId( aId ) {}
+        CPluginData* iPluginData;
+        TMailboxId iMailboxId;
+    };
+    
+    /**
+    * Constructor
+    */
+    static CEmailMailboxCache* NewL();
+    
+    /** destructor */
+    ~CEmailMailboxCache();
+    
+    /**
+    * Clears cache and indicates that one or more AddMailboxL calls will 
+    * follow.
+    * Cleanup support invalidates cache if leave occurs before EndCachingPop()
+    * is called
+    */
+    void StartCachingPushL();
+    
+    /**
+    * Marks caching fully complete for all mailboxes (call when no more
+    * AddMailboxL will follow) and pops cleanup item.
+    */
+    void EndCachingPop();      
+    
+    /**
+    * Returns if mailboxes are cached
+    */
+    TBool IsCached() const;
+
+    /**
+    * Adds mailbox to cache.
+    * @param aPluginData mailbox associated with plugin(data)
+    * @param aMailboxId mailbox id
+    * @precondition: StartCaching must have been called. 
+    */
+    void AddMailboxL( CPluginData& aPluginData, const TMailboxId& aMailboxId );
+    
+    /**
+    * Returns plugin data by mailbox id
+    * @param aMailboxId 
+    * @return plugin data associated with specified mailbox
+    */
+    CPluginData* PluginDataL( const TMailboxId& aMailboxId ) const;
+
+    /**
+    * Returns plugin data by plugin id
+    * @param aPluginId 
+    * @return plugin data associated with specified plugin
+    */
+    CPluginData* PluginDataL( const TUid& aPluginId ) const;
+    
+    /**
+    * Gets all mailbox ids in all protocol plugins
+    */
+    void GetIdsL( REmailMailboxIdArray& aIdArray ) const;
+    
+private:    
+
+    TInt FindById( const TMailboxId& aMailboxId ) const;
+    TInt FindByPluginIdL( const TUid& aPluginId ) const;    
+    static TBool Equals( const TCacheEntry& a1, const  TCacheEntry& a2 );
+    static TBool PluginEquals( const TCacheEntry& a1, const  TCacheEntry& a2 );
+    
+    static void CleanupOp( TAny* aAny );
+    
+private:
+    
+    CEmailMailboxCache();
+    
+    void ConstructL();
+
+    enum TCacheState {
+        EEmpty,
+        ECaching,
+        EComplete
+    };
+private:
+    // empty, caching or caching complete
+    TCacheState iState;
+
+    // cached mailbox id with associated plugin data
+    RArray<TCacheEntry> iEntries;
+};
+
+
+#endif // EMAILMAILBOXCACHE_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailmessage.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,200 @@
+/*
+* 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 message implementation definition
+*
+*/
+
+#ifndef EMAILMESSAGE_H
+#define EMAILMESSAGE_H
+
+#include <memailmessage.h>
+#include "cfsmailcommon.h"
+#include "emailapiutils.h"
+#include "MFSMailRequestObserver.h"
+#include <QEventLoop>
+
+using namespace EmailInterface;
+
+class CFSMailMessagePart;
+class CFSMailMessage;
+class CFSMailAddress;
+class CFSMailPlugin;
+class CPluginData;
+class CEmailAddress;
+class CEmailAttachment;
+class CEmailTextContent;
+class CEmailMultipart;
+
+NONSHARABLE_CLASS( CEmailMessage ) : public CBase, public MEmailMessage, public MFSMailRequestObserver
+    {
+public:
+    /**
+    * Creates email message from plugin message
+    */
+    static CEmailMessage* NewL( CPluginData& aPluginData,
+                                CFSMailMessage* aFsMessage,
+                                const TDataOwner aOwner );
+
+    ~CEmailMessage();
+
+public: // from MEmailInterface
+    TEmailTypeId InterfaceId() const;
+    
+    void Release();
+    
+public: // from MEmailMessage
+    /**@see MEmailMessage */
+    const TMessageId& MessageId() const;
+    
+    /**@see MEmailMessage */
+    MEmailAddress* SenderAddressL() const;
+    
+    /**@see MEmailMessage */
+    MEmailAddress* ReplyToAddressL() const;
+    
+    /**@see MEmailMessage */
+    void SetReplyToAddressL( const MEmailAddress& aSender );
+    
+    /**@see MEmailMessage */
+    TInt GetRecipientsL( const MEmailAddress::TRole aRole,
+        REmailAddressArray& aRecipients ) const;            
+    
+    /**@see MEmailMessage */
+    void SetRecipientsL( const MEmailAddress::TRole aRole, REmailAddressArray& aRecipients );
+    
+    /**@see MEmailMessage */
+    void RemoveRecipientL( const MEmailAddress& aRecipient );
+    
+    /**@see MEmailMessage */
+    TPtrC Subject() const;
+
+    /**@see MEmailMessage */
+    void  SetSubjectL( const TPtrC& aSubject );    
+    
+    /**@see MEmailMessage */
+    TTime Date() const;
+
+    /**@see MEmailMessage */
+    TInt Flags() const;
+    
+    /**@see MEmailMessage */
+    void SetFlag( const TUint aFlag );
+    
+    /**@see MEmailMessage */
+    void ResetFlag( const TUint aFlag );
+
+    /**@see MEmailMessage */
+    MEmailMessageContent* ContentL() const;
+
+    /**@see MEmailMessage */
+    void SetContentL( const MEmailMessageContent* aContent );
+    
+    /**@see MEmailMessage */
+    void SetPlainTextBodyL( const TDesC& aPlainText );
+
+    /**@see MEmailMessage */
+    MEmailAttachment* AddAttachmentL( const TDesC& aFullPath );
+    
+    /**@see MEmailMessage */
+    MEmailAttachment* AddAttachmentL( RFile& aFile );
+    
+    /**@see MEmailMessage */
+    TInt GetAttachmentsL( REmailAttachmentArray& aAttachments );
+    
+    /**@see MEmailMessage */
+    void RemoveAttachmentL( const MEmailAttachment& aAttachment );
+
+    /**@see MEmailMessage */
+    const TFolderId& ParentFolderId() const;
+
+    /**@see MEmailMessage */
+    void SaveChangesL();
+
+    /**@see MEmailMessage */
+    void SendL();
+
+    /**@see MEmailMessage */
+    void ShowMessageViewerL();
+    
+    /**@see MEmailMessage */
+    void ReplyToMessageL( const TBool aReplyToAll = ETrue );
+    
+    /**@see MEmailMessage */
+    void ForwardMessageL();
+    
+protected: // From MFSMailRequestObserver
+    void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
+
+private:        
+
+    // Copies/moves flag values from iPluginMessage's flags to local flag member variable
+    void InitializeFlagValues();
+    
+    CEmailMessage( CPluginData& aPluginData, CFSMailMessage* aMessage, const TDataOwner aOwner );
+    
+    void ConstructL();
+							       
+    void ConvertAddressArrayL( const MEmailAddress::TRole aRole, 
+                               const RPointerArray<CFSMailAddress>& aSrc, 
+                               REmailAddressArray& aDst ) const; 
+    CEmailAddress* CreateAddressLC( const MEmailAddress::TRole aRole, CFSMailAddress& aFsAddress ) const;
+    TUint MapFlags( const TUint& aFlag );
+    
+    TMessageContentId MessageContentId( TEntryId aContentId ) const;
+        
+private:
+    CPluginData&    iPluginData;
+    
+    CFSMailPlugin*  iPlugin;
+
+    TMessageId      iMessageId;
+    
+    TMessageContentId   iMsgContentId;
+                                                                                  
+    mutable CEmailAddress*  iSender;
+    
+    mutable CEmailAddress*  iReplyTo;
+    
+    REmailAddressArray iRecipients;
+    
+    CFSMailMessage* iPluginMessage;
+    
+    TUint        iFlags;
+    
+    mutable CEmailTextContent *iTextContent;
+    mutable CEmailMultipart* iContent;
+    RPointerArray<CEmailAttachment> iAttachments;
+    TDataOwner iOwner;
+    QEventLoop iEventLoop;
+    TInt iError;
+
+    };
+//Class for compare email content type 
+class TContentType
+{
+public:
+    TContentType( const TDesC& aContentType );
+    // Returns ETrue iff the content type represented by this object 
+    // (after parameters have been removed) is equal to the given content type.
+    TBool Equals( const TDesC& aContentType );
+
+private:
+    // Content type (without parameters)
+    TPtrC iContentType;
+};
+
+
+#endif // EMAILMESSAGE_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailmessagesearch.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,170 @@
+/*
+* 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: Definition of Email message search API.
+*
+*/
+
+#ifndef EMAILMESSAGESEARCHASYNCIMPL_H_
+#define EMAILMESSAGESEARCHASYNCIMPL_H_
+
+#include <memailmessage.h>
+#include <memailmessagesearch.h>
+#include <emailsorting.h>
+
+#include "cfsmailclient.h"
+#include "mfsmailboxsearchobserver.h"
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+
+NONSHARABLE_CLASS( CEmailMessageSearchAsync) : 
+    public CBase, 
+    public MEmailMessageSearchAsync, 
+    public MFSMailBoxSearchObserver
+
+{
+public:
+    /**
+    * Constructor
+    * @return
+    */
+    static CEmailMessageSearchAsync* NewL(
+        CPluginData& aPluginData,
+        const TMailboxId& aMailboxId );
+    
+    /**
+     * Destructor
+     */
+    ~CEmailMessageSearchAsync();
+    
+public: // from MEmailInterface
+    TEmailTypeId InterfaceId() const;
+    
+    void Release();
+    
+
+public: // from MEmailMessageSearchAsync
+    /**
+    * Sets sort order for search results.
+    * Leaves KErrNotReady if search is ongoing.
+    */
+    void SetSortCriteriaL( const TEmailSortCriteria& aCriteria );
+    
+    /**
+    * Adds a search key. Leaves KErrNotReady if search is ongoing.
+    */
+    void AddSearchKeyL( const TDesC& aSearchKey );
+                                                                  
+    /**
+    * Enables/disables search from remote email server.
+    * Leaves KErrNotReady if search is ongoing.
+    */
+    void SetRemoteSearchL( TBool aRemote );                                                               
+    
+    /**
+    * Indicates whether remote search is enabled.
+    */
+    TBool IsRemoteSearch() const;
+    
+    /**
+     * Starts search, all methods affecting search attribures leave
+     * KErrNotReady while search is ongoing.
+     * @param aObserver called when results are available.
+     */     
+    void StartSearchL( MEmailSearchObserver& aObserver );
+
+    /**
+     * Cancels search.
+     */
+    void Cancel();
+                                             
+    /** returns search status 
+      * @return search status:
+      *     < 0 : Search has failed
+      *     KRequestPending : search is ongoing. note that status may be
+      *         KRequestPending after HandleResultL callback because results 
+      *         may be given in chunks of results. Size of chunk depends on
+      *         implementation and may vary.
+      *     KErrNone : initial state, or search has finished
+      */
+    TInt Status() const;
+    
+    /**
+     * Resets all search attribures. Cancels search if ongoing. 
+     */
+    void Reset();
+    
+public:  // From MFSMailBoxSearchObserver
+    /** 
+     * Notifies the email search API client that a match has been found
+     * 
+     * @param aMatchMessage contains a pointer to the matched message.
+     *         Ownership is transfered to the observer.
+     *
+     */
+     void MatchFoundL( CFSMailMessage* aMatchMessage );
+
+    /**
+     * Notifies the email search API client that the search has completed
+     *
+     */
+     void SearchCompletedL();
+
+//
+    /**
+    * Asks client if search engine should change search priority 
+  	*/
+    void ClientRequiredSearchPriority(TInt *apRequiredSearchPriority); 
+//
+
+    
+private:
+    /**
+     * Constructor
+     */
+    CEmailMessageSearchAsync(
+        CPluginData& aPluginData,
+        const TMailboxId& aMailboxId );
+
+    void ConstructL();
+    
+    /**
+     * Function leaves if search is going on. Otherwise it doesn't do anything.
+     */
+    inline void IsSearchGoingOnL() const; 
+
+private:
+    
+    CPluginData&    iPluginData;
+    
+    CFSMailPlugin*  iPlugin;
+
+    TMailboxId      iMailboxId;
+    
+    TFSMailSortCriteria iCriteria;
+        
+    RPointerArray<TDesC> iSearchStrings;    
+
+    MEmailSearchObserver* iObserver;
+    
+    mutable RSemaphore iGate;
+
+    TBool iRemote;
+};
+
+#endif // EMAILMESSAGESEARCHASYNCIMPL_H_
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailmultipart.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,123 @@
+/*
+* 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: Definition of Email text content.
+*
+*/
+
+
+#ifndef EMAILMULTIPART_H_
+#define EMAILMULTIPART_H_
+// INCLUDES
+#include "cfsmailclient.h"
+#include <memailcontent.h>
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+class CEmailMessageContent;
+
+
+// CLASS DECLARATION
+
+NONSHARABLE_CLASS( CEmailMultipart ) : public CBase,
+                                       public MEmailMultipart
+{
+public:
+    static CEmailMultipart* NewL( CPluginData& aPluginData, 
+            const TMessageContentId& aMsgContentId, 
+            CFSMailMessagePart* aPart,
+            const TDataOwner aOwner );
+    
+    ~CEmailMultipart();
+    
+public: // from MEmailInterface
+    TEmailTypeId InterfaceId() const;
+    
+    void Release();
+
+public: // from MEmailMessageContent
+    
+    TMessageContentId Id() const;
+
+    TPtrC ContentType() const;
+
+    void SetContentType( const TDesC& aContentType );
+
+    TPtrC ContentId() const;
+
+    void SetContentId( const TDesC& aContentId );
+
+    TPtrC ContentDescription() const;
+
+    void SetContentDescription( const TDesC& aContentDescription );
+
+    TPtrC ContentDisposition() const;
+
+    void SetContentDisposition( const TDesC& aContentDisposition );
+
+    TPtrC ContentClass() const;
+
+    void SetContentClass( const TDesC& aContentClass );
+
+    TInt AvailableSize() const;
+
+    TInt TotalSize() const;
+
+    TPtrC ContentL() const;
+
+    void SetContentL( const TDesC& aContent );
+
+    void FetchL( MEmailFetchObserver& aObserver );
+
+    void CancelFetch();
+
+    void SaveToFileL( const TDesC& aPath );
+
+    MEmailMultipart* AsMultipartOrNull() const;
+    
+    MEmailTextContent* AsTextContentOrNull() const;
+
+    MEmailAttachment* AsAttachmentOrNull() const;
+    
+public: // from MEmailMultipart
+    TInt PartCountL();
+
+    MEmailMessageContent* PartByIndexL( const TUint aIndex ) const;
+
+    void DeletePartL( const TUint aIndex );
+
+    void AddPartL(
+        const MEmailMessageContent& aPart,
+        const TUint aPos );
+    
+public: // for internal usage
+    void SetOwner( const TDataOwner aOwner );
+    
+    
+private:
+    CEmailMultipart( const TDataOwner aOwner );
+    
+    void ConstructL( CPluginData& aPluginData, const TMessageContentId& aMsgContentId, CFSMailMessagePart* aPart );
+    
+private: // Private data        
+    CEmailMessageContent* iEmailMsgContent;
+    RArray<TFSMailMsgId> iChildParts;
+    TUint iChildPartCount;
+    TDataOwner iOwner;
+};
+
+#endif // EMAILMULTIPART_H_
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailtextcontent.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,121 @@
+/*
+* 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: Definition of Email text content.
+*
+*/
+
+
+#ifndef EMAILTEXTCONTENT_H_
+#define EMAILTEXTCONTENT_H_
+
+// INCLUDES
+#include "cfsmailclient.h"
+#include <memailcontent.h>
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+class CEmailMessageContent;
+// CLASS DECLARATION
+
+/**
+ *  CEmailTextContent
+ * 
+ */
+NONSHARABLE_CLASS( CEmailTextContent ) : public CBase,
+                                         public MEmailTextContent
+{   
+public:
+    static CEmailTextContent* NewL( CPluginData& aPluginData, 
+            const TMessageContentId& aMsgContentId, 
+            CFSMailMessagePart* aPart,
+            const TDataOwner aOwner );
+    
+    ~CEmailTextContent();
+    
+public: // from MEmailInterface
+    TEmailTypeId InterfaceId() const;
+    
+    void Release();
+
+public: // from MEmailTextContent
+    TTextType TextType() const;
+
+    void SetTextL(
+            const TTextType aPlainOrHtml,
+            const TDesC& aText );
+    
+public: // from MEmailMessageContent
+    
+    TMessageContentId Id() const;
+
+    TPtrC ContentType() const;
+
+    void SetContentType( const TDesC& aContentType );
+
+    TPtrC ContentId() const;
+
+    void SetContentId( const TDesC& aContentId );
+
+    TPtrC ContentDescription() const;
+
+    void SetContentDescription( const TDesC& aContentDescription );
+
+    TPtrC ContentDisposition() const;
+
+    void SetContentDisposition( const TDesC& aContentDisposition );
+
+    TPtrC ContentClass() const;
+
+    void SetContentClass( const TDesC& aContentClass );
+
+    TInt AvailableSize() const;
+
+    TInt TotalSize() const;
+
+    TPtrC ContentL() const;
+
+    void SetContentL( const TDesC& aContent );
+
+    void FetchL( MEmailFetchObserver& aObserver );
+
+    void CancelFetch();
+
+    void SaveToFileL( const TDesC& aPath );
+
+    MEmailMultipart* AsMultipartOrNull() const;
+    
+    MEmailTextContent* AsTextContentOrNull() const;
+
+    MEmailAttachment* AsAttachmentOrNull() const;
+    
+public: // for internal usage
+    void SetOwner( const TDataOwner aOwner );
+
+    
+private:
+    CEmailTextContent( const TDataOwner aOwner );
+    
+    void ConstructL( CPluginData& aPluginData, const TMessageContentId& aMsgContentId, CFSMailMessagePart* aPart);
+    
+private:        
+    TTextType               iTextType;
+    CEmailMessageContent*   iEmailMsgContent;
+    TDataOwner              iOwner;
+};
+
+#endif // EMAILTEXTCONTENT_H_
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/messageiterator.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,135 @@
+/*
+* 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: Email message iterator
+*
+*/
+
+#ifndef CMESSAGEITERATOR_H
+#define CMESSAGEITERATOR_H
+                                                                             
+#include <mmessageiterator.h>                                                                             
+#include "emailapidefs.h"
+#include "cfsmailcommon.h"
+
+using namespace EmailInterface;
+
+class MFSMailIterator;
+class CPluginData;
+class CFSMailMessage;
+class CEmailMessage;
+/**
+ * Iterator for email messages
+ * @since S60 v5.2
+ */
+NONSHARABLE_CLASS( CMessageIterator ) : public CBase, public MMessageIterator
+{
+public:
+    /**
+    * Constructor
+    * @param aIterator
+    * @param aPluginData
+    * @return new iterator
+    */
+    static CMessageIterator* NewL( MFSMailIterator* aIterator,
+                                   CPluginData& aPluginData,
+                                   TUint aCount );
+    
+    ~CMessageIterator();
+
+private:
+    CMessageIterator( MFSMailIterator* aIterator, CPluginData& aPluginData, TUint aCount );
+    
+    void ConstructL();
+    
+public: // from MEmailInterface              
+
+    TEmailTypeId InterfaceId() const;
+
+    void Release();
+    
+public: // from MMessageIterator
+
+    /** @see MMessageIterator */
+    MEmailMessage* NextL();
+    
+    /** @see MMessageIterator 
+     (not implemented) */
+    
+    MEmailMessage* PreviousL();
+    
+    TUint Count() const;
+        
+
+private:   
+    // Reads next chunk of messages from protocol plugin
+    TBool ReadNextChunkL();
+    TBool ReadPreviousChunkL();
+    MEmailMessage* ReadFromChunkL();
+    void CleanCache();    
+    void AddToCacheL( CFSMailMessage* aFsMsg );    
+private: // data
+    
+    /**
+    * Iterator internal states. "Consuming" in state names mean getting and 
+    * returning next message from the iterator.
+    */
+    enum TState {
+        // No messages available in iterator, read them from protocl plugin.
+        // NextL returns a message from chunk (or NULL if folder is empty)
+        // This is initial state.
+        EReadNextMessageChunk,
+        EReadPreviousMessageChunk,
+        
+        // Message(s) are available (retrieved from plugin). No remaining 
+        // messages excepted from the plugin. NextL returns a message from chunk.
+        EConsumeFromChunk,
+        
+        // Message(s) are available in chunk and more in protocol plugin.
+        EConsumeFromChunkWithMoreChunksToFollow,
+        
+        // Iterator is iterated throuh and NextL would return NULL.
+        EIteratorConsumed
+    };
+
+    // plugin iterator, owned
+    MFSMailIterator* iIterator;
+    
+    // reference to plugin data
+    CPluginData&    iPluginData;
+
+    CFSMailPlugin*  iPlugin;
+    
+    // message id used for reading messages from plugin
+    TFSMailMsgId    iStartMsgId;
+    
+    // Internal state  
+    TState           iState;
+    
+    // pointer array of messages read from protocol plugin (aka message chunk)
+    RPointerArray<CFSMailMessage> iFsMessageArray;
+    RPointerArray<CEmailMessage> iMessageArray;
+    
+    TUint iCount;
+    
+    TInt iCursor;
+    
+    TFSMailMsgId iFirstMsgId;
+    
+    TBool iHasMoreNextItems;
+    TBool iHasMorePrevItems;
+};
+
+#endif // CMESSAGEITERATOR_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/rom/emailclientapi.iby	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +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:  (ROM) Image description file for emailclientapi
+*
+*/
+#include <data_caging_paths_for_iby.hrh>
+#ifdef FF_EMAIL_FRAMEWORK
+
+ECOM_PLUGIN( emailclientapi.dll, emailclientapi.rsc )
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailaddress.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,129 @@
+/*
+* 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: This file implements class CEmailAddress.
+*
+*/
+
+#include "emailaddress.h"
+#include "cfsmailclient.h"
+#include "emailclientapi.hrh"
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailAddress* CEmailAddress::NewL( const TRole aRole, const TDataOwner aOwner )
+    {
+    CEmailAddress* self = new ( ELeave ) CEmailAddress( aRole, aOwner );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailAddress* CEmailAddress::NewLC( const TRole aRole, const TDataOwner aOwner )
+    {
+    CEmailAddress* self = CEmailAddress::NewL( aRole, aOwner );
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailAddress::~CEmailAddress()
+    {
+    iAddress.Close();
+    iDisplayName.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailAddress::CEmailAddress( const TRole aRole, const TDataOwner aOwner ) :
+    iRole( aRole ), 
+    iOwner( aOwner )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailAddress::InterfaceId() const
+    {
+    return KEmailIFUidAddress;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailAddress::Release()
+    {
+    if ( iOwner == EClientOwns )
+        {
+        delete this;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailAddress::SetAddressL( const TDesC& aAddress )
+    {
+    iAddress.Close();
+    iAddress.CreateL( aAddress );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailAddress::Address() const
+    {    
+    return iAddress;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailAddress::SetDisplayNameL( const TDesC& aDisplayName )
+    {
+    iDisplayName.Close();
+    iDisplayName.CreateL( aDisplayName );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailAddress::DisplayName() const
+    {
+    return iDisplayName;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailAddress::TRole CEmailAddress::Role() const
+    {
+    return iRole;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailAddress::SetRole( const TRole aRole )
+    {
+    iRole = aRole;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailapiutils.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,144 @@
+/*
+* 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: This file implements class CEmailApiUtils.
+*
+*/
+
+#include <e32std.h>
+#include "cfsmailplugin.h"
+#include "emailapidefs.h"
+#include "emailclientapiimpldefs.h"
+#include "emailapiutils.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CPluginData::CPluginData( TUid aUid ) :
+    iData( aUid ),
+    iPluginLoadError( KErrNotReady )
+    { 
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CPluginData::~CPluginData()
+    {
+    // panic if a user of plugin has not called ReleaseInstance after ClaimInstance
+    __ASSERT_ALWAYS( iOwned || !iRefCount, Panic( EMailPanicPluginNotReleased ) );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CFSMailPlugin* CPluginData::ClaimInstance()
+    {
+    if ( !iData.iPlugin )
+        {
+        TRAP( iPluginLoadError, iData.iPlugin = CFSMailPlugin::NewL( iData.iUid ) );
+        }
+    if ( !iPluginLoadError )
+        {
+        iRefCount++;
+        }
+    return iData.iPlugin;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CFSMailPlugin* CPluginData::ClaimInstanceL()
+    {
+    ClaimInstance();
+    User::LeaveIfError( iPluginLoadError );
+    return iData.iPlugin;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CPluginData::ReleaseInstance()
+    {
+    if ( iData.iPlugin )
+        {
+        iRefCount--;
+        if ( !iRefCount )
+            {
+            delete iData.iPlugin;
+            iData.iPlugin = NULL;
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CPluginData::ReleasePushL()
+    {
+    TCleanupItem item( &CPluginData::CleanupOperation, this );
+    CleanupStack::PushL( item );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CPluginData::CleanupOperation( TAny* aAny )
+    {
+    CPluginData* pdata = reinterpret_cast<CPluginData*>( aAny );
+    pdata->ReleaseInstance();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TUid CPluginData::Uid() const
+    {
+    return iData.iUid;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TInt CPluginData::LoadResult() const
+    {
+    return iPluginLoadError;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TFSMailMsgId FsMsgId( const CPluginData& aPluginData, const EmailInterface::TBaseId& aId )
+    {
+    TFSMailMsgId id( aPluginData.Uid(), aId.iId );
+    return id;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CleanupReleasePush::PushL( EmailInterface::MEmailInterface& aItem )
+    {
+    TCleanupItem item( &CleanupReleasePush::Release, &aItem );
+    CleanupStack::PushL( item );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CleanupReleasePush::Release( TAny *aPtr )
+    {
+    reinterpret_cast<EmailInterface::MEmailInterface*>( aPtr )->Release();
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailattachment.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,292 @@
+/*
+* 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: This file implements class CEmailAttachment.
+*
+*/
+
+#include "emailattachment.h"
+#include "emailcontent.h"
+#include "emailclientapi.hrh"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------/
+CEmailAttachment::CEmailAttachment( const TDataOwner aOwner ) : iOwner( aOwner )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAttachment::~CEmailAttachment()
+    {
+    delete iEmailMsgContent;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAttachment* CEmailAttachment::NewLC(
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,
+        CFSMailMessagePart *aAtt,
+        const TDataOwner aOwner )
+    {    
+    CEmailAttachment* self = new (ELeave) CEmailAttachment( aOwner );
+    CleanupStack::PushL( self );
+    self->ConstructL( aPluginData, aMsgContentId, aAtt );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAttachment* CEmailAttachment::NewL(
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,
+        CFSMailMessagePart *aAtt,
+        const TDataOwner aOwner )
+    {
+    CEmailAttachment* self = CEmailAttachment::NewLC( aPluginData, aMsgContentId, aAtt, aOwner );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::ConstructL(
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,
+        CFSMailMessagePart *aAtt)
+    {
+    iEmailMsgContent = CEmailMessageContent::NewL( aPluginData, aMsgContentId, aAtt );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailAttachment::AvailableSize() const
+{
+    return iEmailMsgContent->AvailableSize();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::CancelFetch()
+{
+    iEmailMsgContent->CancelFetch();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentL() const
+{
+    User::Leave(KErrNotSupported);
+    return iEmailMsgContent->ContentL();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentClass() const
+{
+    return iEmailMsgContent->ContentClass();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentDescription() const
+{
+    return iEmailMsgContent->ContentDescription();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentDisposition() const
+{
+    return iEmailMsgContent->ContentDisposition();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentId() const
+{
+    return iEmailMsgContent->ContentId();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentType() const
+{
+    return iEmailMsgContent->ContentType();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::FetchL( MEmailFetchObserver & aObserver )
+{
+    iEmailMsgContent->FetchL( aObserver );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TMessageContentId CEmailAttachment::Id() const
+{
+    return iEmailMsgContent->Id();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailAttachment::InterfaceId() const
+    {
+    return KEmailIFUidAttachment;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::Release()
+    {
+    if ( iOwner == EClientOwns )
+        {    
+        delete this;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SaveToFileL( const TDesC& aPath )
+{
+    iEmailMsgContent->SaveToFileL( aPath );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentClass( const TDesC& aContentClass )
+{
+    iEmailMsgContent->SetContentClass( aContentClass );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentDescription( const TDesC& aContentDescription )
+{
+    iEmailMsgContent->SetContentDescription(aContentDescription);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentDisposition( const TDesC& aContentDisposition )
+{
+    iEmailMsgContent->SetContentDisposition( aContentDisposition );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentId( const TDesC &aContentId )
+{
+    iEmailMsgContent->SetContentId( aContentId );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentL( const TDesC &aContent )
+{
+    iEmailMsgContent->SetContentL( aContent );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentType( const TDesC &aContentType )
+{
+    iEmailMsgContent->SetContentType( aContentType );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailAttachment::TotalSize() const
+{
+    return iEmailMsgContent->TotalSize();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMultipart* CEmailAttachment::AsMultipartOrNull() const
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailTextContent* CEmailAttachment::AsTextContentOrNull() const
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAttachment* CEmailAttachment::AsAttachmentOrNull() const
+    {
+    const MEmailAttachment* ptr = this;
+    return const_cast<MEmailAttachment *>( ptr );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+RFile CEmailAttachment::FileL() const
+    {
+    return iEmailMsgContent->Part().GetContentFileL();
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------/
+void CEmailAttachment::SetFileNameL( const TDesC& aFileName )
+    {
+    iEmailMsgContent->Part().SetAttachmentNameL( aFileName );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::FileNameL() const
+    {
+    return iEmailMsgContent->Part().AttachmentNameL();
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailclientapiimpl.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,425 @@
+/*
+* 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: This file implements class CEmailClientApi.
+*
+*/
+
+
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <viewclipartner.h>
+#include <vwsdefpartner.h>
+#else
+#include <viewcli.h>
+#include <vwsdef.h>
+#endif // SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <centralrepository.h>
+#include "emailclientapiimpl.h"
+#include "emailapiutils.h"
+#include "emailmailbox.h"
+#include <memailaddress.h>
+#include "cfsmailplugin.h"
+#include "cfsmailclient.h"
+#include "emailclientapiimpldefs.h"
+#include "emailmailboxcache.h"
+#include "emailclientapi.hrh"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+MEmailMailbox* CEmailClientApi::MailboxL( const TMailboxId& aId )
+    {
+    UpdateMailboxInfoCacheL();
+    CPluginData* pluginData = MailboxInfoCacheL().PluginDataL( aId );
+    MEmailMailbox* mailbox = NULL;
+    if ( pluginData )
+        {
+        mailbox = CEmailMailbox::NewL( *pluginData, aId );
+        }
+    return mailbox;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailMailbox* CEmailClientApi::MailboxL( const TPtrC& aAddress )
+    {
+    MEmailMailbox* mailbox = NULL;
+    REmailMailboxIdArray mailboxes;
+    CleanupClosePushL( mailboxes );
+    TInt count( GetMailboxIdsL( mailboxes ) );
+    while ( count-- )
+        {
+        const TMailboxId mailboxId = mailboxes[count];
+        MEmailMailbox* refMailbox = MailboxL( mailboxId );
+        if ( refMailbox )
+            {
+            TPtrC address( refMailbox->AddressL()->Address() );
+            if ( !address.Compare( aAddress ) )
+                {
+                mailbox = refMailbox; // addresses match
+                count = 0;
+                }
+            else
+                {
+                refMailbox->Release();
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy( &mailboxes );
+    // find mailbox or leave KErrNotFound
+    if ( !mailbox )
+        {
+        User::Leave( KErrNotFound );
+        }
+    return mailbox;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailClientApi::GetMailboxIdsL( 
+    REmailMailboxIdArray& aMailboxes )
+    {
+    UpdateMailboxInfoCacheL();
+
+    aMailboxes.Reset();
+    CEmailMailboxCache& mbcache = MailboxInfoCacheL();
+    mbcache.GetIdsL( aMailboxes ); 
+
+    const TInt mailboxesFound( aMailboxes.Count() );
+    return mailboxesFound;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailClientApi::GetMailboxesL( RMailboxPtrArray& aMailboxes )
+    {
+    REmailMailboxIdArray mailboxIdArray;
+    CleanupClosePushL( mailboxIdArray );
+
+    // GetMailboxIdsL loads plugin and keeps loaded if it contains at
+    // least one mailbox
+    TInt count = GetMailboxIdsL( mailboxIdArray );
+    while ( count-- )
+        {
+        // mailbox creation increases plugin ref count by one
+        MEmailMailbox* mailbox = MailboxL( mailboxIdArray[count] );
+        CleanupReleasePushL( *mailbox );
+        aMailboxes.AppendL( mailbox );
+        CleanupStack::Pop( mailbox );
+        }
+    // Created mailboxes still hold plugin references so we can decrease 
+    // ref count.
+    ReleaseAllPlugins(); 
+    
+    CleanupStack::PopAndDestroy( &mailboxIdArray );
+    return aMailboxes.Count();
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailClientApi::LaunchEmailL( const TLaunchPolicy /*aPolicy*/ )
+    {
+    User::Leave(KErrNotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CPluginData* CEmailClientApi::TPluginIterator::Next()
+    {
+    CPluginData* item = NULL;
+    if ( iIndex < iArray.Count() )
+        {
+        item = iArray[ iIndex++ ];
+        }
+    return item;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailClientApi* CEmailClientApi::NewL()
+    {
+    CEmailClientApi* instance = static_cast<CEmailClientApi*>( Dll::Tls() );
+
+    if ( !instance )
+        {
+        instance = new ( ELeave ) CEmailClientApi();
+        CleanupStack::PushL( instance );
+        instance->ConstructL();
+        User::LeaveIfError( Dll::SetTls( instance ) );
+        CleanupStack::Pop( instance );
+        }
+
+    instance->iInstanceCounter++;
+
+    return instance;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailClientApi::~CEmailClientApi()
+    {
+    // ensure this doesn't held plugin references
+    ReleaseAllPlugins();
+
+    // ResetAndDestroy doesn't work because ~CPluginData is private
+    TInt count( iPluginDataArray.Count() );
+    while ( count-- )
+        {
+        delete iPluginDataArray[count];
+        }
+    iPluginDataArray.Close();
+    iLoadedPluginsArray.Close();
+    delete iMailboxCache;
+
+    Dll::FreeTls();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailClientApi::CEmailClientApi() : iInstanceCounter( 0 )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailClientApi::CleanupImplInfoPushL( RPointerArray<CImplementationInformation>& aArray )
+    {
+    TCleanupItem item( &CEmailClientApi::CleanupImplInfo, &aArray );
+    CleanupStack::PushL( item );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailClientApi::CleanupImplInfo( TAny* aAny )
+    {
+    RPointerArray<CImplementationInformation>* array = 
+        reinterpret_cast<RPointerArray<CImplementationInformation>*>( aAny );
+    array->ResetAndDestroy();
+    }
+ 
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailClientApi::ConstructL()
+    {
+    RPointerArray<CImplementationInformation> implInfoArray;
+    REComSession::ListImplementationsL( KFSMailPluginInterface, implInfoArray );
+    CleanupImplInfoPushL( implInfoArray );
+    TInt err = KErrNone;
+    TInt count( implInfoArray.Count() );
+    // add implementation UIDs to plugin info array, no instantiation at this
+    // phase
+    while ( count-- )
+        {
+        const CImplementationInformation* info = implInfoArray[count];
+        CPluginData* pluginData = new ( ELeave ) CPluginData( info->ImplementationUid() );
+        err = iPluginDataArray.Append( pluginData );
+        if ( err != KErrNone )
+            {
+            // failed to append, give up
+            delete pluginData;
+            count = 0;
+            }
+        }
+    iMailClient =  CFSMailClient::NewL();
+    CleanupStack::PopAndDestroy( &implInfoArray );
+    User::LeaveIfError( err );    
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailClientApi::InterfaceId() const
+    {
+    return KEmailClientApiInterface;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailClientApi::Release()
+    {
+    if( this->iInstanceCounter == 1 )
+        {
+        delete this;
+        }
+    else
+        {
+        this->iInstanceCounter--;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// Returns plugin instance from plugin data. If we already have "claimed"
+// instance once, prevent increment of reference count 
+// -----------------------------------------------------------------------------
+CFSMailPlugin* CEmailClientApi::UsePlugin( CPluginData& aPluginData )
+    {
+    // use 'data' as search key for IndexOfLoadedPluginData()
+    TPluginData data( aPluginData.Uid() );
+    TPluginData* pluginDataPtr = &data;
+    // check if we have plugin already "in use".
+    const TInt index( IndexOfLoadedPluginData( data ) );
+    if ( index == KErrNotFound )
+        { // we don't have plugin instance so take it and add to loaded plugins
+        data.iPlugin = aPluginData.ClaimInstance();
+        if ( data.iPlugin && iLoadedPluginsArray.Append( data ) != KErrNone )
+            {                
+            aPluginData.ReleaseInstance(); // failed to append, don't proceed..
+            data.iPlugin = NULL;           // but return null
+            }          
+        }
+    else
+        {
+        // already in use, obtain plugin pointer from the array
+        pluginDataPtr = &iLoadedPluginsArray[index];
+        }
+    return pluginDataPtr->iPlugin;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailClientApi::ReleasePlugin( CPluginData& aPluginData )
+    {
+    // release plugin but only if it is not already claimed
+    TPluginData data( aPluginData.Uid() );
+    const TInt index( IndexOfLoadedPluginData( data ) );
+     if ( index != KErrNotFound )
+        {
+        aPluginData.ReleaseInstance();
+        iLoadedPluginsArray.Remove( index );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailClientApi::ReleaseAllPlugins()
+    {
+    for ( TInt i = 0; i < iPluginDataArray.Count(); i++ )
+        {
+        CPluginData* pdata = iPluginDataArray[i];
+        ReleasePlugin( *pdata );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailMailboxCache& CEmailClientApi::MailboxInfoCacheL()
+    {
+    if ( !iMailboxCache)
+        {
+        iMailboxCache = CEmailMailboxCache::NewL();
+        }
+    return *iMailboxCache;
+    }
+
+// -----------------------------------------------------------------------------
+// Lists all mailboxes in protocol plugins and adds them to cache. Plugins may 
+// not be loaded so loading is done. The plugin is kept in memory if it contains
+// at least one mailbox to avoid loading again later as typical use case is 
+// creation of a mailbox object => the plugin is again needed 
+//( see ::GetMailboxesL which calls ReleaseAllPlugins()
+// -----------------------------------------------------------------------------
+void CEmailClientApi::UpdateMailboxInfoCacheL()
+    {
+    CEmailMailboxCache& mbcache = MailboxInfoCacheL();
+    if ( !mbcache.IsCached() )
+        {
+        // cache update needed
+        mbcache.StartCachingPushL();
+        TPluginIterator iter( iPluginDataArray );
+        CPluginData* pluginData = iter.Next();
+        while ( pluginData )
+            {
+            TBool containsMailbox( EFalse );
+            // loads plugin if needed
+            CFSMailPlugin* plugin = UsePlugin( *pluginData );
+            if ( plugin )
+                {
+                // if one plugin fails, it should not block other plugins
+                // ==> trap it             
+                
+                TRAPD( err, containsMailbox = CachePluginMailboxesL(
+                    *pluginData, 
+                    *plugin ) );
+                if ( !containsMailbox || err )
+                    {
+                    // plugins with no mailboxes (or failed to cache) is
+                    // released (unloaded) to optimize RAM usage.
+                    ReleasePlugin( *pluginData );
+                    }            
+                }
+            else if ( pluginData->iPluginLoadError == KErrNoMemory )
+                {
+                // don't continue if OOM
+                User::Leave( KErrNoMemory );
+                }
+            pluginData = iter.Next();
+            }
+        mbcache.EndCachingPop();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TBool CEmailClientApi::CachePluginMailboxesL( CPluginData& aPluginData, CFSMailPlugin& aPlugin )
+    {
+    TBool containsMailbox( EFalse );
+    RArray<TFSMailMsgId> pluginMailboxes;
+    CleanupClosePushL( pluginMailboxes );
+    aPlugin.ListMailBoxesL( pluginMailboxes );
+    TInt mailboxCount = pluginMailboxes.Count();
+    while ( mailboxCount-- )
+        {
+        const TFSMailMsgId& mailboxId = pluginMailboxes[mailboxCount];
+        TMailboxId id( mailboxId.Id() );
+        MailboxInfoCacheL().AddMailboxL( aPluginData, id );
+        containsMailbox = ETrue;
+        }
+    CleanupStack::PopAndDestroy( &pluginMailboxes );
+    return containsMailbox;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailClientApi::IndexOfLoadedPluginData( const TPluginData& aPluginData ) const
+    {
+    TIdentityRelation<TPluginData> relation( CEmailClientApi::PluginDataEquals );
+    return iLoadedPluginsArray.Find( aPluginData, relation );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TBool CEmailClientApi::PluginDataEquals( const TPluginData& a1, const TPluginData& a2 )
+    {
+    return ( a1.iUid == a2.iUid );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailcontent.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,412 @@
+/*
+* 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: This file implements class CEmailContent.
+*
+*/
+
+#include <apmstd.h>
+
+#include "emailcontent.h"
+#include "cfsmailclient.h"
+#include "emailclientapi.hrh"
+#include "emailapiutils.h"
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CEmailMessageContent* CEmailMessageContent::NewL( 
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,
+        CFSMailMessagePart* aPart )    
+    {
+
+    CEmailMessageContent* self = new ( ELeave ) 
+        CEmailMessageContent( aPluginData, aMsgContentId, aPart );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CFSMailMessagePart& CEmailMessageContent::Part()
+    {
+    return *iPart;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetPart( CFSMailMessagePart* aPart )
+    {
+    iPart = aPart;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CPluginData& CEmailMessageContent::PluginData()
+    {
+    return iPluginData;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::ConstructL()
+    {
+    iPlugin = iPluginData.ClaimInstanceL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CEmailMessageContent::~CEmailMessageContent()
+    {
+    iPluginData.ReleaseInstance();
+    delete iPart;
+    delete iBuf;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CEmailMessageContent::CEmailMessageContent(
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,
+        CFSMailMessagePart* aPart):
+        iPluginData( aPluginData ), 
+        iPart( aPart ), 
+        iMsgContentId( aMsgContentId ), 
+        iBuf( NULL ), 
+        iUsed( 0 )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TEmailTypeId CEmailMessageContent::InterfaceId() const
+    {
+    return KEmailIFUidMessageContent;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::Release()
+    {
+    delete this;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TMessageContentId CEmailMessageContent::Id() const
+    {
+    return iMsgContentId;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentType() const
+    {
+    if (iPart)
+        {
+        return iPart->GetContentType();
+        } 
+    else
+        {
+        return TPtrC(0,0);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentType( const TDesC& aContentType )
+    {
+    if (iPart)
+        iPart->SetContentType( aContentType );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentId() const
+    {
+    if (iPart)
+        {
+        return iPart->ContentID();
+        }
+    else
+        {
+        return TPtrC(0,0);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentId( const TDesC& aContentId )
+    {
+    if (iPart)
+        TRAP_IGNORE( iPart->SetContentIDL( aContentId ) );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentDescription() const
+    {
+    if (iPart)
+        {
+        return iPart->ContentDescription();
+        }
+    else
+        {
+        return TPtrC(0,0);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentDescription( 
+    const TDesC& aContentDescription )
+    {
+    if (iPart)
+        iPart->SetContentDescription( aContentDescription );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentDisposition() const
+    {
+    if (iPart)
+        {
+        return iPart->ContentDisposition();
+        }
+    else
+        {
+        return TPtrC(0,0);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentDisposition( 
+    const TDesC& aContentDisposition )
+    {
+    if (iPart)
+        iPart->SetContentDisposition( aContentDisposition );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentClass() const
+    {
+    if (iPart)
+        {
+        return iPart->GetContentClass();
+        }
+    else
+        {
+        return TPtrC(0,0);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentClass( const TDesC& aContentClass )
+    {
+    if (iPart)
+        iPart->SetContentClass( aContentClass );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TInt CEmailMessageContent::AvailableSize() const
+    {
+    if (iPart)
+        {
+        return iPart->FetchedContentSize();
+        }
+    else
+        {
+        return 0;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TInt CEmailMessageContent::TotalSize() const
+    {
+    if (iPart)
+        {
+        return iPart->ContentSize();
+        }
+    else
+        {
+        return 0;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentL() const
+    {
+    TInt size = AvailableSize();
+    TPtr16 ptr( 0, size );
+    if ( size != 0 )
+        {
+        if ( !iBuf )
+            {
+            iBuf = HBufC::NewL( size );
+            }
+        
+        if ( size > ptr.MaxLength() )
+            {
+            iBuf = iBuf->ReAlloc( size );
+            }
+        ptr.Set( iBuf->Des() );
+        iPart->GetContentToBufferL( ptr, iUsed );
+        iUsed += size;
+        }
+    return ptr;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentL( const TDesC& aContent )
+    {
+    User::LeaveIfNull( iPart );
+    iPart->SetContentSize( aContent.Length() );
+    iPart->SetFetchedContentSize( aContent.Length() );
+    iPlugin->SetContentL( aContent, 
+            FsMsgId( iPluginData, iMsgContentId.iMessageId.iFolderId.iMailboxId ),
+            FsMsgId( iPluginData, iMsgContentId.iMessageId.iFolderId ),
+            FsMsgId( iPluginData, iMsgContentId.iMessageId ),
+            FsMsgId( iPluginData, iMsgContentId ) );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::FetchL( MEmailFetchObserver&  aObserver )
+    {
+    User::LeaveIfNull( iPart );
+    const TFSMailMsgId fsId = FsMsgId(iPluginData, iMsgContentId);
+    if ( !iFetchObserver )
+        {
+        iFetchObserver = new ( ELeave ) CContentRequestObserver( *this );
+        }
+    iFetchObserver->SetObserverL( &aObserver );
+    iRequestId = iPart->FetchMessagePartL( fsId, *iFetchObserver, TUint( 0 ) );
+
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::CancelFetch()
+    {
+    TRAP_IGNORE( iPlugin->CancelL( iRequestId ) );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SaveToFileL( const TDesC& aPath )
+    {
+    iPlugin->CopyMessagePartFileL(
+        FsMsgId( iPluginData, iMsgContentId.iMessageId.iFolderId.iMailboxId ),
+        FsMsgId( iPluginData, iMsgContentId.iMessageId.iFolderId ),
+        FsMsgId( iPluginData, iMsgContentId.iMessageId ),
+        FsMsgId( iPluginData, iMsgContentId ),
+        aPath );
+    }
+
+/* Dummy implementations, not ever called */
+MEmailMultipart* CEmailMessageContent::AsMultipartOrNull() const 
+    {
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+MEmailTextContent* CEmailMessageContent::AsTextContentOrNull() const
+    {
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+MEmailAttachment* CEmailMessageContent::AsAttachmentOrNull() const
+    {
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CEmailMessageContent::CContentRequestObserver::CContentRequestObserver( 
+    CEmailMessageContent& aParent ) : iObserver( NULL ), iParent( aParent )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::CContentRequestObserver::RequestResponseL( 
+    TFSProgress aEvent, TInt /* aRequestId */ )
+    {
+    if ( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
+        {
+        delete iParent.iPart;
+        iParent.iPart = NULL;
+        CFSMailMessagePart *part = iParent.iPlugin->MessagePartL( 
+            FsMsgId( iParent.iPluginData, iParent.iMsgContentId.iMessageId.iFolderId.iMailboxId ),
+            FsMsgId( iParent.iPluginData, iParent.iMsgContentId.iMessageId.iFolderId ),
+            FsMsgId( iParent.iPluginData, iParent.iMsgContentId.iMessageId ),
+            FsMsgId( iParent.iPluginData, iParent.iMsgContentId ) );
+        iParent.SetPart( part );
+
+        if ( iObserver ) 
+            iObserver->DataFetchedL( aEvent.iError );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::CContentRequestObserver::SetObserverL( MEmailFetchObserver* aObserver )
+    {
+    iObserver = aObserver;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailfolder.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,278 @@
+/*
+* 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: This file implements class CEmailFolder.
+*
+*/
+
+#include "emailfolder.h"
+#include "emailmailbox.h"
+#include "emailapiutils.h"
+#include "messageiterator.h"
+#include "emailsorting.h"
+#include "cfsmailfolder.h"
+#include "cfsmailplugin.h"
+#include "emailclientapi.hrh"
+#include "emailclientapiimpldefs.h"
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailFolder* CEmailFolder::NewLC( 
+    CPluginData& aPluginData,
+    const TFolderId& aFolderId,  
+    CFSMailFolder *aFolder )
+    {
+    CEmailFolder* self = new ( ELeave ) 
+        CEmailFolder( aPluginData, aFolderId, aFolder );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailFolder* CEmailFolder::NewL( 
+    CPluginData& aPluginData,
+    const TFolderId& aFolderId,  
+    CFSMailFolder *aFolder )
+    {
+    CEmailFolder* self = CEmailFolder::NewLC( aPluginData, aFolderId, aFolder);
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailFolder::CEmailFolder( 
+    CPluginData& aPluginData, 
+    const TFolderId& aFolderId,
+    CFSMailFolder* aFolder) : 
+    iPluginData( aPluginData ), 
+    iFolderType( EOther ), 
+    iFolderId( aFolderId ),
+    iFolder( aFolder )
+    {
+    }
+   
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailFolder::ConstructL()
+    {
+    iPlugin = iPluginData.ClaimInstance();
+    
+    User::LeaveIfNull( iFolder );
+    
+    const TFSFolderType fsType = iFolder->GetFolderType();
+    switch ( fsType )
+        {
+        case EFSInbox:
+            iFolderType = EInbox;
+            break;
+        case EFSOutbox:
+            iFolderType = EOutbox;
+            break;
+        case EFSDraftsFolder:
+            iFolderType = EDrafts;
+            break;
+        case EFSSentFolder:
+            iFolderType = ESent;
+            break;
+        case EFSDeleted:
+            iFolderType = EDeleted;
+            break;
+        case EFSOther:
+        default:
+            iFolderType = EOther;
+            break;
+        }
+    iParentId = TFolderId( 
+        iFolder->GetParentFolderId().Id(), 
+        iFolderId.iMailboxId );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailFolder::~CEmailFolder()
+    {
+    iPluginData.ReleaseInstance();
+    delete iFolder;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailFolder::InterfaceId() const
+    {
+    return KEmailIFUidFolder;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailFolder::Release()
+    {
+    delete this;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TFolderId CEmailFolder::FolderId() const
+    {
+    return iFolderId;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TFolderId CEmailFolder::ParentFolderId() const
+    {
+    return iParentId;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TFolderType CEmailFolder::FolderType() const
+    {
+    return iFolderType;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailFolder::Name() const
+    {
+    if ( !iFolder )
+        return KNullDesC();
+    return TPtrC ( iFolder->GetFolderName() );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailFolder::GetSubfoldersL( RFolderArray& aSubfolders ) const
+    {
+    User::LeaveIfNull( iFolder );
+
+    RPointerArray<CFSMailFolder> folders;
+    CleanupResetAndDestroy<RPointerArray<CFSMailFolder> >::PushL( folders );
+
+    iFolder->GetSubFoldersL( folders );
+    
+    TInt res( folders.Count() );
+    
+    for ( TInt i = 0; i < res; i++ )
+        {
+        const CFSMailFolder* fsfolder = folders[i];
+        const TEntryId id = fsfolder->GetFolderId().Id();
+        const TFolderId folderId( id, iFolderId.iMailboxId.iId );
+        MEmailFolder* folder = CEmailFolder::NewL( iPluginData, folderId, folders[i] );
+        aSubfolders.AppendL( folder );
+        }
+    CleanupStack::Pop( &folders );
+    folders.Close();
+    return res;
+    }
+
+// -----------------------------------------------------------------------------
+//  CEmailFolder::MessagesL
+// -----------------------------------------------------------------------------
+MMessageIterator* CEmailFolder::MessagesL(
+        const RSortCriteriaArray& aCriteria )
+    {
+    RArray<TFSMailSortCriteria> sortCriterias;
+    CleanupClosePushL( sortCriterias );
+    CEmailFolder::ToFsSortCriteriaL( aCriteria, sortCriterias );
+
+    MFSMailIterator* fsIter = iFolder->ListMessagesL( EFSMsgDataEnvelope, sortCriterias );
+    TUint count = iFolder->GetMessageCount();
+
+    CleanupStack::PopAndDestroy( &sortCriterias );
+    CMessageIterator* iter = CMessageIterator::NewL( 
+        fsIter, iPluginData, count );
+
+    return iter;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailFolder::DeleteMessagesL( const REmailMessageIdArray& aMessageIds )
+    {
+    RArray<TFSMailMsgId> fsArray;
+    CleanupClosePushL( fsArray );
+    const TInt count( aMessageIds.Count() );
+    for ( TInt i = 0; i < count; i++ )
+        {
+        TMessageId msgId = aMessageIds[i];
+        if ( iFolderId != msgId.iFolderId )
+            {
+            // not all messages in the same folder, plugin API doesn't accept this.
+            User::Leave( KErrArgument );
+            }
+        fsArray.AppendL( FsMsgId( iPluginData, msgId ) );
+        }
+    iPlugin->DeleteMessagesByUidL( 
+            FsMsgId( iPluginData, iFolderId.iMailboxId ), 
+            FsMsgId( iPluginData, iFolderId ), 
+            fsArray );
+    CleanupStack::PopAndDestroy( &fsArray );
+    }
+
+// -----------------------------------------------------------------------------
+// Maps email api sort criteria to sort criteria type that protocol plugin
+// accepts.
+// -----------------------------------------------------------------------------
+void CEmailFolder::ToFsSortCriteriaL( 
+    const RSortCriteriaArray& aSortCriteria, 
+    RArray<TFSMailSortCriteria>& aFsCriteria )
+    {
+    const TFSMailSortField fieldValues[] = {
+        EFSMailDontCare,        
+        EFSMailSortByDate,      
+        EFSMailSortBySender,    
+        EFSMailSortByRecipient, 
+        EFSMailSortBySubject,   
+        EFSMailSortByPriority,  
+        EFSMailSortByFlagStatus,
+        EFSMailSortByUnread,    
+        EFSMailSortBySize,      
+        EFSMailSortByAttachment };
+
+    for ( TInt i=0; i < aSortCriteria.Count(); i++ )
+        {
+        const TEmailSortCriteria& criteria  = aSortCriteria[i];
+        __ASSERT_ALWAYS( criteria.iField < sizeof( fieldValues ) / sizeof (fieldValues [i] ),
+            Panic( EMailPanicSortMapIndexOutOfBounds ) );
+        TFSMailSortCriteria fsCriteria;
+        fsCriteria.iField = fieldValues[ criteria.iField ];
+        if ( criteria.iAscending )
+            {
+            fsCriteria.iOrder = EFSMailAscending;
+            }
+        else
+            {
+            fsCriteria.iOrder = EFSMailDescending;
+            }
+        aFsCriteria.AppendL( fsCriteria );
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailinterfacefactoryimpl.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,216 @@
+/*
+* 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: This file implements class CEmailInterfaceFactoryImpl.
+*
+*/
+
+#include <e32property.h>                // RProperty
+#include <s32mem.h>                     // RDesRead/WriteStream
+
+#include "emailinterfacefactoryimpl.h"
+#include "emailcontent.h"
+#include "cfsmailclient.h"
+#include "emailclientapiimpldefs.h"
+#include "emailclientapiimpl.h"
+#include "emailaddress.h"
+#include "emailmessagesearch.h"
+#include "emailshutdownconst.h"
+
+_LIT( KEmailImplPanic, "Email client API" );
+const TInt KEmailUidExtraBuffer = 2 * KEmailPlatformApiUidItemSize;
+
+// ---------------------------------------------------------------------------
+// Email client API panic wrapper
+// ---------------------------------------------------------------------------
+void Panic( TEmailImplPanic aPanic )
+    {
+    User::Panic( KEmailImplPanic(), aPanic );
+    }
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::NewL
+// ---------------------------------------------------------------------------
+CEmailInterfaceFactoryImpl* CEmailInterfaceFactoryImpl::NewL()
+    {
+    CEmailInterfaceFactoryImpl* self = new (ELeave) CEmailInterfaceFactoryImpl();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl
+// ---------------------------------------------------------------------------
+CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl()
+    {
+    TRAP_IGNORE( AppendOrRemoveUidL( EEmailUidModeRemove ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl
+// ---------------------------------------------------------------------------
+CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl() : 
+    CEmailInterfaceFactory()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::ConstructL
+// ---------------------------------------------------------------------------
+void CEmailInterfaceFactoryImpl::ConstructL()
+    {
+	// This leaves if related P&S keys are not defined by EmailServerMonitor,
+	// so EmailServerMonitor need to be started before using client API.
+	// TRAP_IGNORE should be removed after EmailServerMonitor is added to
+	// starter list.
+    TRAP_IGNORE( AppendOrRemoveUidL( EEmailUidModeAppend ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::InterfaceL
+// ---------------------------------------------------------------------------
+MEmailInterface* CEmailInterfaceFactoryImpl::InterfaceL( const TInt aInterfaceId )
+    {
+    MEmailInterface* interface = NULL;
+    switch ( aInterfaceId )
+        {
+        case KEmailClientApiInterface:
+            interface = CEmailClientApi::NewL();
+            break;
+        case KEmailIFUidAddress:
+            interface = CEmailAddress::NewL( MEmailAddress::EUndefined, EClientOwns );
+            break;
+        case KEmailIFUidTextContent:
+        default:
+            break;
+        }
+    if ( !interface )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    return interface;
+    }
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::AppendOrRemoveUidL
+// ---------------------------------------------------------------------------
+void CEmailInterfaceFactoryImpl::AppendOrRemoveUidL(
+        const TEmailUidAppendRemoveMode aMode )
+    {
+    // Read buffer length
+    TInt bufLength( 0 );
+    User::LeaveIfError( RProperty::Get( KEmailShutdownPsCategory,
+                                        EEmailPsKeyPlatformApiAppsToCloseLength,
+                                        bufLength ) );
+
+    // Allocate buffer for reading and then read the list of UIDs from P&S.
+    // Adding some extra buffer just in case the size key and actual list
+    // are out of sync. This shouldn't happen, but you never know.
+    HBufC8* readBuf = HBufC8::NewLC( bufLength + KEmailUidExtraBuffer );
+    TPtr8 readPtr = readBuf->Des();
+    
+    User::LeaveIfError( RProperty::Get( KEmailShutdownPsCategory,
+                                        EEmailPsKeyPlatformApiAppsToClose,
+                                        readPtr ) );
+    
+    // For writing get the size of the original buffer + room for our own UID
+    // if needed
+    TInt writeBufSize = readPtr.Length();
+    if( aMode == EEmailUidModeAppend )
+        {
+        writeBufSize += KEmailPlatformApiUidItemSize;
+        }
+    
+    HBufC8* writeBuf = HBufC8::NewLC( writeBufSize );
+    TPtr8 writePtr = writeBuf->Des();
+
+    // Read and write streams used to read/write the UIDs from/to descriptors
+    RDesReadStream readStream( readPtr );
+    CleanupClosePushL( readStream );
+
+    RDesWriteStream writeStream( writePtr );
+    CleanupClosePushL( writeStream );
+
+    // Get our own process UID
+    RProcess ownProcess;
+    TUid ownUid = ownProcess.SecureId();
+    ownProcess.Close();
+
+    TInt itemsCount = readPtr.Length() / KEmailPlatformApiUidItemSize;
+
+    TBool ownUidFound = EFalse;
+    TInt writeLength = 0;
+    for ( TInt ii = 0;ii < itemsCount; ++ii )
+        {
+        // Read next UID from the stream
+        TUid item = TUid::Uid( readStream.ReadInt32L() );
+        
+        // We can skip our own UID. If we are removing, then we don't want
+        // our UID to be written. If we are adding, we don't need to set
+        // the new values as our UID already exists in the list.
+        if( item == ownUid )
+            {
+            ownUidFound = ETrue;
+            if( aMode == EEmailUidModeAppend )
+                {
+                // Our own UID is already in the list, so no need to update
+                // the list. Hence we can quit here.
+                break;
+                }
+            }
+        else
+            {
+            writeStream.WriteInt32L( item.iUid );
+            writeLength += KEmailPlatformApiUidItemSize;
+            }
+        }
+
+    // If we are appending our UID and it wasn't found from the list,
+    // write it to the stream
+    if( aMode == EEmailUidModeAppend && !ownUidFound )
+        {
+        writeStream.WriteInt32L( ownUid.iUid );
+        writeLength += KEmailPlatformApiUidItemSize;
+        }
+
+    // Set correct length for the write ptr buffer as it might not be
+    // updated correctly by the write stream
+    writePtr.SetLength( writeLength );
+
+    // Set new values to P&S only if something has changed, so either:
+    // 1) We are appending our UID and it didn't exist before
+    // 2) We are removing our UID and it did exist before
+    if( ( aMode == EEmailUidModeAppend && !ownUidFound ) ||
+        ( aMode == EEmailUidModeRemove && ownUidFound ) )
+        {
+        // Write first the UID list as it is more probable to fail, writing
+        // plain integer value shouldn't fail in any case. This way these
+        // values stay in sync also in case of error, as the list length
+        // gets updated only if the list itself is updated succesfully.
+        User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory,
+                        EEmailPsKeyPlatformApiAppsToClose,
+                        writePtr ) );
+
+        User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory,
+                        EEmailPsKeyPlatformApiAppsToCloseLength,
+                        writeLength ) );
+        }
+
+    CleanupStack::PopAndDestroy( 4, readBuf );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailmailbox.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,662 @@
+/*
+* 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: This file implements class CEmailMailbox.
+*
+*/
+
+#include <e32cmn.h>
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <viewclipartner.h>
+#include <vwsdefpartner.h>
+#else
+#include <viewcli.h>
+#include <vwsdef.h>
+#endif // SYMBIAN_ENABLE_SPLIT_HEADERS
+
+#include <mmailboxsyncobserver.h>
+#include "emailmailbox.h"
+#include "emailapiutils.h"
+#include "emailaddress.h"
+#include "emailfolder.h"
+#include "emailmessage.h"
+#include "emailmessagesearch.h"
+#include "cfsmailclient.h"
+#include "emailclientapiimpl.h"
+#include "cfsmailplugin.h"
+#include "cfsmailbox.h"
+#include "cfsmailfolder.h"
+#include "emailclientapi.hrh"
+
+#include <XQServiceRequest.h>
+#include "email_services_api.h"
+
+// Constants
+
+#include <QStringList>
+
+_LIT( KNewLine, "\n" );
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox* CEmailMailbox::NewL(
+    CPluginData& aPluginData,
+    const TMailboxId& aMailboxId )
+    {
+    CEmailMailbox* self = new ( ELeave ) CEmailMailbox( aPluginData, aMailboxId );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox::CEmailMailbox(
+    CPluginData& aPluginData,
+    const TMailboxId& aMailboxId )
+    : iPluginData( aPluginData ),
+    iMailboxId( aMailboxId.iId )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::ConstructL()
+    {
+    iPlugin = iPluginData.ClaimInstanceL();
+    iEventMapper = new ( ELeave ) TObserverEventMapper(
+        iPlugin, iPluginData.Uid(), iMailboxId );
+    iFsMailbox = iPlugin->GetMailBoxByUidL( FsMailboxId() );
+    iSyncObserver = new ( ELeave ) CEmailMailbox::CEmailRequestObserver();
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox::~CEmailMailbox()
+    {
+    delete iFsMailbox;
+    delete iEventMapper;
+    delete iAddress;
+    iPluginData.ReleaseInstance();
+    delete iSyncObserver;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailMailbox::InterfaceId() const
+    {
+    return KEmailIFUidMailbox;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::Release()
+    {
+    delete this;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TMailboxId CEmailMailbox::MailboxId() const
+    {
+    return iMailboxId;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAddress* CEmailMailbox::AddressL() const
+    {
+    if ( !iAddress )
+        {
+        iAddress = CEmailAddress::NewL(
+            MEmailAddress::ESender, EAPIOwns );
+        iAddress->SetDisplayNameL( iFsMailbox->GetName() );
+        iAddress->SetAddressL( iFsMailbox->OwnMailAddress().GetEmailAddress() );
+        }
+    return iAddress;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailMailbox::MailboxName() const
+    {
+    return iFsMailbox->GetName();
+    }
+
+// -----------------------------------------------------------------------------
+// Constructs and returns type mailbox id of internal data type TFSMailMsgId
+// -----------------------------------------------------------------------------
+TFSMailMsgId CEmailMailbox::FsMailboxId() const
+    {
+    return FsMsgId( iPluginData, iMailboxId );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailMailbox::GetFoldersL( RFolderArray& aFolders ) const
+    {
+    TFSMailMsgId rootId = TFSMailMsgId();
+    RPointerArray<CFSMailFolder> folders;
+    CleanupResetAndDestroyPushL( folders );
+    iPlugin->ListFoldersL( FsMailboxId(), rootId, folders );
+    TInt res( folders.Count() );
+    for ( TInt i = 0; i < res; i++ )
+        {
+        const CFSMailFolder* fsfolder = folders[i];
+        const TEntryId id = fsfolder->GetFolderId().Id();
+        const TFolderId folderId( id, iMailboxId );
+        CEmailFolder* folder = CEmailFolder::NewLC( iPluginData, folderId, folders[i] );
+        aFolders.AppendL( folder );
+        CleanupStack::Pop( folder );
+        }
+    CleanupStack::Pop( &folders );
+    folders.Close(); // close but don't delete folders because they are
+                     // owned by CEmailFolder
+    return res;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailFolder* CEmailMailbox::FolderL( const TFolderId& aFolderId ) const
+    {
+    CFSMailFolder* fsFolder = iPlugin->GetFolderByUidL(
+            FsMsgId( iPluginData, iMailboxId ),
+            FsMsgId( iPluginData, aFolderId ) );
+    CleanupStack::PushL( fsFolder );
+
+    CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
+                aFolderId, fsFolder );
+    CleanupStack::Pop( fsFolder );
+
+    return folder;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailFolder* CEmailMailbox::FolderByTypeL(
+    const TFolderType aFolderType ) const
+    {
+    TFSMailMsgId fsFolderId;
+
+    switch ( aFolderType )
+        {
+        case EInbox:
+            fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSInbox );
+            break;
+        case EOutbox:
+            fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSOutbox );
+            break;
+        case EDrafts:
+            fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSDraftsFolder );
+            break;
+        case EDeleted:
+            fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSDeleted );
+            break;
+        case ESent:
+            fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSSentFolder );
+            break;
+        case EOther:
+        default:
+            User::Leave( KErrNotFound );
+            break;
+        }
+
+    const TFolderId folderId( fsFolderId.Id(), iMailboxId );
+
+    CFSMailFolder* fsFolder = iPlugin->GetFolderByUidL(
+            FsMsgId( iPluginData, iMailboxId ),
+            fsFolderId );
+    CleanupStack::PushL( fsFolder );
+
+    CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
+            folderId,
+            fsFolder );
+
+    CleanupStack::Pop( fsFolder );
+
+    return folder;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessage* CEmailMailbox::MessageL( const TMessageId& aMessageId )
+    {
+    CFSMailMessage *fsMessage = iPlugin->GetMessageByUidL(
+            FsMsgId( iPluginData, aMessageId.iFolderId.iMailboxId ),
+            FsMsgId( iPluginData, aMessageId.iFolderId ),
+            FsMsgId( iPluginData, aMessageId ),
+            EFSMsgDataEnvelope );
+
+    CleanupStack::PushL( fsMessage );
+    CEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
+    CleanupStack::Pop( fsMessage );
+
+    return message;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessage* CEmailMailbox::CreateDraftMessageL() const
+    {
+    CFSMailMessage* fsMessage = iFsMailbox->CreateMessageToSend();
+    User::LeaveIfNull( fsMessage );
+    CleanupStack::PushL( fsMessage );
+    MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
+    CleanupStack::Pop( fsMessage );
+
+    return message;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessage* CEmailMailbox::CreateReplyMessageL( 
+        const TMessageId& aMessageId, const TBool aReplyToAll ) const
+    {
+    CFSMailMessage* fsMessage = iFsMailbox->CreateReplyMessage( 
+        FsMsgId( iPluginData, aMessageId ), aReplyToAll );
+    User::LeaveIfNull( fsMessage );
+    CleanupStack::PushL( fsMessage );
+    MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
+    CleanupStack::Pop( fsMessage );
+
+    return message;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessage* CEmailMailbox::CreateForwardMessageL( const TMessageId& aMessageId ) const
+    {
+    CFSMailMessage* fsMessage = iFsMailbox->CreateForwardMessage(
+        FsMsgId( iPluginData, aMessageId ), KNewLine() );
+    User::LeaveIfNull( fsMessage );
+    CleanupStack::PushL( fsMessage );
+    MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
+    CleanupStack::Pop( fsMessage );
+
+    return message;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::SynchroniseL( MMailboxSyncObserver& aObserver )
+    {
+    iSyncObserver->SetObserverL( &aObserver );
+    iRequestId = iFsMailbox->RefreshNowL( *iSyncObserver );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::CancelSynchronise()
+    {
+    iFsMailbox->CancelSearch();
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::RegisterObserverL( MMailboxContentObserver& aObserver )
+    {
+    iEventMapper->AddObserverL( aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::UnregisterObserver( MMailboxContentObserver& aObserver )
+    {
+    iEventMapper->RemoveObserver( aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessageSearchAsync* CEmailMailbox::MessageSearchL()
+    {
+    MEmailMessageSearchAsync* searchAPI = 
+        CEmailMessageSearchAsync::NewL( iPluginData, iMailboxId );
+    return searchAPI;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::ShowInboxL()
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::EditNewMessageL()
+    {
+    bool syncronous;
+
+    XQServiceRequest request( emailInterfaceNameSend,
+                             emailOperationSendMail,
+                             syncronous );
+
+    QVariant returnValue;
+    if ( !request.send( returnValue ) )
+        User::Leave( KErrGeneral );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox::TObserverEventMapper::TObserverEventMapper(
+    CFSMailPlugin* aPlugin,
+    TUid aPluginUid, const TMailboxId& aMailboxId )
+     : iPlugin( aPlugin ),
+       iFsMailboxId( aPluginUid.iUid, aMailboxId.iId )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox::TObserverEventMapper::~TObserverEventMapper()
+    {
+    iClientObservers.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// Adds mailbox observer and subscribes to plugin mailbox events if there
+// were no previous observers.
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::AddObserverL( 
+        MMailboxContentObserver& aObserver )
+    {
+    TIdentityRelation<MMailboxContentObserver> relation( 
+        &CEmailMailbox::TObserverEventMapper::Equals );
+    if ( iClientObservers.Find( &aObserver, relation ) == KErrNotFound )
+        {
+        const TInt count( iClientObservers.Count() );
+        if  ( !count )
+            {
+            iPlugin->SubscribeMailboxEventsL( iFsMailboxId, *this );
+            }
+        iClientObservers.AppendL( &aObserver );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// Removes an observer and removes event subscription if the observer was
+// last in observer array.
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::RemoveObserver( 
+        MMailboxContentObserver& aObserver )
+    {
+    TIdentityRelation<MMailboxContentObserver> relation( 
+        &CEmailMailbox::TObserverEventMapper::Equals );
+    const TInt index( iClientObservers.Find( &aObserver, relation ) );
+    if ( index != KErrNotFound )
+        {
+        iClientObservers.Remove( index );
+        const TInt count( iClientObservers.Count() );
+        if  ( !count )
+            {
+            iPlugin->UnsubscribeMailboxEvents( iFsMailboxId, *this );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// Maps protocol a plugin event to client event
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::EventL(
+    TFSMailEvent aEvent,
+    TFSMailMsgId aMailbox,
+    TAny* aParam1,
+    TAny* aParam2,
+    TAny* aParam3 )
+    {
+    const TEventMapFunc KMailboxEventHandlers[] = {
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+    &CEmailMailbox::TObserverEventMapper::NewMessageL,
+    &CEmailMailbox::TObserverEventMapper::MessageChangedL,
+    &CEmailMailbox::TObserverEventMapper::MessageDeletedL,
+    &CEmailMailbox::TObserverEventMapper::MessageMoved,
+    &CEmailMailbox::TObserverEventMapper::MessageCopiedL,
+    &CEmailMailbox::TObserverEventMapper::NewFolderL,
+    &CEmailMailbox::TObserverEventMapper::FolderChangeL,
+    &CEmailMailbox::TObserverEventMapper::FoldersDeletedL,
+    &CEmailMailbox::TObserverEventMapper::FoldersMovedL,
+    &CEmailMailbox::TObserverEventMapper::ExceptionL
+    };
+
+    TMailboxId id( aMailbox.Id() );
+    // boundary check
+    const TInt index( aEvent );
+    if ( index < sizeof( KMailboxEventHandlers ) / sizeof( KMailboxEventHandlers[ index ] ) )
+        {
+        // call event handler function
+        TEventMapFunc method = KMailboxEventHandlers[ index ];
+        (this->*method)(id, aParam1,aParam2,aParam3 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::ConvertParamsL( 
+        TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, 
+        REmailMessageIdArray& aMessageIds, TFolderId& aFolderId )
+    {
+    RArray<TFSMailMsgId>* newEntries( static_cast< RArray<TFSMailMsgId>* >( aParam1 ) );
+    CleanupClosePushL( *newEntries );
+    TFSMailMsgId* parentFolder = static_cast<TFSMailMsgId*>( aParam2 );
+    aFolderId = TFolderId( parentFolder->Id(), aMailbox );
+
+    for ( TInt j = 0; j < newEntries->Count(); j++ ) 
+        {
+        TFSMailMsgId fsId(( *newEntries )[j] );
+        TMessageId messageId( fsId.Id(), aFolderId.iId, aMailbox );
+        aMessageIds.Append( messageId );
+        }
+
+    CleanupStack::PopAndDestroy( newEntries );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::IgnoreEventL(
+    TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::NewMessageL(
+    TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
+    {
+    REmailMessageIdArray messageIds;
+    TFolderId folderId;
+    ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
+    CleanupClosePushL( messageIds );
+
+    for ( TInt i = 0; i < iClientObservers.Count(); i++ )
+        {
+        MMailboxContentObserver* observer = iClientObservers[i];
+        if (observer)
+            observer->NewMessageEventL( aMailbox, messageIds, folderId );
+        }
+    
+    CleanupStack::PopAndDestroy( &messageIds );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::MessageChangedL(
+    TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
+    {
+    REmailMessageIdArray messageIds;
+    TFolderId folderId;
+    ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
+    CleanupClosePushL( messageIds );
+
+    for ( TInt i = 0; i < iClientObservers.Count(); i++ )
+        {
+        MMailboxContentObserver* observer = iClientObservers[i];
+        if (observer)
+            observer->MessageChangedEventL( aMailbox, messageIds, folderId );
+        }
+    CleanupStack::PopAndDestroy( &messageIds );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::MessageDeletedL(
+    TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
+    {
+    REmailMessageIdArray messageIds;    
+    TFolderId folderId;
+    ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
+    CleanupClosePushL( messageIds );
+
+    for ( TInt i = 0; i < iClientObservers.Count(); i++ )
+        {
+        MMailboxContentObserver* observer = iClientObservers[i];
+        if (observer)
+            observer->MessageDeletedEventL( aMailbox, messageIds, folderId );
+        }
+    
+    CleanupStack::PopAndDestroy( &messageIds );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::MessageMoved(
+    TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::MessageCopiedL(
+    TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::NewFolderL(
+    TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::FolderChangeL(
+    TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::FoldersDeletedL(
+    TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::FoldersMovedL(
+    TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::ExceptionL(
+    TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TBool CEmailMailbox::TObserverEventMapper::Equals( 
+        const MMailboxContentObserver& a1, const MMailboxContentObserver& a2 )
+    {
+    return ( &a1 == &a2 );
+    }
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox::CEmailRequestObserver::CEmailRequestObserver() : iObserver( NULL )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::CEmailRequestObserver::RequestResponseL( 
+        TFSProgress aEvent, TInt /* aRequestId */ )
+    {
+    if ( iObserver && aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
+        {
+        iObserver->MailboxSynchronisedL(aEvent.iError);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::CEmailRequestObserver::SetObserverL( MMailboxSyncObserver* aObserver )
+    {
+    iObserver = aObserver;
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailmailboxcache.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,194 @@
+/*
+* 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: This file implements class CEmailMailboxCache.
+*
+*/
+
+#include "emailmailboxcache.h"
+#include "emailapiutils.h"
+
+static const TInt KCacheGranularity = 2;
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CEmailMailboxCache* CEmailMailboxCache::NewL()
+    {
+    CEmailMailboxCache* cache = new ( ELeave ) CEmailMailboxCache();
+    return cache;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CEmailMailboxCache::~CEmailMailboxCache()
+    {
+    iEntries.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// Start of cache transaction with clenanup support
+// ---------------------------------------------------------------------------
+void CEmailMailboxCache::StartCachingPushL()
+    {
+    TCleanupItem item( &CEmailMailboxCache::CleanupOp, this );
+    CleanupStack::PushL( item );
+    iState = ECaching;
+    iEntries.Reset();
+    }
+
+// ---------------------------------------------------------------------------
+//  End of cache transaction
+// ---------------------------------------------------------------------------
+void CEmailMailboxCache::EndCachingPop()
+    {
+    iState = EComplete;
+    CleanupStack::Pop();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TBool CEmailMailboxCache::IsCached() const
+    {
+    return iState == EComplete;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMailboxCache::AddMailboxL( 
+    CPluginData& aPluginData, 
+    const TMailboxId& aMailboxId )
+    {
+    if ( iState != ECaching )
+        {
+        User::Leave( KErrNotReady );
+        }
+    if ( FindById( aMailboxId ) == KErrNotFound )
+        {
+        TCacheEntry entry( &aPluginData, aMailboxId );
+        iEntries.AppendL( entry );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CPluginData* CEmailMailboxCache::PluginDataL( const TMailboxId& aMailboxId ) const
+    {
+    CPluginData* pdata = NULL;
+    const TInt index( FindById( aMailboxId ) );
+    if ( index != KErrNotFound )
+        {
+        const TCacheEntry& entry = iEntries[ index ];
+        pdata = entry.iPluginData;
+        }
+    return pdata;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CPluginData* CEmailMailboxCache::PluginDataL( const TUid& aPluginId ) const
+    {
+    CPluginData* pdata = NULL;
+    const TInt index( FindByPluginIdL( aPluginId ) );
+    if ( index != KErrNotFound )
+        {
+        const TCacheEntry& entry = iEntries[ index ];
+        pdata = entry.iPluginData;
+        }
+    return pdata;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+void CEmailMailboxCache::GetIdsL( REmailMailboxIdArray& aIdArray ) const
+    {
+    if ( iState != EComplete )
+        {
+        // cache not up to date
+        User::Leave( KErrNotReady );
+        }
+    for ( TInt i=0; i < iEntries.Count(); i++ )
+        {
+        TMailboxId id = iEntries[i].iMailboxId;
+        aIdArray.AppendL( id );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TInt CEmailMailboxCache::FindById( const TMailboxId& aMailboxId ) const
+    {
+    TIdentityRelation<TCacheEntry> rel( CEmailMailboxCache::Equals );
+
+    // don't care about plugin data because this is seach key only and
+    // mailbox id is used for search
+    TCacheEntry entry( NULL, aMailboxId );
+    return iEntries.Find( entry, rel );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TInt CEmailMailboxCache::FindByPluginIdL( const TUid& aPluginId ) const
+    {
+    TIdentityRelation<TCacheEntry> rel( CEmailMailboxCache::PluginEquals );
+    CPluginData* key = new ( ELeave ) CPluginData( aPluginId );
+    TCacheEntry entry( key, TMailboxId() );
+    TInt index = iEntries.Find( entry, rel ); 
+    delete key;
+    return index;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TBool CEmailMailboxCache::Equals( const TCacheEntry& a1, const TCacheEntry& a2 )
+    {
+    return ( a1.iMailboxId == a2.iMailboxId );
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+TBool CEmailMailboxCache::PluginEquals( const TCacheEntry& a1, const TCacheEntry& a2 )
+    {
+    return ( a1.iPluginData->Uid() == a2.iPluginData->Uid() );
+    }
+
+// ---------------------------------------------------------------------------
+// Cleanup 
+// ---------------------------------------------------------------------------
+void CEmailMailboxCache::CleanupOp( TAny* aAny )
+    {
+    CEmailMailboxCache* cache = reinterpret_cast<CEmailMailboxCache*>( aAny );
+    cache->iEntries.Reset();
+    cache->iState = EEmpty;
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+CEmailMailboxCache::CEmailMailboxCache() : 
+    iState( EEmpty ), 
+    iEntries( KCacheGranularity )
+    {
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailmessage.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,912 @@
+/*
+* 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: This file implements class CEmailMessage.
+*
+*/
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <viewclipartner.h>
+#include <vwsdefpartner.h>
+#else
+#include <viewcli.h>
+#include <vwsdef.h>
+#endif // SYMBIAN_ENABLE_SPLIT_HEADERS
+
+#include "emailmessage.h"
+#include "emailaddress.h"
+#include "emailapiutils.h"
+#include "emailclientapi.hrh"
+#include "emailapiutils.h"
+#include "emailinterfacefactoryimpl.h"
+#include "emailcontent.h"
+#include "emailtextcontent.h"
+#include "emailmultipart.h"
+#include "emailattachment.h"
+#include "cfsmailplugin.h"
+#include "cfsmailclient.h"
+
+#include <XQServiceRequest.h>
+#include "email_services_api.h"
+
+const TInt KSendMessageRequestId = 100;
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailMessage* CEmailMessage::NewL( CPluginData& aPluginData,
+                                    CFSMailMessage* aFsMessage,
+                                    const TDataOwner aOwner )
+    {
+    CEmailMessage* message = new ( ELeave ) CEmailMessage( aPluginData, aFsMessage, aOwner );
+    CleanupStack::PushL( message );
+    message->ConstructL();
+    CleanupStack::Pop( message );
+    return message;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailMessage::CEmailMessage(
+        CPluginData& aPluginData,
+        CFSMailMessage *aFsMessage,
+        const TDataOwner aOwner)
+        : iPluginData( aPluginData ), iPluginMessage( aFsMessage ), iOwner( aOwner )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::ConstructL()
+    {
+    User::LeaveIfNull( iPluginMessage );
+    iPlugin = iPluginData.ClaimInstanceL();
+    if ( iPluginMessage )
+        {
+        iMessageId = TMessageId( 
+            iPluginMessage->GetMessageId().Id(),
+            iPluginMessage->GetFolderId().Id(), 
+            iPluginMessage->GetMailBoxId().Id() );
+
+        // Copy the message flags
+        InitializeFlagValues();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailMessage::~CEmailMessage()
+    {
+    delete iPluginMessage;
+    delete iSender;
+    delete iReplyTo;
+    delete iTextContent;
+    delete iContent;
+    iPluginData.ReleaseInstance();
+    iAttachments.ResetAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailMessage::InterfaceId() const
+    {
+    return KEmailIFUidMessage;
+    }
+    
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::Release()
+    {
+    if ( iOwner == EClientOwns )
+        {
+        delete this;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+const TMessageId& CEmailMessage::MessageId() const
+    {
+    return iMessageId;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailAddress* CEmailMessage::SenderAddressL() const
+    {
+    User::LeaveIfNull( iPluginMessage );
+
+    CFSMailAddress* fsAddress = iPluginMessage->GetSender();
+    if ( fsAddress )
+        {
+        if ( !iSender )
+            {
+            iSender = CEmailAddress::NewL( MEmailAddress::ESender, EAPIOwns );
+            }
+        iSender->SetAddressL(fsAddress->GetEmailAddress());
+        iSender->SetDisplayNameL(fsAddress->GetDisplayName());
+        }
+    else
+        {
+        // Sender address not defined. Delete client object as well
+        delete iSender;
+        iSender = NULL;
+        }
+    return iSender;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailAddress* CEmailMessage::ReplyToAddressL() const
+    {
+    User::LeaveIfNull( iPluginMessage );
+
+    const CFSMailAddress& fsAddress = iPluginMessage->GetReplyToAddress();
+    if ( &fsAddress )
+        {
+        if ( !iReplyTo )
+            {
+            iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns );
+            }
+        iReplyTo->SetAddressL( fsAddress.GetEmailAddress() );
+        iReplyTo->SetDisplayNameL( fsAddress.GetDisplayName() );
+        }
+    else
+        {
+        delete iReplyTo;
+        iReplyTo = NULL;
+        }
+    return iReplyTo;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetReplyToAddressL( const MEmailAddress& aSender )
+    {
+    User::LeaveIfNull( iPluginMessage );
+    
+    CFSMailAddress *fsAddress = CFSMailAddress::NewLC();
+    if ( !iReplyTo )
+        {
+        iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns );
+        }
+    fsAddress->SetDisplayName( aSender.DisplayName() );
+    fsAddress->SetEmailAddress( aSender.Address() );
+    iPluginMessage->SetReplyToAddress( fsAddress );
+    iReplyTo->SetAddressL( fsAddress->GetEmailAddress() );
+    iReplyTo->SetDisplayNameL( fsAddress->GetDisplayName() );
+    CleanupStack::Pop();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailMessage::GetRecipientsL( const MEmailAddress::TRole aRole,
+        REmailAddressArray& aRecipients ) const
+    {
+    if( aRole == MEmailAddress::EReplyTo ||
+        aRole == MEmailAddress::ESender )
+        {
+        User::Leave( KErrArgument );
+        }
+    else 
+        {
+        User::LeaveIfNull( iPluginMessage );
+        
+        if( aRole == MEmailAddress::ETo || 
+            aRole == MEmailAddress::EUndefined )
+            {
+            const RPointerArray<CFSMailAddress>& toRecipients =
+                iPluginMessage->GetToRecipients();
+            ConvertAddressArrayL( 
+                    MEmailAddress::ETo, 
+                    toRecipients, aRecipients );
+            }
+        if( aRole == MEmailAddress::ECc || 
+            aRole == MEmailAddress::EUndefined )
+            {
+            const RPointerArray<CFSMailAddress>& ccRecipients =
+                iPluginMessage->GetCCRecipients();
+            ConvertAddressArrayL( 
+                    MEmailAddress::ECc, 
+                    ccRecipients, aRecipients );
+            }
+        if( aRole == MEmailAddress::EBcc || 
+            aRole == MEmailAddress::EUndefined )
+            {
+            const RPointerArray<CFSMailAddress>& bccRecipients =
+                iPluginMessage->GetBCCRecipients();
+            ConvertAddressArrayL( 
+                    MEmailAddress::EBcc, 
+                    bccRecipients, aRecipients );
+            }
+        }
+    return aRecipients.Count();
+    }
+    
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetRecipientsL( const MEmailAddress::TRole aRole,
+        REmailAddressArray& aRecipients )
+    {
+    TInt count( aRecipients.Count() );
+
+    for( TInt i=0;i<count;i++ )
+        {
+        const MEmailAddress* address = aRecipients[i];
+        CFSMailAddress* fsAddress = CFSMailAddress::NewLC();
+        fsAddress->SetEmailAddress( address->Address() );
+        fsAddress->SetDisplayName( address->DisplayName() );
+        
+        User::LeaveIfNull( iPluginMessage );
+        
+        if( aRole == MEmailAddress::ETo )
+            {
+            iPluginMessage->AppendToRecipient( fsAddress );
+            }
+        else if( aRole == MEmailAddress::ECc )
+            {
+            iPluginMessage->AppendCCRecipient( fsAddress );
+            }
+        else if( aRole == MEmailAddress::EBcc )
+            {
+            iPluginMessage->AppendBCCRecipient( fsAddress );
+            }
+        else
+            {
+            User::Leave( KErrArgument );
+            }
+        CleanupStack::Pop( fsAddress );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::RemoveRecipientL( const MEmailAddress& /*aRecipient*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailMessage::Subject() const
+    {
+    if ( !iPluginMessage )
+        return KNullDesC();
+    return iPluginMessage->GetSubject();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void  CEmailMessage::SetSubjectL( const TPtrC& aSubject )
+    {
+    User::LeaveIfNull( iPluginMessage );
+    iPluginMessage->SetSubject( aSubject );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TTime CEmailMessage::Date() const
+    {
+    TTime time;
+
+    if ( iPluginMessage ) {
+        time = iPluginMessage->GetDate();
+    }
+
+    return time;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailMessage::Flags() const
+    {
+    return iFlags;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetFlag( const TUint aFlag )
+    {
+    iFlags |= aFlag;
+    TUint flag = MapFlags( aFlag );
+    if ( iPluginMessage )
+        iPluginMessage->SetFlag( flag );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::ResetFlag( const TUint aFlag )
+    {
+    iFlags &= ~aFlag;
+    TUint flag = MapFlags( aFlag );
+    if ( iPluginMessage )
+        iPluginMessage->ResetFlag( flag );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::InitializeFlagValues()
+    {
+    if ( !iPluginMessage )
+        return;
+    // 1st reset member value, then start copying different flags
+    iFlags = 0;
+    
+    // EFlag_Read
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Read ) )
+        {
+        iFlags |= EFlag_Read;
+        }
+    else
+        {
+        iFlags &= ~EFlag_Read;
+        }
+    //    EFlag_Read_Locally
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Read_Locally ) )
+        {
+        iFlags |= EFlag_Read_Locally;
+        }
+    else
+        {
+        iFlags &= ~EFlag_Read_Locally;
+        }    
+    // EFlag_Low
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Low ) )
+        {
+        iFlags |= EFlag_Low;
+        }
+    else
+        {
+        iFlags &= ~EFlag_Low;
+        }
+    // EFlag_Important
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Important ) )
+        {
+        iFlags |= EFlag_Important;
+        }
+    else
+        {
+        iFlags &= ~EFlag_Important;
+        }
+    // EFlag_FollowUpComplete
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_FollowUpComplete ) )
+        {
+        iFlags |= EFlag_FollowUpComplete;
+        }
+    else
+        {
+        iFlags &= ~EFlag_FollowUpComplete;
+        }
+    // EFlag_FollowUp
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_FollowUp ) )
+        {
+        iFlags |= EFlag_FollowUp;
+        }
+    else
+        {
+        iFlags &= ~EFlag_FollowUp;
+        }
+    // EFlag_Attachments
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Attachments ) )
+        {
+        iFlags |= EFlag_Attachments;
+        }
+    else
+        {
+        iFlags &= ~EFlag_Attachments;
+        }
+    // EFlag_Multiple
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Multiple ) )
+        {
+        iFlags |= EFlag_Multiple;
+        }
+    else
+        {
+        iFlags &= ~EFlag_Multiple;
+        }
+    // EFlag_CalendarMsg
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_CalendarMsg ) )
+        {
+        iFlags |= EFlag_CalendarMsg;
+        }
+    else
+        {
+        iFlags &= ~EFlag_CalendarMsg;
+        }
+    // EFlag_Answered
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Answered ) )
+        {
+        iFlags |= EFlag_Answered;
+        }
+    else
+        {
+        iFlags &= ~EFlag_Answered;
+        }
+    // EFlag_Forwarded
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Forwarded ) )
+        {
+        iFlags |= EFlag_Forwarded;
+        }
+    else
+        {
+        iFlags &= ~EFlag_Forwarded;
+        }
+    // EFlag_OnlyToMe
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_OnlyToMe ) )
+        {
+        iFlags |= EFlag_OnlyToMe;
+        }
+    else
+        {
+        iFlags &= ~EFlag_OnlyToMe;
+        }
+    // EFlag_RemoteDeleted
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_RemoteDeleted ) )
+        {
+        iFlags |= EFlag_RemoteDeleted;
+        }
+    else
+        {
+        iFlags &= ~EFlag_RemoteDeleted;
+        }
+    // EFlag_HasMsgSender 
+    if ( iPluginMessage->IsFlagSet( EFSMsgFlag_HasMsgSender ) )
+        {
+        iFlags |= EFlag_HasMsgSender;
+        }
+    else
+        {
+        iFlags &= ~EFlag_HasMsgSender;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailMessageContent* CEmailMessage::ContentL() const
+    {
+    if ( iTextContent )
+        {
+        return iTextContent;
+        }
+    if ( iContent )
+        {
+        return iContent;
+        }
+
+    User::LeaveIfNull( iPluginMessage );
+    
+    RPointerArray<CFSMailMessagePart> parts;
+    CleanupResetAndDestroyPushL( parts );
+    iPluginMessage->ChildPartsL( parts );
+    TInt count( parts.Count() );
+    if( count == 0 )
+        {
+        /* No content, return NULL */
+        CleanupStack::PopAndDestroy( &parts ); // in case heap allocated but not used
+        return NULL;
+        }
+    CFSMailMessagePart* part = parts[0];
+    TContentType contentType( part->GetContentType() );
+    TMessageContentId msgContentId = TMessageContentId(
+                        part->GetPartId().Id(),
+                        iMessageId.iId,
+                        iMessageId.iFolderId.iId,
+                        iMessageId.iFolderId.iMailboxId );
+
+    if ( contentType.Equals( KFSMailContentTypeTextPlain ) ||
+        contentType.Equals( KFSMailContentTypeTextHtml ) )
+        {                                
+        iTextContent = CEmailTextContent::NewL(iPluginData, msgContentId, part, EAPIOwns );
+        parts[0] = NULL; // ownership of part transferred
+        }
+    else if ( contentType.Equals( KFSMailContentTypeMultipartMixed ) ||
+              contentType.Equals( KFSMailContentTypeMultipartAlternative ) ||
+              contentType.Equals( KFSMailContentTypeMultipartDigest ) ||
+              contentType.Equals( KFSMailContentTypeMultipartRelated ) ||
+              contentType.Equals( KFSMailContentTypeMultipartParallel ) )
+        {
+        iContent = CEmailMultipart::NewL(iPluginData, msgContentId, part, EAPIOwns);
+        parts[0] = NULL; // ownership of part transferred
+        }
+
+    CleanupStack::PopAndDestroy( &parts ); // parts
+
+    if (iTextContent)
+        {
+        return iTextContent;
+        }
+    return iContent;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetContentL( const MEmailMessageContent*  aContent )
+    {
+    User::LeaveIfNull( aContent );
+    MEmailTextContent* textContent = aContent->AsTextContentOrNull();
+    if ( textContent )
+        {
+        if ( iTextContent )
+            {
+            delete iTextContent; // Destroy old content
+            }
+        iTextContent = dynamic_cast<CEmailTextContent*>( textContent );
+        if ( iTextContent )
+            {
+            iTextContent->SetOwner( EAPIOwns );
+            }
+        return;
+        }
+    MEmailMultipart* mPart = aContent->AsMultipartOrNull();
+    if ( mPart )
+        {
+        if ( iContent )
+            {
+            delete iContent;
+            }
+        iContent = dynamic_cast<CEmailMultipart*>( mPart );
+        if ( iContent )
+            {
+            iContent->SetOwner( EAPIOwns );
+            }
+        }    
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetPlainTextBodyL( const TDesC& aPlainText )
+    {
+    if ( iTextContent )
+        {
+        iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText );
+        return;
+        }
+
+    User::LeaveIfNull( iPluginMessage );
+
+    CFSMailMessagePart* msgTextPart = iPluginMessage->PlainTextBodyPartL();
+    
+    if( !msgTextPart )
+        {
+        msgTextPart = iPluginMessage->NewChildPartL( TFSMailMsgId(), KFSMailContentTypeTextPlain );
+        }
+    CleanupStack::PushL( msgTextPart );
+
+    TMessageContentId msgContentId = MessageContentId( msgTextPart->GetPartId().Id() );
+
+    msgTextPart->SetContentType( KFSMailContentTypeTextPlain );
+    iTextContent = CEmailTextContent::NewL( iPluginData, msgContentId, msgTextPart, EAPIOwns );
+    if (iTextContent)
+        {
+        iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText );
+        }
+    CleanupStack::Pop( msgTextPart );
+
+    return;
+
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailAttachment* CEmailMessage::AddAttachmentL( const TDesC& aFullPath )
+    {
+    User::LeaveIfNull( iPluginMessage );
+
+    CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL( aFullPath, TFSMailMsgId() );
+    CleanupStack::PushL( part );    
+    CEmailAttachment* att = CEmailAttachment::NewLC( iPluginData, iMsgContentId, part, EAPIOwns );
+    iAttachments.AppendL( att );
+    CleanupStack::Pop( 2, part );
+
+    return att;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailAttachment* CEmailMessage::AddAttachmentL( RFile& aFile )
+    {
+    User::LeaveIfNull( iPluginMessage );
+    TBufC8 <1> mime;
+    CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL( aFile, mime );
+    CleanupStack::PushL( part );
+    CEmailAttachment* att = CEmailAttachment::NewLC( iPluginData, iMsgContentId, part, EAPIOwns );
+    iAttachments.AppendL( att );
+
+    CleanupStack::Pop( 2, part );
+
+    return att;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailMessage::GetAttachmentsL( REmailAttachmentArray& aAttachments )
+    {
+    User::LeaveIfNull( iPluginMessage );
+
+    RPointerArray<CFSMailMessagePart> attachments;
+    CleanupResetAndDestroyPushL( attachments );
+    iPluginMessage->AttachmentListL( attachments );
+    const TInt count( attachments.Count() );
+    for (TInt i = 0; i < count; i++)
+        {
+        TMessageContentId msgContentId = MessageContentId( attachments[i]->GetPartId().Id() );
+
+        CEmailAttachment* att = CEmailAttachment::NewL( 
+            iPluginData, msgContentId, attachments[i], EClientOwns );
+
+        aAttachments.AppendL( att );
+        }
+    CleanupStack::Pop( &attachments );
+    return count;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::RemoveAttachmentL( const MEmailAttachment& /*aAttachment*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+const TFolderId& CEmailMessage::ParentFolderId() const
+    {
+    return iMessageId.iFolderId;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::SaveChangesL()
+    {
+    User::LeaveIfNull( iPluginMessage );
+    
+    TFSMailMsgId mailboxId( 
+            FsMsgId( iPluginData, iMessageId.iFolderId.iMailboxId ) );
+    
+    iPlugin->StoreMessageL( mailboxId, *iPluginMessage );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::SendL()
+    {
+    User::LeaveIfNull( iPluginMessage );
+    
+    if ( iEventLoop.isRunning() )
+        User::Leave( KErrInUse );
+    
+    SaveChangesL();
+    iError = KErrNone;
+    iPlugin->SendMessageL( *iPluginMessage, *this, KSendMessageRequestId );
+    iEventLoop.exec();
+
+    User::LeaveIfError( iError );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::RequestResponseL( TFSProgress aEvent, TInt aRequestId )
+    {
+    iError = aEvent.iError;
+
+    if ( aRequestId == KSendMessageRequestId &&
+            aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
+        iEventLoop.quit();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessage::ConvertAddressArrayL(
+        const MEmailAddress::TRole aRole,
+        const RPointerArray<CFSMailAddress>& aSrc,
+        REmailAddressArray& aDst ) const
+    {
+    for ( TInt i=0; i<aSrc.Count(); i++ )
+        {
+        CEmailAddress* recipient = CreateAddressLC( aRole, *aSrc[i] );
+        aDst.AppendL( recipient );
+        CleanupStack::Pop( recipient );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAddress* CEmailMessage::CreateAddressLC(
+        const MEmailAddress::TRole aRole, 
+        CFSMailAddress& aFsAddress ) const
+    {
+    CEmailAddress* address = CEmailAddress::NewLC( aRole, EClientOwns );
+    TDesC& temp1 = aFsAddress.GetEmailAddress();
+    if ( &temp1 )
+        {
+        address->SetAddressL( temp1 );
+        }
+    TDesC& temp2 = aFsAddress.GetDisplayName();
+    if ( &temp2 )
+        {
+        address->SetDisplayNameL( temp2 );
+        }   
+    return address;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TUint CEmailMessage::MapFlags( const TUint& aFlag )
+    {
+    TUint flag = 0;
+    switch( aFlag )
+        {
+        case EFlag_Read:
+            flag = EFSMsgFlag_Read;
+            break;
+        case EFlag_Read_Locally:
+            flag = EFSMsgFlag_Read_Locally;
+            break;
+        case EFlag_Low:
+            flag = EFSMsgFlag_Low;
+            break;
+        case EFlag_Important:
+            flag = EFSMsgFlag_Important;
+            break;
+        case EFlag_FollowUpComplete:
+            flag = EFSMsgFlag_FollowUpComplete;
+            break;
+        case EFlag_FollowUp:
+            flag = EFSMsgFlag_FollowUp;
+            break;
+        case EFlag_Attachments:
+            flag = EFSMsgFlag_Attachments;
+            break;
+        case EFlag_Multiple:
+            flag = EFSMsgFlag_Multiple;
+            break;
+        case EFlag_CalendarMsg:
+            flag = EFSMsgFlag_CalendarMsg;
+            break;
+        case EFlag_Answered:
+            flag = EFSMsgFlag_Answered;
+            break;
+        case EFlag_Forwarded:
+            flag = EFSMsgFlag_Forwarded;
+            break;
+        case EFlag_OnlyToMe:
+            flag = EFSMsgFlag_OnlyToMe;
+            break;
+        case EFlag_RemoteDeleted:
+            flag = EFSMsgFlag_RemoteDeleted;
+            break;
+        case EFlag_HasMsgSender:
+            flag = EFSMsgFlag_HasMsgSender;
+            break;
+        default:
+            break;
+        }
+    return flag;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::ShowMessageViewerL()
+    {   
+    bool syncronous;
+
+    XQServiceRequest request(
+       emailInterfaceNameMessage,
+       emailOperationViewMessage,
+       syncronous );
+
+    TFSMailMsgId mailboxId = FsMsgId( iPluginData, iMessageId.iFolderId.iMailboxId );
+    TFSMailMsgId folderId = FsMsgId( iPluginData, iMessageId.iFolderId );
+    TFSMailMsgId messageId = FsMsgId( iPluginData, iMessageId );
+
+    QList<QVariant> list;
+    list.append( mailboxId.Id() );
+    list.append( folderId.Id() );
+    list.append( messageId.Id() );
+    request.setArguments( list );
+
+    QVariant returnValue;
+    if ( !request.send( returnValue ) )
+        User::Leave( KErrGeneral );
+    }
+
+// -----------------------------------------------------------------------------
+// Launches Email application and new reply message in editor. 
+// The method follows "fire and forget" pattern, returns immediately.
+// -----------------------------------------------------------------------------
+void CEmailMessage::ReplyToMessageL( const TBool /*aReplyToAll*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::ForwardMessageL()
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TMessageContentId CEmailMessage::MessageContentId( TEntryId aContentId ) const
+    {
+    TMessageContentId msgContentId = TMessageContentId( 
+                    aContentId,
+                    iMessageId.iId,
+                    iMessageId.iFolderId.iId,
+                    iMessageId.iFolderId.iMailboxId );
+    return msgContentId;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TContentType::TContentType( const TDesC& aContentType ) : iContentType( aContentType )
+    {
+    _LIT( KSeparator, ";" );
+    TInt end = aContentType.Find( KSeparator );
+    if ( end != KErrNotFound )
+        {
+        iContentType.Set( aContentType.Left( end ) );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TBool TContentType::Equals( const TDesC& aContentType )
+    {
+    TBool ret = iContentType.CompareF( aContentType );
+    if ( ret == 0  )
+        return ETrue;
+    else
+        return EFalse;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailmessagesearch.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,362 @@
+/*
+* 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: This file implements class CEmailMessageSearchAsync
+*
+*/
+
+#include <emailclientapi.hrh>
+#include "emailmessagesearch.h"
+#include "emailmessage.h"
+
+/**
+ * Global semaphore name. Semaphore blocks parallel service access.
+ */
+_LIT( KGlobalSemaphoreToPreventParallelCall, "12mymessaging.nokia.com34" );
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CEmailMessageSearchAsync::NewL
+// ---------------------------------------------------------------------------
+CEmailMessageSearchAsync* CEmailMessageSearchAsync::NewL(
+    CPluginData& aPluginData,
+    const TMailboxId& aMailboxId )
+    {
+    CEmailMessageSearchAsync* self = 
+        new ( ELeave ) CEmailMessageSearchAsync( aPluginData, aMailboxId );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageSearchAsync::ConstructL()
+    {
+    iPlugin = iPluginData.ClaimInstanceL();
+    // Open existing semaphore, or create a new one
+    if ( KErrNone != iGate.OpenGlobal( KGlobalSemaphoreToPreventParallelCall, EOwnerProcess ) )
+        {
+        User::LeaveIfError( 
+            iGate.CreateGlobal( KGlobalSemaphoreToPreventParallelCall, 1, EOwnerProcess ) );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailMessageSearchAsync::CEmailMessageSearchAsync(    
+    CPluginData& aPluginData,
+    const TMailboxId& aMailboxId )
+    : iPluginData( aPluginData ), iMailboxId( aMailboxId.iId ),
+    iCriteria(), iObserver( NULL ), iRemote( EFalse )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailMessageSearchAsync::~CEmailMessageSearchAsync()
+    {
+    iSearchStrings.Close();
+    iPluginData.ReleaseInstance();
+    iGate.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailMessageSearchAsync::InterfaceId() const
+    {
+    return KEmailIFUidSearch;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::Release()
+    {
+    if (KErrNone != iGate.Wait(1))
+        {
+        this->Cancel();
+        }
+    delete this;
+    }
+
+// -----------------------------------------------------------------------------
+// Sets sort order for search results.
+// Leaves KErrNotReady if search is ongoing.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::SetSortCriteriaL( const TEmailSortCriteria& aCriteria )
+    {
+    IsSearchGoingOnL();
+
+    switch (aCriteria.iField)
+        {
+        case TEmailSortCriteria::EDontCare:
+            iCriteria.iField = EFSMailDontCare;
+            break;
+
+        case TEmailSortCriteria::EByDate:
+            iCriteria.iField = EFSMailSortByDate;
+            break;
+
+        case TEmailSortCriteria::EBySender:
+            iCriteria.iField = EFSMailSortBySender;
+            break;
+
+        case TEmailSortCriteria::EByRecipient:
+            iCriteria.iField = EFSMailSortByRecipient;
+            break;
+
+        case TEmailSortCriteria::EBySubject:
+            iCriteria.iField = EFSMailSortBySubject;
+            break;
+
+        case TEmailSortCriteria::EByPriority:
+            iCriteria.iField = EFSMailSortByPriority;
+            break;
+
+        case TEmailSortCriteria::EByFlagStatus:
+            iCriteria.iField = EFSMailSortByFlagStatus;
+            break;
+
+        case TEmailSortCriteria::EByUnread:
+            iCriteria.iField = EFSMailSortByUnread;
+            break;
+
+        case TEmailSortCriteria::EBySize:
+            iCriteria.iField = EFSMailSortBySize;
+            break;
+
+        case TEmailSortCriteria::EByAttachment:
+            iCriteria.iField = EFSMailSortByAttachment;
+            break;
+
+        default:
+            User::Leave( KErrNotSupported );
+            break;
+
+        }
+    if (aCriteria.iAscending)
+        {
+        iCriteria.iOrder = EFSMailAscending;
+        }
+    else
+        {
+        iCriteria.iOrder = EFSMailDescending;
+        }
+    // Release gate
+    iGate.Signal();
+    }
+
+// -----------------------------------------------------------------------------
+// Adds a search key. Leaves KErrNotReady if search is ongoing.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::AddSearchKeyL( const TDesC& aSearchKey ) 
+    {
+    IsSearchGoingOnL();
+
+    iSearchStrings.AppendL(&aSearchKey);
+    // Release gate
+    iGate.Signal();
+    }
+
+/// -----------------------------------------------------------------------------
+// Enables/disables search from remote email server.
+// Leaves KErrNotReady if search is ongoing.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::SetRemoteSearchL( TBool aRemote )  
+    {    
+    IsSearchGoingOnL();
+
+    iRemote = aRemote;
+    // Release gate
+    iGate.Signal();
+    // Currently plugins do not support this function
+    User::Leave( KErrNotSupported );    
+    }
+
+// -----------------------------------------------------------------------------
+// Indicates whether remote search is enabled.
+// -----------------------------------------------------------------------------
+TBool CEmailMessageSearchAsync::IsRemoteSearch() const
+    {
+    // Currently plugins do not support this function
+    return EFalse; 
+    }
+
+// -----------------------------------------------------------------------------
+// Starts search, all methods affecting search attribures leave
+// KErrNotReady while search is ongoing.
+// @param aObserver called when results are available.
+//     
+void CEmailMessageSearchAsync::StartSearchL( MEmailSearchObserver& aObserver )
+    {
+    IsSearchGoingOnL();
+
+    iObserver = &aObserver;
+    const TFSMailMsgId fsMailboxId( iPluginData.Uid(), iMailboxId.iId );
+    RArray <TFSMailMsgId> folderIds;
+
+    /** Search API */
+
+    /**
+     * Asyncronous call for starting search for given string. Only one search can be
+     * performed at a time.
+     *
+     *
+     * This function will search for message's containing the given search string.
+     * The search will be performed on the all message fields: To, Cc, Bcc, subject, body.
+     * The search client will be notified of each found message,
+     * and upon completion of the search.  Only one search can be performed at a time.  
+     *  
+     * To change the sort order in the search result, use the same search string in the
+     * but change the aSortCriteria parameter.  The store "caches" the search
+     * results generated by the same search string.
+     *    
+     * The function will leave with KErrInUse if a search is already in progress.
+     *
+     * /note Only works if the store is in an authenticated state,
+     *  otherwise this function leaves with KErrNotReady
+     * 
+     * @paran aMailBoxId id of the mailbox where messages are to be searched
+     * @param aFolderIds list of folders where messages are to be searched
+     *        global or folder specific search depends on the size of array is 0 or not.
+     * @param aSearchStrings text strings that will be searched from different message fields.
+     * @param aSortCriteria sort criteria for the results
+     * @param aSearchObserver client observer that will be notified about search status.
+     *
+     */
+    iPlugin->SearchL( fsMailboxId,
+        folderIds,
+        iSearchStrings,
+        iCriteria,
+        *this );
+    // Gate is kept closed as search is asynchronous. Gate will be reopen after search is completed, i.e.
+    // CEmailMessageSearchAsync::SearchCompleted.
+    }
+
+// -----------------------------------------------------------------------------
+// Cancels search.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::Cancel()
+    {
+    if (KErrNone != iGate.Wait(1))
+        {
+        
+        /**
+         * Cancels current search. Does nothing if there is not any search.
+         * The search client will not be called back after this function is called.
+         *
+         */
+        const TFSMailMsgId fsMailboxId( iPluginData.Uid(), iMailboxId.iId );
+        iPlugin->CancelSearch( fsMailboxId );
+        }
+    else
+        {
+        // Release gate
+        iGate.Signal();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+//  * @return search status:
+//  *     < 0 : Search has failed
+//  *     KRequestPending : search is ongoing. note that status may be
+//  *         KRequestPending after HandleResultL callback because results 
+//  *         may be given in chunks of results. Size of chunk depends on
+//  *         implementation and may vary.
+//  *     KErrNone : initial state, or search has finished
+// -----------------------------------------------------------------------------
+TInt CEmailMessageSearchAsync::Status() const
+    {
+    if (KErrNone != iGate.Wait(1))
+        {
+        // Search is going on
+        return KRequestPending;
+        }
+    else
+        {
+        // Release gate
+        iGate.Signal();       
+        }
+
+    return KErrNone; 
+    }
+
+// -----------------------------------------------------------------------------
+// Resets all search attribures. Cancels search if ongoing. 
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::Reset()
+    {
+    if ( KErrNone != iGate.Wait( 1 ) )
+        {
+        this->Cancel();
+        }
+    
+    iCriteria = TFSMailSortCriteria();
+    iSearchStrings.Reset();
+    
+    // Release gate
+    iGate.Signal();
+    
+    };
+
+// -----------------------------------------------------------------------------
+// Notifies the email search API client that a match has been found
+// 
+// @param aMatchMessage contains a pointer to the matched message.
+//         Ownership is transfered to the observer.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::MatchFoundL( CFSMailMessage* aMatchMessage )
+{
+    User::LeaveIfNull( iObserver );
+    CEmailMessage *result = CEmailMessage::NewL(iPluginData, aMatchMessage, EClientOwns );
+    iObserver->HandleResultL( result );
+}
+
+// -----------------------------------------------------------------------------
+// Notifies the email search API client that the search has completed
+// -----------------------------------------------------------------------------
+ void CEmailMessageSearchAsync::SearchCompletedL()
+{
+    User::LeaveIfNull( iObserver );
+    iObserver->SearchCompletedL();
+    // Search is now complete, release gate.
+    iGate.Signal();
+}
+
+// -----------------------------------------------------------------------------
+// Asks client if search engine should change search priority 
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::ClientRequiredSearchPriority(TInt* /*apRequiredSearchPriority*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Function leaves if search is going on. Otherwise it doesn't do anything.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::IsSearchGoingOnL() const
+    {
+    if ( KErrNone != iGate.Wait( 1 ) )
+        {
+        // Leave now, search is going on
+        User::Leave( KErrNotReady );
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailmultipart.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,378 @@
+/*
+* 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: This file implements class CEmailAttachment.
+*
+*/
+
+#include "emailcontent.h"
+#include "emailtextcontent.h"
+#include "emailattachment.h"
+#include "emailmultipart.h"
+#include "emailmessage.h"
+#include "emailclientapi.hrh"
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailMultipart* CEmailMultipart::NewL( 
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,
+        CFSMailMessagePart* aPart,
+        const TDataOwner aOwner ) 
+    {
+    CEmailMultipart* self = new ( ELeave ) CEmailMultipart( aOwner );
+    CleanupStack::PushL( self );
+    self->ConstructL( aPluginData, aMsgContentId, aPart );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::ConstructL(
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,
+        CFSMailMessagePart* aPart )
+    {
+    iEmailMsgContent = CEmailMessageContent::NewL( aPluginData, aMsgContentId, aPart );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailMultipart::~CEmailMultipart()
+    {
+    delete iEmailMsgContent;
+    iChildParts.Reset();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailMultipart::CEmailMultipart( const TDataOwner aOwner ) : iOwner( aOwner )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailMultipart::PartCountL()
+    {
+    iChildParts.Reset();
+    RPointerArray<CFSMailMessagePart> childParts;
+    CleanupResetAndDestroyPushL( childParts );
+    iEmailMsgContent->Part().ChildPartsL( childParts );
+    iChildPartCount = childParts.Count();
+
+    for ( TInt i = 0; i < iChildPartCount; i++ )
+        {
+        TFSMailMsgId id = childParts[i]->GetPartId();
+        iChildParts.AppendL( id );
+        }
+    CleanupStack::PopAndDestroy( &childParts );
+    return iChildPartCount;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailMessageContent* CEmailMultipart::PartByIndexL( const TUint aIndex ) const
+    {
+    if ( aIndex >= iChildPartCount )
+        {
+        User::Leave( KErrArgument );
+        }
+    MEmailMessageContent* content = NULL;
+    TFSMailMsgId partId = iChildParts[aIndex];
+    CFSMailMessagePart* copy = iEmailMsgContent->Part().ChildPartL( partId );
+    if ( !copy )
+        return content;
+
+    TContentType contentType( copy->GetContentType() );
+    TMessageContentId msgContentId = TMessageContentId( 
+            copy->GetPartId().Id(),
+            Id().iMessageId.iId,
+            Id().iMessageId.iFolderId.iId,
+            Id().iMessageId.iFolderId.iMailboxId );
+
+    if ( contentType.Equals( KFSMailContentTypeTextPlain ) || 
+         contentType.Equals( KFSMailContentTypeTextHtml ) )
+        {
+        content = CEmailTextContent::NewL( 
+            iEmailMsgContent->PluginData(), msgContentId, copy, EClientOwns );
+        }
+    else if ( contentType.Equals( KFSMailContentTypeMultipartMixed ) ||
+              contentType.Equals( KFSMailContentTypeMultipartAlternative ) ||
+              contentType.Equals( KFSMailContentTypeMultipartDigest ) ||
+              contentType.Equals( KFSMailContentTypeMultipartRelated ) ||
+              contentType.Equals( KFSMailContentTypeMultipartParallel ) )
+        {
+        content = CEmailMultipart::NewL( 
+            iEmailMsgContent->PluginData(), msgContentId, copy, EClientOwns );
+        }
+    else 
+        {
+        content = CEmailAttachment::NewL( 
+            iEmailMsgContent->PluginData(), msgContentId, copy, EClientOwns );
+        } 
+    return content;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::DeletePartL( const TUint aIndex )
+    {
+    if ( aIndex >= iChildPartCount )
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    TFSMailMsgId partId = iChildParts[aIndex];
+    iEmailMsgContent->Part().RemoveChildPartL( partId );
+    iChildParts.Remove( aIndex );
+    iChildPartCount--;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::AddPartL(
+        const MEmailMessageContent& aPart,
+        const TUint aPos )
+    {
+    if ( aPos > iChildPartCount )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TFSMailMsgId insertBefore = TFSMailMsgId();
+    if ( aPos <  iChildPartCount )
+        {
+        insertBefore = iChildParts[aPos];
+        }
+    const TDesC& contentType = aPart.ContentType();
+
+    CFSMailMessagePart* newPart = 
+        iEmailMsgContent->Part().NewChildPartL( insertBefore, contentType );
+    CleanupStack::PushL( newPart );
+    TFSMailMsgId newPartId = newPart->GetPartId(); 
+    iChildParts.InsertL( newPartId, aPos );
+    iChildPartCount = iChildParts.Count();
+    CleanupStack::Pop( newPart );
+    
+
+
+    return;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailMultipart::InterfaceId() const
+    {
+    return KEmailIFUidMultipart;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::Release()
+    {
+    if ( iOwner == EClientOwns )
+        {
+        delete this;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TMessageContentId CEmailMultipart::Id() const
+    {
+    return iEmailMsgContent->Id(); 
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentType() const
+    {
+    return iEmailMsgContent->ContentType();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentType( const TDesC& aContentType )
+    {
+    iEmailMsgContent->SetContentType( aContentType );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentId() const
+    {
+    return iEmailMsgContent->ContentId();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentId( const TDesC& aContentId )
+    {
+    iEmailMsgContent->SetContentId( aContentId );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentDescription() const
+    {
+    return iEmailMsgContent->ContentDescription();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentDescription( const TDesC& aContentDescription )
+    {
+    iEmailMsgContent->SetContentDescription( aContentDescription );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentDisposition() const
+    {
+    return iEmailMsgContent->ContentDisposition();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentDisposition( const TDesC& aContentDisposition )
+    {
+    iEmailMsgContent->SetContentDisposition( aContentDisposition );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentClass() const
+    {
+    return iEmailMsgContent->ContentClass();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentClass( const TDesC& aContentClass )
+    {
+    iEmailMsgContent->SetContentClass( aContentClass );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailMultipart::AvailableSize() const
+    {
+    return iEmailMsgContent->AvailableSize();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailMultipart::TotalSize() const
+    {
+    return iEmailMsgContent->TotalSize();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentL() const
+    {
+    User::Leave(KErrNotSupported);
+    return iEmailMsgContent->ContentL();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentL( const TDesC& aContent )
+    {
+    iEmailMsgContent->SetContentL( aContent );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::FetchL( MEmailFetchObserver& aObserver )
+    {
+    iEmailMsgContent->FetchL( aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::CancelFetch()
+    {
+    iEmailMsgContent->CancelFetch();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SaveToFileL( const TDesC& aPath )
+    {
+    iEmailMsgContent->SaveToFileL( aPath );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailMultipart* CEmailMultipart::AsMultipartOrNull() const
+    {
+    const MEmailMultipart* ptr = this;
+    return const_cast<MEmailMultipart*>( ptr );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailTextContent* CEmailMultipart::AsTextContentOrNull() const
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailAttachment* CEmailMultipart::AsAttachmentOrNull() const
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetOwner( const TDataOwner aOwner )
+    {
+    iOwner = aOwner;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailtextcontent.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,298 @@
+/*
+* 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: This file implements class CEmailAttachment.
+*
+*/
+
+#include "emailcontent.h"
+#include "emailtextcontent.h"
+#include "emailmessage.h"
+#include "emailclientapi.hrh"
+
+// CEmailTextContent
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailTextContent* CEmailTextContent::NewL( 
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,
+        CFSMailMessagePart* aPart,
+        const TDataOwner aOwner ) 
+    {
+    CEmailTextContent* self = new ( ELeave ) CEmailTextContent( aOwner );
+    CleanupStack::PushL( self );
+    self->ConstructL( aPluginData, aMsgContentId, aPart );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::ConstructL(
+        CPluginData& aPluginData,
+        const TMessageContentId& aMsgContentId,
+        CFSMailMessagePart* aPart )
+    {
+    iEmailMsgContent = CEmailMessageContent::NewL( aPluginData, aMsgContentId, aPart );
+    TContentType contentType( aPart->GetContentType() );
+    if ( contentType.Equals( KFSMailContentTypeTextHtml ) )
+        {
+        iTextType = EHtmlText;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailTextContent::~CEmailTextContent()
+    {
+    delete iEmailMsgContent;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CEmailTextContent::CEmailTextContent( TDataOwner aOwner ) : 
+    iTextType( EPlainText ), 
+    iOwner( aOwner )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailTextContent::InterfaceId() const
+    {
+    return KEmailIFUidTextContent;
+    }
+    
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::Release()
+    {
+    if ( iOwner == EClientOwns )
+        {
+        delete this;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailTextContent::TTextType CEmailTextContent::TextType() const
+    {
+    return iTextType;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetTextL(
+            const TTextType aPlainOrHtml,
+            const TDesC& aText )
+    {    
+    iTextType = aPlainOrHtml;
+
+    if( aPlainOrHtml == EPlainText )
+        {
+        SetContentType( KContentTypeTextPlain );
+        }
+    else if( aPlainOrHtml == EHtmlText )
+        {
+        SetContentType( KContentTypeTextHtml );
+        }
+    SetContentL( aText );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TMessageContentId CEmailTextContent::Id() const
+    {
+    return iEmailMsgContent->Id(); 
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentType() const
+    {
+    return iEmailMsgContent->ContentType();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentType( const TDesC& aContentType )
+    {
+    iEmailMsgContent->SetContentType( aContentType );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentId() const
+    {
+    return iEmailMsgContent->ContentId();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentId( const TDesC& aContentId )
+    {
+    iEmailMsgContent->SetContentId( aContentId );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentDescription() const
+    {
+    return iEmailMsgContent->ContentDescription();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentDescription( const TDesC& aContentDescription )
+    {
+    iEmailMsgContent->SetContentDescription( aContentDescription );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentDisposition() const
+    {
+    return iEmailMsgContent->ContentDisposition();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentDisposition( const TDesC& aContentDisposition )
+    {
+    iEmailMsgContent->SetContentDisposition( aContentDisposition );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentClass() const
+    {
+    return iEmailMsgContent->ContentClass();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentClass( const TDesC& aContentClass )
+    {
+    iEmailMsgContent->SetContentClass( aContentClass );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailTextContent::AvailableSize() const
+    {
+    return iEmailMsgContent->AvailableSize();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TInt CEmailTextContent::TotalSize() const
+    {
+    return iEmailMsgContent->TotalSize();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentL() const
+    {
+    return iEmailMsgContent->ContentL();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentL( const TDesC& aContent )
+    {
+    iEmailMsgContent->SetContentL( aContent );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::FetchL( MEmailFetchObserver& aObserver )
+    {
+    iEmailMsgContent->FetchL( aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::CancelFetch()
+    {
+    iEmailMsgContent->CancelFetch();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SaveToFileL( const TDesC& aPath )
+    {
+    iEmailMsgContent->SaveToFileL( aPath );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailMultipart* CEmailTextContent::AsMultipartOrNull() const
+    {    
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailTextContent* CEmailTextContent::AsTextContentOrNull() const
+    {
+    const MEmailTextContent* ptr = this;
+    return const_cast<MEmailTextContent *>(ptr);
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailAttachment* CEmailTextContent::AsAttachmentOrNull() const
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetOwner( const TDataOwner aOwner )
+    {
+    iOwner = aOwner;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/implproxy.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -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:  ECom impementation proxy for Email client API
+*
+*/
+
+#include "emailclientapiimpl.hrh"
+#include "emailclientapiimpl.h"
+#include "emailinterfacefactoryimpl.h"
+#include <implementationproxy.h>	//TImplementationProxy
+
+// -----------------------------------------------------------------------------
+// Defines the pairing required by the ECOM framework to correctly identify the
+// instantiation method pointer for client's request.
+// -----------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(
+            KEmailClientApiImplUid,
+            CEmailInterfaceFactoryImpl::NewL )
+    };
+
+// -----------------------------------------------------------------------------
+// Returns the TImplementationProxy for email client api implementation
+// -----------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+
+    return ImplementationTable;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/messageiterator.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,319 @@
+/*
+* 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: This file implements class CMessageIterator.
+*
+*/
+
+#include "emailmessage.h"
+#include "messageiterator.h"
+#include "emailapiutils.h"
+#include "cfsmailplugin.h"
+#include "emailapiutils.h"
+#include "emailclientapi.hrh"
+#include "mfsmailiterator.h"
+
+// number of messages in chunk to retrive from protocol plugin. Actual chunk
+// size is one less because last element is used for reference to next chunk
+// retrieval. See ReadNextChunkL() for details.
+const TInt KMessageChunkSize = 5;
+
+const TInt KUndefined = -1;
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CMessageIterator* CMessageIterator::NewL( 
+    MFSMailIterator* aIterator,
+    CPluginData& aPluginData,
+    TUint aCount )
+    {
+    CMessageIterator* iter = new ( ELeave ) 
+        CMessageIterator( aIterator, aPluginData, aCount );
+    return iter;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CMessageIterator::~CMessageIterator()
+    {
+    iPluginData.ReleaseInstance();
+    TInt count = iMessageArray.Count();
+    iMessageArray.ResetAndDestroy();
+    for ( TInt i = count; i < iFsMessageArray.Count(); i++ )
+        {
+        delete iFsMessageArray[i];
+        }
+    iFsMessageArray.Reset();
+    delete iIterator;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TEmailTypeId CMessageIterator::InterfaceId() const
+    {
+    return KEmailIFUidMessageIterator;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CMessageIterator::Release()
+    {
+    delete this;
+    }
+
+// -----------------------------------------------------------------------------
+// Returns next message
+// Messages are retrieved from protocol plugin in chunks of x messages and
+// when NextL has be called for x times, next chunk is retrieved. This
+// is trade-off between RAM consumption and speed.
+// -----------------------------------------------------------------------------
+MEmailMessage* CMessageIterator::NextL()
+    {
+    if ( iCursor == KUndefined )
+        {
+        // Buffer empty, read the first chunk
+        if ( !ReadNextChunkL() )
+            {
+            // No messages found, 
+            // Reset the cursor and return NULL
+            iCursor = KUndefined;
+            iStartMsgId = TFSMailMsgId();
+            return NULL;
+            }
+        // Items found, return the first item in the buffer
+        iCursor = 0;
+        }
+    else
+        {
+        // Iterate to the next item
+        iCursor++;
+        }
+    return ReadFromChunkL();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailMessage* CMessageIterator::PreviousL()
+    {
+    if ( iCursor == KUndefined )
+        {
+        iStartMsgId = TFSMailMsgId();
+        // Buffer empty, client should first call NextL
+        return NULL;
+        }
+    // Iterate to the previous item
+    iCursor--;
+    return ReadFromChunkL();
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TBool CMessageIterator::ReadNextChunkL()
+    {
+    User::LeaveIfNull( iIterator );
+    
+    TBool chunkFound = EFalse;
+
+    // Delete previous items if exist
+    CleanCache();
+    iHasMoreNextItems = iIterator->NextL(
+            iStartMsgId,
+            KMessageChunkSize,
+            iFsMessageArray );
+    if ( iFsMessageArray.Count() > 0 )
+        {
+        chunkFound = ETrue;
+        // Set the cursor to the first item 
+        iCursor = 0;
+        iHasMorePrevItems = ETrue;
+        }
+    return chunkFound;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TBool CMessageIterator::ReadPreviousChunkL()
+    {
+    User::LeaveIfNull( iIterator );
+
+    TBool chunkFound = EFalse;
+
+    // Delete previous items if exist
+    CleanCache();
+    RPointerArray<CFSMailMessage> tmp;
+    iHasMorePrevItems = iIterator->PreviousL(
+            iStartMsgId,
+            KMessageChunkSize, 
+            tmp );
+    TInt count = tmp.Count();
+    if ( count > 0 )
+        {
+        // It seems that items have been found
+        // Set the cursor to the end of array
+        iCursor = count - 1;
+        iHasMoreNextItems = ETrue;
+        chunkFound = ETrue;
+        // Revise the order of the buffer.
+        // Create complete cache, so it is easier to iterate, 
+        // as now we have to start from the end of cache
+        for ( TInt i = count; i > 0; i-- )
+            {
+            CFSMailMessage* msg = tmp[i-1];
+            iFsMessageArray.AppendL( msg );
+            AddToCacheL( msg );
+            }
+        }
+
+    return chunkFound;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+MEmailMessage* CMessageIterator::ReadFromChunkL()
+    {
+    if ( iCursor >= KMessageChunkSize )
+        {
+        if ( iHasMoreNextItems )
+            {
+            iStartMsgId = iFsMessageArray[iCursor-1]->GetMessageId();
+            if ( !ReadNextChunkL() )
+                {
+                // No more items found, 
+                // set the cursor to the previous item,
+                // and return NULL.
+                iCursor--;
+                return NULL;
+                }
+            }
+        else
+            {
+            // No more items found, 
+            // set the cursor to the previous item,
+            // and return NULL.
+            iCursor--;
+            return NULL;
+            }
+        }
+    else if ( iCursor < 0 )
+        {
+        iStartMsgId = iFsMessageArray[0]->GetMessageId();
+        if ( iHasMorePrevItems )
+            {
+            if ( !ReadPreviousChunkL() )
+                {
+                // Buffer is empty now, client should call nextL,
+                // and start reading from the start of the buffer
+                iCursor = KUndefined;
+                return NULL;
+                }
+            }
+        else
+            {
+            // Buffer is empty now, client should call nextL,
+            // and start reading from the start of the buffer
+            iCursor = KUndefined;   
+            return NULL;
+            }
+        }
+
+    if ( iCursor < iFsMessageArray.Count() )
+        {
+        /* There are items to read in the cache */
+        if ( iCursor >= iMessageArray.Count() )
+            {
+            AddToCacheL( iFsMessageArray[iCursor] );
+            }
+        return iMessageArray[iCursor];
+        }
+    else
+        {
+        // No more items found,
+        // set the cursor to the previous item,
+        // and return NULL.
+        iCursor--;
+        return NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CMessageIterator::AddToCacheL( CFSMailMessage* aFsMsg )
+    {
+    CEmailMessage* message = CEmailMessage::NewL( iPluginData, aFsMsg, EAPIOwns );
+    iMessageArray.AppendL( message );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CMessageIterator::CleanCache()
+    {
+    // This is strange loop indeed
+    // Both arrays has items that are deleted, iMessageArray has objects that point to iFsMessageArray
+    // Index in both arrays goes syncronously
+    // To prevent double destruction, first delete iMessageArray onjects and then the rest of the iFsMessageArray
+    TInt count = iMessageArray.Count();
+    iMessageArray.ResetAndDestroy();
+    for ( TInt i = count; i < iFsMessageArray.Count(); i++ )
+        {
+        iFsMessageArray.Remove( count );
+        }
+    iFsMessageArray.Reset();    
+    }
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+TUint CMessageIterator::Count() const
+    {
+    return iCount;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+void CMessageIterator::ConstructL()
+    {
+    iPlugin = iPluginData.ClaimInstanceL();
+    
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+CMessageIterator::CMessageIterator( 
+    MFSMailIterator* aIterator,
+    CPluginData& aPluginData,
+    TUint aCount ) :
+    iIterator( aIterator ),
+    iPluginData( aPluginData ),
+    iStartMsgId( TFSMailMsgId() ),
+    iState( EReadNextMessageChunk ),
+    iFsMessageArray( KMessageChunkSize ),
+    iCount( aCount ),
+    iCursor ( KUndefined ),
+    iFirstMsgId( TFSMailMsgId() ),
+    iHasMoreNextItems( ETrue ),
+    iHasMorePrevItems( ETrue )
+    {
+    }
+
+// End of file
--- a/emailservices/emailcommon/bwins/fsfwcommonlibu.def	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/bwins/fsfwcommonlibu.def	Thu Jul 22 16:30:28 2010 +0100
@@ -257,4 +257,5 @@
 	??_ECEmailExtension@@UAE@I@Z @ 256 NONAME ; CEmailExtension::~CEmailExtension(unsigned int)
 	?GetCCRecipients@CFSMailMessageBase@@QAE?AV?$RPointerArray@VCFSMailAddress@@@@XZ @ 257 NONAME ; class RPointerArray<class CFSMailAddress> CFSMailMessageBase::GetCCRecipients(void)
 	?NewL@CFSMailMessagePart@@SAPAV1@VTFSMailMsgId@@0@Z @ 258 NONAME ; class CFSMailMessagePart * CFSMailMessagePart::NewL(class TFSMailMsgId, class TFSMailMsgId)
+	?RemoveMessageL@CFSMailFolder@@QAEHVTFSMailMsgId@@AAVMFSMailRequestObserver@@@Z @ 259 NONAME ; int CFSMailFolder::RemoveMessageL(class TFSMailMsgId, class MFSMailRequestObserver &)
 
--- a/emailservices/emailcommon/eabi/fsfwcommonlibu.def	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/eabi/fsfwcommonlibu.def	Thu Jul 22 16:30:28 2010 +0100
@@ -292,4 +292,5 @@
 	_ZThn4_N15CFSMailIterator9PreviousLERK7TDesC16jR13RPointerArrayI14CFSMailMessageE @ 291 NONAME
 	_ZThn4_N15CFSMailIteratorD0Ev @ 292 NONAME
 	_ZThn4_N15CFSMailIteratorD1Ev @ 293 NONAME
+	_ZN13CFSMailFolder14RemoveMessageLE12TFSMailMsgIdR22MFSMailRequestObserver @ 294 NONAME
 
--- a/emailservices/emailcommon/emailcommon.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/emailcommon.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -23,8 +23,9 @@
 DEFINES += BUILD_DLL 
 
 INCLUDEPATH += ../../inc \
-../inc \
-/epoc32/include/ecom 
+               ../inc \
+               /epoc32/include/ecom \
+               $$APP_LAYER_SYSTEMINCLUDE
 
 HEADERS   += inc/cemailextensionbase.h \ 
     inc/CFSMailBox.h \
--- a/emailservices/emailcommon/inc/CFSMailBox.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/inc/CFSMailBox.h	Thu Jul 22 16:30:28 2010 +0100
@@ -158,7 +158,7 @@
      *
      * @param aOperationObserver Observer for the operation 
      * 
-     * @return id of the request, KErrNotSupported if the protocol plugin this
+     * @return id of the request, KErrFSMailPluginNotSupported if the protocol plugin this
      * instance is attached to does not support the async method.
      */
      IMPORT_C TInt CreateMessageToSendL( MFSMailRequestObserver& aOperationObserver );
--- a/emailservices/emailcommon/inc/CFSMailCommon.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/inc/CFSMailCommon.h	Thu Jul 22 16:30:28 2010 +0100
@@ -52,6 +52,7 @@
     EFSMsgFlag_OnlyToMe = 2048,          // The message was sent only to this user
     EFSMsgFlag_RemoteDeleted = 4096,     // The message has been deleted on the server
     EFSMsgFlag_HasMsgSender = 8192,      // The message has one or more senders 
+	// <qmail> Not using EFSMsgFlag_BodyTruncated </qmail>
     };
 
 /** email list sorting options */  
--- a/emailservices/emailcommon/inc/CFSMailFolder.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/inc/CFSMailFolder.h	Thu Jul 22 16:30:28 2010 +0100
@@ -76,6 +76,20 @@
      */
      IMPORT_C void RemoveMessageL( const TFSMailMsgId aMessageId );
 
+     // <qmail>
+     /**
+      * removes given message from folder
+      *
+      * @param aMessageId id of message to be removed
+      * @param aObserver Observer for the operation completion
+      * 
+      * @return id of the request, KErrFSMailPluginNotSupported if the protocol plugin this
+      * instance is attached to does not support the async method.
+      */
+     IMPORT_C TInt RemoveMessageL( const TFSMailMsgId aMessageId,
+                                   MFSMailRequestObserver& aObserver );
+     // </qmail>
+     
     /**
      * lists subfolders contained by this folder
      *
--- a/emailservices/emailcommon/inc/CFSMailMessageBase.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/inc/CFSMailMessageBase.h	Thu Jul 22 16:30:28 2010 +0100
@@ -299,6 +299,7 @@
      CFSMailMessageBase();
 
 // <qmail>
+     // iMessageId removed
     /**
      * ConstructL
      */
--- a/emailservices/emailcommon/inc/CFSMailRequestHandler.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/inc/CFSMailRequestHandler.h	Thu Jul 22 16:30:28 2010 +0100
@@ -81,7 +81,7 @@
     /**
      * destructor.
      */
-      ~CFSMailRequestHandler();
+     virtual ~CFSMailRequestHandler();
 
     /**
      * two based constructor
--- a/emailservices/emailcommon/inc/cmailboxstateext.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/inc/cmailboxstateext.h	Thu Jul 22 16:30:28 2010 +0100
@@ -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"
@@ -11,7 +11,8 @@
 *
 * Contributors:
 *
-* Description:  Message extension interface
+* Description:  Mailbox state extension for notifying email protocol plugins
+*               about application state changes.
 *
 */
 
@@ -30,16 +31,21 @@
 class MEmailMailboxState
 {
 public:
+// <qmail>
     /**
     * Returns currently active folder and related mailbox that
     * is currently being used.
-    * @param aActiveMailboxId id of currently active mailbox 
+    * @param aActiveMailboxId id of currently active mailbox
+    * 
     * @param aActiveFolderId id of currently active mail folder
+    *        If aActiveFolderId.IsNullId() returns true there is no active
+    *        folder. This happens if e.g. email applications is closed. 
     * @return Symbian OS error code
     */
     virtual TInt GetActiveFolderId( 
         TFSMailMsgId& aActiveMailboxId,
         TFSMailMsgId& aActiveFolderId ) const = 0;
+// </qmail>    
 };
 
 /**
@@ -50,10 +56,21 @@
 public:
     
     /**
-     * Sets data provider interface
-     * @param aDataProvider data provider
+     * Sets data provider interface.
+     * @param aDataProvider data provider.
      */
     virtual void SetStateDataProvider( MEmailMailboxState* aDataProvider ) = 0;
+// <qmail>    
+    /**
+    * Notification that folder has changed in email application.
+    * @param aActiveMailboxId id of the mailbox container the folder
+    * @param aActiveFolderId currently active folder id or null id if
+    *        there's currently no active folder (e.g. application is closed)
+    */
+    virtual void NotifyActiveFolderChanged(
+        const TFSMailMsgId& aActiveMailboxId,
+        const TFSMailMsgId& aActiveFolderId) = 0;
+// </qmail>
 
 protected:    
     inline CMailboxStateExtension();
@@ -66,5 +83,5 @@
          CEmailExtension( KEmailMailboxStateExtensionUid )
     {
     }
-         
+
 #endif // CMAILBOXSTATEEXT_H
--- a/emailservices/emailcommon/src/CFSMailAddress.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailAddress.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,10 +15,10 @@
 *
 */
 
+#include "emailtrace.h"
 
 //<cmail>
 #include <nmcommonheaders.h>
-#include "emailtrace.h"
 #include "CFSMailAddress.h"
 //</cmail>
 
@@ -32,7 +32,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailAddress* CFSMailAddress::NewLC()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailAddress* adr = new (ELeave) CFSMailAddress();
     CleanupStack::PushL(adr);
     adr->ConstructL();
@@ -44,7 +45,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailAddress* CFSMailAddress::NewL()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailAddress* adr =  CFSMailAddress::NewLC();
     CleanupStack::Pop(adr);
     return adr;
@@ -56,7 +58,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailAddress* CFSMailAddress::NewL( const NmAddress& aNmAddress )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailAddress* adr = new (ELeave) CFSMailAddress();
     CleanupStack::PushL(adr);
     adr->ConstructL(aNmAddress);
@@ -70,7 +73,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailAddress::ConstructL()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     // Construction of shared data object
     iNmPrivateAddress = new NmAddressPrivate();
@@ -83,7 +87,8 @@
 // --------------------------------_--------------------------------------------
 void CFSMailAddress::ConstructL( const NmAddress& aNmAddress )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     // shared data object
     iNmPrivateAddress = aNmAddress.d;
 	}
@@ -94,7 +99,8 @@
 // -----------------------------------------------------------------------------
 CFSMailAddress::CFSMailAddress()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
 // Unnecessary members initialization removed: iEmailAddress, iDisplayName
 // </qmail>
@@ -105,7 +111,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailAddress::~CFSMailAddress()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
 // Unnecessary members destruction removed: iEmailAddress, iDisplayName
 // </qmail>
@@ -116,7 +123,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TDesC& CFSMailAddress::GetEmailAddress() const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iEmailAddressPtr.Set(reinterpret_cast<const TUint16*> (iNmPrivateAddress->mAddress.utf16()),
         iNmPrivateAddress->mAddress.length());
@@ -129,7 +137,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailAddress::SetEmailAddress(const TDesC& aAddress)
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     QString qtEmailAddress = QString::fromUtf16(aAddress.Ptr(), aAddress.Length());
     iNmPrivateAddress->mAddress = qtEmailAddress;
@@ -141,7 +150,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TDesC& CFSMailAddress::GetDisplayName() const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iDisplayNamePtr.Set(reinterpret_cast<const TUint16*> (iNmPrivateAddress->mDisplayName.utf16()),
         iNmPrivateAddress->mDisplayName.length());
@@ -154,7 +164,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailAddress::SetDisplayName(const TDesC& aDisplayName)
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     QString qtDisplayName = QString::fromUtf16(aDisplayName.Ptr(), aDisplayName.Length());
     iNmPrivateAddress->mDisplayName = qtDisplayName;
@@ -167,7 +178,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C NmAddress CFSMailAddress::GetNmAddress()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     NmAddress nmAddress(iNmPrivateAddress);
     return nmAddress;
 	}
--- a/emailservices/emailcommon/src/CFSMailBox.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailBox.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 // <qmail>
 #include <nmcommonheaders.h>
 // <//qmail>
 
-#include "emailtrace.h"
 #include <bamdesca.h>
 #include "CFSMailPlugin.h"
 #include "cmrcalendarinfoimpl.h"
@@ -39,11 +40,12 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailBox* CFSMailBox::NewLC(TFSMailMsgId aMailBoxId)
 {
-    FUNC_LOG;
-  CFSMailBox* api = new (ELeave) CFSMailBox();
-  CleanupStack:: PushL(api);
-  api->ConstructL(aMailBoxId);
-  return api;
+    NM_FUNCTION;
+    
+    CFSMailBox* api = new (ELeave) CFSMailBox();
+    CleanupStack:: PushL(api);
+    api->ConstructL(aMailBoxId);
+    return api;
 } 
 
 // -----------------------------------------------------------------------------
@@ -51,10 +53,11 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailBox* CFSMailBox::NewL(TFSMailMsgId aMailBoxId)
 {
-    FUNC_LOG;
-  CFSMailBox* api =  CFSMailBox::NewLC(aMailBoxId);
-  CleanupStack:: Pop(api);
-  return api;
+    NM_FUNCTION;
+    
+    CFSMailBox* api =  CFSMailBox::NewLC(aMailBoxId);
+    CleanupStack:: Pop(api);
+    return api;
 }
 
 // -----------------------------------------------------------------------------
@@ -62,7 +65,8 @@
 // -----------------------------------------------------------------------------
 CFSMailBox::CFSMailBox()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     // get requesthandler pointer
     iRequestHandler = static_cast<CFSMailRequestHandler*>(Dll::Tls());
 }
@@ -72,7 +76,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailBox::~CFSMailBox()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    // <qmail> Not using KMailboxExtMrCalInfo </qmail>
     iFolders.ResetAndDestroy();
 }
 
@@ -81,7 +86,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailBox::ConstructL(TFSMailMsgId aMailBoxId)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     CFSMailBoxBase::ConstructL(aMailBoxId);
 // </qmail>
@@ -92,7 +98,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBox::GoOnlineL()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
@@ -105,7 +111,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBox::GoOfflineL()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
@@ -119,7 +125,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBox::CancelSyncL()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
@@ -132,7 +138,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSProgress CFSMailBox::GetLastSyncStatusL()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TFSProgress progress;
     progress.iError = EFalse;
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
@@ -148,8 +155,8 @@
 EXPORT_C TInt CFSMailBox::RefreshNowL(
     MFSMailRequestObserver& aOperationObserver )
     {
-    FUNC_LOG;
-
+    NM_FUNCTION;
+    
     TFSPendingRequest request;
     request.iRequestId = 0;
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
@@ -166,16 +173,15 @@
             }
         }
     return request.iRequestId;
-
-   }
+    }
 
 // -----------------------------------------------------------------------------
 // CFSMailBox::RefreshNowL
 // -----------------------------------------------------------------------------
 EXPORT_C TInt CFSMailBox::RefreshNowL( )
     {
-    FUNC_LOG;
-
+    NM_FUNCTION;
+    
     TFSPendingRequest request;
     request.iRequestId = 0;
     MFSMailRequestObserver* observer = NULL;
@@ -193,16 +199,15 @@
             }
         }
     return request.iRequestId;
-
-   }
+    }
 
 // -----------------------------------------------------------------------------
 // CFSMailBox::CreateMessageToSend
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessage* CFSMailBox::CreateMessageToSend( )
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
+    
     CFSMailMessage* message = NULL;
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
@@ -222,6 +227,8 @@
 EXPORT_C TInt CFSMailBox::CreateMessageToSendL(
         MFSMailRequestObserver& aOperationObserver )
     {
+    NM_FUNCTION;
+    
     TFSPendingRequest request;
     
     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() );
@@ -258,6 +265,8 @@
     RPointerArray<CFSMailMessage> &messages,
     MFSMailRequestObserver& aOperationObserver)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(aMailboxId);
     TFSPendingRequest request;
         
@@ -298,7 +307,8 @@
 EXPORT_C CFSMailMessage* CFSMailBox::CreateForwardMessage(  TFSMailMsgId aOriginalMessageId,
                                                             const TDesC& aHeaderDescriptor )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailMessage* message = NULL;
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
@@ -321,6 +331,8 @@
                         MFSMailRequestObserver& aOperationObserver,
                         const TDesC& aHeaderDescriptor )
     {
+    NM_FUNCTION;
+    
     TFSPendingRequest request;
     
     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() );
@@ -358,7 +370,8 @@
                                                          TBool aReplyToAll,
                                                          const TDesC& aHeaderDescriptor )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailMessage* message = NULL;
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
@@ -383,6 +396,8 @@
                                       MFSMailRequestObserver& aOperationObserver,
                                       const TDesC& aHeaderDescriptor )
 {
+    NM_FUNCTION;
+    
     TFSPendingRequest request;
     
     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() );
@@ -418,8 +433,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailMsgId CFSMailBox::GetStandardFolderId(TFSFolderType aFolderType)
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
+    
     TFSMailMsgId folderId;
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
@@ -437,14 +452,11 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBox::SendMessageL( CFSMailMessage& aMessage )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
-        // <qmail> Not activated yet.
-        //UpdateMrusL( aMessage.GetToRecipients(),
-        //         aMessage.GetCCRecipients(),
-        //       aMessage.GetBCCRecipients() );
-        // </qmail>
+        // <qmail> Removed UpdateMrusL. </qmail>
         plugin->SendMessageL( aMessage );
         }
 	}
@@ -457,7 +469,7 @@
         CFSMailMessage& aMessage,
         MFSMailRequestObserver& aOperationObserver )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     TFSPendingRequest request;
 
@@ -465,11 +477,7 @@
 
     if ( plugin )
         {
-        // <qmail> Not activated yet.
-        //UpdateMrusL( aMessage.GetToRecipients(),
-        //         aMessage.GetCCRecipients(),
-        //       aMessage.GetBCCRecipients() );
-        // </qmail>
+        // <qmail> Removed UpdateMrusL. </qmail>
 
         // init asynchronous request
         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
@@ -501,8 +509,8 @@
 EXPORT_C void CFSMailBox::ListFolders(  TFSMailMsgId aFolder,
                                         RPointerArray<CFSMailFolder>& aFolderList)
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
+    
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
     {
         TRAPD(err, plugin->ListFoldersL(GetId(),aFolder,aFolderList));
@@ -518,6 +526,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C RPointerArray<CFSMailFolder>& CFSMailBox::ListFolders( )
 {   
+    NM_FUNCTION;
+    
     iFolders.ResetAndDestroy();
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
     {
@@ -536,7 +546,13 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TDesC& CFSMailBox::GetBrandingIdL( )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+	if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
+        {
+        TDesC& result = plugin->GetBrandingIdL( GetId() );
+        return result;
+        }
+    
     return BrandingId();
 }
 
@@ -547,7 +563,8 @@
                                          const TFSMailMsgId aSourceFolderId, 
                                          const TFSMailMsgId aDestinationFolderId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
         plugin->MoveMessagesL(GetId(), aMessageIds, aSourceFolderId, aDestinationFolderId);
@@ -562,8 +579,10 @@
                                          const TFSMailMsgId aSourceFolderId, 
                                          const TFSMailMsgId aDestinationFolderId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TFSPendingRequest request;
+    request.iRequestId = 0;
     if( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
         {
         // init asynchronous request
@@ -588,7 +607,8 @@
                                          const TFSMailMsgId aSourceFolderId, 
                                          const TFSMailMsgId aDestinationFolderId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
         plugin->CopyMessagesL(GetId(), aMessageIds, aNewMessages,
@@ -604,8 +624,7 @@
                                    MFSMailBoxSearchObserver&   /*aSearchObserver*/,
                                    const RArray<TFSMailMsgId>  /*aFolderIds */ )
     {
-    FUNC_LOG;
-
+    NM_FUNCTION;
     }
     
 // -----------------------------------------------------------------------------
@@ -615,7 +634,8 @@
                                    const TFSMailSortCriteria& aSortCriteria,
                                    MFSMailBoxSearchObserver& aSearchObserver )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
 
@@ -628,7 +648,7 @@
         
         // remove outbox, drafts folder from folder list
         RArray<TFSMailMsgId> folderIds;
-        folderIds.Reset();
+        CleanupClosePushL( folderIds );  
         for(TInt i=0;i<iFolders.Count();i++)
         {
             TFSMailMsgId id = iFolders[i]->GetFolderId();
@@ -640,7 +660,7 @@
         
         // start search
         plugin->SearchL( GetId(), folderIds, aSearchStrings, aSortCriteria, aSearchObserver );
-        folderIds.Reset();
+        CleanupStack::PopAndDestroy( &folderIds );
         }
     }
 
@@ -649,7 +669,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBox::CancelSearch()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
         plugin->CancelSearch( GetId() );
@@ -661,7 +682,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBox::ClearSearchResultCache()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
         {
         plugin->ClearSearchResultCache( GetId() );
@@ -673,7 +695,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C MDesCArray* CFSMailBox::ListMrusL() const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     MDesCArray* mruList(0);
     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
         {
@@ -688,7 +711,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TSSMailSyncState CFSMailBox::CurrentSyncState() const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TSSMailSyncState syncState(Idle);
     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
         {
@@ -702,7 +726,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TBool CFSMailBox::HasCapability( const TFSMailBoxCapabilities aCapability ) const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TBool capability = EFalse;
     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
         {
@@ -720,7 +745,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailBoxStatus CFSMailBox::GetMailBoxStatus()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TFSMailBoxStatus status(EFSMailBoxOffline);
     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
     {
@@ -734,7 +760,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBox::SetCredentialsL( const TDesC& aUsername, const TDesC& aPassword )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
         {
         plugin->SetCredentialsL( GetId(), aUsername, aPassword );
@@ -746,7 +773,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBox::RemoveDownLoadedAttachmentsL()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() );
     if ( plugin )
@@ -767,7 +794,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TInt CFSMailBox::GetConnectionId( TUint32& aConnectionId )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TInt rcode = KErrNotSupported;
     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
         {
@@ -781,7 +809,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TInt CFSMailBox::IsConnectionAllowedWhenRoaming( TBool& aConnectionAllowed )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TInt rcode = KErrNotSupported;
     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
         {
@@ -795,7 +824,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessage* CFSMailBox::CreateMessageFromFileL( const RFile& aFile )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailMessage* message = NULL;
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
     {
@@ -812,7 +842,7 @@
     const RPointerArray<CFSMailAddress>& aCCRecipients,
     const RPointerArray<CFSMailAddress>& aBCCRecipients ) const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
     // First lets make a copy of the current mru list
     // whose content we can later alter as we wish
@@ -867,7 +897,8 @@
 // -----------------------------------------------------------------------------    
 CDesCArraySeg* CFSMailBox::CopyArrayL( MDesCArray& aArrayToBeCopied ) const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CDesCArraySeg* newArray = new (ELeave) CDesCArraySeg( 10 );
     CleanupStack::PushL( newArray );
     
@@ -890,7 +921,8 @@
     CDesCArraySeg& aMruList,
     const RPointerArray<CFSMailAddress>& aNewRecentlyUsedOnes ) const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TUint newCount( aNewRecentlyUsedOnes.Count() );
     TUint newIndexer( 0 );
     
@@ -931,7 +963,8 @@
                                          TDesC& searchedAddress,
                                          TInt& aPos ) const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     // CDesCArray::Find() is not used here because there is
     // possibility that we have to go through the whole array
     // and return the index for one specific match. Find() returns
@@ -971,7 +1004,8 @@
 void CFSMailBox::AddAndRemoveExcessMruL( CDesCArraySeg& aMruList,
                                          CFSMailAddress& aToBeAdded ) const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if ( aMruList.Count() == KMaxMruEntries )
         {
         // Remove the oldest entry pair from the beginning
@@ -988,7 +1022,8 @@
                                       TInt aPosition,
                                       CFSMailAddress& aMostRecent ) const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     // Position of the address is given so the possible display name is
     // in the previous slot. Delete both.
     aMruList.Delete( aPosition - 1, 2 );
@@ -1002,7 +1037,8 @@
 void CFSMailBox::AppendMruItemL( CDesCArraySeg& aMruList,
                                  CFSMailAddress& aToBeAppended ) const
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     // In the array, display name is always the first and then comes
     // the actual address.
     
@@ -1028,9 +1064,12 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBox::ReleaseExtension( CEmailExtension* aExtension )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+	// <qmail> Not using KMailboxExtMrCalInfo
+    
     // no specialized behaviour, call base class
     CExtendableEmail::ReleaseExtension( aExtension );
+	// </qmail>
     }
     
 // -----------------------------------------------------------------------------
@@ -1038,11 +1077,14 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CEmailExtension* CFSMailBox::ExtensionL( const TUid& aInterfaceUid )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CEmailExtension* extension = NULL;
+// <qmail>
+    extension = CExtendableEmail::ExtensionL( aInterfaceUid );    
     if ( aInterfaceUid == KMailboxExtMrCalInfo )
         {
-        extension = CExtendableEmail::ExtensionL( aInterfaceUid );
+// </qmail>        
         if ( extension == NULL )
             {
             extension = new ( ELeave ) CMRCalendarInfoImpl();
@@ -1052,6 +1094,7 @@
             }
         }    
     else if ( aInterfaceUid == KEmailMailboxStateExtensionUid )
+		// <qmail> Not using KEmailSettingExtensionUid or KEmailConnectionStatusQueryExtensionUid </qmail>
         {
         if ( !extension )
             {
--- a/emailservices/emailcommon/src/CFSMailBoxBase.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailBoxBase.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 // <qmail>
 #include <nmcommonheaders.h>
 // </qmail>
 
-#include "emailtrace.h"
 #include "CFSMailBoxBase.h"
 // <qmail>
 #include "CFSMailAddress.h"
@@ -38,11 +39,12 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailBoxBase* CFSMailBoxBase::NewLC(TFSMailMsgId aMailBoxId)
 {
-    FUNC_LOG;
-  CFSMailBoxBase* api = new (ELeave) CFSMailBoxBase();
-  CleanupStack:: PushL(api);
-  api->ConstructL(aMailBoxId);
-  return api;
+    NM_FUNCTION;
+    
+    CFSMailBoxBase* api = new (ELeave) CFSMailBoxBase();
+    CleanupStack:: PushL(api);
+    api->ConstructL(aMailBoxId);
+    return api;
 } 
 
 // -----------------------------------------------------------------------------
@@ -50,10 +52,11 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailBoxBase* CFSMailBoxBase::NewL(TFSMailMsgId aMailBoxId)
 {
-    FUNC_LOG;
-  CFSMailBoxBase* api =  CFSMailBoxBase::NewLC(aMailBoxId);
-  CleanupStack:: Pop(api);
-  return api;
+    NM_FUNCTION;
+    
+    CFSMailBoxBase* api =  CFSMailBoxBase::NewLC(aMailBoxId);
+    CleanupStack:: Pop(api);
+    return api;
 }
 
 // -----------------------------------------------------------------------------
@@ -61,8 +64,7 @@
 // -----------------------------------------------------------------------------
 CFSMailBoxBase::CFSMailBoxBase() : CExtendableEmail()
 {
-    FUNC_LOG;
-	
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -70,7 +72,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailBoxBase::~CFSMailBoxBase()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if( iMailBoxName )
         {
   		delete iMailBoxName;
@@ -101,7 +104,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailBoxBase::ConstructL(const TFSMailMsgId aMailBoxId)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail> Removed iMailboxId </qmail>
     // prepare null empty descriptor
     iMailBoxName = HBufC::NewL(1);
@@ -132,7 +136,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailMsgId CFSMailBoxBase::GetId() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return TFSMailMsgId(iNmPrivateMailbox->mId);
 // </qmail>
@@ -143,7 +148,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TDesC& CFSMailBoxBase::GetName()const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iTextPtr.Set( 
         reinterpret_cast<const TUint16*> (iNmPrivateMailbox->mName.utf16()),
@@ -157,7 +163,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBoxBase::SetName( const TDesC& aMailBoxName )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     QString qtName = QString::fromUtf16(aMailBoxName.Ptr(), aMailBoxName.Length());
     // Fix from Cmail 9.2 rewritten with QString methods
@@ -174,7 +181,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailBoxStatus CFSMailBoxBase::GetStatus( ) const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return EFSMailBoxOffline;
 }
 
@@ -183,8 +191,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBoxBase::SetStatus( const TFSMailBoxStatus /*aStatus*/ )
 {
-    FUNC_LOG;
-	
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -192,7 +199,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBoxBase::GetRCLInfo(TUid& aProtocolUid, TUint& aAccountUid)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	aProtocolUid = iProtocolUid;
 	aAccountUid = iAccountUid;
 }
@@ -202,7 +210,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBoxBase::SetRCLInfo(const TUid aProtocolUid, const TUint aAccountUid)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iProtocolUid = aProtocolUid;
 	iAccountUid = aAccountUid;
 }
@@ -212,7 +221,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C const TUid CFSMailBoxBase::GetSettingsUid()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return iSettingsUid;
 	}
 
@@ -221,7 +231,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBoxBase::SetSettingsUid(const TUid aUid)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 		iSettingsUid = aUid;
 	}
 
@@ -230,7 +241,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C MMRInfoProcessor& CFSMailBoxBase::MRInfoProcessorL()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return *iMRInfoProcessor;
 	}
 
@@ -239,7 +251,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TBool CFSMailBoxBase::IsMRInfoProcessorSet()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(iMRInfoProcessor)
 		{
 		return ETrue;
@@ -255,8 +268,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBoxBase::SetMRInfoProcessorL(MMRInfoProcessor* aMRInfoProcessor)
 	{
-    FUNC_LOG;
-
+    NM_FUNCTION;
+    
 	if(iMRInfoProcessor)
 	{
 		delete iMRInfoProcessor;
@@ -269,7 +282,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailAddress& CFSMailBoxBase::OwnMailAddress( )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return *iOwnMailAddress;
 }
 
@@ -278,7 +292,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailBoxBase::SetOwnMailAddressL( CFSMailAddress* aOwnMailAddress)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(iOwnMailAddress)
 		{
 		delete iOwnMailAddress;
@@ -309,7 +324,8 @@
 // -----------------------------------------------------------------------------
 TDesC& CFSMailBoxBase::BrandingId( )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return *iBrId;
 }
 
@@ -321,6 +337,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C NmMailbox* CFSMailBoxBase::GetNmMailbox()
 {
+    NM_FUNCTION;
+    
     NmMailbox* nmmailbox = new NmMailbox(iNmPrivateMailbox);
     return nmmailbox;
 }
--- a/emailservices/emailcommon/src/CFSMailFolder.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailFolder.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,12 +15,13 @@
 *
 */
 
+#include "emailtrace.h"
+
 // <qmail>
 #include <nmcommonheaders.h>
 // </qmail>
 
 //<cmail>
-#include "emailtrace.h"
 #include "CFSMailFolder.h"
 #include "CFSMailPlugin.h"
 //</cmail>
@@ -34,11 +35,12 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailFolder* CFSMailFolder::NewLC( TFSMailMsgId aFolderId )
 {
-    FUNC_LOG;
-  CFSMailFolder* api = new (ELeave) CFSMailFolder();
-  CleanupStack:: PushL(api);
-  api->ConstructL( aFolderId );
-  return api;
+    NM_FUNCTION;
+    
+    CFSMailFolder* api = new (ELeave) CFSMailFolder();
+    CleanupStack:: PushL(api);
+    api->ConstructL( aFolderId );
+    return api;
 } 
 
 // -----------------------------------------------------------------------------
@@ -46,10 +48,11 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailFolder* CFSMailFolder::NewL( TFSMailMsgId aFolderId )
 {
-    FUNC_LOG;
-  CFSMailFolder* api =  CFSMailFolder::NewLC( aFolderId );
-  CleanupStack:: Pop(api);
-  return api;
+    NM_FUNCTION;
+    
+    CFSMailFolder* api =  CFSMailFolder::NewLC( aFolderId );
+    CleanupStack:: Pop(api);
+    return api;
 }
 
 // -----------------------------------------------------------------------------
@@ -57,8 +60,7 @@
 // -----------------------------------------------------------------------------
 CFSMailFolder::CFSMailFolder()
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -66,7 +68,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailFolder::ConstructL( TFSMailMsgId aFolderId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     CFSMailFolderBase::ConstructL( aFolderId );
 // </qmail>
@@ -80,8 +83,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailFolder::~CFSMailFolder()
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -90,8 +92,8 @@
 EXPORT_C MFSMailIterator* CFSMailFolder::ListMessagesL( const TFSMailDetails aDetails,
         						const RArray<TFSMailSortCriteria>& aSorting)
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
+    
 	CFSMailIterator* iterator = NULL;
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
 		{
@@ -112,7 +114,8 @@
      							 				TFSMailDetails aDetails,
      							 				MFSMailRequestObserver& aObserver )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	// init asynchronous request
 	CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId());
     TFSPendingRequest request = 
@@ -150,7 +153,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolder::GetSubFoldersL(RPointerArray<CFSMailFolder>& aSubFolders)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
 		{
 		TRAPD(err,plugin->ListFoldersL( GetMailBoxId(), GetFolderId(), aSubFolders));
@@ -166,7 +170,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolder::RemoveMessageL(TFSMailMsgId aMessage)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
 		{
 		RArray<TFSMailMsgId> messages;
@@ -177,13 +182,60 @@
 		}
 }
 
+// <qmail>
+// -----------------------------------------------------------------------------
+// CFSMailFolder::RemoveMessageL
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CFSMailFolder::RemoveMessageL(TFSMailMsgId aMessage,
+                                            MFSMailRequestObserver& aObserver)
+{
+    NM_FUNCTION;
+
+    // init asynchronous request
+    CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId());
+    TFSPendingRequest request = 
+        iRequestHandler->InitAsyncRequestL( GetFolderId().PluginId(), aObserver );
+
+    TInt err = KErrNone;
+    
+    if (plugin)
+        {
+        MFSMailRequestObserver* observer = request.iObserver;
+        
+        RArray<TFSMailMsgId> messages;
+        messages.Reset();
+        messages.Append(aMessage);
+        
+        TRAP(err,plugin->DeleteMessagesByUidL(
+            GetMailBoxId(),
+            GetFolderId(),
+            messages,
+            *observer,
+            request.iRequestId));
+        
+        messages.Close();
+        }
+    else 
+        {
+        err = KErrNotFound;        
+        }
+    
+    if(err != KErrNone)
+        {
+        iRequestHandler->CompleteRequest(request.iRequestId);
+        User::Leave(err);
+        }
+    return request.iRequestId;
+}
+// </qmail>
+
 // -----------------------------------------------------------------------------
 // CFSMailFolder::SupportsCopyFromL
 // -----------------------------------------------------------------------------
 EXPORT_C TBool CFSMailFolder::SupportsCopyFromL( TFSFolderType aFolderType )
 	{
-    FUNC_LOG;
-	
+    NM_FUNCTION;
+    
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
 		{
 		TFSMailBoxStatus onlineStatus = plugin->GetMailBoxStatus(GetMailBoxId());
@@ -216,8 +268,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TBool CFSMailFolder::SupportsMoveFromL( TFSFolderType aFolderType )
 	{
-    FUNC_LOG;
-
+    NM_FUNCTION;
+    
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
 		{
 		TFSMailBoxStatus onlineStatus = plugin->GetMailBoxStatus(GetMailBoxId());
@@ -250,7 +302,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolder::RemoveDownLoadedAttachmentsL()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId());
     if(plugin != NULL)
@@ -291,7 +343,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolder::ReleaseExtension( CEmailExtension* aExtension )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     // no specialized behaviour, call base class
     CExtendableEmail::ReleaseExtension( aExtension );
     }
@@ -301,7 +354,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CEmailExtension* CFSMailFolder::ExtensionL( const TUid& aInterfaceUid )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return CExtendableEmail::ExtensionL( aInterfaceUid );
     }
 
--- a/emailservices/emailcommon/src/CFSMailFolderBase.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailFolderBase.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,12 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 // <qmail>
 #include <nmcommonheaders.h>
 // </qmail>
 
-#include "emailtrace.h"
-
 // <qmail>
 #include "CFSMailFolderBase.h"
 #include "nmfolder.h"
@@ -32,7 +32,8 @@
 // -----------------------------------------------------------------------------
 CFSMailFolderBase::CFSMailFolderBase()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail> unnecessary iFolderName initialization removed </qmail>
 	iMoveOfflineBlocked.Reset();
 	iMoveOnlineBlocked.Reset();
@@ -45,7 +46,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailFolderBase::~CFSMailFolderBase()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail> unnecessary iFolderName destruction removed </qmail>
 	iMoveOfflineBlocked.Reset();
 	iMoveOnlineBlocked.Reset();
@@ -58,7 +60,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolderBase::ConstructL( TFSMailMsgId aFolderId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateFolder = new NmFolderPrivate();
     iNmPrivateFolder->mFolderId = aFolderId.GetNmId();
@@ -70,11 +73,12 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailFolderBase* CFSMailFolderBase::NewLC( TFSMailMsgId aFolderId )
 {
-    FUNC_LOG;
-  CFSMailFolderBase* folder = new (ELeave) CFSMailFolderBase();
-  CleanupStack:: PushL(folder);
-  folder->ConstructL(aFolderId);
-  return folder;
+    NM_FUNCTION;
+    
+    CFSMailFolderBase* folder = new (ELeave) CFSMailFolderBase();
+    CleanupStack:: PushL(folder);
+    folder->ConstructL(aFolderId);
+    return folder;
 } 
 
 // -----------------------------------------------------------------------------
@@ -82,10 +86,11 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailFolderBase* CFSMailFolderBase::NewL(const TFSMailMsgId aFolderId)
 {
-    FUNC_LOG;
-  CFSMailFolderBase* folder =  CFSMailFolderBase::NewLC(aFolderId);
-  CleanupStack:: Pop(folder);
-  return folder;
+    NM_FUNCTION;
+    
+    CFSMailFolderBase* folder =  CFSMailFolderBase::NewLC(aFolderId);
+    CleanupStack:: Pop(folder);
+    return folder;
 }
 
 // -----------------------------------------------------------------------------
@@ -93,7 +98,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailMsgId CFSMailFolderBase::GetFolderId() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
 	return TFSMailMsgId(iNmPrivateFolder->mFolderId);
 // </qmail>
@@ -105,7 +111,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailMsgId CFSMailFolderBase::GetParentFolderId() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return TFSMailMsgId(iNmPrivateFolder->mParentFolderId);
 // </qmail>
@@ -116,7 +123,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolderBase::SetParentFolderId(TFSMailMsgId aFolderId)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateFolder->mParentFolderId = aFolderId.GetNmId();
 // </qmail>
@@ -127,7 +135,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailMsgId CFSMailFolderBase::GetMailBoxId() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
 	return TFSMailMsgId(iNmPrivateFolder->mMailboxId);
 // </qmail>
@@ -138,7 +147,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolderBase::SetMailBoxId(TFSMailMsgId aMailBoxId)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateFolder->mMailboxId = aMailBoxId.GetNmId();
 // </qmail>
@@ -150,7 +160,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSFolderType CFSMailFolderBase::GetFolderType() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return static_cast<TFSFolderType>(iNmPrivateFolder->mFolderType);
 // </qmail>
@@ -161,7 +172,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolderBase::SetFolderType(const TFSFolderType aFolderType)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateFolder->mFolderType = static_cast<NmFolderType>(aFolderType);
 // </qmail>
@@ -172,7 +184,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TDesC& CFSMailFolderBase::GetFolderName() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iTextPtr.Set(
         reinterpret_cast<const TUint16*> (iNmPrivateFolder->mName.utf16()),
@@ -186,7 +199,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolderBase::SetFolderName(const TDesC& aFolderName)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     QString qtName = QString::fromUtf16(aFolderName.Ptr(), aFolderName.Length());
     iNmPrivateFolder->mName = qtName;
@@ -198,7 +212,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TUint CFSMailFolderBase::GetMessageCount() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return (TUint)iNmPrivateFolder->mMessageCount;
 // </qmail>
@@ -209,7 +224,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TUint CFSMailFolderBase::GetUnreadCount() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return (TUint)iNmPrivateFolder->mUnreadMessageCount;
 // </qmail>
@@ -220,7 +236,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TUint CFSMailFolderBase::GetUnseenCount() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return (TUint)iNmPrivateFolder->mUnseenCount;
 // </qmail>
@@ -231,7 +248,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TUint CFSMailFolderBase::GetSubFolderCount() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return (TUint)iNmPrivateFolder->mSubFolderCount;
 // </qmail>
@@ -241,7 +259,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolderBase::SetMessageCount( TUint aMessageCount )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateFolder->mMessageCount = aMessageCount;
 // </qmail>
@@ -252,7 +271,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolderBase::SetUnreadCount( TUint aMessageCount )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateFolder->mUnreadMessageCount = aMessageCount;
 // </qmail>
@@ -263,7 +283,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolderBase::SetUnseenCount( TUint aMessageCount )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateFolder->mUnseenCount = aMessageCount;
 // </qmail>
@@ -274,7 +295,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailFolderBase::SetSubFolderCount(TUint aFolderCount)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateFolder->mSubFolderCount = aFolderCount;
 // </qmail>
@@ -286,7 +308,8 @@
 EXPORT_C void CFSMailFolderBase::BlockCopyFromL( RArray<TFSFolderType> aFolderTypes, 
 													TFSMailBoxStatus aMailBoxStatus )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	switch(aMailBoxStatus)
 		{
 			case EFSMailBoxOnline:
@@ -314,7 +337,8 @@
 EXPORT_C void CFSMailFolderBase::BlockMoveFromL( RArray<TFSFolderType> aFolderTypes, 
 													TFSMailBoxStatus aMailBoxStatus )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	switch(aMailBoxStatus)
 		{
 			case EFSMailBoxOnline:
@@ -342,6 +366,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C NmFolder* CFSMailFolderBase::GetNmFolder()
 {
+    NM_FUNCTION;
+    
     NmFolder* nmFolder = new NmFolder(iNmPrivateFolder);
     return nmFolder;
 }
--- a/emailservices/emailcommon/src/CFSMailIterator.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailIterator.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 // <qmail>
 #include <nmcommonheaders.h>
 // </qmail>
 
-#include "emailtrace.h"
 #include "CFSMailIterator.h"
 
 // ================= MEMBER FUNCTIONS ==========================================
@@ -29,11 +30,12 @@
 EXPORT_C CFSMailIterator* CFSMailIterator::NewLC( 	MFSMailIterator& aIterator,
 													CFSMailRequestHandler* aRequestHandler )
 {
-    FUNC_LOG;
-  CFSMailIterator* api = new (ELeave) CFSMailIterator();
-  CleanupStack:: PushL(api);
-  api->ConstructL( aIterator, aRequestHandler );
-  return api;
+    NM_FUNCTION;
+    
+    CFSMailIterator* api = new (ELeave) CFSMailIterator();
+    CleanupStack:: PushL(api);
+    api->ConstructL( aIterator, aRequestHandler );
+    return api;
 } 
 
 // -----------------------------------------------------------------------------
@@ -42,10 +44,11 @@
 EXPORT_C CFSMailIterator* CFSMailIterator::NewL( 	MFSMailIterator& aIterator,
 													CFSMailRequestHandler* aRequestHandler )
 {
-    FUNC_LOG;
-  CFSMailIterator* api =  CFSMailIterator::NewLC( aIterator, aRequestHandler );
-  CleanupStack:: Pop(api);
-  return api;
+    NM_FUNCTION;
+    
+    CFSMailIterator* api =  CFSMailIterator::NewLC( aIterator, aRequestHandler );
+    CleanupStack:: Pop(api);
+    return api;
 }
 
 // -----------------------------------------------------------------------------
@@ -53,7 +56,8 @@
 // -----------------------------------------------------------------------------
 CFSMailIterator::CFSMailIterator()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iIterator = NULL;
 }
 
@@ -63,7 +67,8 @@
 void CFSMailIterator::ConstructL( 	MFSMailIterator& aIterator,
 									CFSMailRequestHandler* aRequestHandler )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iIterator = &aIterator;
 	iRequestHandler = aRequestHandler;
  }
@@ -73,7 +78,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailIterator::~CFSMailIterator()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(iIterator)
 		{
 		delete iIterator;
@@ -88,7 +94,8 @@
         TUint aCount, 
         RPointerArray<CFSMailMessage>& aMessages)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	// call plugin iterator
 	TBool ret = iIterator->NextL(aCurrentMessageId,aCount,aMessages);
 	
@@ -104,7 +111,7 @@
         TUint aCount, 
         RPointerArray<CFSMailMessage>& aMessages)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	// call plugin iterator
 	TBool ret = iIterator->NextL(aStartWith,aCount,aMessages);
@@ -120,8 +127,9 @@
         TUint aCount, 
         RPointerArray<CFSMailMessage>& aMessages)
 	{
-    FUNC_LOG;
-		// call plugin iterator
+    NM_FUNCTION;
+    
+	// call plugin iterator
 	TBool ret = iIterator->PreviousL(aCurrentMessageId,aCount,aMessages);
 		
 	return ret;
@@ -136,7 +144,7 @@
         TUint aCount, 
         RPointerArray<CFSMailMessage>& aMessages)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	// call plugin iterator
 	TBool ret = iIterator->PreviousL(aStartWith,aCount,aMessages);
--- a/emailservices/emailcommon/src/CFSMailMessage.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailMessage.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -16,6 +16,7 @@
 */
 
 #include "emailtrace.h"
+
 #include <apgcli.h>
 #include <apmrec.h>
 #include <mmf/common/mmfcontrollerpluginresolver.h> // CleanupResetAndDestroy
@@ -39,7 +40,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessage * CFSMailMessage::NewLC(TFSMailMsgId aMessageId)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
   	CFSMailMessage* message = new (ELeave) CFSMailMessage();
   	CleanupStack:: PushL(message);
   	message->ConstructL( aMessageId );
@@ -51,7 +53,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessage * CFSMailMessage::NewL(TFSMailMsgId aMessageId)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
   	CFSMailMessage* message =  CFSMailMessage::NewLC(aMessageId);
   	CleanupStack:: Pop(message);
   	return message;
@@ -63,7 +66,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessage* CFSMailMessage::NewL( const NmMessage &aMessage )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailMessage* self = new (ELeave) CFSMailMessage();
     CleanupStack::PushL(self);
     self->ConstructL(aMessage);
@@ -77,7 +81,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailMessage::ConstructL( TFSMailMsgId aMessageId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     // Base class initialization
     CFSMailMessagePart::ConstructL( aMessageId, TFSMailMsgId() );
@@ -90,7 +95,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailMessage::ConstructL( const NmMessage &aMessage )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     // Base class initialization
     
     CFSMailMessagePart::ConstructL( aMessage, aMessage.envelope() );
@@ -102,7 +108,7 @@
 // -----------------------------------------------------------------------------
 CFSMailMessage::CFSMailMessage() : CFSMailMessagePart()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -110,7 +116,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessage::~CFSMailMessage()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iMessageBufferForAsyncOp.Reset();
 // </qmail>
@@ -121,7 +128,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessage::SaveMessageL()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
 		{
 		plugin->StoreMessageL(GetMailBoxId(),*this);
@@ -134,7 +142,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TInt CFSMailMessage::SaveMessageL( MFSMailRequestObserver& aOperationObserver )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId());
     TFSPendingRequest request = iRequestHandler->InitAsyncRequestL(
@@ -160,7 +168,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TInt CFSMailMessage::SaveMessagePartsL( MFSMailRequestObserver& aOperationObserver )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     RPointerArray<CFSMailMessagePart> messageParts;
     CleanupResetAndDestroyPushL(messageParts);
@@ -208,7 +216,7 @@
 EXPORT_C CFSMailMessagePart* CFSMailMessage::AddNewAttachmentL( RFile& aFile,
                                                                 const TDesC8& aMimeType )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
     CFSMailMessagePart* newPart = NULL;
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
@@ -259,7 +267,7 @@
 EXPORT_C CFSMailMessagePart* CFSMailMessage::AddNewAttachmentL(	const TDesC& aFilePath,
 																const TFSMailMsgId /*aInsertBefore*/ )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	CFSMailMessagePart* newPart = NULL;
 	
@@ -304,7 +312,8 @@
 EXPORT_C TInt CFSMailMessage::AddNewAttachmentL( const TDesC& aFilePath,
                                                  MFSMailRequestObserver& aOperationObserver)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TFSPendingRequest request;
   
     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
@@ -358,7 +367,8 @@
 EXPORT_C void CFSMailMessage::AttachmentListL(
     RPointerArray<CFSMailMessagePart>& aParts )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     // First list all message parts
     AppendAttachmentsL( aParts ); 
 
@@ -420,7 +430,8 @@
 EXPORT_C CFSMailMessagePart* CFSMailMessage::PlainTextBodyPartL(
         TFSMailMessagePartDataSource aDataSource)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailMessagePart* part = FindBodyPartL(KFSMailContentTypeTextPlain, aDataSource);
     
     // special case, single part content type is not given
@@ -442,7 +453,8 @@
 EXPORT_C CFSMailMessagePart* CFSMailMessage::HtmlBodyPartL(
         TFSMailMessagePartDataSource aDataSource)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailMessagePart* part = FindBodyPartL(KFSMailContentTypeTextHtml, aDataSource);
     iMessageParts.ResetAndDestroy();
 	iReadMessageParts = ETrue;
@@ -456,7 +468,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TBool CFSMailMessage::IsMessageL() const
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return CFSMailMessagePart::IsMessageL();
 	}
 // </qmail>
@@ -466,7 +479,8 @@
 // -----------------------------------------------------------------------------
 CDesCArray& CFSMailMessage::ContentTypeParameters()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
    CDesCArray* faked = NULL;
    return *faked;
 }
@@ -476,7 +490,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailMessage::DoAttachmentListL( RPointerArray<CFSMailMessagePart>& aParts )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     AttachmentListL(aParts);
     }
 
@@ -487,6 +502,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C NmMessage* CFSMailMessage::GetNmMessage()
 {
+    NM_FUNCTION;
+    
 	NmMessage* message = new NmMessage(iNmPrivateMessageEnvelope, iNmPrivateMessagePart);
 	return message;
 }
--- a/emailservices/emailcommon/src/CFSMailMessageBase.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailMessageBase.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,10 +15,10 @@
 *
 */
 
+#include "emailtrace.h"
 
 //<cmail>
 #include "CFSMailRequestHandler.h"
-#include "emailtrace.h"
 #include "CFSMailMessageBase.h"
 #include "cmailmessageext.h"
 //</cmail>
@@ -35,7 +35,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessageBase * CFSMailMessageBase::NewLC( TFSMailMsgId aMessageId )
 {
-  FUNC_LOG;
+  NM_FUNCTION;
+  
   CFSMailMessageBase* message = new (ELeave) CFSMailMessageBase();
   CleanupStack:: PushL(message);
   message->ConstructL(aMessageId);
@@ -47,7 +48,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessageBase * CFSMailMessageBase::NewL( TFSMailMsgId aMessageId )
 {
-  FUNC_LOG;
+  NM_FUNCTION;
+  
   CFSMailMessageBase* message =  CFSMailMessageBase::NewLC(aMessageId);
   CleanupStack:: Pop(message);
   return message;
@@ -58,7 +60,8 @@
 // -----------------------------------------------------------------------------
 CFSMailMessageBase::CFSMailMessageBase(): iSender(NULL)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail> unnecessary member initialization removed: iSubject, iFlags </qmail>
   	// set request handler pointer
 	iRequestHandler = static_cast<CFSMailRequestHandler*>(Dll::Tls());
@@ -69,7 +72,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::ConstructL( TFSMailMsgId aMessageId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     // Construction of shared data object
     iNmPrivateMessageEnvelope = new NmMessageEnvelopePrivate();
@@ -92,7 +96,7 @@
 EXPORT_C void CFSMailMessageBase::ConstructL(
     const NmMessageEnvelope &aMessageEnvelope )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     iNmPrivateMessageEnvelope = aMessageEnvelope.d;
 }
@@ -103,7 +107,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessageBase::~CFSMailMessageBase()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(iSender)
 		{
 		delete iSender;
@@ -117,7 +122,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailMsgId CFSMailMessageBase::GetMessageId(  ) const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     //For message  
     TFSMailMsgId id = TFSMailMsgId(iNmPrivateMessageEnvelope->mMessageId);
@@ -137,6 +143,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::SetMessageId( const TFSMailMsgId aMessageId )
 {
+    NM_FUNCTION;
+    
     // typedef long int TInt32 -> typedef unsigned int quint32
     iNmPrivateMessageEnvelope->mMessageId.setId32( aMessageId.Id() );
 
@@ -151,7 +159,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailMsgId CFSMailMessageBase::GetFolderId( ) const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return TFSMailMsgId(iNmPrivateMessageEnvelope->mFolderId);
 // </qmail>
@@ -162,7 +171,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::SetFolderId( const TFSMailMsgId aFolderId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->mFolderId = NmConverter::mailMsgIdToNmId(aFolderId);
 // </qmail>
@@ -173,7 +183,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailMsgId CFSMailMessageBase::GetMailBoxId( ) const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return NmId(iNmPrivateMessageEnvelope->mMailboxId);
 // </qmail>
@@ -184,7 +195,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::SetMailBoxId( const TFSMailMsgId aMailBoxId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->mMailboxId = NmConverter::mailMsgIdToNmId(aMailBoxId);
 // </qmail>
@@ -195,7 +207,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::SetSender(CFSMailAddress* aSender)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
 	// store sender
 	if (iSender)
@@ -213,7 +226,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailAddress* CFSMailMessageBase::GetSender() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return iSender;
 }
 
@@ -223,7 +237,8 @@
 EXPORT_C RPointerArray<CFSMailAddress> CFSMailMessageBase::GetToRecipients()
 {
 // <qmail>
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return NmConverter::toRPointerArray(
         iNmPrivateMessageEnvelope->mToRecipients);
 // </qmail>
@@ -235,7 +250,8 @@
 EXPORT_C RPointerArray<CFSMailAddress> CFSMailMessageBase::GetCCRecipients()
 {
 // <qmail>
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return NmConverter::toRPointerArray(
         iNmPrivateMessageEnvelope->mCcRecipients);
 // </qmail>
@@ -247,7 +263,8 @@
 EXPORT_C RPointerArray<CFSMailAddress> CFSMailMessageBase::GetBCCRecipients()
 {
 // <qmail>
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return NmConverter::toRPointerArray(
         iNmPrivateMessageEnvelope->mBccRecipients);
 // </qmail>
@@ -258,7 +275,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::AppendToRecipient(CFSMailAddress* aRecipient)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->mToRecipients.append(
         aRecipient->GetNmAddress());
@@ -270,7 +288,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::AppendCCRecipient(CFSMailAddress* aRecipient )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->mCcRecipients.append(
         aRecipient->GetNmAddress());
@@ -282,7 +301,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::AppendBCCRecipient( CFSMailAddress* aRecipient )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->mBccRecipients.append(
         aRecipient->GetNmAddress());
@@ -294,7 +314,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::ClearToRecipients( )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->mToRecipients.clear();
 // </qmail>
@@ -305,7 +326,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::ClearCcRecipients( )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->mCcRecipients.clear();
 // </qmail>
@@ -316,7 +338,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::ClearBccRecipients( )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->mBccRecipients.clear();
 // </qmail>
@@ -328,7 +351,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TDesC& CFSMailMessageBase::GetSubject() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iSubjectPtr.Set(reinterpret_cast<const TUint16*> (iNmPrivateMessageEnvelope->mSubject.utf16()),
         iNmPrivateMessageEnvelope->mSubject.length());
@@ -341,7 +365,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TTime CFSMailMessageBase::GetDate() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return NmConverter::toTTime(iNmPrivateMessageEnvelope->mSentTime);
 // </qmail>
@@ -352,7 +377,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::SetDate( const TTime aDate )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->mSentTime = NmConverter::toQDateTime(aDate);
 // </qmail>
@@ -363,7 +389,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::SetSubject(const TDesC& aSubject)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     QString qtSubject = QString::fromUtf16(aSubject.Ptr(), aSubject.Length());
     iNmPrivateMessageEnvelope->mSubject = qtSubject;
@@ -375,7 +402,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TInt CFSMailMessageBase::GetFlags( ) const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     return (TInt)iNmPrivateMessageEnvelope->flags();
 // </qmail>
@@ -386,7 +414,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::SetFlag(const TInt aFlag)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->setFlags((NmMessageFlags)aFlag, true);
 // </qmail>
@@ -397,7 +426,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::ResetFlag(const TInt aFlag)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     iNmPrivateMessageEnvelope->setFlags((NmMessageFlags)aFlag, false);
 // </qmail>
@@ -408,7 +438,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TBool CFSMailMessageBase::IsFlagSet(const TInt aFlag) const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 // <qmail>
     TBool result = EFalse;
     if (iNmPrivateMessageEnvelope->isFlagSet((NmMessageFlag)aFlag)) 
@@ -424,7 +455,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailMsgId CFSMailMessageBase::IsRelatedTo() const
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return iRelatedTo;
 	}
 
@@ -433,7 +465,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::SetRelatedTo( const TFSMailMsgId aMessageId )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iRelatedTo = aMessageId;
 	}
 
@@ -442,7 +475,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::SetReplyToAddress(CFSMailAddress* aReplyToAddress)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	// store sender
 	if (iReplyTo)
 		{
@@ -457,12 +491,15 @@
 // -----------------------------------------------------------------------------
 EXPORT_C const CFSMailAddress& CFSMailMessageBase::GetReplyToAddress()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return *iReplyTo;
 }
 
 EXPORT_C CFSMailRequestHandler& CFSMailMessageBase::RequestHandler( )
 {
+    NM_FUNCTION;
+    
 	return *iRequestHandler;
 }
 
@@ -472,7 +509,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C NmMessageEnvelope* CFSMailMessageBase::GetNmMessageEnvelope()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return new NmMessageEnvelope(iNmPrivateMessageEnvelope);
 }
 // </qmail>
@@ -482,7 +520,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessageBase::ReleaseExtension( CEmailExtension* aExtension )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(
 		iNmPrivateMessageEnvelope->mMessageId ) )
         {
@@ -501,7 +540,8 @@
 EXPORT_C CEmailExtension* CFSMailMessageBase::ExtensionL( 
     const TUid& aInterfaceUid )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CEmailExtension* ext = CExtendableEmail::ExtensionL( aInterfaceUid );
     // didn't find already created instance, try now
     if ( !ext )
--- a/emailservices/emailcommon/src/CFSMailMessagePart.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailMessagePart.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 //<qmail>
 #include <nmcommonheaders.h>
 //</qmail>
 
-#include "emailtrace.h"
 #include <apgcli.h>
 #include <apmrec.h>
 #include <mmf/common/mmfcontrollerpluginresolver.h> // CleanupResetAndDestroy
@@ -44,11 +45,12 @@
 EXPORT_C CFSMailMessagePart* CFSMailMessagePart::NewLC( TFSMailMsgId aMessageId,
 														TFSMailMsgId aMessagePartId )
 {
-    FUNC_LOG;
-  CFSMailMessagePart* adr = new (ELeave) CFSMailMessagePart();
-  CleanupStack::PushL(adr);
-  adr->ConstructL( aMessageId, aMessagePartId );
-  return adr;
+    NM_FUNCTION;
+    
+    CFSMailMessagePart* adr = new (ELeave) CFSMailMessagePart();
+    CleanupStack::PushL(adr);
+    adr->ConstructL( aMessageId, aMessagePartId );
+    return adr;
 } 
 
 // -----------------------------------------------------------------------------
@@ -57,10 +59,11 @@
 EXPORT_C CFSMailMessagePart* CFSMailMessagePart::NewL(	TFSMailMsgId aMessageId,
 														TFSMailMsgId aMessagePartId )
 {
-    FUNC_LOG;
-  CFSMailMessagePart* adr =  CFSMailMessagePart::NewLC( aMessageId, aMessagePartId );
-  CleanupStack::Pop(adr);
-  return adr;
+    NM_FUNCTION;
+    
+    CFSMailMessagePart* adr =  CFSMailMessagePart::NewLC( aMessageId, aMessagePartId );
+    CleanupStack::Pop(adr);
+    return adr;
 }
 
 //<qmail>
@@ -70,7 +73,8 @@
 EXPORT_C CFSMailMessagePart* CFSMailMessagePart::NewLC(const NmId &aNmMessageId,
     const NmMessagePart& aNmMessage )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailMessagePart* self = new (ELeave) CFSMailMessagePart();
 	CleanupStack::PushL(self);
 	self->ConstructL( aNmMessageId,aNmMessage );
@@ -84,7 +88,8 @@
 void CFSMailMessagePart::ConstructL( TFSMailMsgId aMessageId,
                                      TFSMailMsgId aMessagePartId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
 	// Base class initialization
     CFSMailMessageBase::ConstructL(aMessageId);
@@ -107,7 +112,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailMessagePart::ConstructL( const NmId &aNmMessageId,const NmMessagePart& aNmMessage )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     // Base class initialization
     CFSMailMessageBase::ConstructL(TFSMailMsgId(aNmMessageId));
     
@@ -129,7 +135,8 @@
     const NmMessagePart& aNmMessage,
     const NmMessageEnvelope& aNmMessageEnvelope)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     // Base class initialization
     CFSMailMessageBase::ConstructL(aNmMessageEnvelope);
     
@@ -148,7 +155,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessagePart::~CFSMailMessagePart()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail> iContentType, iContentDescription, iContentDisposition, iContentID removed </qmail>
 	if(iAttachmentName)
 	{
@@ -187,7 +195,7 @@
 // -----------------------------------------------------------------------------
 CFSMailMessagePart::CFSMailMessagePart() : CFSMailMessageBase()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 	
 //<qmail> iContentType, iContentDescription, iContentDisposition, iContentID removed </qmail>
 	iContentClass = HBufC::New(1);
@@ -204,7 +212,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C const TDesC& CFSMailMessagePart::GetContentType() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     iContentTypePtr.Set(reinterpret_cast<const TUint16*> (iNmPrivateMessagePart->mContentType.utf16()),
     		iNmPrivateMessagePart->mContentType.length());
@@ -217,7 +226,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetContentType(const TDesC& aContentType)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     QString qtContentType = QString::fromUtf16(aContentType.Ptr(), aContentType.Length());
     iNmPrivateMessagePart->mContentType = qtContentType;
@@ -229,7 +239,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSMailMsgId CFSMailMessagePart::GetPartId() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     return TFSMailMsgId(iNmPrivateMessagePart->mPartId);
 //</qmail>	
@@ -242,7 +253,7 @@
 EXPORT_C void CFSMailMessagePart::ChildPartsL( RPointerArray<CFSMailMessagePart>& aParts,
     TFSMailMessagePartDataSource aDataSource)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 
     if (aDataSource == EDataSourceMessageStore)
         {
@@ -272,7 +283,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailMessagePart* CFSMailMessagePart::ChildPartL(TFSMailMsgId aPartId)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 	
 	CFSMailMessagePart* part = NULL;
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
@@ -290,7 +301,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TBool CFSMailMessagePart::IsMessageL() const
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	TBuf<KMaxDataTypeLength> ptr;
 //<qmail>
@@ -318,7 +329,7 @@
 EXPORT_C CFSMailMessagePart* CFSMailMessagePart::NewChildPartL( const TFSMailMsgId aInsertBefore,
 																const TDesC& aContentType )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	CFSMailMessagePart* part = NULL;
 	
@@ -335,7 +346,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::RemoveChildPartL(TFSMailMsgId aPartId)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	// get plugin pointer
 	TFSMailMsgId id = GetPartId();
 	if(id.IsNullId())
@@ -357,7 +369,8 @@
 EXPORT_C TInt CFSMailMessagePart::RemoveChildPartL( TFSMailMsgId aPartId,
                                                     MFSMailRequestObserver& aOperationObserver)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TFSPendingRequest request;
     // get plugin pointer
     TFSMailMsgId id = GetPartId();
@@ -402,7 +415,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C const TDesC& CFSMailMessagePart::GetContentClass()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 		return *iContentClass;
 	}
 
@@ -411,7 +425,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetContentClass( const TDesC& aContentClass )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	// 
 	HBufC* contentClass = HBufC::New(aContentClass.Length());
@@ -435,7 +449,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TUint CFSMailMessagePart::ContentSize() const
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     return (TUint)iNmPrivateMessagePart->mSize;
 //</qmail>
@@ -446,7 +461,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetContentSize( TUint aContentSize )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     iNmPrivateMessagePart->mSize = quint32(aContentSize);
 //</qmail>
@@ -457,7 +473,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C const TDesC& CFSMailMessagePart::ContentID()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>	
     iContentIDPtr.Set(reinterpret_cast<const TUint16*> (iNmPrivateMessagePart->mContentId.utf16()),
     		iNmPrivateMessagePart->mContentId.length());
@@ -470,7 +487,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetContentIDL(const TDesC& aContentID)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     QString qtContentID = QString::fromUtf16(aContentID.Ptr(), aContentID.Length());
     iNmPrivateMessagePart->mContentId = qtContentID;    
@@ -484,7 +502,7 @@
 													TFSMailMsgId aInsertBefore,
 													CFSMailMessage* aMessage)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 	
 	CFSMailMessagePart* part = NULL;
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
@@ -500,7 +518,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::RemoveContentL()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 	
 	CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId());
 	if(plugin == NULL)
@@ -511,16 +529,19 @@
 	if(plugin != NULL)
 		{
 		RPointerArray<CFSMailMessagePart> parts;
-		RArray<TFSMailMsgId> partIds;
-    	plugin->ChildPartsL(GetMailBoxId(),GetFolderId(),GetMessageId(),GetPartId(),parts);
+        CleanupResetAndDestroyPushL( parts );
+        plugin->ChildPartsL(GetMailBoxId(),GetFolderId(),GetMessageId(),GetPartId(),parts);
+        RArray<TFSMailMsgId> partIds;
+        CleanupClosePushL( partIds );
+        partIds.ReserveL( 1 + parts.Count() );
 		for(TInt i=0;i<parts.Count();i++)
 			{
-			partIds.Append(parts[i]->GetMessageId());
+			partIds.AppendL( parts[i]->GetMessageId() );
 			}
-        partIds.Append(GetPartId());
+        partIds.AppendL( GetPartId() );
 		plugin->RemovePartContentL(GetMailBoxId(), GetFolderId(), GetMessageId(), partIds);
-        parts.ResetAndDestroy();
-		partIds.Reset();
+        CleanupStack::PopAndDestroy( &partIds );
+        CleanupStack::PopAndDestroy( &parts );
 		}
 	}
 
@@ -529,7 +550,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::RemoveDownLoadedAttachmentsL()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
         
     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId());
     if(plugin == NULL)
@@ -541,12 +562,12 @@
         {
         // get attachment list
         RPointerArray<CFSMailMessagePart> attachments;
-        attachments.Reset();
+        CleanupResetAndDestroyPushL( attachments );
         DoAttachmentListL(attachments);
 
         // copy attachment part ids
         RArray<TFSMailMsgId> ids;
-        ids.Reset();
+        CleanupClosePushL( ids ); 
         for(TInt i=0;i<attachments.Count();i++)
             {
             ids.Append(attachments[i]->GetPartId());
@@ -559,8 +580,8 @@
             }
         
         // clean tables
-        attachments.ResetAndDestroy();
-        ids.Reset();
+        CleanupStack::PopAndDestroy( &ids );
+        CleanupStack::PopAndDestroy( &attachments );
         }
     }
 
@@ -569,7 +590,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C RFile CFSMailMessagePart::GetContentFileL()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 	
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
 		{
@@ -596,7 +617,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetContentFromFileL(const TDesC& aFilePath)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
 		{
 		plugin->SetPartContentFromFileL(GetMailBoxId(), GetFolderId(),
@@ -609,7 +631,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::CopyContentFileL( const TDesC& aFilePath )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
 		{
 		plugin->CopyMessagePartFileL( GetMailBoxId(), GetFolderId(),
@@ -622,7 +645,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::GetContentToBufferL(TDes16& aBuffer, TUint aStartOffset)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
 		{
 		plugin->GetContentToBufferL( GetMailBoxId(), GetFolderId(), GetMessageId(),
@@ -635,7 +659,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetContent( TDes16& aBuffer )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
 		{
 // <qmail>
@@ -650,7 +675,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C const TDesC& CFSMailMessagePart::ContentDescription()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     iContentDescriptionPtr.Set(reinterpret_cast<const TUint16*> (
             iNmPrivateMessagePart->mContentDescription.utf16()),
@@ -665,7 +691,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetContentDescription( const TDesC& aContentDescription )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     QString qtContentDescription = QString::fromUtf16(
             aContentDescription.Ptr(), aContentDescription.Length());
@@ -677,7 +704,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C const TDesC& CFSMailMessagePart::ContentDisposition()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
 	iContentDispositionPtr.Set(reinterpret_cast<const TUint16*> (
 	        iNmPrivateMessagePart->mContentDisposition.utf16()),
@@ -691,7 +719,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetContentDisposition( const TDesC& aContentDisposition )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     QString qtContentDisposition = QString::fromUtf16(
             aContentDisposition.Ptr(), aContentDisposition.Length());
@@ -704,7 +733,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CDesCArray& CFSMailMessagePart::ContentTypeParameters()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>	
     if (iNmPrivateMessagePart->mContentType.isNull())
 		{
@@ -801,7 +831,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CDesCArray& CFSMailMessagePart::ContentDispositionParameters()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 	
 //<qmail>
     const TDesC& contentDisposition = ContentDisposition();
@@ -935,7 +965,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C MMRInfoObject& CFSMailMessagePart::GetMRInfo()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return *iMeetingRequest;
 }
 
@@ -944,7 +975,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TBool CFSMailMessagePart::IsMRInfoSet()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(iMeetingRequest)
 		{
 		return ETrue;
@@ -960,7 +992,8 @@
 // -----------------------------------------------------------------------------	
 EXPORT_C void CFSMailMessagePart::SetMRInfo(MMRInfoObject* aMeetingRequest)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(iMeetingRequest)
 	{
 		delete iMeetingRequest;
@@ -973,7 +1006,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SaveL()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
 		{
 		plugin->StoreMessagePartL( GetMailBoxId(), GetFolderId(), GetMessageId(), *this );		
@@ -986,7 +1020,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetAttachmentNameL(const TDesC& aFilePath)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	    // Parse file name in case full path is given
 		TPtrC name;
 		for(TInt i=0;i<aFilePath.Length();)
@@ -1057,7 +1092,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TDesC& CFSMailMessagePart::AttachmentNameL()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     // Look first from Content-Type param "name"
 	TInt ptr = GetContentType().Find(KFSMailContentTypeParamName);
@@ -1109,7 +1145,7 @@
         const TDesC& aContentType, 
         TFSMailMessagePartDataSource aDataSource)
     {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     TBuf<KMaxDataTypeLength> ptr;
     if (!iNmPrivateMessagePart->mContentType.isNull())
@@ -1216,7 +1252,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TBool CFSMailMessagePart::ContentTypeMatches( const TDesC& aContentType )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	TBuf<KMaxDataTypeLength> ptr;
 	TBool result(EFalse);
@@ -1246,7 +1282,8 @@
 EXPORT_C void CFSMailMessagePart::AppendAttachmentsL(
     RPointerArray<CFSMailMessagePart>& aParts)
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetMessageId() );
     if ( plugin )
         {
@@ -1283,7 +1320,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TUint CFSMailMessagePart::FetchedContentSize() const
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     return (TUint)iNmPrivateMessagePart->mFetchedSize;
 //</qmail>
@@ -1294,7 +1332,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetFetchedContentSize(TUint aContentSize)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
     iNmPrivateMessagePart->mFetchedSize = quint32(aContentSize);
 //</qmail>
@@ -1305,7 +1344,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TFSPartFetchState CFSMailMessagePart::FetchLoadState() const
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 //<qmail>
 	 if(iMessagePartsStatus != EFSDefault)
 		{
@@ -1337,7 +1377,7 @@
         										  		MFSMailRequestObserver& aOperationObserver,
         												const TUint aPreferredByteCount)
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
 	TInt requestId(0);
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
@@ -1379,7 +1419,7 @@
         							MFSMailRequestObserver& aOperationObserver,
         							const TUint aPreferredByteCount)
     {
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	TInt requestId(0);
     
@@ -1421,7 +1461,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetMessagePartsStatus(TFSPartFetchState aMessagePartStatus)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iMessagePartsStatus = aMessagePartStatus;
 	}
 
@@ -1432,7 +1473,8 @@
 																const TFSMailMsgId /*aInsertBefore*/,
 																const TDesC& aContentType )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailMessagePart* newPart = NULL;
 
     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetMessageId() );
@@ -1464,7 +1506,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TUint CFSMailMessagePart::ReadOnlyPartSize() const
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return iReadOnlyPartSize;
 }
 
@@ -1473,7 +1516,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailMessagePart::SetReadOnlyPartSize(const TUint aReadOnlyPartSize)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     iReadOnlyPartSize = aReadOnlyPartSize;
 }
 
@@ -1482,7 +1526,7 @@
 // -----------------------------------------------------------------------------
 void CFSMailMessagePart::DoAttachmentListL( RPointerArray<CFSMailMessagePart>& /*aParts*/ )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 }
 
 //<qmail>
@@ -1491,7 +1535,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C NmMessagePart* CFSMailMessagePart::GetNmMessagePart()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return new NmMessagePart(iNmPrivateMessagePart);
 }
 //</qmail>
@@ -1502,7 +1547,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C HBufC* CFSMailMessagePart::GetLocalTextContentLC()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return NmConverter::qstringToHBufCLC(iNmPrivateMessagePart->mTextContent);
 }
 //</qmail>
--- a/emailservices/emailcommon/src/CFSMailPluginData.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailPluginData.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 // <qmail>
 #include <nmcommonheaders.h>
 // </qmail>
 
-#include "emailtrace.h"
 #include "CFSMailPluginData.h"
 
 // -----------------------------------------------------------------------------
@@ -27,8 +28,7 @@
 // -----------------------------------------------------------------------------
 CFSMailPluginData::CFSMailPluginData()
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -36,7 +36,8 @@
 // -----------------------------------------------------------------------------
 CFSMailPluginData::~CFSMailPluginData()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(iPlugin)
 		{
 		delete iPlugin;
--- a/emailservices/emailcommon/src/CFSMailRequestHandler.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailRequestHandler.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,12 +15,13 @@
 *
 */
 
+#include "emailtrace.h"
+
 // <qmail>
 // Exports removed because entire class is exported from DLL
 #include <nmcommonheaders.h>
 // </qmail>
 
-#include "emailtrace.h"
 #include "CFSMailRequestHandler.h"
 #include "CFSMailRequestObserver.h"
 
@@ -31,7 +32,7 @@
 // -----------------------------------------------------------------------------
  CFSMailRequestHandler::CFSMailRequestHandler() : iRequestId(0)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     // store pointer to TLS
     TInt err = Dll::SetTls(static_cast<TAny*>(this));
@@ -48,7 +49,8 @@
 // -----------------------------------------------------------------------------
  CFSMailRequestHandler::~CFSMailRequestHandler()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TRAP_IGNORE( CancelAllRequestsL() );
     RemoveAllRequests();
     iPendingRequests.Reset();
@@ -72,11 +74,12 @@
                                     RPointerArray<CImplementationInformation>& aPluginInfo,
                                     RPointerArray<CFSMailPlugin>& aPlugins )
 {
-    FUNC_LOG;
-  CFSMailRequestHandler* pluginHandler = new (ELeave) CFSMailRequestHandler();
-  CleanupStack:: PushL(pluginHandler);
-  pluginHandler->ConstructL( aPluginInfo, aPlugins );
-  return pluginHandler;
+    NM_FUNCTION;
+    
+    CFSMailRequestHandler* pluginHandler = new (ELeave) CFSMailRequestHandler();
+    CleanupStack:: PushL(pluginHandler);
+    pluginHandler->ConstructL( aPluginInfo, aPlugins );
+    return pluginHandler;
 } 
 
 // -----------------------------------------------------------------------------
@@ -86,11 +89,12 @@
                                     RPointerArray<CImplementationInformation>& aPluginInfo,
                                     RPointerArray<CFSMailPlugin>& aPlugins )
 {
-    FUNC_LOG;
-  CFSMailRequestHandler* pluginHandler =  
-                CFSMailRequestHandler::NewLC( aPluginInfo, aPlugins );
-  CleanupStack:: Pop(pluginHandler);
-  return pluginHandler;
+    NM_FUNCTION;
+    
+    CFSMailRequestHandler* pluginHandler =  
+        CFSMailRequestHandler::NewLC( aPluginInfo, aPlugins );
+    CleanupStack:: Pop(pluginHandler);
+    return pluginHandler;
 }
 
 // -----------------------------------------------------------------------------
@@ -100,9 +104,7 @@
                                 RPointerArray<CImplementationInformation> /*aPluginInfo*/,
                                 RPointerArray<CFSMailPlugin> /*aPlugins*/ )
 {
-    FUNC_LOG;
-
-
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -110,7 +112,7 @@
 // -----------------------------------------------------------------------------
  CFSMailPlugin* CFSMailRequestHandler::GetPluginByUid( TFSMailMsgId aObjectId )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     for(TInt i=0;i<iPluginList.Count();i++)
         {
@@ -131,7 +133,8 @@
                                                     TUid aPluginId,
                                                     MFSMailRequestObserver& aOperationObserver)
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
         TFSPendingRequest newRequest;
         for(TInt i=0;i<iPendingRequests.Count();i++)
             {
@@ -161,7 +164,8 @@
 // -----------------------------------------------------------------------------
  void CFSMailRequestHandler::CompleteRequest( TInt aRequestId )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
         for(TInt i=0;i<iPendingRequests.Count();i++)
         {
         if(iPendingRequests[i].iRequestId == aRequestId)
@@ -178,7 +182,8 @@
 // -----------------------------------------------------------------------------
  void CFSMailRequestHandler::CancelRequestL( TInt aRequestId )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
         for(TInt i=0;i<iPendingRequests.Count();i++)
         {
         if(iPendingRequests[i].iRequestId == aRequestId &&
@@ -200,7 +205,8 @@
 // -----------------------------------------------------------------------------
  void CFSMailRequestHandler::CancelAllRequestsL( )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
         for(TInt i=0;i<iPendingRequests.Count();i++)
         {
             if(iPendingRequests[i].iRequestStatus == TFSPendingRequest::EFSRequestPending)
@@ -220,7 +226,7 @@
 // -----------------------------------------------------------------------------
  void CFSMailRequestHandler::AddPluginL( TUid aPluginId, CFSMailPlugin* aPlugin )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     CFSMailPluginData* pluginData = new (ELeave) CFSMailPluginData;
     pluginData->iPluginId = aPluginId;
@@ -234,7 +240,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailRequestHandler::RemoveAllRequests()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     for(TInt i=0;i<iPendingRequests.Count();i++)
         {
         delete iPendingRequests[i].iObserver;
@@ -247,7 +254,7 @@
 // -----------------------------------------------------------------------------
  RFile CFSMailRequestHandler::GetTempFileL( TFSMailMsgId aContentId, TFileName aFileName )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
     
     // get temp dir path
     if(iTempDirName == NULL)
@@ -274,7 +281,7 @@
 // -----------------------------------------------------------------------------
  void CFSMailRequestHandler::CleanTempDirL( )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     }
 
 // -----------------------------------------------------------------------------
@@ -282,7 +289,8 @@
 // -----------------------------------------------------------------------------
  TDesC& CFSMailRequestHandler::GetTempDirL( )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     return *iTempDirName;
     }
 
--- a/emailservices/emailcommon/src/CFSMailRequestObserver.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/CFSMailRequestObserver.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 // <qmail>
 #include <nmcommonheaders.h>
 // </qmail>
 
-#include "emailtrace.h"
 #include "CFSMailRequestObserver.h"
 #include "CFSMailRequestHandler.h"
 
@@ -29,8 +30,7 @@
 // -----------------------------------------------------------------------------
 CFSMailRequestObserver::CFSMailRequestObserver()
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -38,8 +38,7 @@
 // -----------------------------------------------------------------------------
 CFSMailRequestObserver::~CFSMailRequestObserver()
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
 }
 // -----------------------------------------------------------------------------
 // CFSMailRequestObserver::NewLC
@@ -47,7 +46,8 @@
 CFSMailRequestObserver* CFSMailRequestObserver::NewLC( CFSMailRequestHandler& aPluginManager,
 											 MFSMailRequestObserver& aObserver)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailRequestObserver* obs = new (ELeave) CFSMailRequestObserver();
   	CleanupStack:: PushL(obs);
   	obs->ConstructL(aPluginManager,aObserver);
@@ -60,7 +60,8 @@
 CFSMailRequestObserver* CFSMailRequestObserver::NewL( CFSMailRequestHandler& aPluginRequestHandler,
 											MFSMailRequestObserver& aObserver )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
   	CFSMailRequestObserver* obs =  CFSMailRequestObserver::NewLC(aPluginRequestHandler,aObserver);
   	CleanupStack::Pop(obs);
   	return obs;
@@ -72,7 +73,8 @@
 void CFSMailRequestObserver::ConstructL( CFSMailRequestHandler& aPluginRequestHandler,
 									MFSMailRequestObserver& aObserver )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iObserver = &aObserver;
 	iRequestHandler = &aPluginRequestHandler;
 }
@@ -82,7 +84,7 @@
 // -----------------------------------------------------------------------------
 void CFSMailRequestObserver::RequestResponseL( TFSProgress aEvent, TInt aRequestId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	if(iObserver)
 		{
@@ -102,7 +104,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailRequestObserver::SetUserObserver(MFSMailRequestObserver& aObserver)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     iObserver = &aObserver;
 	}
 	
--- a/emailservices/emailcommon/src/cemailextensionbase.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/cemailextensionbase.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,8 +15,9 @@
 *
 */
 
+#include "emailtrace.h"
+
 #include "cemailextensionbase.h"
-#include "emailtrace.h"
 
 /**
 *
@@ -29,7 +30,8 @@
     
 void Panic( TEmailFwPanic aPanic )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     User::Panic( KEmailExtensionPanic, aPanic );
     }
 
@@ -40,6 +42,7 @@
 CEmailExtension::CEmailExtension( const TUid& aUid ) : 
     iUid( TUid::Uid(aUid.iUid ) )
     {
+    NM_FUNCTION;
     }
 
 // ---------------------------------------------------------------------------
@@ -48,6 +51,7 @@
 //
 CEmailExtension::~CEmailExtension()
     {
+    NM_FUNCTION;
     }
 
 // ---------------------------------------------------------------------------
@@ -56,6 +60,8 @@
 //
 TUid CEmailExtension::Uid() const
     {
+    NM_FUNCTION;
+    
     return iUid;
     }
 
@@ -65,6 +71,8 @@
 //
 TUint CEmailExtension::DecRef()
     {
+    NM_FUNCTION;
+    
     if ( iRefCount )
         {
         iRefCount--;
@@ -78,6 +86,8 @@
 //
 void CEmailExtension::IncRef()
     {
+    NM_FUNCTION;
+    
     ++iRefCount;
     }
         
@@ -87,7 +97,8 @@
 //
 void CExtendableEmail::ReleaseExtension( CEmailExtension* aExtension )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if ( !aExtension->DecRef() )
         {
         iExtensions.Remove( aExtension );
@@ -101,7 +112,8 @@
 //
 CEmailExtension* CExtendableEmail::ExtensionL( const TUid& aInterfaceUid )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TInt index = iExtensions.FindExtension( aInterfaceUid );
     CEmailExtension* ext = NULL;
     if ( index != KErrNotFound )
@@ -119,7 +131,8 @@
 //
 CExtendableEmail::CExtendableEmail()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     }
 //</qmail>
 
@@ -129,6 +142,8 @@
 //
 TEmailExtensions::~TEmailExtensions()
     {
+    NM_FUNCTION;
+    
     iExtensions.Close();
     }
 
@@ -138,6 +153,8 @@
 //
 TEmailExtensions::TEmailExtensions() : iExtensions( 1 )
     {
+    NM_FUNCTION;
+    
     }
 
 // ---------------------------------------------------------------------------
@@ -146,6 +163,8 @@
 //
 TInt TEmailExtensions::FindExtension( const TUid& aUid ) const
     {
+    NM_FUNCTION;
+    
     TInt index = KErrNotFound;
     for ( TInt i = 0; i < iExtensions.Count(); i++ )
         {        
@@ -165,6 +184,8 @@
 //
 CEmailExtension* TEmailExtensions::Extension( const TInt aIndex ) const
     {
+    NM_FUNCTION;
+    
     __ASSERT_ALWAYS( aIndex>=0 && aIndex < iExtensions.Count(),
         Panic( EEmailExtensionIndexOutOfRange ) );
     return iExtensions[aIndex];
@@ -176,7 +197,8 @@
 //
 void TEmailExtensions::AddL( CEmailExtension* aExtension )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if ( !aExtension )
         {
         User::Leave( KErrArgument );
@@ -194,7 +216,8 @@
 void TEmailExtensions::Remove( 
     const CEmailExtension* aExtension )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     const TInt index( FindExtension( aExtension->Uid() ) );
     if ( index != KErrNotFound )    
         {
--- a/emailservices/emailcommon/src/emailcalendarinfoimpl.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/emailcalendarinfoimpl.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -16,6 +16,7 @@
 */
 
 #include "emailtrace.h"
+
 #include "cmrcalendarinfoimpl.h"          
 
 // ---------------------------------------------------------------------------
@@ -24,6 +25,7 @@
 //
 CMRCalendarInfo::CMRCalendarInfo( const TUid& aUid ) : CEmailExtension( aUid )
     {
+    NM_FUNCTION;
     }
 
 // ---------------------------------------------------------------------------
@@ -33,6 +35,8 @@
 CMRCalendarInfoImpl::CMRCalendarInfoImpl() : 
     CMRCalendarInfo( KMailboxExtMrCalInfo )
     {
+    NM_FUNCTION;
+    
     iDatabaseId = MAKE_TINT64(0,0);
     }
 
@@ -42,7 +46,7 @@
 //
 CMRCalendarInfoImpl::~CMRCalendarInfoImpl()
     {
-    FUNC_LOG
+    NM_FUNCTION;
     }
 
 // ---------------------------------------------------------------------------
@@ -51,7 +55,8 @@
 //
 void CMRCalendarInfoImpl::GetCalendarDatabaseIdL( TCalFileId& aId ) const
     {
-    FUNC_LOG
+    NM_FUNCTION;
+    
     aId = iDatabaseId;
     }
     
@@ -61,7 +66,8 @@
 //
 void CMRCalendarInfoImpl::SetCalendarDatabaseIdL( const TCalFileId& aId )
     {
-    FUNC_LOG
+    NM_FUNCTION;
+    
     iDatabaseId = aId;
     }
 
--- a/emailservices/emailcommon/src/nmconverter.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailcommon/src/nmconverter.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
 *
 */
 
+#include "emailtrace.h"
+
 #include "nmconverter.h"
 
 /*!
@@ -22,6 +24,8 @@
  */
 EXPORT_C NmMailSortCriteria NmConverter::FSMailSortCriteria2NM(TFSMailSortCriteria criteria) 
 {
+    NM_FUNCTION;
+    
     NmMailSortCriteria toReturn;
 
     // setting defaults
@@ -78,6 +82,8 @@
  */
 EXPORT_C QString NmConverter::toQString(const TDesC& aText)
 {
+    NM_FUNCTION;
+    
     return QString::fromUtf16(aText.Ptr(), aText.Length());
 }
 
@@ -86,6 +92,8 @@
  */
 EXPORT_C QDateTime NmConverter::toQDateTime(const TTime& aTime)
 {
+    NM_FUNCTION;
+    
     QDateTime toReturn;
     TDateTime sTime = aTime.DateTime();
 
@@ -106,6 +114,8 @@
  */
 EXPORT_C TTime NmConverter::toTTime(const QDateTime &aTime)
 {
+    NM_FUNCTION;
+    
     QDate qDate = aTime.date();
     QTime qTime = aTime.time();
 
@@ -120,6 +130,8 @@
  */
 EXPORT_C TFSMailSortCriteria NmConverter::NMMailSortCriteria2FS(NmMailSortCriteria criteria)
 {
+    NM_FUNCTION;
+    
     TFSMailSortCriteria toReturn;
 
     // setting defaults
@@ -176,6 +188,8 @@
  */
 EXPORT_C NmId NmConverter::mailMsgIdToNmId(const TFSMailMsgId aId)
 {
+    NM_FUNCTION;
+    
     NmId id;
     id.setId32( aId.Id() );
     id.setPluginId32( aId.PluginId().iUid );
@@ -188,6 +202,8 @@
  */
 EXPORT_C TFSMailMsgId NmConverter::nmIdToMailMsgId(const NmId aId)
 {
+    NM_FUNCTION;
+    
     TFSMailMsgId id( aId.pluginId32(), aId.id32() );
     return id;
 }
@@ -197,6 +213,8 @@
  */
 EXPORT_C HBufC* NmConverter::qstringToHBufCLC( const QString &string )
 {
+    NM_FUNCTION;
+    
     HBufC* buf = HBufC::NewLC(string.length());    
     buf->Des().Copy( string.utf16() );
     return buf;
@@ -208,6 +226,8 @@
 EXPORT_C RPointerArray<CFSMailAddress> NmConverter::toRPointerArray(
     const QList<NmAddress> &list)
 {
+    NM_FUNCTION;
+    
     RPointerArray<CFSMailAddress> ret;
 
      for (QList<NmAddress>::const_iterator it = list.constBegin();
--- a/emailservices/emaildebug/inc/emailtrace.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emaildebug/inc/emailtrace.h	Thu Jul 22 16:30:28 2010 +0100
@@ -1,309 +1,210 @@
 /*
-* 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:  Header file describing trace utilities for commonemail
-*
-*/
+ * 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 EMAILTRACE_H
 #define EMAILTRACE_H
 
-#include "emailtraceconfig.hrh"
+#include <QCoreApplication>
+#include <QDebug>
+#include <QFile>
+#include <QThread>
 
-#ifdef TRACE_INTO_FILE
-#include <flogger.h> // RFileLogger
-#else
-#include <e32debug.h> // RDebug
-#endif
+/*
+ * The macros NM_COMMENT_TRACES, NM_ERROR_TRACES, and NM_FUNCTION_TRACES
+ * control which debug messages are printed. The trace logging is controlled
+ * with the NM_LOG_TO_FILE macro, whereas the NM_LOG_DIRECTORY macro defines
+ * which directory is to be used to store the log files. The print_trace()
+ * helper function implements printing. Log files are named according to
+ * process and thread IDs. If NM_LOG_TO_FILE is zero or a log file cannot be
+ * 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)
+
+#define NM_COMMENT_TRACES  0
+#define NM_ERROR_TRACES    0
+#define NM_FUNCTION_TRACES 0
 
-/**
-* Constants
-*/
-#ifdef TRACE_INTO_FILE
+#if NM_COMMENT_TRACES || NM_ERROR_TRACES || NM_FUNCTION_TRACES
+
+#define NM_LOG_TO_FILE   1
+#define NM_LOG_DIRECTORY "c:/data/logs/"
 
-    _LIT(  KEmailDir, "email" );
-    _LIT(  KEmailTraceFile, "email.txt" );
+inline void print_trace(const QString& msg)
+{
+    static QFile file(NM_LOG_DIRECTORY+
+                      QString("nmail_p%1_t%2.log").
+                      arg(QCoreApplication::applicationPid()).
+                      arg(QThread::currentThreadId()));
+    if (NM_LOG_TO_FILE && !file.isOpen()) {
+        file.open(QIODevice::Append | QIODevice::Text);
+    }
+    if (file.isWritable()) {
+        QDebug(&file).nospace() << msg << '\n';
+    } else {
+        qDebug().nospace() << "[Nmail] " << msg;
+    }
+}
 
 #endif
 
-//-----------------------------------------------------------------------------
-// Error trace macros
-//-----------------------------------------------------------------------------
-//
-#ifdef ERROR_TRACE
+inline QString DSC2STR(const TDesC& dsc)
+{
+    return QString::fromRawData(reinterpret_cast<const QChar*>(dsc.Ptr()),
+                                dsc.Length());
+}
 
-    /**
-    * Error trace definitions. Does not automatically log the error code!
-    */
-    #ifdef TRACE_INTO_FILE
+#else
+
+#define DSC2STR(dsc)
 
-        #define ERROR( aErr, aMsg )\
-            {\
-            if( aErr != KErrNone )\
-                {\
-                _LIT( KMsg, aMsg );\
-                RFileLogger::Write(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg );\
-                }\
-            }
-        #define ERROR_1( aErr, aMsg, aP1 )\
-            {\
-            if( aErr != KErrNone )\
-                {\
-                _LIT( KMsg, aMsg );\
-                RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1 );\
-                }\
-            }
-        #define ERROR_2( aErr, aMsg, aP1, aP2 )\
-            {\
-            if( aErr != KErrNone )\
-                {\
-                _LIT( KMsg, aMsg );\
-                RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2 );\
-                }\
-            }
-        #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\
-            {\
-            if( aErr != KErrNone )\
-                {\
-                _LIT( KMsg, aMsg );\
-                RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2, aP3 );\
-                }\
-            }
-        #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg )
-        #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 )
+#endif /* DEBUG */
 
-    #else//TRACE_INTO_FILE not defined
+/*
+ * The function NM_COMMENT() prints a debug message. The INFO macros and the
+ * NMLOG macro are provided for legacy compatibility. They are deprecated and
+ * should not be used. If sprintf() type of formatting is desired, consider
+ * using QString::arg() or QTextStream.
+ */
+#if NM_COMMENT_TRACES
 
-        #define ERROR( aErr, aMsg )\
-            {\
-            if( aErr != KErrNone )\
-                {\
-                _LIT( KMsg, aMsg ); RDebug::Print( KMsg );\
-                }\
-            }
-        #define ERROR_1( aErr, aMsg, aP1 )\
-            {\
-            if( aErr != KErrNone )\
-                {\
-                _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1 );\
-                }\
-            }
-        #define ERROR_2( aErr, aMsg, aP1, aP2 )\
-            {\
-            if( aErr != KErrNone )\
-                {\
-                _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2 );\
-                }\
-            }
-        #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\
-            {\
-            if( aErr != KErrNone )\
-                {\
-                _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2, aP3 );\
-                }\
-            }
-        #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg )
-        #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 )
-
-    #endif//TRACE_INTO_FILE
-
-#else//ERROR_TRACE not defined
+inline void NM_COMMENT(const QString& msg)
+{
+    print_trace("COMMENT : " + msg);
+}
+#define INFO(msg) NM_COMMENT(msg)
+#define INFO_1(msg,arg1)\
+do {\
+    QString __msg;\
+    __msg.sprintf(msg,arg1);\
+    NM_COMMENT(__msg);\
+} while (0)
+#define INFO_2(msg,arg1,arg2)\
+do {\
+    QString __msg;\
+    __msg.sprintf(msg,arg1,arg2);\
+    NM_COMMENT(__msg);\
+} while (0)
+#define INFO_3(msg,arg1,arg2,arg3)\
+do {\
+    QString __msg;\
+    __msg.sprintf(msg,arg1,arg2,arg3);\
+    NM_COMMENT(__msg);\
+} while (0)
+#define NMLOG(msg) NM_COMMENT(msg)
 
-    #define ERROR( aErr, aMsg )
-    #define ERROR_1( aErr, aMsg, aP1 )
-    #define ERROR_2( aErr, aMsg, aP1, aP2 )
-    #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )
-    #define ERROR_GEN( aMsg )
-    #define ERROR_GEN_1( aMsg, aP1 )
-
-#endif//ERROR_TRACE
+#else
 
-//-----------------------------------------------------------------------------
-// Info trace macros
-//-----------------------------------------------------------------------------
-//
-#ifdef INFO_TRACE
-
-    /**
-    * Info log message definitions.
-    */
-    #ifdef TRACE_INTO_FILE
+#define NM_COMMENT(msg)
+#define INFO(msg)
+#define INFO_1(msg,arg1)
+#define INFO_2(msg,arg1,arg2)
+#define INFO_3(msg,arg1,arg2,arg3)
+#define NMLOG(msg)
 
-        #define INFO( aMsg )\
-            {\
-            _LIT( KMsg, aMsg );\
-            RFileLogger::Write(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg );\
-            }
-        #define INFO_1( aMsg, aP1 )\
-            {\
-            _LIT( KMsg, aMsg );\
-            RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1 );\
-            }
-        #define INFO_2( aMsg, aP1, aP2 )\
-            {\
-            _LIT( KMsg, aMsg );\
-            RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2 );\
-            }
-        #define INFO_3( aMsg, aP1, aP2, aP3 )\
-            {\
-            _LIT( KMsg, aMsg );\
-            RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2, aP3 );\
-            }
+#endif /* NM_COMMENT_TRACES */
 
-    #else//TRACE_INTO_FILE not defined
+/*
+ * The function NM_ERROR() prints its second argument if the first argument
+ * is non-zero. The ERROR macros are provided for legacy compatibility. They
+ * are deprecated and should not be used. If sprintf() type of formatting is
+ * desired, consider using QString::arg() or QTextStream.
+ */
+#if NM_ERROR_TRACES
 
-        #define INFO( aMsg )\
-            {\
-            _LIT( KMsg, aMsg ); RDebug::Print( KMsg );\
-            }
-        #define INFO_1( aMsg, aP1 )\
-            {\
-            _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1 );\
-            }
-        #define INFO_2( aMsg, aP1, aP2 )\
-            {\
-            _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2 );\
-            }
-        #define INFO_3( aMsg, aP1, aP2, aP3 )\
-            {\
-            _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2, aP3 );\
-            }
-
-    #endif//TRACE_INTO_FILE
-
-#else//INFO_TRACE not defined
-
-    #define INFO( aMsg )
-    #define INFO_1( aMsg, aP1 )
-    #define INFO_2( aMsg, aP1, aP2 )
-    #define INFO_3( aMsg, aP1, aP2, aP3 )
-
-#endif//INFO_TRACE
-
-//-----------------------------------------------------------------------------
-// Function trace macros
-//-----------------------------------------------------------------------------
-//
-#ifdef FUNC_TRACE
+inline void NM_ERROR(int err, const QString& msg)
+{
+    if (err) {
+        print_trace("ERROR : " + msg);
+    }
+}
+#define ERROR(err,msg) NM_ERROR(err,msg)
+#define ERROR_1(err,msg,arg1)\
+do {\
+    QString __msg;\
+    __msg.sprintf(msg,arg1);\
+    NM_ERROR(err,__msg);\
+} while (0)
+#define ERROR_2(err,msg,arg1,arg2)\
+do {\
+    QString __msg;\
+    __msg.sprintf(msg,arg1,arg2);\
+    NM_ERROR(err,__msg);\
+} while(0)
+#define ERROR_3(err,msg,arg1,arg2,arg3)\
+do {\
+    QString __msg;\
+    __msg.sprintf(msg,arg1,arg2,arg3);\
+    NM_ERROR(err,__msg);\
+} while(0)
+#define ERROR_GEN(msg) ERROR(KErrGeneral,msg)
+#define ERROR_GEN_1(msg,arg1) ERROR_1(KErrGeneral,msg,arg1)
 
-    // Constants
-    _LIT8( KEllipse, "(" );
-
-    /**
-    * Function logging definitions.
-    */
-    #ifdef TRACE_INTO_FILE
-
-        #define FUNC( aMsg, aP1 )\
-            {\
-            _LIT8( KMsg, aMsg ); RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1 );\
-            }\
-
-    #else//TRACE_INTO_FILE not defined
+#else
 
-        #define FUNC( aMsg, aP1 )\
-            {\
-            RDebug::Printf( aMsg, aP1 );\
-            }\
-
-    #endif//TRACE_INTO_FILE
+#define NM_ERROR(err,msg)
+#define ERROR(err,msg)
+#define ERROR_1(err,msg,arg1)
+#define ERROR_2(err,msg,arg1,arg2)
+#define ERROR_3(err,msg,arg1,arg2,arg3)
+#define ERROR_GEN(msg)
+#define ERROR_GEN_1(msg,arg1)
 
-    /**
-    * Function trace helper class.
-    */
-    class TFuncLog
-        {
-        public:
-            inline TFuncLog( const char* aFunc ): iFunc( (TUint8*)aFunc )
-                {
-                TInt pos = iFunc.Find( KEllipse );
-                if( pos != KErrNotFound )
-                    {
-                    iFunc.Set( iFunc.Left( iFunc.Find( KEllipse ) ) );
-                    }
-                #ifdef TRACE_INTO_FILE
+#endif /* NM_ERROR_TRACES */
 
-                    //"CMAIL" string is added in the beginning of every trace
-                    //line for filtering purposes
-                    FUNC( "CMAIL %S <", &iFunc );
-
-                #else//TRACE_INTO_FILE notdefined
-
-                    FUNC( "CMAIL %s <", iFunc.Ptr() );
-
-                #endif//TRACE_INTO_FILE
-                }
-            inline ~TFuncLog()
-                {
-                #ifdef TRACE_INTO_FILE
-
-                    FUNC( "CMAIL %S >", &iFunc );
-
-                #else//TRACE_INTO_FILE not defined
-
-                    FUNC( "CMAIL %s >", iFunc.Ptr() );
-
-                #endif//TRACE_INTO_FILE
-                }
-            TPtrC8 iFunc;
-        };
-
-    #define FUNC_LOG TFuncLog _fl( __PRETTY_FUNCTION__ );
-
-#else//FUNC_TRACE not defined
-
-    #define FUNC_LOG
-
-#endif//FUNC_TRACE
+/*
+ * The macro NM_FUNCTION, when used inside a function body, enables tracing
+ * for a function. If used, it should be placed on the first line of the
+ * function body. ENTER and RETURN messages are printed when entering into
+ * and returning from a function, respectively. In case of an exception,
+ * UNWIND (for stack unwinding) is printed instead of RETURN. The FUNC_LOG
+ * macro is provided for legacy compatibility. It is deprecated and should
+ * not be used.
+ */
+#if NM_FUNCTION_TRACES
 
-//-----------------------------------------------------------------------------
-// Timestamp trace macros
-//-----------------------------------------------------------------------------
-//
-#ifdef TIMESTAMP_TRACE
-
-    #ifdef TRACE_INTO_FILE
-
-        #define TIMESTAMP( aCaption )\
-            {\
-            TTime t;\
-            t.HomeTime();\
-            TDateTime dt = t.DateTime();\
-            _LIT( KMsg, aCaption );\
-            _LIT( KFormat, "[TIMESTAMP] %S %d:%02d:%02d.%d us");\
-            RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KFormat,\
-                &KMsg, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond() );\
-            }
-
-    #else//TRACE_INTO_FILE not defined
+class __ftracer
+{
+public:
+    __ftracer(const QString& _fn)
+    : fn(_fn)
+    {
+        print_trace("ENTER : " + fn);
+    }
+    ~__ftracer()
+    {
+        if (std::uncaught_exception()) {
+            print_trace("UNWIND : " + fn);
+        } else {
+            print_trace("RETURN : " + fn);
+        }
+    }
+private:
+    QString fn;
+};
 
-        #define TIMESTAMP( aCaption )\
-            {\
-            TTime t;\
-            t.HomeTime();\
-            TDateTime dt = t.DateTime();\
-            _LIT( KMsg, aCaption );\
-            _LIT( KFormat, "[TIMESTAMP] %S %d:%02d:%02d.%d us");\
-            RDebug::Print( KFormat,\
-                &KMsg, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond() );\
-            }
+#define NM_FUNCTION __ftracer __ft(__PRETTY_FUNCTION__)
+#define FUNC_LOG NM_FUNCTION
+
+#else
 
-    #endif//TRACE_INTO_FILE
-
-#else//TIMESTAMP_TRACE not defined
+#define NM_FUNCTION
+#define FUNC_LOG
 
-    #define TIMESTAMP( aCaption )
+#endif /* NM_FUNCTION_TRACES */
 
-#endif//TIMESTAMP_TRACE
-
-#endif // EMAILTRACE_H
+#endif /* EMAILTRACE_H */
--- a/emailservices/emaildebug/inc/emailtraceconfig.hrh	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
-* 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:  Configuration header file for tracing utilities in commonemail
-*
-*/
-
-
-#ifndef EMAILTRACECONFIG_HRH
-#define EMAILTRACECONFIG_HRH
-
-#ifndef __WINS__
-#ifdef _DEBUG
-#define ENABLE_TRACES
-#endif // _DEBUG
-#endif // __WINS__
-                     
-#ifdef ENABLE_TRACES                     
-/**
-* Trace definitions
-*/
-// Error trace enabled
-#define ERROR_TRACE
-
-// Info trace enabled
-#define INFO_TRACE
-
-// Function trace enabled
-#define FUNC_TRACE
-
-// Tracing into file enabled, default RDebug
-#undef TRACE_INTO_FILE
-
-#endif // ENABLE_TRACES
-
-#endif // EMAILTRACECONFIG_HRH
--- a/emailservices/emailframework/inc/CFSMailPlugin.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailframework/inc/CFSMailPlugin.h	Thu Jul 22 16:30:28 2010 +0100
@@ -133,10 +133,13 @@
      *        will receive progress notifications during the operation.
      * @param aRequestId identifies asynchronous request if parallel
      * requests exist
+     * @param aSilentConnection defines if connection is needed to be 
+     *        silent connection or non-silent one (default).
      */
      virtual void RefreshNowL( const TFSMailMsgId& aMailBoxId,
                                MFSMailRequestObserver& aOperationObserver,
-                               TInt aRequestId ) = 0;
+                               TInt aRequestId,
+                               const TBool aSilentConnection=EFalse ) = 0;
 
     /**
      * Returns last synchronization operation status.
@@ -529,7 +532,25 @@
      virtual void DeleteMessagesByUidL( const TFSMailMsgId& aMailBoxId,
                                         const TFSMailMsgId& aFolderId,
                                         const RArray<TFSMailMsgId>& aMessages ) = 0;
-
+     
+// <qmail>
+     /**
+      * deletes email defined by message id
+      *
+      * @param aMailBoxId id of the mailbox containing email
+      * @param aFolderId email parent folder id
+      * @param aMessages ids of messages to be deleted
+      * @param aOperationObserver Observer for the operation 
+      * @param aRequestId id of the operation
+      * @return KErrNone if this method is supported, KErrNotSupported if not
+      */
+      virtual void DeleteMessagesByUidL( const TFSMailMsgId& aMailBoxId,
+                                         const TFSMailMsgId& aFolderId,
+                                         const RArray<TFSMailMsgId>& aMessages,
+                                         MFSMailRequestObserver& aOperationObserver,
+                                         const TInt aRequestId );
+// </qmail>
+      
     /**
      * creates new email template into drafts folder
      *
--- a/emailservices/emailframework/inc/CFSMailPlugin.inl	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailframework/inc/CFSMailPlugin.inl	Thu Jul 22 16:30:28 2010 +0100
@@ -164,4 +164,16 @@
     {
     User::Leave( KErrFSMailPluginNotSupported );
     }
+
+// -----------------------------------------------------------------------------
+// CFSMailPlugin::DeleteMessagesByUidL
+// -----------------------------------------------------------------------------
+inline void CFSMailPlugin::DeleteMessagesByUidL( const TFSMailMsgId& /*aMailBoxId*/,
+                                   const TFSMailMsgId& /*aFolderId*/,
+                                   const RArray<TFSMailMsgId>& /*aMessages*/,
+                                   MFSMailRequestObserver& /*aOperationObserver*/,
+                                   const TInt /*aRequestId*/ )
+    {
+    User::Leave( KErrFSMailPluginNotSupported );
+    }
 // </qmail>
--- a/emailservices/emailframework/src/CFSFWImplementation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailframework/src/CFSFWImplementation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 //<qmail>
 #include <nmcommonheaders.h>
 //</qmail>
 
-#include "emailtrace.h"
 #include "CFSFWImplementation.h"
 //<cmail>
 #include "CFSMailPlugin.h"
@@ -32,7 +33,8 @@
 // -----------------------------------------------------------------------------
 CFSFWImplementation::CFSFWImplementation()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iPluginManager = NULL;
 }
 
@@ -41,7 +43,8 @@
 // -----------------------------------------------------------------------------
 CFSFWImplementation::~CFSFWImplementation()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	delete iPluginManager;
 }
 // -----------------------------------------------------------------------------
@@ -49,11 +52,12 @@
 // -----------------------------------------------------------------------------
 CFSFWImplementation* CFSFWImplementation::NewLC(TInt aConfiguration)
 {
-    FUNC_LOG;
-  CFSFWImplementation* impl = new (ELeave) CFSFWImplementation();
-  CleanupStack:: PushL(impl);
-  impl->ConstructL(aConfiguration);
-  return impl;
+    NM_FUNCTION;
+    
+    CFSFWImplementation* impl = new (ELeave) CFSFWImplementation();
+    CleanupStack:: PushL(impl);
+    impl->ConstructL(aConfiguration);
+    return impl;
 } 
 
 // -----------------------------------------------------------------------------
@@ -61,10 +65,11 @@
 // -----------------------------------------------------------------------------
 CFSFWImplementation* CFSFWImplementation::NewL(TInt aConfiguration)
 {
-    FUNC_LOG;
-  CFSFWImplementation* impl =  CFSFWImplementation::NewLC(aConfiguration);
-  CleanupStack:: Pop(impl);
-  return impl;
+    NM_FUNCTION;
+    
+    CFSFWImplementation* impl =  CFSFWImplementation::NewLC(aConfiguration);
+    CleanupStack:: Pop(impl);
+    return impl;
 }
 
 // -----------------------------------------------------------------------------
@@ -72,7 +77,8 @@
 // -----------------------------------------------------------------------------
 void CFSFWImplementation::ConstructL(TInt aConfiguration)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	// create plugin manager
 	iPluginManager = CFSMailPluginManager::NewL(aConfiguration);
 }
@@ -82,7 +88,8 @@
 // -----------------------------------------------------------------------------
 CFSMailPluginManager& CFSFWImplementation::GetPluginManager( )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return *iPluginManager;
 }
 
--- a/emailservices/emailframework/src/CFSMailBrand.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailframework/src/CFSMailBrand.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 //<qmail>
 #include <nmcommonheaders.h>
 //</qmail>
 
-#include "emailtrace.h"
 #include <barsread.h>
 //<qmail> Commented out in Qmail
 //#include <AknIconUtils.h>
@@ -45,7 +46,8 @@
 // -----------------------------------------------------------------------------
 CFSMailBrand* CFSMailBrand::NewL( TResourceReader& aReader, TBool aIsWhiteLabel )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailBrand* brManager =  CFSMailBrand::NewLC(aReader, aIsWhiteLabel);
   	CleanupStack:: Pop(brManager);
   	return brManager;
@@ -56,7 +58,8 @@
 // -----------------------------------------------------------------------------
 CFSMailBrand* CFSMailBrand::NewLC( TResourceReader& aReader, TBool aIsWhiteLabel )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailBrand* self = new ( ELeave ) CFSMailBrand();
     CleanupStack::PushL( self );
     if ( aIsWhiteLabel )
@@ -76,7 +79,7 @@
 // -----------------------------------------------------------------------------
 void CFSMailBrand::ConstructFromCenrepL( )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
 	/*
     TBuf<KMaxStringLenFromCenrep> tBuf; // Temporary buffer
@@ -144,7 +147,7 @@
 // -----------------------------------------------------------------------------
 void CFSMailBrand::ConstructFromResourceL( TResourceReader& aReader )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     // read icon filepath
     iIconFilePath = aReader.ReadHBufCL();
@@ -206,7 +209,8 @@
 // -----------------------------------------------------------------------------
 CFSMailBrand::~CFSMailBrand()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iBrandMatchStrings.ResetAndDestroy();
 	delete iIconFilePath;
 	delete iGraphicElements;
@@ -221,7 +225,8 @@
 // -----------------------------------------------------------------------------
 CFSMailBrand::CFSMailBrand()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 		// prepare null empty descriptor
 	iEmpty = HBufC::New(1);
 	iEmpty->Des().Copy(KNullDesC());
@@ -233,7 +238,7 @@
 // -----------------------------------------------------------------------------
 TBool CFSMailBrand::IsMatching( const TDesC& aBrandId )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     TInt count = iBrandMatchStrings.Count();
     for(TInt i=0;i<count;i++)
@@ -251,7 +256,8 @@
 // -----------------------------------------------------------------------------
 TDesC& CFSMailBrand::GetText( TFSBrandElement aElementId )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TInt textCount( iTextElements->Count() );
 
     for ( TInt i( 0 ); i < textCount; i++ )
@@ -270,7 +276,8 @@
 // -----------------------------------------------------------------------------
 TInt CFSMailBrand::GetColor( TFSBrandElement aElementId, TRgb& aColor )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TInt colorCount( iColorElements->Count() );
 
     for ( TInt i( 0 ); i < colorCount; i++ )
@@ -290,7 +297,8 @@
 // -----------------------------------------------------------------------------
 CGulIcon* CFSMailBrand::GetGraphicL( TFSBrandElement aElementId )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     TInt graphicsCount( iGraphicElements->Count() );
 
     for ( TInt i( 0 ); i < graphicsCount; i++ )
@@ -340,7 +348,7 @@
 TInt CFSMailBrand::GetGraphicIdsL( TFSBrandElement aElementId,
                                    TDes& aIconIds)
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
     aIconIds.Zero();
     TInt graphicsCount( iGraphicElements->Count() );
--- a/emailservices/emailframework/src/CFSMailBrandManagerImpl.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailframework/src/CFSMailBrandManagerImpl.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 //<qmail>
 #include <nmcommonheaders.h>
 //</qmail>
 
-#include "emailtrace.h"
 #include <FSMAILBRANDMANAGER.rsg>
 #include <barsread.h>
 #include <bautils.h>
@@ -61,6 +62,8 @@
 #ifdef __WINS__
 LOCAL_C void RetrieveNextToken( TDes8& aContent, TDes& aToken )	
 	{
+    NM_FUNCTION;
+    
 	_LIT8( KComma, "," );
 	TInt pos = aContent.Find( KComma );
 	if ( pos != KErrNotFound ) 
@@ -80,8 +83,7 @@
     CFSMailClient& aMailClient ) :
     iMailClient( aMailClient )
 	{
-    FUNC_LOG;
-
+    NM_FUNCTION;
 	}
 
 // -----------------------------------------------------------------------------
@@ -89,7 +91,7 @@
 // -----------------------------------------------------------------------------
 void CFSMailBrandManagerImpl::ConstructL()
     {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     // Read resource file, get the drive letter according to the DLL drive
     TFileName dllFileName;
@@ -126,7 +128,7 @@
 // -----------------------------------------------------------------------------
 CFSMailBrandManagerImpl::~CFSMailBrandManagerImpl()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 	
 	iResourceFile.Close();
     iFsSession.Close();
@@ -144,7 +146,8 @@
 CFSMailBrandManagerImpl* CFSMailBrandManagerImpl::NewL(
     CFSMailClient& aMailClient )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailBrandManagerImpl* self =
         CFSMailBrandManagerImpl::NewLC( aMailClient );
     CleanupStack::Pop( self );
@@ -157,7 +160,8 @@
 CFSMailBrandManagerImpl* CFSMailBrandManagerImpl::NewLC(
     CFSMailClient& aMailClient )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailBrandManagerImpl* self =
         new( ELeave ) CFSMailBrandManagerImpl( aMailClient );
     CleanupStack::PushL( self );
@@ -170,7 +174,7 @@
 // -----------------------------------------------------------------------------
 void CFSMailBrandManagerImpl::UpdateMailboxNamesL( const TFSMailMsgId aMailBoxId )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
     
     // list all mailboxes
     RPointerArray<CFSMailBox> mailBoxes;
@@ -220,7 +224,8 @@
     TFSBrandElement aElement, 
 	const TFSMailMsgId& aMailboxId )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailBox* mailBox( NULL );
 	TRAPD( mailboxError,
 	       mailBox = iMailClient.GetMailBoxByUidL( aMailboxId ) );
@@ -250,7 +255,8 @@
     TFSBrandElement aElement, 
     const TDesC& aBrandId )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     CFSMailBrand* brand = FindMatchingBrandL( aBrandId );
     if ( brand == NULL )
         {
@@ -267,7 +273,8 @@
 	const TFSMailMsgId& aMailboxId,
     TDes& aIconIds  )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailBox* mailBox( NULL );
 	TRAPD( mailboxError,
 	       mailBox = iMailClient.GetMailBoxByUidL( aMailboxId ) );
@@ -298,7 +305,7 @@
     const TDesC& aBrandId,
     TDes& aIconIds  )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
 
     CFSMailBrand* brand = FindMatchingBrandL( aBrandId );
     if ( brand == NULL )
@@ -315,7 +322,8 @@
     TFSBrandElement aElement,
     const TFSMailMsgId& aMailboxId )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailBox* mailBox( NULL );
 	TRAPD( mailboxError,
 	       mailBox = iMailClient.GetMailBoxByUidL( aMailboxId ) );
@@ -345,7 +353,7 @@
 	TFSBrandElement aElement,
 	const TDesC& aBrandId )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	CFSMailBrand* brand = FindMatchingBrandL( aBrandId );
 	if ( brand == NULL )
@@ -364,7 +372,8 @@
     const TFSMailMsgId& aMailboxId,
     TRgb& aColor )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailBox* mailBox = iMailClient.GetMailBoxByUidL( aMailboxId );
 	User::LeaveIfNull( mailBox );
     CleanupStack::PushL( mailBox );    
@@ -385,7 +394,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailBrandManagerImpl::ConstructFromResourceL( TResourceReader& aReader )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iBrands = new ( ELeave )
 				CArrayPtrSeg< CFSMailBrand >( KBrandArrayGranularity );
 						
@@ -411,7 +421,8 @@
 // -----------------------------------------------------------------------------
 CFSMailBrand* CFSMailBrandManagerImpl::FindMatchingBrandL( const TDesC& aBrandId )
     {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     if( aBrandId.Length() )
         {
         TInt brandCount( iBrands->Count() );
@@ -430,6 +441,8 @@
 CFSMailBox* CFSMailBrandManagerImpl::MailboxMatchingBrandIdL(
     const TDesC& aBrandId ) const
     {    
+    NM_FUNCTION;
+    
     RPointerArray<CFSMailBox> mailboxes;
 
     CleanupResetAndDestroyPushL( mailboxes );
@@ -471,6 +484,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailBrandManagerImpl::GetMCCValueL( TDes& aMcc ) const
     {
+    NM_FUNCTION;
+    
     aMcc.Zero();
     
     TInt err = KErrNone;
@@ -561,6 +576,8 @@
 // 
 void CFSMailBrandManagerImpl::GetMCCValueFromSIML( TDes& aMcc ) const
     {
+    NM_FUNCTION;
+    
     RTelServer telServer;
 
     CleanupClosePushL( telServer );
@@ -601,6 +618,8 @@
 // 
 TUint8 CFSMailBrandManagerImpl::GetCurrentCountryL() const
     {
+    NM_FUNCTION;
+    
     CTzLocalizer* localizer = CTzLocalizer::NewLC();
 
     CTzLocalizedCity* city = localizer->GetFrequentlyUsedZoneCityL(
@@ -627,6 +646,8 @@
 void CFSMailBrandManagerImpl::VerifyMailAccountName(
         TPtrC& aBrandedName ) const
     {
+    NM_FUNCTION;
+    
     // Due to legal reasons we don't show brand name "Gmail" in Germany and UK
     if ( !aBrandedName.CompareF( KBrandNameGmail ) )
         {
--- a/emailservices/emailframework/src/CFSMailClient.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailframework/src/CFSMailClient.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 //<qmail>
 #include <nmcommonheaders.h>
 //</qmail>
 
-#include "emailtrace.h"
 #include "CFSMailClient.h"
 #include "CFSFWImplementation.h"
 #include "CFSMailPluginManager.h"
@@ -34,7 +35,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailClient* CFSMailClient::NewLC(TInt aConfiguration)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	CFSMailClient* client = Instance();
 	if(!client)
@@ -61,10 +62,11 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailClient* CFSMailClient::NewL()
 {
-    FUNC_LOG;
-  CFSMailClient* client =  CFSMailClient::NewLC(EFSLoadPlugins);
-  CleanupStack:: Pop(client);
-  return client;
+    NM_FUNCTION;
+    
+    CFSMailClient* client =  CFSMailClient::NewLC(EFSLoadPlugins);
+    CleanupStack:: Pop(client);
+    return client;
 }
 
 // -----------------------------------------------------------------------------
@@ -72,11 +74,11 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailClient* CFSMailClient::NewL(TInt aConfiguration)
 {
-    FUNC_LOG;
-
-  CFSMailClient* client =  CFSMailClient::NewLC(aConfiguration);
-  CleanupStack:: Pop(client);
-  return client;
+    NM_FUNCTION;
+    
+    CFSMailClient* client =  CFSMailClient::NewLC(aConfiguration);
+    CleanupStack:: Pop(client);
+    return client;
 }
 
 // -----------------------------------------------------------------------------
@@ -84,7 +86,8 @@
 // -----------------------------------------------------------------------------
 void CFSMailClient::ConstructL(TInt aConfiguration)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iFWImplementation = CFSFWImplementation::NewL(aConfiguration);
 }
 
@@ -93,7 +96,8 @@
 // -----------------------------------------------------------------------------
 CFSMailClient::CFSMailClient()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	// clear pointers
 	iFWImplementation = NULL;
 	iBrandManager = NULL;
@@ -105,7 +109,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailClient::~CFSMailClient()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	if(iBrandManager)
 		{
 		delete iBrandManager;
@@ -118,7 +123,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailBox* CFSMailClient::GetMailBoxByUidL(const TFSMailMsgId aMailBoxId)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	// select plugin
 	CFSMailBox* mailBox = NULL;
 	CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid(aMailBoxId);
@@ -137,7 +143,8 @@
 EXPORT_C CFSMailFolder* CFSMailClient::GetFolderByUidL( const TFSMailMsgId aMailBoxId,
 													   const TFSMailMsgId aFolderId )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailFolder* folder = NULL;
 	
 	// select plugin
@@ -158,7 +165,8 @@
 														 const TFSMailMsgId aMessageId,
 														 const TFSMailDetails aDetails)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailMessage* message = NULL;
     // select plugin
     CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid(aMessageId);
@@ -178,8 +186,9 @@
 												   const TFSMailMsgId aFolderId,
 											 	   const RArray<TFSMailMsgId>& aMessages )
 {
-    FUNC_LOG;
-	CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid(aFolderId);
+    NM_FUNCTION;
+    
+	CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid(aMailBoxId);
 	if(plugin)
 	{
 		plugin->DeleteMessagesByUidL(aMailBoxId,aFolderId,aMessages);
@@ -192,7 +201,8 @@
 EXPORT_C TInt CFSMailClient::DeleteMailBoxByUidL( const TFSMailMsgId aMailBoxId,
  								  MFSMailRequestObserver& aOperationObserver )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	// select plugin
 	CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid(aMailBoxId);
 	if(plugin)
@@ -218,7 +228,7 @@
 EXPORT_C TInt CFSMailClient::ListMailBoxes(const TFSMailMsgId aPlugin,
 											 RPointerArray<CFSMailBox>& aMailBoxes)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	RArray<TFSMailMsgId> mailBoxList;
 	mailBoxList.Reset();
@@ -311,7 +321,7 @@
         						const TFSMailMsgId aFolderId, const TFSMailDetails aDetails,
         						const RArray<TFSMailSortCriteria>& aSorting)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	MFSMailIterator* iterator = NULL;
 	MFSMailIterator* pluginIterator = NULL;
@@ -339,7 +349,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C MFSMailBrandManager& CFSMailClient::GetBrandManagerL( void )
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	if(iBrandManager == NULL)
 		{
@@ -360,7 +370,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailClient::AddObserverL(MFSMailEventObserver& aObserver)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	for(TInt i=0;i<iFWImplementation->GetPluginManager().GetPluginCount();i++)
 		{
 		CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByIndex(i);
@@ -376,7 +387,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailClient::RemoveObserver(MFSMailEventObserver& aObserver)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	for(TInt i=0;i<iFWImplementation->GetPluginManager().GetPluginCount();i++)
 	{
 		CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByIndex(i);
@@ -392,7 +404,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailClient::UnregisterRequestObserver(TInt aRequestId)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	for(TInt i=0;i<iFWImplementation->GetPluginManager().GetPluginCount();i++)
 	{
 		if(CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByIndex(i))
@@ -409,7 +422,8 @@
 EXPORT_C void CFSMailClient::SubscribeMailboxEventsL(TFSMailMsgId aMailBoxId,
 													 	MFSMailEventObserver& aObserver)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	// select plugin
 	if(CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid(aMailBoxId))
 		{
@@ -424,7 +438,8 @@
 EXPORT_C void CFSMailClient::UnsubscribeMailboxEvents(TFSMailMsgId aMailBoxId,
 														MFSMailEventObserver& aObserver)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	// select plugin
 	if(CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid(aMailBoxId))
 		{
@@ -438,7 +453,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TInt CFSMailClient::WizardDataAvailableL()
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 	
 	TInt ret = KErrNone;
 	for(TInt i=0;i<iFWImplementation->GetPluginManager().GetPluginCount();i++)
@@ -465,7 +480,7 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TInt CFSMailClient::AuthenticateL(MFSMailRequestObserver& aOperationObserver)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	TInt requestId(0);
 	
@@ -496,7 +511,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailClient::CleanTempDirL( )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
     iFWImplementation->GetPluginManager().CleanTempDirL();	
 	}
 
@@ -505,7 +521,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TDesC& CFSMailClient::GetTempDirL( )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return iFWImplementation->GetPluginManager().GetTempDirL();
 	}
 
@@ -514,7 +531,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailClient::CancelL( const TInt aRequestId )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iFWImplementation->GetPluginManager().CancelRequestL(aRequestId);
 	}
 
@@ -523,7 +541,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailClient::CancelAllL( )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 		iFWImplementation->GetPluginManager().CancelAllRequestsL();
 	}
 
@@ -532,7 +551,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailClient::SetMailboxName( const TFSMailMsgId aMailboxId, const TDesC& aMailboxName )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid( aMailboxId );
 	if ( plugin )
 		{
@@ -545,7 +565,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailClient::Close()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	CFSMailClient* instance = Instance();
 	if(!instance)
 	{
@@ -569,7 +590,8 @@
 // -----------------------------------------------------------------------------
 CFSMailClient* CFSMailClient::Instance()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return static_cast<CFSMailClient*>(Dll::Tls());
 }
 
@@ -578,7 +600,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C TInt CFSMailClient::IncReferenceCount()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return ++iReferenceCount;
 }
 
@@ -587,7 +610,8 @@
 // -----------------------------------------------------------------------------
 TInt CFSMailClient::DecReferenceCount()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return --iReferenceCount;
 }
 
@@ -596,6 +620,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C void CFSMailClient::ReleaseExtension( CEmailExtension* aExtension )
     {
+    NM_FUNCTION;
+    
     CExtendableEmail::ReleaseExtension( aExtension );
     }
 
@@ -604,6 +630,8 @@
 // -----------------------------------------------------------------------------
 EXPORT_C CEmailExtension* CFSMailClient::ExtensionL( const TUid& aInterfaceUid )
     {
+    NM_FUNCTION;
+    
     return CExtendableEmail::ExtensionL( aInterfaceUid );
     }
     
--- a/emailservices/emailframework/src/CFSMailEventObserver.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailframework/src/CFSMailEventObserver.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,12 @@
 *
 */
 
+#include "emailtrace.h"
+
 //<qmail>
 #include <nmcommonheaders.h>
 //</qmail>
 
-#include "emailtrace.h"
 #include "CFSClientRequestObserver.h"
 
 // ================= MEMBER FUNCTIONS ==========================================
@@ -28,8 +29,7 @@
 // -----------------------------------------------------------------------------
 CFSClientRequestObserver::CFSClientRequestObserver()
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -37,19 +37,19 @@
 // -----------------------------------------------------------------------------
 CFSClientRequestObserver::~CFSClientRequestObserver()
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
 }
 // -----------------------------------------------------------------------------
 // CFSClientRequestObserver::NewLC
 // -----------------------------------------------------------------------------
 CFSClientRequestObserver* CFSClientRequestObserver::NewLC()
 {
-    FUNC_LOG;
-  CFSClientRequestObserver* obs = new (ELeave) CFSClientRequestObserver();
-  CleanupStack:: PushL(obs);
-  obs->ConstructL();
-  return obs;
+    NM_FUNCTION;
+    
+    CFSClientRequestObserver* obs = new (ELeave) CFSClientRequestObserver();
+    CleanupStack:: PushL(obs);
+    obs->ConstructL();
+    return obs;
 } 
 
 // -----------------------------------------------------------------------------
@@ -57,10 +57,11 @@
 // -----------------------------------------------------------------------------
 CFSClientRequestObserver* CFSClientRequestObserver::NewL()
 {
-    FUNC_LOG;
-  CFSClientRequestObserver* obs =  CFSClientRequestObserver::NewLC();
-  CleanupStack:: Pop(obs);
-  return obs;
+    NM_FUNCTION;
+    
+    CFSClientRequestObserver* obs =  CFSClientRequestObserver::NewLC();
+    CleanupStack:: Pop(obs);
+    return obs;
 }
 
 // -----------------------------------------------------------------------------
@@ -68,8 +69,7 @@
 // -----------------------------------------------------------------------------
 void CFSClientRequestObserver::ConstructL()
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -77,8 +77,7 @@
 // -----------------------------------------------------------------------------
 void CFSClientRequestObserver::ListMessagesResponse( RPointerArray<CFSMailMessage>& aMessages )
 {
-    FUNC_LOG;
-	
+    NM_FUNCTION;
 }
 
 
--- a/emailservices/emailframework/src/CFSMailPluginManager.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailframework/src/CFSMailPluginManager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,10 +15,11 @@
 *
 */
 
+#include "emailtrace.h"
+
 //<qmail>
 #include <nmcommonheaders.h>
 //</qmail>
-#include "emailtrace.h"
 #include "CFSMailPluginManager.h"
 #include "CFSMailRequestObserver.h"
 #include "CFSMailRequestHandler.h"
@@ -29,8 +30,7 @@
 // -----------------------------------------------------------------------------
 CFSMailPluginManager::CFSMailPluginManager()
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
 }
 
 // -----------------------------------------------------------------------------
@@ -38,7 +38,8 @@
 // -----------------------------------------------------------------------------
 CFSMailPluginManager::~CFSMailPluginManager()
 {
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	iPluginInfo.ResetAndDestroy();
 }
 
@@ -48,11 +49,12 @@
 // -----------------------------------------------------------------------------
 CFSMailPluginManager* CFSMailPluginManager::NewLC(TInt aConfiguration)
 {
-    FUNC_LOG;
-  CFSMailPluginManager* pluginManager = new (ELeave) CFSMailPluginManager();
-  CleanupStack:: PushL(pluginManager);
-  pluginManager->ConstructL(aConfiguration);
-  return pluginManager;
+    NM_FUNCTION;
+    
+    CFSMailPluginManager* pluginManager = new (ELeave) CFSMailPluginManager();
+    CleanupStack:: PushL(pluginManager);
+    pluginManager->ConstructL(aConfiguration);
+    return pluginManager;
 } 
 
 // -----------------------------------------------------------------------------
@@ -60,10 +62,11 @@
 // -----------------------------------------------------------------------------
 CFSMailPluginManager* CFSMailPluginManager::NewL(TInt aConfiguration)
 {
-    FUNC_LOG;
-  CFSMailPluginManager* pluginManager =  CFSMailPluginManager::NewLC(aConfiguration);
-  CleanupStack:: Pop(pluginManager);
-  return pluginManager;
+    NM_FUNCTION;
+    
+    CFSMailPluginManager* pluginManager =  CFSMailPluginManager::NewLC(aConfiguration);
+    CleanupStack:: Pop(pluginManager);
+    return pluginManager;
 }
 
 // -----------------------------------------------------------------------------
@@ -71,7 +74,7 @@
 // -----------------------------------------------------------------------------
 void CFSMailPluginManager::ConstructL(TInt aConfiguration)
 {
-    FUNC_LOG;
+    NM_FUNCTION;
 
 	// list plugin implementations
 
@@ -110,8 +113,7 @@
 // -----------------------------------------------------------------------------
 void CFSMailPluginManager::LoadPluginL( TUid /*aPlugin*/ )
 {
-    FUNC_LOG;
-
+    NM_FUNCTION;
 }
 	
 // -----------------------------------------------------------------------------
@@ -119,7 +121,8 @@
 // -----------------------------------------------------------------------------
 CFSMailPlugin* CFSMailPluginManager::GetPluginByIndex(TUint aIndex)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return iPluginList[aIndex]->iPlugin;
 	}
 
@@ -128,7 +131,8 @@
 // -----------------------------------------------------------------------------
 TUid CFSMailPluginManager::GetPluginIdByIndex(TUint aIndex)
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return iPluginList[aIndex]->iPluginId;
 	}
 
@@ -137,7 +141,8 @@
 // -----------------------------------------------------------------------------
 TUint CFSMailPluginManager::GetPluginCount( )
 	{
-    FUNC_LOG;
+    NM_FUNCTION;
+    
 	return iPluginList.Count();
 	}
 	
--- a/emailservices/emailserver/inc/fsmailserverconst.h	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* 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:  Constant definitions for FSMailServer
-*
-*/
-
-
-#ifndef FSMAILSERVERCONST_H_
-#define FSMAILSERVERCONST_H_
-
-//<cmail>
-#include "fsmailserverconst.hrh"
-//</cmail>
-
-///////////////////////////////////////////////////////////////////////////
-// Different error notes that can be shown via this notifier
-enum TFsEmailNotifierSystemMessageType
-    {
-    // Used to indicate that system message type is not set
-    // -> meant only for internal use
-    EFsEmailNotifErrUndefined = -1,
-
-    EFsEmailNotifErrCustom = 0,
-
-    // Error messages that doesn't require response
-    EFsEmailNotifErrAccountDisabled,
-    EFsEmailNotifErrPasswordExpired,
-    EFsEmailNotifErrDataDeleted,
-    EFsEmailNotifErrLoginUnsuccesfull,
-    EFsEmailNotifErrPasswordChanged,
-    EFsEmailNotifErrLoginCanceled,
-    EFsEmailNotifErrServerNotAvailable,
-    EFsEmailNotifErrNetworkNotAvailable,
-    EFsEmailNotifErrServerBusy,
-    EFsEmailNotifErrUnableToConnectToServerTryAgain,
-    EFsEmailNotifErrEmailAddrAndPwdDontMatch,
-    EFsEmailNotifErrInvalidEmailAddress,
-    EFsEmailNotifErrServerOffline,
-    EFsEmailNotifErrRoamingTurnedOn,
-    EFsEmailNotifErrRoamingCosts,
-    EFsEmailNotifErrUnableToComplete,
-    EFsEmailNotifErrConnectionError,
-    EFsEmailNotifErrUnableToConnect,
-    EFsEmailNotifErrMultipleSyncErrors,
-    EFsEmailNotifErrOutOfMemory,
-    EFsEmailNotifErrLoginFailed,
-    EFsEmailNotifErrServerNotFoundCheckSettings,
-    EFsEmailNotifErrUnableToConnectToServer,
-    EFsEmailNotifErrDisconnected,
-    EFsEmailNotifErrServerErroTryAgain,
-    
-    EFsEmailNotifErrLastNoResponse = 1000,
-
-    // Error messages that do require response (which soft key pressed)
-    EFsEmailNotifErrCustomResponse,
-    EFsEmailNotifErrSynchronizationFailed,
-
-    // Note! Not yet implemented as not currently needed.
-    // Value kept here as a placeholder for future needs.
-    EFsEmailNotifErrAuthenticatingWaitNote = 2000
-    };
-
-#endif /*FSMAILSERVERCONST_H_*/
--- a/emailservices/emailserver/inc/fsmailserverconst.hrh	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* 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:  Resource headers for project FSMailServer
-*
-*/
-
-
-#ifndef FSMAILSERVERCONST_HRH_
-#define FSMAILSERVERCONST_HRH_
-
-#define KFsEmailNotifierMailboxNameMaxLength 50
-#define KFsEmailNotifierPasswordMaxLength 50
-#define KFsEmailNotifierCustomMessageMaxLength 200
-
-#endif /*FSMAILSERVERCONST_HRH_*/
--- a/emailservices/emailservermonitor/inc/emailshutdownconst.h	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
-* 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:
-* Constant definitions for Email shutdown
-*
-*/
-
-#ifndef EMAILSHUTDOWNCONST_H
-#define EMAILSHUTDOWNCONST_H
-
-#include <e32cmn.h>                 // TUid
-#include "emailshutdownconst.hrh"   // KEmailShutdownUidAsTInt
-
-
-// Publish & Subscribe category for Email shutdown events
-const TUid KEmailShutdownPsCategory = { KEmailShutdownUidAsTInt };
-
-// Size of one item in platform API UID list (in Publish & Subscribe
-// key EEmailPsKeyPlatformApiAppsToClose)
-const TInt KEmailPlatformApiUidItemSize = sizeof( TInt32 );
-
-// Publish & Subscribe keys used in shutdown process
-enum TEmailShutdownPsKeys
-    {
-    // Publish & Subscribe key used in communication between Shutter
-    // application and installation initiators
-    EEmailPsKeyInstallationStatus = 1,
-    
-    // Publish & Subscribe keys for Email shutdown events
-    EEmailPsKeyShutdownClients,
-    EEmailPsKeyShutdownPlugins,
-    EEmailPsKeyShutdownMsgStore,
-    
-    // Publish & Subscribe keys to register 3rd party applications to be closed
-    EEmailPsKeyPlatformApiAppsToCloseLength,
-    EEmailPsKeyPlatformApiAppsToClose
-    };
-
-// Publish & Subscribe values to be used with key EEmailPsKeyInstallationStatus
-enum TEmailShutdownPsInstallationValues
-    {
-    // Value to be set by installation initiators when installation is starting
-    EEmailPsValueInstallationStarting = 1,
-    // Value to be set by Shutter when all services are shutdown
-    EEmailPsValueInstallationOkToStart,
-    // Value to be set by installation initiators when installation is started
-    // after EEmailPsValueInstallationOkToStart event received
-    EEmailPsValueInstallationStarted,
-    // Value to be set by Starter when installation has finished
-    EEmailPsValueInstallationFinished
-    };
-
-// Executable name of the process that implements the shutdown functionality
-_LIT( KEmailShutdownHandlerExe, "emailservermonitor.exe" );
-
-// Command line arguments that can be given to shutdown handler process when
-// starting it
-
-// KEmailShutdownHandlerArgOnlyShutter should be used when starting the process
-// just before starting installation (if it wasn't already running)
-_LIT( KEmailShutdownHandlerArgOnlyShutter, "OnlyShutter" );
-
-// KEmailShutdownHandlerArgRestart should be given when restarting
-// the process after installation
-_LIT( KEmailShutdownHandlerArgRestart, "RestartAfterInstallation" );
-
-
-#endif // EMAILSHUTDOWNCONST_H
--- a/emailservices/emailservermonitor/inc/emailshutdownconst.hrh	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
-* 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:
-* Constant definitions for Cmail shutdown
-*
-*/
-
-#ifndef EMAILSHUTDOWNCONST_HRH
-#define EMAILSHUTDOWNCONST_HRH
-
-
-// Publish & Subscribe category for Cmail shutdown events, needs to be the
-// same as UID of the process that implements the shutdown functionality
-#define KEmailShutdownUidAsTInt 0x20025FAD
-
-// Executable name of the process that implements the shutdown functionality
-#define KEmailShutdownProcessExeName emailservermonitor.exe
-
-
-#endif // EMAILSHUTDOWNCONST_HRH
--- a/emailservices/emailstore/base_plugin/BWINS/basepluginU.DEF	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/base_plugin/BWINS/basepluginU.DEF	Thu Jul 22 16:30:28 2010 +0100
@@ -192,8 +192,8 @@
 	?AttachmentsL@CBaseMrInfoObject@@UBEABV?$RPointerArray@VMMRAttachment@@@@XZ @ 191 NONAME ; class RPointerArray<class MMRAttachment> const & CBaseMrInfoObject::AttachmentsL(void) const
 	?RecurrenceStartTime@CBaseMrRecurrenceRule@@UBE?AVTTime@@XZ @ 192 NONAME ; class TTime CBaseMrRecurrenceRule::RecurrenceStartTime(void) const
 	?CreationTimeInUtcL@CBaseMrInfoObject@@UBE?AVTTime@@XZ @ 193 NONAME ; class TTime CBaseMrInfoObject::CreationTimeInUtcL(void) const
-	?SetReplyOrForwardToFieldL@CBasePlugin@@IAEXAAVCMsgStoreMessage@@@Z @ 194 NONAME ; void CBasePlugin::SetReplyOrForwardToFieldL(class CMsgStoreMessage &)
-	?RefreshNowL@CBasePlugin@@UAEXABVTFSMailMsgId@@AAVMFSMailRequestObserver@@H@Z @ 195 NONAME ; void CBasePlugin::RefreshNowL(class TFSMailMsgId const &, class MFSMailRequestObserver &, int)
+	?SetReplyOrForwardToFieldL@CBasePlugin@@IAEXAAVCMsgStoreMessage@@@Z @ 194 NONAME ; void CBasePlugin::SetReplyOrForwardToFieldL(class CMsgStoreMessage &)	
+	?RefreshNowL@CBasePlugin@@UAEXABVTFSMailMsgId@@AAVMFSMailRequestObserver@@HH@Z @ 195 NONAME ; void CBasePlugin::RefreshNowL(class TFSMailMsgId const &, class MFSMailRequestObserver &, int, int)
 	?CreateResourceReaderLC@CResourceLoader@@QBEPAVHBufC8@@AAVTResourceReader@@H@Z @ 196 NONAME ; class HBufC8 * CResourceLoader::CreateResourceReaderLC(class TResourceReader &, int) const
 	?ModificationNotify@CBasePlugin@@UAEXIW4TMsgStoreOperation@@W4TMsgStoreContainerType@@KIII@Z @ 197 NONAME ; void CBasePlugin::ModificationNotify(unsigned int, enum TMsgStoreOperation, enum TMsgStoreContainerType, unsigned long, unsigned int, unsigned int, unsigned int)
 	?SystemEventNotify@CBasePlugin@@UAEXW4TMsgStoreSystemEvent@@@Z @ 198 NONAME ; void CBasePlugin::SystemEventNotify(enum TMsgStoreSystemEvent)
--- a/emailservices/emailstore/base_plugin/EABI/basepluginU.DEF	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/base_plugin/EABI/basepluginU.DEF	Thu Jul 22 16:30:28 2010 +0100
@@ -13,7 +13,7 @@
 	_ZN11CBasePlugin11CancelSyncLERK12TFSMailMsgId @ 12 NONAME
 	_ZN11CBasePlugin11ChildPartsLERK12TFSMailMsgIdS2_S2_S2_R13RPointerArrayI18CFSMailMessagePartE @ 13 NONAME
 	_ZN11CBasePlugin11GetPluginIdEv @ 14 NONAME
-	_ZN11CBasePlugin11RefreshNowLERK12TFSMailMsgIdR22MFSMailRequestObserveri @ 15 NONAME
+	_ZN11CBasePlugin11RefreshNowLERK12TFSMailMsgIdR22MFSMailRequestObserverii @ 15 NONAME
 	_ZN11CBasePlugin11SetContentLERK7TDesC16RK12TFSMailMsgIdS5_S5_S5_ @ 16 NONAME
 	_ZN11CBasePlugin12AddObserverLER20MFSMailEventObserver @ 17 NONAME
 	_ZN11CBasePlugin12CancelSearchERK12TFSMailMsgId @ 18 NONAME
--- a/emailservices/emailstore/base_plugin/base_plugin.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/base_plugin/base_plugin.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -21,7 +21,8 @@
 DEPENDPATH += . inc src
 DEFINES += BUILD_BASEPLUGIN_DLL
 INCLUDEPATH += . \
-			../../../inc
+               ../../../inc \
+               $$APP_LAYER_SYSTEMINCLUDE
 			
 
 HEADERS += inc/BaseMrInfoObject.h \
@@ -57,7 +58,9 @@
 		-lmessagestoreclient \
 		-lfsfwcommonlib \
 		-ldebuglog \
-		-lcalinterimapi
+		-lcalinterimapi \
+        -lefsrv \
+        -lgdi
 		
 symbian*: { 
     
--- a/emailservices/emailstore/base_plugin/inc/BasePlugin.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/base_plugin/inc/BasePlugin.h	Thu Jul 22 16:30:28 2010 +0100
@@ -50,6 +50,7 @@
 class CMailboxInfo;
 class CSearchHandler;
 class HMailIterator;
+class CDelayedOp;
 class CDelayedOpsManager;
 class MDelayedOpsManager;
 
@@ -85,6 +86,7 @@
     friend class CDelayedMessageStorerOp;
 	// <qmail>
     friend class CDelayedAddNewOrRemoveChildPartOp;
+    friend class CDelayedOp;
 	// </qmail>
 	protected:
     struct TOngoingFetchInfo;
@@ -153,7 +155,8 @@
          void RefreshNowL(
             const TFSMailMsgId& aMailBoxId,
          	MFSMailRequestObserver& aOperationObserver,
-         	TInt aRequestId );
+         	TInt aRequestId,
+         	const TBool aSilentConnection=EFalse );
 
          virtual CFSMailFolder* GetFolderByUidL(
             const TFSMailMsgId& aMailBoxId,
@@ -829,7 +832,8 @@
         //does not actually own the observers.
         RPointerArray<MFSMailEventObserver> iObservers;
         //async fetch reqs.
-        RPointerArray<CFetchRequester> iReqs;
+        RPointerArray<CFetchRequester> iReqs;       
+        RPointerArray<CDelayedOp> iDelayedOpReqs;
 
         TCacheLine iCacheLine;
 
--- a/emailservices/emailstore/base_plugin/inc/baseplugindelayedops.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/base_plugin/inc/baseplugindelayedops.h	Thu Jul 22 16:30:28 2010 +0100
@@ -108,6 +108,10 @@
     MDelayedOpsManager* iManager;   //not owned
     CBasePlugin* iPlugin;           //not owned
     
+public:
+    TInt iRequestId;
+    MFSMailRequestObserver* iOperationObserver;
+    
     __LOG_DECLARATION
     };
 
--- a/emailservices/emailstore/base_plugin/inc/baseplugindelayedopsprivate.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/base_plugin/inc/baseplugindelayedopsprivate.h	Thu Jul 22 16:30:28 2010 +0100
@@ -231,8 +231,6 @@
     TFSMailMsgId iMailBox;
     RPointerArray<CFSMailMessage> iMessages;
     RPointerArray<CFSMailMessagePart> iMessageParts;
-    MFSMailRequestObserver& iOperationObserver;
-    TInt iRequestId;
     TInt iType;
     // Data buffer for async operations
     HBufC8* iDataBuffer;
@@ -273,8 +271,6 @@
 private:
     CBasePlugin& iBasePlugin;
     TFSMailMsgId iMailBox;
-    MFSMailRequestObserver& iOperationObserver;
-    TInt iRequestId;
 
     __LOG_DECLARATION
     };
@@ -342,8 +338,6 @@
     TFSMailMsgId iPartId;
     HBufC* iContentType;
     HBufC* iFilePath;
-    MFSMailRequestObserver& iOperationObserver;
-    TInt iRequestId;
     TInt iActionType;
     __LOG_DECLARATION
     };
--- a/emailservices/emailstore/base_plugin/src/BasePlugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/base_plugin/src/BasePlugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -130,7 +130,12 @@
 
     iReqs.ResetAndDestroy();
     iReqs.Close();
-    
+
+    // Note that all the ops in iDelayedOpReqs array (if any) have already been
+    // deleted in the destructor of CDelayedOpsManager class.
+    iDelayedOpReqs.Reset();
+    iDelayedOpReqs.Close();
+
     ResetCache();
 
     __LOG_DESTRUCT
@@ -800,6 +805,7 @@
      CDelayedMessageToSendOp* delayedOp = CDelayedMessageToSendOp::NewLC(
     *this,aMailBoxId,aOperationObserver,aRequestId);
     iDelayedOpsManager->EnqueueOpL( delayedOp );
+    iDelayedOpReqs.AppendL(delayedOp);
     CleanupStack::Pop( delayedOp );      
     }
  // </qmail> 
--- a/emailservices/emailstore/base_plugin/src/baseplugindelayedops.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/base_plugin/src/baseplugindelayedops.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -72,6 +72,16 @@
     
     //self-destroy.
     iManager->DequeueOp( *this );
+    
+    //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;
+            }
+        }
     delete this;
     }
     
@@ -241,6 +251,8 @@
     __LOG_ENTER( "DeleteMessagesInChunksL" );
     TBool done=EFalse;
     TInt endIndex;
+//<qmail>
+    TInt result(KErrNone);
     if( aStartIndex + KSizeOfChunk < iMessages.Count() )
         {
             endIndex = aStartIndex + KSizeOfChunk;
@@ -260,18 +272,30 @@
         
         if ( EFalse == iImmediateDelete )
             {
-            //try to find the message in the deleted items folder.
+            //try to find the message
             CMsgStoreMessage* theMessage = NULL;
-            TRAP_IGNORE( theMessage = mailBox.FetchMessageL(
-              msgId, mailBoxInfo.iRootFolders.iFolders[EFSDeleted] ) );
-            
-            if ( NULL == theMessage )
+            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.
+            	//if not in deleted items then move it there.
                 __LOG_WRITE8_FORMAT1_INFO("Moving message 0x%X to the deleted items.", msgId );
-                mailBox.MoveMessageL(
+                TRAP(result,mailBox.MoveMessageL(
                    msgId, KMsgStoreInvalidId,
-                   mailBoxInfo.iRootFolders.iFolders[EFSDeleted] );
+                   mailBoxInfo.iRootFolders.iFolders[EFSDeleted] ));
+                if(result == KErrNone)
+                    {
+                    GetPlugin().NotifyEventL( iMailBoxId, msgId, KMsgStoreInvalidId , TFSEventMailMoved, msgParentId);
+                    }
+                else
+                    {
+                    User::Leave(result);
+                    }
+                
                 }
             else
                 {
@@ -279,13 +303,30 @@
                 __LOG_WRITE8_FORMAT1_INFO( "Deleting message 0x%X.", msgId );
 
                 delete theMessage;
-                mailBox.DeleteMessageL( msgId, iFolderId );
+                TRAP(result,mailBox.DeleteMessageL( msgId, iFolderId ));
+                if(result == KErrNone)
+                    {
+                    GetPlugin().NotifyEventL( iMailBoxId, msgId, KMsgStoreInvalidId, TFSEventMailDeleted, iFolderId );
+                    }
+                else
+                    {
+                    User::Leave(result);
+                    }
                 }
             }
         else
-            {
-            mailBox.DeleteMessageL( msgId, iFolderId );
+            {        
+            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;    
@@ -582,10 +623,12 @@
     MFSMailRequestObserver& aOperationObserver,
     const TInt aRequestId)
     : iMailBox( aMailBox ), 
-      iOperationObserver( aOperationObserver ),
-      iRequestId( aRequestId ),
       iType(EHeaders)
     {
+    
+    CDelayedOp::iOperationObserver = &aOperationObserver ;
+    CDelayedOp::iRequestId =  aRequestId ;
+       
     for(TInt i=0; i < messages.Count(); i++)
         {
         iMessages.Append(messages[i]);
@@ -599,10 +642,12 @@
     RPointerArray<CFSMailMessagePart>& aMessageParts,
     MFSMailRequestObserver& aOperationObserver,
     const TInt aRequestId)
-    :iOperationObserver( aOperationObserver ),
-    iRequestId( aRequestId ),
-    iType(EParts)
+    :iType(EParts)
     {
+    
+    CDelayedOp::iOperationObserver = &aOperationObserver ;
+    CDelayedOp::iRequestId =  aRequestId ;
+    
     for(TInt i=0; i < aMessageParts.Count(); i++)
         {
         iMessageParts.Append(aMessageParts[i]);
@@ -673,8 +718,12 @@
         progress.iError = KErrNone;
         progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
         }
-
-    iOperationObserver.RequestResponseL( progress, iRequestId );
+		
+		if(iOperationObserver)
+			{
+				iOperationObserver->RequestResponseL( progress, iRequestId );
+			}
+    
     
     __LOG_EXIT;
     }
@@ -683,35 +732,39 @@
 /**
  * 
  */
-void CDelayedMessageStorerOp::StorePartL(
-        CFSMailMessagePart* aPart)
+void CDelayedMessageStorerOp::StorePartL(CFSMailMessagePart* aPart)
     {
     User::LeaveIfNull(aPart);
-    
+
     // Text buffer for html text content
     HBufC* data16 = aPart->GetLocalTextContentLC();
 
-    TPtrC8 ptr8(reinterpret_cast<const TUint8*>( data16->Ptr() ),
-            data16->Size() );
-    
+    // Convert from 16 to 8 bit data -
+    HBufC8* dataBuffer = HBufC8::NewLC((data16->Length() * 2) + 1);
+    TPtr8 ptr8(dataBuffer->Des());
+    CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr8, *data16);
+
     //get msgstore part
-    CMailboxInfo& mailBox = GetPlugin().GetMailboxInfoL( aPart->GetMailBoxId().Id() );
-    
+    CMailboxInfo& mailBox = GetPlugin().GetMailboxInfoL(
+            aPart->GetMailBoxId().Id());
+
     CMsgStoreMessage* msg = mailBox().FetchMessageL(
-            aPart->GetMessageId().Id(), KMsgStoreInvalidId );
-    CleanupStack::PushL( msg );
-    
-    CMsgStoreMessagePart* part= msg->ChildPartL( aPart->GetPartId().Id(), ETrue );
-    
-    CleanupStack::PopAndDestroy( msg );
-    CleanupStack::PushL( part );
+            aPart->GetMessageId().Id(), KMsgStoreInvalidId);
+    CleanupStack::PushL(msg);
+
+    CMsgStoreMessagePart* part = msg->ChildPartL(aPart->GetPartId().Id(),
+            ETrue);
+
+    CleanupStack::PopAndDestroy(msg);
+    CleanupStack::PushL(part);
 
     //replace content
     part->ReplaceContentL(ptr8);
-    
-    CleanupStack::PopAndDestroy( part );
-    CleanupStack::PopAndDestroy( data16 );
-       
+
+    CleanupStack::PopAndDestroy(part);
+    CleanupStack::PopAndDestroy(dataBuffer);
+    CleanupStack::PopAndDestroy(data16);
+
     }
 
 
@@ -763,10 +816,11 @@
     MFSMailRequestObserver& aOperationObserver,
     const TInt aRequestId)
     : iBasePlugin(aPlugin), 
-      iMailBox( aMailBox ), 
-      iOperationObserver( aOperationObserver ),
-      iRequestId( aRequestId )
+      iMailBox( aMailBox )
     {
+    
+    CDelayedOp::iOperationObserver = &aOperationObserver ;
+    CDelayedOp::iRequestId =  aRequestId ;
 
     }
 
@@ -790,7 +844,10 @@
         progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
         }
 
-    iOperationObserver.RequestResponseL( progress, iRequestId );
+		if(iOperationObserver)
+			{
+				iOperationObserver->RequestResponseL( progress, iRequestId );
+			}
     
     __LOG_EXIT;
     }
@@ -854,10 +911,10 @@
     iParentFolderId( aParentFolderId ),
     iMessageId( aMessageId ),
     iParentPartId( aParentPartId ),
-    iOperationObserver( aOperationObserver ),
-    iRequestId( aRequestId ),
     iActionType( AddNewChild)
     {
+    CDelayedOp::iOperationObserver = &aOperationObserver ;
+    CDelayedOp::iRequestId =  aRequestId ;
     }
 
 /**
@@ -876,10 +933,10 @@
     iMessageId( aMessageId ),
     iParentPartId( aParentPartId ),
     iPartId( aPartId ),
-    iOperationObserver( aOperationObserver ),
-    iRequestId( aRequestId ),
     iActionType( RemoveChild)
     {
+    CDelayedOp::iOperationObserver = &aOperationObserver ;
+    CDelayedOp::iRequestId =  aRequestId ;
     }
 
 /**
@@ -947,7 +1004,10 @@
         progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
         }
 		
-    iOperationObserver.RequestResponseL( progress, iRequestId );
+		if(iOperationObserver)
+			{
+				iOperationObserver->RequestResponseL( progress, iRequestId );
+			}
     
     __LOG_EXIT;
     }
--- a/emailservices/emailstore/base_plugin/src/basepluginmisc.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/base_plugin/src/basepluginmisc.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -266,7 +266,8 @@
 void CBasePlugin::RefreshNowL(
     const TFSMailMsgId& /*aMailBoxId*/,
  	MFSMailRequestObserver& /*aOperationObserver*/,
- 	TInt /*aRequestId*/ )
+ 	TInt /*aRequestId*/,
+ 	const TBool /*aSilentConnection=EFalse*/ )
     {
 
     }
@@ -383,6 +384,23 @@
     		break;
     		}
     	}
+    count = iDelayedOpReqs.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        if ( iDelayedOpReqs[i]->iRequestId == aRequestId )
+            {
+            CDelayedOp* request = iDelayedOpReqs[i];
+            TFSProgress progress = TFSProgress();
+            progress.iProgressStatus = TFSProgress::EFSStatus_RequestCancelled;
+            progress.iCounter = progress.iMaxCount = 1;
+            progress.iError = KErrNone;
+            request->iOperationObserver->RequestResponseL( progress, aRequestId );
+            iDelayedOpsManager->DequeueOp(*request);
+            iDelayedOpReqs.Remove( i );
+            delete request;
+            break;
+            }
+        }
     }
 
 
--- a/emailservices/emailstore/base_plugin/src/nestedao.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/base_plugin/src/nestedao.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -20,7 +20,7 @@
 //
 
 
-#include "NestedAO.h"
+#include "nestedao.h"
 #include "baseplugindelayedops.h"
 #include "baseplugindelayedopsprivate.h"
 
--- a/emailservices/emailstore/emailstore.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/emailstore.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -29,7 +29,8 @@
         preinstall
         
     BLD_INF_RULES.prj_exports += \
-        "rom/emailstore.iby $$CORE_APP_LAYER_IBY_EXPORT_PATH(emailstore.iby)"        
+        "rom/emailstore.iby $$CORE_APP_LAYER_IBY_EXPORT_PATH(emailstore.iby)" \
+        "sis/emailstore_stub.sis             /epoc32/data/z/system/install/emailstore_stub.sis"     
  
 }
 CONFIG += ordered
--- a/emailservices/emailstore/message_store/client/inc/MsgStoreObserverHandler.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/message_store/client/inc/MsgStoreObserverHandler.h	Thu Jul 22 16:30:28 2010 +0100
@@ -84,6 +84,7 @@
 		RArray<MMsgStoreObserver*>                       iObservers;
 		RArray<TMailBoxObserverInfo>                     iMailBoxObservers;
 		TBuf8<sizeof(TMsgStoreEvent)*KEventBufferLength> iEventBuffer;
+		TBool                                            iObjectDeleted;
 		
 		__LOG_DECLARATION
 	
--- a/emailservices/emailstore/message_store/client/src/MsgStoreObserverHandler.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/message_store/client/src/MsgStoreObserverHandler.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -45,6 +45,8 @@
 	iSession( aSession )
 	{
 	__LOG_CONSTRUCT( "MsgClient", "CMsgStoreObserverHandler" )
+	//initialize variable to false.
+    iObjectDeleted = EFalse;
 	} // end constructor
 
 // ==========================================================================
@@ -57,6 +59,10 @@
 	iMailBoxObservers.Close();
 	iObservers.Close();
 		
+	//object is being deleted. Mark variable as true to cover case where delete
+	//has come while RunL was running and "AccountEventNotify" was called and
+	//has not completed.
+	iObjectDeleted = ETrue;
 	__LOG_DESTRUCT
 	} // end destructor
 
@@ -233,9 +239,15 @@
     	    eventPtr++;
             }
             
-    	// Get the next event(s).    	
-    	iSession.GetEvents( iStatus, iEventBuffer );
-    	SetActive();
+        //check that "this" object was not deleted by client during "AccountEventNotify".
+        //If object has been deleted there is no need to get session events and activate itself.
+        if ( !iObjectDeleted )
+            {
+            // Get the next event(s).       
+            iSession.GetEvents(iStatus, iEventBuffer);
+            SetActive();
+            }
+    	
 	    }
     else
     	{
--- a/emailservices/emailstore/message_store/server/group/MessageStoreServer.mmp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/message_store/server/group/MessageStoreServer.mmp	Thu Jul 22 16:30:28 2010 +0100
@@ -30,8 +30,8 @@
 CAPABILITY    CAP_CLIENT_DLL
 //<qmail>
 //VERSION       KEmailBinaryVersionNumber
+//KEmailBinaryDemandPaging
 //</qmail>
-KEmailBinaryDemandPaging
 
 MACRO DEBUG_USE_PROJECT_LOGGING_OPTIONS
 MACRO DEBUG_LOG_OPTION_ENTER
--- a/emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -38,7 +38,7 @@
 #include "ImsPointsecMonitor.h"
 #include "ImsPointsecObserver.h"
 #include "emailstorepskeys.h" // Support for on-the-fly upgrade
-#include "emailshutdownconst.h"
+//<qmail> removing #include "emailshutdownconst.h"
 //</cmail>
 
 // =========
@@ -318,19 +318,9 @@
     // Support for on-the-fly upgrade
     // Watch for KProperty_EmailStore_Upgrade property. When set to our UID3/SECUREID,
     // then, this server should stop.
-    RProcess process;
-	CleanupClosePushL( process ); //+process
-    TSecurityPolicy readPolicy( ECapabilityReadDeviceData );
-    TSecurityPolicy writePolicy( ECapabilityWriteDeviceData );
-    iUpgradePropertyWatcher = CPSIntPropertyWatcher::NewL( this );
-    iUpgradePropertyWatcher->StartL( KEmailShutdownPsCategory, 
-                                     EEmailPsKeyShutdownMsgStore,
-                                     KEmailShutterPsValue,
-                                     /*ETrue*/EFalse,
-                                     readPolicy,
-                                     writePolicy ); 
-    CleanupStack::PopAndDestroy(); //-process
-        
+
+    // <qmail> removed code to observe shutdown commands
+
     __LOG_EXIT
     } // end ConstructL
 
Binary file emailservices/nmailagent/conf/2002C326.txt has changed
--- a/emailservices/nmailagent/inc/nmmailagent.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailagent/inc/nmmailagent.h	Thu Jul 22 16:30:28 2010 +0100
@@ -20,9 +20,14 @@
 
 #include <nmcommon.h>
 
+class CHWRMVibra;
 class NmMailbox;
 class NmDataPluginFactory;
 class NmDataPluginInterface;
+class HbIndicator;
+class XQSystemToneService;
+class XQSettingsManager;
+class XQSettingsKey;
 
 class NmMailboxInfo
 {
@@ -41,10 +46,12 @@
     QList<NmId> mUnreadMailIdList;
     int mOutboxMails;
     bool mActive;
+    bool mInboxActive;
 
     NmMailboxInfo();
 };
 
+
 class NmMailAgent : public QObject
 {
     Q_OBJECT
@@ -66,36 +73,48 @@
             NmMessageEvent event,
             const NmId &folderId,
             const QList<NmId> &messageIds,
-            const NmId& mailboxId);
+            const NmId &mailboxId);
 
     void handleSyncStateEvent(
             NmSyncState state,
             const NmOperationCompletionEvent &event);
 
-    void handleConnectionEvent(NmConnectState state, const NmId mailboxId);
+    void handleConnectionEvent(NmConnectState state, const NmId mailboxId, int errorcode);
 
     void delayedStart();
-    
+
     void enableAlertTone();
 
+    void indicatorActivated(const QString &type, const QVariantMap &data);
+
+    void valueChanged(const XQSettingsKey& key, const QVariant& value);
+
 private:
 
     void initMailboxStatus();
 
     bool updateUnreadCount(const NmId &mailboxId, NmMailboxInfo &mailboxInfo);
 
-    int getOutboxCount(const NmId& mailboxId);
+    int getOutboxCount(const NmId &mailboxId);
+
+    NmMailboxInfo *getMailboxByType(const QString &type);
+
+    int getFreeIndicatorIndex();
 
-    int getIndicatorIndex();
+    int getTotalUnreadCount() const;
+
+    bool updateUnreadIndicator();
+
+    bool updateUnreadIndicator(bool active);
 
     bool updateIndicator(bool active,
         const NmMailboxInfo& mailboxInfo);
 
-    NmMailboxInfo* getMailboxInfo(const NmId &id);
+    NmMailboxInfo *getMailboxInfo(const NmId &id);
 
-    NmMailboxInfo* createMailboxInfo(const NmId &id);
+    NmMailboxInfo *createMailboxInfo(const NmId &id);
 
-    NmMailboxInfo* createMailboxInfo(const NmMailbox &mailbox,
+    NmMailboxInfo *createMailboxInfo(const NmMailbox &mailbox,
         NmDataPluginInterface *plugin);
 
     bool removeMailboxInfo(const NmId &id);
@@ -104,18 +123,34 @@
         bool active, bool refreshAlways);
 
     static QStringList pluginFolders();
-    
-    bool getMessageUnreadInfo(const NmId &folderId, 
+
+    bool getMessageUnreadInfo(const NmId &folderId,
         const NmId &messageId, const NmId &mailboxId, bool &unreadMessage);
+
+    bool playAlertTone();
+
+    void updateSendIndicator();
     
-    void playAlertTone();
+    void storeMailboxActive(const NmId &mailboxId, bool active);
+    
+    bool isMailboxActive(const NmId &mailboxId);
     
+    void deleteStoredMailboxActivity(const NmId &mailboxId);
+
+    bool launchMailbox(quint64 mailboxId);
+
 private: // data
 
+    HbIndicator *mIndicator;
+    XQSystemToneService *mSystemTone;
     NmDataPluginFactory *mPluginFactory;
     QList<NmMailboxInfo*> mMailboxes;
-    bool mSendingState;
+    CHWRMVibra *mVibra; // Owned
     bool mAlertToneAllowed;
+    int mLastOutboxCount;
+    bool mUnreadIndicatorActive;
+    XQSettingsManager *mSettingManager;
+    int mSilenceMode;
 };
 
 
--- a/emailservices/nmailagent/inc/nmmailagentheaders.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailagent/inc/nmmailagentheaders.h	Thu Jul 22 16:30:28 2010 +0100
@@ -17,13 +17,19 @@
 #ifndef NMAILAGENTHEADERS_H
 #define NMAILAGENTHEADERS_H
 
+// Qt
 #include <QDir>
 #include <QPluginLoader>
 #include <QCoreApplication>
 #include <QTimer>
 
+// Hb
 #include <hbindicator.h>
 
+// Symbian
+#include <hwrmvibra.h>
+
+// Nmail
 #include <nmcommon.h>
 #include <nmdatapluginfactory.h>
 #include <nmdataplugininterface.h>
--- a/emailservices/nmailagent/nmailagent.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailagent/nmailagent.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -46,9 +46,20 @@
     INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
     BLD_INF_RULES.prj_exports += "rom/nmailagent.iby $$CORE_APP_LAYER_IBY_EXPORT_PATH(nmailagent.iby)"
 
+    BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>" \
+                             "conf/2002C326.txt                  /epoc32/release/winscw/udeb/z/private/10202BE9/2002C326.txt" \
+                             "conf/2002C326.txt                  /epoc32/release/winscw/urel/z/private/10202BE9/2002C326.txt" \
+                             "conf/2002C326.txt                  /epoc32/data/z/private/10202BE9/2002C326.txt"
+
+    RSS_RULES += "hidden = KAppIsHidden;"
+
     TARGET.EPOCHEAPSIZE = 0x1000 0x100000 // MAX 1MB
 
     LIBS += -ldomaincli
+    LIBS += -lxqservice
+    LIBS += -lxqsettingsmanager
+    LIBS += -lxqsystemtoneservice
+    LIBS += -lhwrmvibraclient
 
     TARGET.UID2 = 0x100039CE
     TARGET.UID3 = 0x2002C326
--- a/emailservices/nmailagent/rom/nmailagent.iby	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailagent/rom/nmailagent.iby	Thu Jul 22 16:30:28 2010 +0100
@@ -19,6 +19,7 @@
 
 #include <bldvariant.hrh>
 
-file=ABI_DIR\BUILD_DIR\nmailagent.exe SHARED_LIB_DIR\nmailagent.exe
+file=ABI_DIR\BUILD_DIR\nmailagent.exe      SHARED_LIB_DIR\nmailagent.exe
+data=DATAZ_\private\10202be9\2002C326.txt  private\10202be9\2002C326.txt
 
 #endif // __NMAILAGENT_IBY__
--- a/emailservices/nmailagent/src/main.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailagent/src/main.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -14,6 +14,9 @@
 * Description:
 *
 */
+
+#include "emailtrace.h"
+
 #include "nmmailagentheaders.h"
 #include "nmmailagent.h"
 #include "ssastartupwatcher.h"
@@ -31,7 +34,9 @@
 */
 static void startupCallback(int status)
 {
-    NMLOG(QString("nmailagent: startupCallback %1").arg(status));
+    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
@@ -44,13 +49,15 @@
 */
 int main(int argc, char *argv[])
 {
+    NM_FUNCTION;
+    
     QCoreApplication app(argc, argv);
 
     agent = new NmMailAgent;
 
     CSSAStartupWatcher *startupWatcher = CSSAStartupWatcher::New(startupCallback);
     if (!startupWatcher) {
-        NMLOG("nmmailagent - watcher start failed");
+        NM_ERROR(1,"nmmailagent: watcher start failed");
         QTimer::singleShot(NmStartupDelay, agent, SLOT(delayedStart()));
     }
 
--- a/emailservices/nmailagent/src/nmmailagent.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailagent/src/nmmailagent.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,12 +15,45 @@
 *
 */
 
+#include "emailtrace.h"
 #include "nmmailagentheaders.h"
 #include "nmmailagent.h"
 
+#include <xqaiwdeclplat.h>
+#include <xqapplicationmanager.h>
+#include <xqaiwrequest.h>
+
+#include <xqsettingsmanager.h>
+#include <xqcentralrepositoryutils.h>
+#include <xqsystemtoneservice.h>
+#include <xqsettingskey.h>
+#include <ProfileEngineInternalCRKeys.h>
+
 // CONSTS
 const int NmAgentIndicatorNotSet = -1;
 const int NmAgentAlertToneTimer = 60000; // 60s
+const int NmAgentDefaultVibraDuration = 1000; // 1 second
+static const quint32 NmRepositoryId = 0x2002C326;
+static const QString NmMailboxIndicatorType = "com.nokia.nmail.indicatorplugin_%1/1.0";
+static const QString NmSendIndicatorName = "com.nokia.nmail.indicatorplugin.send/1.0";
+static const QString NmUnreadIndicatorName = "com.nokia.nmail.indicatorplugin.unread/1.0";
+const XQCentralRepositorySettingsKey NmSilenceModeKey(KCRUidProfileEngine.iUid, KProEngSilenceMode);
+const int NmSilenceModeOn = 1;
+
+/*!
+    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>
+*/
+bool keysEqual(const XQSettingsKey& settingKey, const XQCentralRepositorySettingsKey& cenrepSettingKey)
+{
+    return ((settingKey.target() == cenrepSettingKey.target()) &&
+            (settingKey.uid() == cenrepSettingKey.uid()) &&
+            (settingKey.key() == cenrepSettingKey.key()));
+}
 
 
 /*!
@@ -31,6 +64,8 @@
 
 NmMailboxInfo::NmMailboxInfo()
 {
+    NM_FUNCTION;
+
     mId = 0;
     mIndicatorIndex = NmAgentIndicatorNotSet;
     mSyncState = SyncComplete;
@@ -42,14 +77,21 @@
     mInboxChangedMessages = 0;
     mInboxDeletedMessages = 0;
     mActive = false;
+    mInboxActive = false;
 }
 
 NmMailAgent::NmMailAgent() :
+ mIndicator(NULL),
+ mSystemTone(NULL),
  mPluginFactory(NULL),
- mSendingState(false),
- mAlertToneAllowed(true)
+ mVibra(NULL),
+ mAlertToneAllowed(true),
+ mLastOutboxCount(0),
+ mUnreadIndicatorActive(false),
+ mSettingManager(NULL),
+ mSilenceMode(NmSilenceModeOn)  // by default silent mode is on
 {
-    NMLOG("NmMailAgent::NmMailAgent");
+    NM_FUNCTION;
 }
 
 /*!
@@ -57,7 +99,8 @@
 */
 void NmMailAgent::delayedStart()
 {
-	NMLOG("NmMailAgent::delayedStart");
+    NM_FUNCTION;
+
 	if (!init()) {
 		// Initialisation failed. Quit the agent.
 		QCoreApplication::exit(1);
@@ -69,13 +112,46 @@
 */
 bool NmMailAgent::init()
 {
-	NMLOG("NmMailAgent::init");
+    NM_FUNCTION;
+
     mPluginFactory = NmDataPluginFactory::instance();
     if (!mPluginFactory) {
-        NMLOG("NmMailAgent::init PluginFactory not created");
+        NM_ERROR(1,"NmMailAgent::init(): PluginFactory not created");
         return false;
     }
 
+    // Check status of silent mode.
+    delete mSettingManager;
+    mSettingManager = NULL;
+    mSettingManager = new XQSettingsManager();
+    QVariant silenceMode = mSettingManager->readItemValue(NmSilenceModeKey,
+        XQSettingsManager::TypeInt);
+    mSilenceMode = silenceMode.toInt();
+
+    // Start monitoring silence mode key.
+    bool monitoring(mSettingManager->startMonitoring(NmSilenceModeKey, XQSettingsManager::TypeInt));
+    monitoring &= connect(mSettingManager,
+                          SIGNAL(valueChanged(const XQSettingsKey&, const QVariant&)),
+                          this,
+                          SLOT(valueChanged(const XQSettingsKey&, const QVariant&)),
+                          Qt::UniqueConnection);
+
+    // If silence mode monitoring can't be started, then change silence mode on to be sure
+    // that no tone is played if silence mode is turned on at somepoint.
+    if (!monitoring) {
+        mSilenceMode = NmSilenceModeOn;
+    }
+
+    delete mSystemTone;
+    mSystemTone = NULL;
+    mSystemTone = new XQSystemToneService();
+
+    delete mIndicator;
+    mIndicator = NULL;
+    mIndicator = new HbIndicator();
+    connect(mIndicator,SIGNAL(userActivated(const QString &, const QVariantMap&)),
+        this, SLOT(indicatorActivated(const QString&, const QVariantMap&)));
+
     QList<QObject*> *plugins = mPluginFactory->pluginInstances();
 
     foreach (QObject *plugin, *plugins) {
@@ -95,12 +171,17 @@
 				this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent&)),
 				Qt::UniqueConnection);
 
-			connect(plugin, SIGNAL(connectionEvent(NmConnectState, const NmId)),
-				this, SLOT(handleConnectionEvent(NmConnectState, const NmId)),
+			connect(plugin, SIGNAL(connectionEvent(NmConnectState, const NmId, int)),
+				this, SLOT(handleConnectionEvent(NmConnectState, const NmId, int)),
 				Qt::UniqueConnection);
     	}
     }
 
+    // Construct the vibra interface instance.
+    delete mVibra;
+    mVibra = NULL;
+    TRAP_IGNORE(mVibra = CHWRMVibra::NewL());
+
     // load all current mailboxes
     initMailboxStatus();
 
@@ -109,7 +190,16 @@
 
 NmMailAgent::~NmMailAgent()
 {
+    NM_FUNCTION;
+
+    delete mVibra;
+    delete mSystemTone;
+    if (mSettingManager) {
+        mSettingManager->stopMonitoring(NmSilenceModeKey);
+        delete mSettingManager;
+    }
     qDeleteAll(mMailboxes);
+
     NmDataPluginFactory::releaseInstance(mPluginFactory);
 }
 
@@ -118,7 +208,8 @@
 */
 void NmMailAgent::initMailboxStatus()
 {
-    NMLOG("NmMailAgent::initMailboxStatus");
+    NM_FUNCTION;
+
     QList<NmMailbox*> mailboxes;
     QList<QObject*> *plugins = mPluginFactory->pluginInstances();
 
@@ -140,19 +231,32 @@
                 NmMailboxInfo *mailboxInfo = createMailboxInfo(*mailbox,plugin);
                 if (mailboxInfo) {
                     bool activate = updateUnreadCount(mailbox->id(), *mailboxInfo);
+                    bool wasActive = isMailboxActive(mailbox->id());
+                    if (activate) {
+                        if(!wasActive) {
+                            // do not activate the mailbox if it was left as hidden last time
+                            activate = false;
+                        }
+                        else {
+                            // otherwise, activate the mailbox and show inbox state
+                            mailboxInfo->mInboxActive = true;
+                        }
+                    }
+
                     mailboxInfo->mOutboxMails = getOutboxCount(mailbox->id());
-                    if (mailboxInfo->mOutboxMails > 0) {
+                    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);
                 }
             }
         }
         qDeleteAll(mailboxes);
     }
+    updateUnreadIndicator();
+    updateSendIndicator();
 }
 
 /*!
@@ -163,7 +267,8 @@
 */
 bool NmMailAgent::updateUnreadCount(const NmId &mailboxId, NmMailboxInfo &mailboxInfo)
 {
-    NMLOG("NmMailAgent::getUnreadCount");
+    NM_FUNCTION;
+
     int newUnreadMessages(0);
 
     NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
@@ -202,8 +307,8 @@
 		// Save updated list of unread message IDs
         mailboxInfo.mUnreadMailIdList = newUnreadMessageIdList;
     }
-	NMLOG(QString("NmMailAgent::getUnreadCount count=%1 new=%2").
-	    arg(mailboxInfo.mUnreadMailIdList.count()).arg(newUnreadMessages));
+    NM_COMMENT(QString("NmMailAgent::getUnreadCount(): count=%1, new=%2").
+        arg(mailboxInfo.mUnreadMailIdList.count()).arg(newUnreadMessages));
 
     return (newUnreadMessages > 0);
 }
@@ -216,7 +321,8 @@
 */
 int NmMailAgent::getOutboxCount(const NmId &mailboxId)
 {
-    NMLOG("NmMailAgent::getOutboxCount");
+    NM_FUNCTION;
+
     int count(0);
 
     NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
@@ -231,12 +337,41 @@
 		count = messageList.count();
 		qDeleteAll(messageList);
     }
-    NMLOG(QString("NmMailAgent::getOutboxCount count=%1").arg(count));
+    NM_COMMENT(QString("NmMailAgent::getOutboxCount(): count=%1").arg(count));
 
     return count;
 }
 
 /*!
+    Get list of unread counts in active mailboxes
+	\returns total number of unread mails
+*/
+int NmMailAgent::getTotalUnreadCount() const
+{
+    NM_FUNCTION;
+
+    int unreads = 0;
+    foreach (const NmMailboxInfo *mailbox, mMailboxes) {
+        if (mailbox->mActive && mailbox->mInboxActive) {
+            unreads += mailbox->mUnreadMailIdList.count();
+        }
+    }
+    return unreads;
+}
+
+/*!
+    Update the "@" indicator state according to unread state
+    \return true if the indicator was activated
+*/
+bool NmMailAgent::updateUnreadIndicator()
+{
+    NM_FUNCTION;
+
+    int unreads = getTotalUnreadCount();
+    return updateUnreadIndicator(unreads>0);
+}
+
+/*!
     Update the mailbox visibility and status
     \param mailboxId id of the mailbox
     \param active visibility state of the mailbox
@@ -246,25 +381,22 @@
 bool NmMailAgent::updateMailboxState(const NmId &mailboxId,
     bool active, bool refreshAlways)
 {
-    // Update the global sending state
-    mSendingState = false;
-    foreach (NmMailboxInfo *mailboxInfo, mMailboxes) {
-        if (mailboxInfo->mOutboxMails>0) {
-            mSendingState = true;
-            break;
-        }
-    }
+    NM_FUNCTION;
 
     NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
     bool changed = false;
     if (mailboxInfo->mActive != active ||
         refreshAlways) {
+
+		// store the new state to permanent storage
+        storeMailboxActive(mailboxId, active);
+
         mailboxInfo->mActive = active;
         changed = true;
         if (active) {
             // Mailbox is not yet assigned to any indicator
             if (mailboxInfo->mIndicatorIndex < 0) {
-                mailboxInfo->mIndicatorIndex = getIndicatorIndex();
+                mailboxInfo->mIndicatorIndex = getFreeIndicatorIndex();
             }
 
             updateIndicator(true,*mailboxInfo);
@@ -290,11 +422,12 @@
 bool NmMailAgent::updateIndicator(bool active,
     const NmMailboxInfo& mailboxInfo)
 {
-    NMLOG(QString("NmMailAgent::updateIndicator index=%1 active=%2").
+    NM_FUNCTION;
+    NM_COMMENT(QString("NmMailAgent::updateIndicator(): index=%1, active=%2").
         arg(mailboxInfo.mIndicatorIndex).arg(active));
 
     bool ok = false;
-    QString name = QString("com.nokia.nmail.indicatorplugin_%1/1.0").
+    QString name = QString(NmMailboxIndicatorType).
         arg(mailboxInfo.mIndicatorIndex);
 
     QList<QVariant> list;
@@ -305,14 +438,64 @@
     list.append(mailboxInfo.mConnectState);
     list.append(mailboxInfo.mOutboxMails);
     list.append(mailboxInfo.mIconName);
-    list.append(mSendingState);
+    list.append(mLastOutboxCount);
 
-    HbIndicator indicator;
     if (active) {
-        ok = indicator.activate(name,list);
+        ok = mIndicator->activate(name,list);
     }
     else {
-        ok = indicator.deactivate(name,list);
+        ok = mIndicator->deactivate(name,list);
+    }
+
+    updateUnreadIndicator();
+
+    return ok;
+}
+
+/*!
+    update the unread indicator state
+    \return true if the indicator was activated
+*/
+bool NmMailAgent::updateUnreadIndicator(bool active)
+{
+    NM_FUNCTION;
+
+    bool activated = false;
+    if (active != mUnreadIndicatorActive) {
+        if (active) {
+            mIndicator->activate(NmUnreadIndicatorName);
+            activated = true;
+        }
+        else {
+            mIndicator->deactivate(NmUnreadIndicatorName);
+        }
+        mUnreadIndicatorActive = active;
+    }
+
+    return activated;
+}
+
+/*!
+    Opens inbox view to specific mailbox
+    \return true if inbox is succesfully opened
+*/
+bool NmMailAgent::launchMailbox(quint64 mailboxId)
+{
+    NM_FUNCTION;
+
+    bool ok(false);
+    XQApplicationManager appManager;
+    XQAiwRequest *request = appManager.create(
+        XQI_EMAIL_INBOX_VIEW, XQOP_EMAIL_INBOX_VIEW, false);
+    // Instance might be NULL if the service is not available.
+    if (request) {
+        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;
     }
     return ok;
 }
@@ -321,8 +504,10 @@
     Get next free indicator index, starting from 0
     @return index of the indicator that is available
  */
-int NmMailAgent::getIndicatorIndex()
+int NmMailAgent::getFreeIndicatorIndex()
 {
+    NM_FUNCTION;
+
     int index = 0;
     bool found(false);
     do {
@@ -345,12 +530,16 @@
 */
 void NmMailAgent::handleMailboxEvent(NmMailboxEvent event, const QList<NmId> &mailboxIds)
 {
-    NMLOG(QString("NmMailAgent::handleMailboxEvent %1").arg(event));
+    NM_FUNCTION;
+    NM_COMMENT(QString("NmMailAgent::handleMailboxEvent(): event=%1").arg(event));
 
     switch(event) {
         case NmMailboxCreated:
             foreach (NmId mailboxId, mailboxIds) {
                 getMailboxInfo(mailboxId); // create a new mailbox if needed
+
+                // make sure the mailbox activity data is reseted
+                deleteStoredMailboxActivity(mailboxId);
             }
             break;
         case NmMailboxChanged:
@@ -380,7 +569,11 @@
             foreach (NmId mailboxId, mailboxIds) {
                 // Will hide also the indicator
                 removeMailboxInfo(mailboxId);
+
+                // make sure the mailbox activity data is deleted
+                deleteStoredMailboxActivity(mailboxId);
             }
+            updateUnreadIndicator();
             break;
         default:
             break;
@@ -388,6 +581,66 @@
 }
 
 /*!
+   Map the type name to mailbox info
+    \return NULL if no mailbox match the type
+*/
+NmMailboxInfo *NmMailAgent::getMailboxByType(const QString &type)
+{
+    NM_FUNCTION;
+
+    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;
+            }
+        }
+    }
+    return NULL;
+}
+
+/*!
+    Called when indicator is clicked from the indicator menu
+    - indicator will be hide from the menu
+    - mailbox will be launched
+*/
+void NmMailAgent::indicatorActivated(const QString &type, const QVariantMap &data)
+{
+    NM_FUNCTION;
+    Q_UNUSED(data);
+
+    // map the indicator type to mailbox
+    NmMailboxInfo *info = getMailboxByType(type);
+    if (info) {
+        info->mActive = false; // indicator is no longer active
+        info->mInboxActive = false; // also inbox does not activate the indicator
+        storeMailboxActive(info->mId, false);
+        updateUnreadIndicator();
+
+        launchMailbox(info->mId.id());
+    }
+}
+
+/*!
+    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)
+{
+    NM_FUNCTION;
+
+    if(keysEqual(key, NmSilenceModeKey)) {
+        mSilenceMode = value.toInt();
+    }
+}
+
+/*!
     Received from NmFrameworkAdapter messageEvent signal
     \sa NmFrameworkAdapter
 */
@@ -397,50 +650,70 @@
             const QList<NmId> &messageIds,
             const NmId& mailboxId)
 {
-    NMLOG(QString("NmMailAgent::handleMessageEvent %1 %2").arg(event).arg(mailboxId.id()));
+    NM_FUNCTION;
+
+    NM_COMMENT(QString("NmMailAgent::handleMessageEvent(): event=%1, id=%2").
+        arg(event).arg(mailboxId.id()));
+
     bool updateNeeded = false;
     bool activate = false;
 
     switch (event) {
         case NmMessageCreated: {
+            // Check the new messages to make the indicator appear earlier
             NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
-
-            // Check the new messages to make the indicator appear earlier
-            if (mailboxInfo->mSyncState == Synchronizing &&
-                mailboxInfo->mUnreadMailIdList.count()==0) {
+            
+            // Inbox folder ID may be still unknown
+            if (mailboxInfo->mInboxFolderId.id() == 0) {
+                NmDataPluginInterface *plugin =
+                    mPluginFactory->interfaceInstance(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 (plugin) {
+                    mailboxInfo->mInboxFolderId =
+                        plugin->getStandardFolderId(mailboxId, NmFolderInbox);
                 }
+            }
 
-                if (folderId == mailboxInfo->mInboxFolderId) {
+            if (folderId == mailboxInfo->mInboxFolderId) {
+                foreach (NmId messageId, messageIds) {
                     bool messageUnread = false;
-                    foreach (NmId messageId, messageIds) {
+
+                    // 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++;
+                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) {
-                    updateNeeded = true;
+					NM_COMMENT("NmMailAgent: first mail in outbox");
                 }
+                // Always activate the indicator
+                activate = true;
+                updateNeeded = true;
+
                 mailboxInfo->mOutboxMails += messageIds.count();
+				updateSendIndicator();
             }
             break;
         }
@@ -458,8 +731,8 @@
                 int oldCount = mailboxInfo->mUnreadMailIdList.count();
                 activate = updateUnreadCount(mailboxId, *mailboxInfo);
 
-                // new unread mails found or no more unread mails in the mailbox
-                if (activate || (oldCount>0 && mailboxInfo->mUnreadMailIdList.count()==0)) {
+                // new unread mails found or no more unread mails in the inbox
+                if (oldCount>0 && mailboxInfo->mUnreadMailIdList.count()==0) {
                     updateNeeded = true;
                 }
             }
@@ -483,10 +756,23 @@
 
                 // The last mail was now deleted
                 if (mailboxInfo->mOutboxMails == 0) {
-                    // Keep it active if there is unread mails
-                    activate = mailboxInfo->mUnreadMailIdList.count() > 0;
-                    updateNeeded = true;
-                }
+					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();
             }
             break;
         }
@@ -495,6 +781,8 @@
     }
 
     if (updateNeeded) {
+        updateUnreadIndicator();
+
         NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
         updateMailboxState(mailboxId,
             activate, true /* force refresh */);
@@ -509,7 +797,10 @@
             NmSyncState state,
             const NmOperationCompletionEvent &event)
 {
-    NMLOG(QString("NmMailAgent::handleSyncStateEvent %1 %2").arg(state).arg(event.mMailboxId.id()));
+    NM_FUNCTION;
+    NM_COMMENT(QString("NmMailAgent::handleSyncStateEvent(): state=%1, id=%2").
+        arg(state).arg(event.mMailboxId.id()));
+
     NmMailboxInfo *info = getMailboxInfo(event.mMailboxId);
     if (info) {
         info->mSyncState = state;
@@ -533,12 +824,15 @@
                 info->mOutboxMails;
 
             // Refresh the indicator if messages created or changed
-            NMLOG(QString(" created=%1, changed=%2, deleted=%3").
+            NM_COMMENT(QString("NmMailAgent::handleSyncStateEvent(): "
+                "created=%1, changed=%2, deleted=%3").
                 arg(info->mInboxCreatedMessages).
                 arg(info->mInboxChangedMessages).
                 arg(info->mInboxDeletedMessages));
             bool refresh = (info->mInboxCreatedMessages > 0) || (info->mInboxChangedMessages > 0);
 
+            updateUnreadIndicator();
+
             if (activate) {
                 updateMailboxState(event.mMailboxId, active, refresh);
             }
@@ -550,9 +844,13 @@
     Received from NmFrameworkAdapter connectionState signal
     \sa NmFrameworkAdapter
 */
-void NmMailAgent::handleConnectionEvent(NmConnectState state, const NmId mailboxId)
+void NmMailAgent::handleConnectionEvent(NmConnectState state, const NmId mailboxId, int errorcode)
 {
-    NMLOG(QString("NmMailAgent::handleConnectionEvent %1 %2").arg(state).arg(mailboxId.id()));
+    NM_FUNCTION;
+    NM_COMMENT(QString("NmMailAgent::handleConnectionEvent(): state=%1, id=%2").
+        arg(state).arg(mailboxId.id()));
+    Q_UNUSED(errorcode);
+
     NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
     if (mailboxInfo) {
         // Connecting, Connected, Disconnecting, Disconnected
@@ -566,6 +864,8 @@
 */
 bool NmMailAgent::removeMailboxInfo(const NmId &id)
 {
+    NM_FUNCTION;
+
     bool found = false;
     foreach (NmMailboxInfo *mailbox, mMailboxes) {
         if (mailbox->mId == id) {
@@ -587,6 +887,8 @@
 */
 NmMailboxInfo *NmMailAgent::createMailboxInfo(const NmId &id)
 {
+    NM_FUNCTION;
+
     // get information of the mailbox
     NmMailbox *mailbox = NULL;
     NmMailboxInfo *info = NULL;
@@ -607,6 +909,8 @@
 */
 NmMailboxInfo *NmMailAgent::createMailboxInfo(const NmMailbox &mailbox, NmDataPluginInterface *plugin)
 {
+    NM_FUNCTION;
+
     NmMailboxInfo *mailboxInfo = new NmMailboxInfo();
     mailboxInfo->mId = mailbox.id();
     mailboxInfo->mName = mailbox.name();
@@ -627,15 +931,10 @@
     // Get branded mailbox icon
     NmMailbox mailbox2( mailbox );
     QString domainName = mailbox2.address().address();
-    int delimIndex = domainName.indexOf('@');
-    if( delimIndex >= 0 ) {
-        domainName = domainName.mid(delimIndex+1);
-        NMLOG(QString("Mailbox domain name: %1").arg(domainName));
-    }
     EmailMailboxInfo emailMailboxInfo;
     mailboxInfo->mIconName =
         emailMailboxInfo.mailboxIcon(domainName);
-    
+
     return mailboxInfo;
 }
 
@@ -645,6 +944,8 @@
 */
 NmMailboxInfo *NmMailAgent::getMailboxInfo(const NmId &id)
 {
+    NM_FUNCTION;
+
     foreach (NmMailboxInfo *mailbox, mMailboxes) {
         if (mailbox->mId == id) {
             return mailbox;
@@ -666,7 +967,7 @@
 bool NmMailAgent::getMessageUnreadInfo(const NmId &folderId,
     const NmId &messageId, const NmId &mailboxId, bool &unreadMessage)
 {
-    NMLOG("NmMailAgent::messageInfo");
+    NM_FUNCTION;
 
     NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
     bool ok = false;
@@ -687,15 +988,33 @@
 }
 
 /*!
-    Plays email alert tune when new messages arrive
+    Plays email alert tone when new messages arrive
+	\returns true if the tone was played
 */
-void NmMailAgent::playAlertTone()
+bool NmMailAgent::playAlertTone()
 {
+    NM_FUNCTION;
+	bool played(false);
+
     if (mAlertToneAllowed) {
-        // play alert
+        // Play tone only if system tone service is available and
+        // phone is not in silence mode.
+        if (mSystemTone && !mSilenceMode) {
+            mSystemTone->playTone(XQSystemToneService::EmailAlertTone);
+        }
+
+        // Execute the vibra effect.
+        if (mVibra) {
+            TRAP_IGNORE(mVibra->StartVibraL(NmAgentDefaultVibraDuration));
+        }
+
+        // play alert only once per minute
         mAlertToneAllowed = false;
         QTimer::singleShot(NmAgentAlertToneTimer, this, SLOT(enableAlertTone()));
+		played = true;
     }
+
+	return played;
 }
 
 /*!
@@ -703,8 +1022,91 @@
 */
 void NmMailAgent::enableAlertTone()
 {
+    NM_FUNCTION;
+
     mAlertToneAllowed = true;
 }
 
+/*!
+    update send indicator according to outbox state
+*/
+void NmMailAgent::updateSendIndicator()
+{
+    NM_FUNCTION;
+
+    // Get number of mails in outboxes
+    int outboxMails = 0;
+    foreach (NmMailboxInfo *mailboxInfo, mMailboxes) {
+        outboxMails += mailboxInfo->mOutboxMails;
+    }
+
+    if( outboxMails == 0 ) {
+        mIndicator->deactivate(NmSendIndicatorName);
+    }
+    else if (outboxMails > mLastOutboxCount) {
+        // New mails detected in outbox
+
+    	// indicator will disappear automatically after a delay
+        mIndicator->activate(NmSendIndicatorName);
+	}
+
+	mLastOutboxCount = outboxMails;
+}
+
+/*!
+    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;
+
+    if (mSettingManager) {
+        XQCentralRepositorySettingsKey key(NmRepositoryId, mailboxId.id());
+        XQCentralRepositoryUtils utils(*mSettingManager);
+
+        if (active) {
+            // when mailbox is active, key can be deleted
+            utils.deleteKey(key);
+        }
+        else {
+            utils.createKey(key,(int)active);
+        }
+    }
+}
+
+/*!
+    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;
+
+    bool mailboxActive(true);
+    if (mSettingManager) {
+        XQCentralRepositorySettingsKey key(NmRepositoryId, mailboxId.id());
+        QVariant value = mSettingManager->readItemValue(key, XQSettingsManager::TypeInt);
+        if (value.isValid()) {
+            NM_COMMENT(QString("NmMailAgent::isMailboxActive - value=%1").arg(value.toInt()));
+            mailboxActive = value.toInt();
+        }
+    }
+    return mailboxActive;
+}
+
+/*!
+    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);
+}
+
 // End of file
-
--- a/emailservices/nmailagent/src/ssastartupwatcher.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailagent/src/ssastartupwatcher.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -13,6 +13,8 @@
 // Description:
 //
 
+#include "emailtrace.h"
+
 #include "ssastartupwatcher.h"
 
 /*!
@@ -21,6 +23,8 @@
 */
 CSSAStartupWatcher* CSSAStartupWatcher::NewL(TStartupCallBack aCallback)
 {
+    NM_FUNCTION;
+    
 	CSSAStartupWatcher* self = new (ELeave) CSSAStartupWatcher(KDmHierarchyIdStartup, 
 	    KSM2AppServicesDomain3, aCallback);
 	CleanupStack::PushL(self);
@@ -35,6 +39,8 @@
 */
 CSSAStartupWatcher* CSSAStartupWatcher::New(TStartupCallBack aCallback)
 {
+    NM_FUNCTION;
+    
     CSSAStartupWatcher* self = NULL;
     TRAP_IGNORE( self = NewL(aCallback); );
     return self;
@@ -51,6 +57,7 @@
 : CDmDomain(aHierarchyId,aDomainId), 
   iCallback(aCallback)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -58,6 +65,8 @@
 */
 CSSAStartupWatcher::~CSSAStartupWatcher()
 {
+    NM_FUNCTION;
+    
 	Cancel();
 }
 
@@ -69,6 +78,8 @@
 */
 void CSSAStartupWatcher::ConstructL()
 {
+    NM_FUNCTION;
+    
 	// Connect to the Domain Manager
 	CDmDomain::ConstructL();
 
@@ -94,6 +105,8 @@
 */
 void CSSAStartupWatcher::NotifyState(TInt aValue) 
 {
+    NM_FUNCTION;
+    
     (*iCallback)(aValue);
 }
 
@@ -103,6 +116,8 @@
 */
 void CSSAStartupWatcher::RunL()
 {
+    NM_FUNCTION;
+    
 	// Leave if our previous request to be notified a state change has
 	// returned an error and let RunError handle this.
 	if (iStatus.Int()!=KErrNone) {
--- a/emailservices/nmailbase/inc/nmcommon.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailbase/inc/nmcommon.h	Thu Jul 22 16:30:28 2010 +0100
@@ -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"
@@ -22,6 +22,9 @@
 #include <QString>
 #include <QMetaType>
 #include <QVariant>
+#include <QDateTime>
+
+#include "emailtrace.h"
 
 #define USE_POPIMAP_TESTPLUGIN
 
@@ -52,7 +55,8 @@
 {
     NmMessageCreated,
     NmMessageChanged,
-    NmMessageDeleted
+    NmMessageDeleted,
+    NmMessageFound // Search functionality related enumeration.
 };
 Q_DECLARE_METATYPE(NmMessageEvent)
 
@@ -302,52 +306,6 @@
     mPluginId = pluginId32;
 }
 
-/*!
-     static function for debug prints
- */
-#include <QDebug>
-#include <QFile>
-#include <QDateTime>
-
-static void printToFileAndConsole(QString str, QString filename)
-{    
-    // Print to file
-    QFile debugFile(filename);
-    QIODevice::OpenMode openMode = QIODevice::Text;
-    if (debugFile.exists()) {
-        openMode |= QIODevice::Append;
-    } else {
-        openMode |= QIODevice::WriteOnly;
-    }
-
-    // Create date string
-    QString d = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss");
-
-    if (debugFile.open(openMode)) {
-        QTextStream debugStream(&debugFile);
-        debugStream << d << "  " << str << endl;
-        debugFile.close();
-    }
-    // Print to console
-    qDebug() << d << str << endl; 
-}
-
-// 
-// NMLOG is used to log QStrings to text file. For example:
-//
-// NMLOG("nmailui: application opened successfully");
-//
-// QString fileName = "mailbox.xml";
-// int error = -12;
-// NMLOG(QString("### cannot open file: err=%1  file='%2' ###").arg(error).arg(fileName));
-//
-#ifdef _DEBUG
-#define NMLOG(a) { printToFileAndConsole(a, "c:/logs/nmail.log"); }
-#else
-#define NMLOG(a)
-#endif
-
-
 /*! email list sort criteria definition */
 class NmMailSortCriteria
 {
--- a/emailservices/nmailbase/src/nmaddress.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailbase/src/nmaddress.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
 *
 */
 
+#include "emailtrace.h"
+
 #include <QString>
 
 #include "nmaddress.h"
@@ -26,6 +28,7 @@
 :mDisplayName(""),
 mAddress("")
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -33,6 +36,7 @@
  */
 NmAddressPrivate::~NmAddressPrivate()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -53,6 +57,8 @@
  */
 NmAddress::NmAddress()
 {
+    NM_FUNCTION;
+    
     d = new NmAddressPrivate();
 }
 
@@ -61,6 +67,8 @@
  */
 NmAddress::NmAddress(const QString &displayName, const QString &address)
 {
+    NM_FUNCTION;
+    
     d = new NmAddressPrivate();
     d->mDisplayName = displayName;
     d->mAddress = address;
@@ -71,6 +79,8 @@
  */
 NmAddress::NmAddress(const QString &address)
 {
+    NM_FUNCTION;
+    
     d = new NmAddressPrivate();
     d->mAddress = address;
 }
@@ -80,6 +90,7 @@
  */
 NmAddress::NmAddress(const NmAddress &nmAddress) : d(nmAddress.d)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -87,6 +98,8 @@
  */
 NmAddress::NmAddress(QExplicitlySharedDataPointer<NmAddressPrivate> nmPrivateAddress)
 {
+    NM_FUNCTION;
+    
     d = nmPrivateAddress;
 }
 
@@ -95,6 +108,8 @@
  */
 NmAddress &NmAddress::operator=(const NmAddress &nmAddress)
 {
+    NM_FUNCTION;
+    
     if (this != &nmAddress) {
       d = nmAddress.d;
     }
@@ -106,6 +121,7 @@
  */
 NmAddress::~NmAddress()
 {
+    NM_FUNCTION;
 }
 
 
@@ -115,6 +131,8 @@
  */
 bool NmAddress::operator==(const NmAddress &otherAddress) const
 {
+    NM_FUNCTION;
+    
     bool ret = false;
     if (otherAddress.address().compare(d->mAddress, Qt::CaseInsensitive) == 0 &&
         otherAddress.displayName().compare(
@@ -130,6 +148,8 @@
  */
 bool NmAddress::operator!=(const NmAddress &otherAddress) const
 {
+    NM_FUNCTION;
+    
     bool ret = true;
     if (otherAddress.address().compare(d->mAddress, Qt::CaseInsensitive) == 0 &&
         otherAddress.displayName().compare(
@@ -144,6 +164,8 @@
  */
 void NmAddress::setDisplayName(const QString &displayName)
 {
+    NM_FUNCTION;
+    
     d->mDisplayName = displayName;
 }
 
@@ -152,6 +174,8 @@
  */
 QString NmAddress::displayName() const
 {
+    NM_FUNCTION;
+    
     return d->mDisplayName;
 }
 
@@ -160,6 +184,8 @@
  */
 void NmAddress::setAddress(const QString &address)
 {
+    NM_FUNCTION;
+    
     d->mAddress = address;
 }
 
@@ -168,5 +194,7 @@
  */
 QString NmAddress::address() const
 {
+    NM_FUNCTION;
+    
     return d->mAddress;
 }
--- a/emailservices/nmailbase/src/nmfolder.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailbase/src/nmfolder.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
 *
 */
 
+#include "emailtrace.h"
+
 #include "nmfolder.h"
 
 
@@ -31,10 +33,12 @@
 mSubFolderCount(0),
 mUpdated(QDateTime())
 {
+    NM_FUNCTION;
 }
 
 NmFolderPrivate::~NmFolderPrivate()
 {
+    NM_FUNCTION;
 }
 
 
@@ -49,6 +53,8 @@
 */
 NmFolder::NmFolder(NmId folderId)
 {
+    NM_FUNCTION;
+    
     d = new NmFolderPrivate();
     d->mFolderId = folderId;
 }
@@ -58,6 +64,8 @@
 */
 NmFolder::NmFolder(const NmFolder &folder)
 {
+    NM_FUNCTION;
+    
     d = folder.d;
 }
 
@@ -66,6 +74,8 @@
  */
 NmFolder::NmFolder(QExplicitlySharedDataPointer<NmFolderPrivate> folderPrivate)
 {
+    NM_FUNCTION;
+    
   d = folderPrivate;
 }
 
@@ -74,6 +84,8 @@
 */
 NmFolder &NmFolder::operator=(const NmFolder &folder)
 {
+    NM_FUNCTION;
+    
   if (this != &folder) {
     d = folder.d;
   }
@@ -85,6 +97,7 @@
 */
 NmFolder::~NmFolder()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -92,6 +105,8 @@
 */
 NmId NmFolder::folderId() const
 {
+    NM_FUNCTION;
+    
     return d->mFolderId;
 }
 
@@ -100,6 +115,8 @@
 */
 void NmFolder::setFolderId(NmId folderId)
 {
+    NM_FUNCTION;
+    
   d->mFolderId = folderId;
 }
 
@@ -108,6 +125,8 @@
 */
 NmId NmFolder::parentId() const
 {
+    NM_FUNCTION;
+    
     return d->mParentFolderId;
 }
 
@@ -116,6 +135,8 @@
 */
 void NmFolder::setParentId(NmId parentFolderId)
 {
+    NM_FUNCTION;
+    
     d->mParentFolderId = parentFolderId;
 }
 
@@ -124,6 +145,8 @@
 */
 NmId NmFolder::mailboxId() const
 {
+    NM_FUNCTION;
+    
     return d->mMailboxId;
 }
 
@@ -132,6 +155,8 @@
 */
 void NmFolder::setMailboxId(NmId mailboxId)
 {
+    NM_FUNCTION;
+    
     d->mMailboxId = mailboxId;
 }
 
@@ -140,6 +165,8 @@
 */
 QString NmFolder::name() const
 {
+    NM_FUNCTION;
+    
     return d->mName;
 }
 
@@ -148,6 +175,8 @@
 */
 void NmFolder::setName(QString name)
 {
+    NM_FUNCTION;
+    
     d->mName = name;
 }
 
@@ -156,6 +185,8 @@
 */
 NmFolderType NmFolder::folderType() const
 {
+    NM_FUNCTION;
+    
     return d->mFolderType;
 }
 
@@ -164,6 +195,8 @@
 */
 void NmFolder::setFolderType(NmFolderType folderType)
 {
+    NM_FUNCTION;
+    
     d->mFolderType = folderType;
 }
 
@@ -172,6 +205,8 @@
 */
 QDateTime NmFolder::lastUpdated() const
 {
+    NM_FUNCTION;
+    
     return d->mUpdated;
 }
 
@@ -180,6 +215,8 @@
 */
 void NmFolder::setLastUpdated(QDateTime time)
 {
+    NM_FUNCTION;
+    
     d->mUpdated = time;
 }
 
@@ -188,6 +225,8 @@
  */
 quint32 NmFolder::messageCount() const
 {
+    NM_FUNCTION;
+    
   return d->mMessageCount;
 }
 
@@ -196,6 +235,8 @@
  */
 void NmFolder::setMessageCount(quint32 messageCount)
 {
+    NM_FUNCTION;
+    
   d->mMessageCount = messageCount;
 }
 
@@ -204,6 +245,8 @@
  */
 quint32 NmFolder::unreadMessageCount() const
 {
+    NM_FUNCTION;
+    
   return d->mUnreadMessageCount;
 }
 
@@ -212,6 +255,8 @@
  */
 void NmFolder::setUnreadMessageCount(quint32 unreadMessageCount)
 {
+    NM_FUNCTION;
+    
   d->mUnreadMessageCount = unreadMessageCount;
 }
 
@@ -220,6 +265,8 @@
  */
 quint32 NmFolder::unseenCount() const
 {
+    NM_FUNCTION;
+    
   return d->mUnseenCount;
 }
 
@@ -228,6 +275,8 @@
  */
 void NmFolder::setUnseenCount(quint32 unseenCount)
 {
+    NM_FUNCTION;
+    
   d->mUnseenCount =  unseenCount;
 }
 
@@ -236,6 +285,8 @@
  */
 quint32 NmFolder::subFolderCount() const
 {
+    NM_FUNCTION;
+    
   return d->mSubFolderCount;
 }
 
@@ -244,6 +295,8 @@
  */
 void NmFolder::setSubFolderCount(quint32 subFolderCount)
 {
+    NM_FUNCTION;
+    
   d->mSubFolderCount = subFolderCount;
 }
 
--- a/emailservices/nmailbase/src/nmmailbox.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailbase/src/nmmailbox.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -14,16 +14,21 @@
 * Description:
 *
 */
+
+#include "emailtrace.h"
+
 #include <QString>
 
 #include "nmmailbox.h"
 
 NmMailboxPrivate::NmMailboxPrivate()
 {
+    NM_FUNCTION;
 }
 
 NmMailboxPrivate::~NmMailboxPrivate()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -36,6 +41,8 @@
  */
 NmMailbox::NmMailbox()
 {
+    NM_FUNCTION;
+    
     d = new NmMailboxPrivate();
 }
 
@@ -44,6 +51,8 @@
  */
 NmMailbox::NmMailbox(const NmMailbox &mailbox)
 {
+    NM_FUNCTION;
+    
     d = mailbox.d;
 }
 
@@ -52,6 +61,8 @@
  */
 NmMailbox::NmMailbox(QExplicitlySharedDataPointer<NmMailboxPrivate> mailboxprivate)
 {
+    NM_FUNCTION;
+    
     d = mailboxprivate;
 }
 
@@ -60,6 +71,8 @@
  */
 NmMailbox &NmMailbox::operator=(const NmMailbox &mailbox)
 {
+    NM_FUNCTION;
+    
     if (this != &mailbox) {
         d = mailbox.d;
     }
@@ -71,6 +84,7 @@
  */
 NmMailbox::~NmMailbox()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -78,6 +92,8 @@
  */
 NmId NmMailbox::id() const
 {
+    NM_FUNCTION;
+    
     return d->mId;
 }
 
@@ -86,6 +102,8 @@
  */
 void NmMailbox::setId(const NmId& id)
 {
+    NM_FUNCTION;
+    
     d->mId = id;
 }
 
@@ -94,6 +112,8 @@
  */
 QString NmMailbox::name() const
 {
+    NM_FUNCTION;
+    
     return d->mName;
 }
 
@@ -102,6 +122,8 @@
  */
 void NmMailbox::setName(const QString &name)
 {
+    NM_FUNCTION;
+    
     d->mName = name;
 }
 
@@ -110,6 +132,8 @@
  */
 bool NmMailbox::operator==(const NmMailbox &mailbox) const
 {
+    NM_FUNCTION;
+    
     bool ret = true;
 
     if (this->name().compare(mailbox.name()) != 0) {
@@ -124,12 +148,16 @@
 
 NmAddress NmMailbox::address() const
 {
+    NM_FUNCTION;
+    
     return d->mAddress;
 }
 
 
 void NmMailbox::setAddress(const NmAddress& address)
 {
+    NM_FUNCTION;
+    
     d->mAddress = address;
 }
 
--- a/emailservices/nmailbase/src/nmmessage.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailbase/src/nmmessage.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
 *
 */
 
+#include "emailtrace.h"
+
 #include "nmmessage.h"
 #include "nmmessageenvelope.h"
 
@@ -23,7 +25,7 @@
  */
 NmMessagePrivate::NmMessagePrivate() : mEnvelope(0)
 {
-    
+    NM_FUNCTION;
 }
 
 /*!
@@ -31,7 +33,7 @@
  */
 NmMessagePrivate::~NmMessagePrivate()
 {
-    
+    NM_FUNCTION;
 }
 
 /*!
@@ -44,6 +46,8 @@
  */
 NmMessage::NmMessage()
 {
+    NM_FUNCTION;
+    
     d = new NmMessagePrivate();
 }
 
@@ -52,6 +56,8 @@
  */
 NmMessage::NmMessage(const NmId &messageId) : NmMessagePart(0)
 {
+    NM_FUNCTION;
+    
     d = new NmMessagePrivate();
     d->mEnvelope.setMessageId(messageId);
 }
@@ -63,6 +69,8 @@
 NmMessage::NmMessage(const NmId &messageId, const NmId &folderId)
 : NmMessagePart(0)
 {
+    NM_FUNCTION;
+    
     d = new NmMessagePrivate();
 	d->mEnvelope.setMessageId(messageId);
 	d->mEnvelope.setFolderId(folderId);
@@ -77,6 +85,8 @@
                      const NmId &mailboxId)
 :NmMessagePart(0)
 {
+    NM_FUNCTION;
+    
     d = new NmMessagePrivate();
 	d->mEnvelope.setMessageId(messageId);
 	d->mEnvelope.setFolderId(folderId);
@@ -88,6 +98,8 @@
  */
 NmMessage::NmMessage(const NmMessageEnvelope &envelope)
 {
+    NM_FUNCTION;
+    
     d = new NmMessagePrivate();
     d->mEnvelope = envelope;
     // set message id same as envelope id
@@ -101,6 +113,8 @@
         QExplicitlySharedDataPointer<NmMessagePartPrivate> nmPrivateMessagePart)
         : NmMessagePart(nmPrivateMessagePart)
 {
+    NM_FUNCTION;
+    
     d = new NmMessagePrivate();
 	d->mEnvelope = envelope;
     // set message id same as envelope id
@@ -112,6 +126,8 @@
  */
 NmMessage::NmMessage(const NmMessagePart& message):NmMessagePart(message)
 {
+    NM_FUNCTION;
+    
     d = new NmMessagePrivate();
 }
 
@@ -124,6 +140,8 @@
  */
 NmMessage &NmMessage::operator=(const NmMessage &message)
 {
+    NM_FUNCTION;
+    
 	if (this != &message) {
 		d = message.d;
 	}
@@ -135,6 +153,7 @@
  */
 NmMessage::~NmMessage()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -144,6 +163,8 @@
  */
 const NmMessagePart *NmMessage::plainTextBodyPart() const
 {
+    NM_FUNCTION;
+    
     const NmMessagePart *ret = NULL;
     ret = findContentPart(NmContentTypeTextPlain);
     return ret;
@@ -156,6 +177,8 @@
  */
 NmMessagePart *NmMessage::plainTextBodyPart()
 {
+    NM_FUNCTION;
+    
     NmMessagePart *ret = NULL;
     ret = findContentPart(NmContentTypeTextPlain);
     return ret;
@@ -168,6 +191,8 @@
  */
 const NmMessagePart *NmMessage::htmlBodyPart() const
 {
+    NM_FUNCTION;
+    
     const NmMessagePart *ret = NULL;
     ret = findContentPart(NmContentTypeTextHtml);
     return ret;
@@ -180,6 +205,8 @@
  */
 NmMessagePart *NmMessage::htmlBodyPart()
 {
+    NM_FUNCTION;
+    
     NmMessagePart *ret = NULL;
     ret = findContentPart(NmContentTypeTextHtml);
     return ret;
@@ -190,6 +217,8 @@
  */
 NmMessageEnvelope &NmMessage::envelope()
 {
+    NM_FUNCTION;
+    
     return d->mEnvelope;
 }
 
@@ -198,6 +227,8 @@
  */
 const NmMessageEnvelope &NmMessage::envelope() const
 {
+    NM_FUNCTION;
+    
     return d->mEnvelope;
 }
 
@@ -210,6 +241,8 @@
 */        
 void NmMessage::attachmentList(QList<NmMessagePart*> &parts) const
 {
+    NM_FUNCTION;
+    
     parts.clear();
     appendAttachments(parts);
 
--- a/emailservices/nmailbase/src/nmmessageenvelope.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailbase/src/nmmessageenvelope.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -18,6 +18,8 @@
 #ifndef NMMESSAGEENVELOPE_CPP_
 #define NMMESSAGEENVELOPE_CPP_
 
+#include "emailtrace.h"
+
 #include "nmmessageenvelope.h"
 
 /*!
@@ -29,6 +31,7 @@
 mMailboxId(0),
 mMessageFlags(0)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -36,15 +39,20 @@
  */
 NmMessageEnvelopePrivate::~NmMessageEnvelopePrivate()
 {
+    NM_FUNCTION;
 }
 
 NmMessageFlags NmMessageEnvelopePrivate::flags() const
 {
+    NM_FUNCTION;
+    
     return mMessageFlags;
 }
 
 void NmMessageEnvelopePrivate::setFlags(const NmMessageFlags flags, bool set)
 {
+    NM_FUNCTION;
+    
     if (set) {
         mMessageFlags |= flags;
     } else {
@@ -54,6 +62,8 @@
 
 void NmMessageEnvelopePrivate::setFlag(const NmMessageFlag flag, bool set)
 {
+    NM_FUNCTION;
+    
     if (set) {
         mMessageFlags |= flag;
     } else {
@@ -63,6 +73,8 @@
 
 bool NmMessageEnvelopePrivate::isFlagSet(const NmMessageFlag flag) const
 {
+    NM_FUNCTION;
+    
     return mMessageFlags.testFlag(flag);
 }
 
@@ -79,6 +91,8 @@
  */
 NmMessageEnvelope::NmMessageEnvelope()
 {
+    NM_FUNCTION;
+    
     d = new NmMessageEnvelopePrivate();
 }
 
@@ -87,6 +101,8 @@
  */
 NmMessageEnvelope::NmMessageEnvelope(const NmId &messageId)
 {
+    NM_FUNCTION;
+    
     d = new NmMessageEnvelopePrivate();
     d->mMessageId = messageId;
 }
@@ -96,6 +112,7 @@
  */
 NmMessageEnvelope::NmMessageEnvelope(const NmMessageEnvelope &envelope):d(envelope.d)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -103,6 +120,8 @@
  */
 NmMessageEnvelope::NmMessageEnvelope(QExplicitlySharedDataPointer<NmMessageEnvelopePrivate> nmPrivateMessageEnvelope)
 {
+    NM_FUNCTION;
+    
     d = nmPrivateMessageEnvelope;
 }
 
@@ -111,6 +130,8 @@
  */
 NmMessageEnvelope &NmMessageEnvelope::operator=(const NmMessageEnvelope &envelope)
 {
+    NM_FUNCTION;
+    
     if (this != &envelope) {
         d = envelope.d;
     }
@@ -124,6 +145,8 @@
  */
 bool NmMessageEnvelope::operator==(const NmMessageEnvelope &envelope) const
 {
+    NM_FUNCTION;
+    
     bool ret = false;
     if (0 == subject().compare(envelope.subject(), Qt::CaseInsensitive)
         && sender() == envelope.sender()
@@ -142,6 +165,8 @@
  */
 bool NmMessageEnvelope::operator!=(const NmMessageEnvelope &envelope) const
 {
+    NM_FUNCTION;
+    
     return !(*this==envelope);
 }
 
@@ -150,6 +175,7 @@
  */
 NmMessageEnvelope::~NmMessageEnvelope()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -157,6 +183,8 @@
  */
 void NmMessageEnvelope::setMessageId(const NmId &messageId)
 {
+    NM_FUNCTION;
+    
     d->mMessageId = messageId;
 }
 
@@ -165,6 +193,8 @@
  */
 NmId NmMessageEnvelope::messageId() const
 {
+    NM_FUNCTION;
+    
     return d->mMessageId;
 }
 
@@ -173,6 +203,8 @@
  */
 NmId NmMessageEnvelope::folderId() const
 {
+    NM_FUNCTION;
+    
     return d->mFolderId;
 }
 
@@ -181,6 +213,8 @@
  */
 void NmMessageEnvelope::setFolderId(const NmId &folderId)
 {
+    NM_FUNCTION;
+    
     d->mFolderId = folderId;
 }
 
@@ -189,6 +223,8 @@
  */
 NmId NmMessageEnvelope::mailboxId() const
 {
+    NM_FUNCTION;
+    
     return d->mMailboxId;
 }
 
@@ -197,6 +233,8 @@
  */
 void NmMessageEnvelope::setMailboxId(const NmId &mailboxId)
 {
+    NM_FUNCTION;
+    
     d->mMailboxId = mailboxId;
 }
 
@@ -205,6 +243,8 @@
  */
 void NmMessageEnvelope::setSubject(const QString &subject)
 {
+    NM_FUNCTION;
+    
     d->mSubject = subject;
 }
 
@@ -213,6 +253,8 @@
  */
 QString NmMessageEnvelope::subject() const
 {
+    NM_FUNCTION;
+    
   return d->mSubject;
 }
 
@@ -221,6 +263,8 @@
  */
 void NmMessageEnvelope::setSender(const NmAddress &sender)
 {
+    NM_FUNCTION;
+    
     d->mSender = sender;
 }
 
@@ -229,6 +273,8 @@
  */
 NmAddress NmMessageEnvelope::sender() const
 {
+    NM_FUNCTION;
+    
     return d->mSender;
 }
 
@@ -237,6 +283,8 @@
  */
 void NmMessageEnvelope::setSentTime(const QDateTime &sentTime)
 {
+    NM_FUNCTION;
+    
     d->mSentTime = sentTime;
 }
 
@@ -245,6 +293,8 @@
  */
 QDateTime NmMessageEnvelope::sentTime() const
 {
+    NM_FUNCTION;
+    
     return d->mSentTime;
 }
 
@@ -253,6 +303,8 @@
  */
 void NmMessageEnvelope::setHasAttachments(bool hasAttachments)
 {
+    NM_FUNCTION;
+    
     d->setFlag(NmMessageFlagAttachments, hasAttachments);
 }
 
@@ -261,6 +313,8 @@
  */
 bool NmMessageEnvelope::hasAttachments() const
 {
+    NM_FUNCTION;
+    
     return d->isFlagSet(NmMessageFlagAttachments);
 }
 
@@ -269,6 +323,8 @@
  */
 void NmMessageEnvelope::setRead(bool read)
 {
+    NM_FUNCTION;
+    
     d->setFlag(NmMessageFlagRead, read);
 }
 
@@ -277,6 +333,8 @@
  */
 bool NmMessageEnvelope::isRead() const
 {
+    NM_FUNCTION;
+    
     return d->isFlagSet(NmMessageFlagRead);
 }
 
@@ -285,6 +343,8 @@
  */
 void NmMessageEnvelope::setReplied(bool replyed)
 {
+    NM_FUNCTION;
+    
     d->setFlag(NmMessageFlagAnswered, replyed);
 }
 
@@ -293,6 +353,8 @@
  */
 bool NmMessageEnvelope::isReplied() const
 {
+    NM_FUNCTION;
+    
     return d->isFlagSet(NmMessageFlagAnswered);
 }
 
@@ -301,6 +363,8 @@
  */
 void NmMessageEnvelope::setForwarded(bool forwarded)
 {
+    NM_FUNCTION;
+    
     d->setFlag(NmMessageFlagForwarded, forwarded);
 }
 
@@ -309,6 +373,8 @@
  */
 bool NmMessageEnvelope::isForwarded() const
 {
+    NM_FUNCTION;
+    
     return d->isFlagSet(NmMessageFlagForwarded);
 }
 
@@ -317,6 +383,8 @@
  */
 void NmMessageEnvelope::setPriority(NmMessagePriority priority)
 {
+    NM_FUNCTION;
+    
     if (priority == NmMessagePriorityLow) {
         d->setFlag(NmMessageFlagLow, true);
         d->setFlag(NmMessageFlagImportant, false);
@@ -336,6 +404,8 @@
  */
 NmMessagePriority NmMessageEnvelope::priority() const
 {
+    NM_FUNCTION;
+    
     NmMessagePriority ret = NmMessagePriorityNormal;
     if (d->isFlagSet(NmMessageFlagImportant)) {
         ret = NmMessagePriorityHigh;
@@ -351,6 +421,8 @@
  */
 NmMessageFlags NmMessageEnvelope::flags() const
 {
+    NM_FUNCTION;
+    
     return d->flags();
 }
 
@@ -359,6 +431,8 @@
  */
 QList<NmAddress>& NmMessageEnvelope::toRecipients() const
 {
+    NM_FUNCTION;
+    
     return d->mToRecipients;
 }
 
@@ -367,6 +441,8 @@
  */
 void NmMessageEnvelope::setToRecipients(QList<NmAddress> toRecipients)
 {
+    NM_FUNCTION;
+    
     clearToRecipients();
     d->mToRecipients = toRecipients;
 }
@@ -376,6 +452,8 @@
  */
 void NmMessageEnvelope::clearToRecipients()
 {
+    NM_FUNCTION;
+    
     d->mToRecipients.clear();
 }
 
@@ -384,6 +462,8 @@
  */
 QList<NmAddress>& NmMessageEnvelope::ccRecipients() const
 {
+    NM_FUNCTION;
+    
     return d->mCcRecipients;
 }
 
@@ -392,6 +472,8 @@
  */
 void NmMessageEnvelope::setCcRecipients(QList<NmAddress> ccRecipients)
 {
+    NM_FUNCTION;
+    
     clearCcRecipients();
     d->mCcRecipients = ccRecipients;
 }
@@ -401,6 +483,8 @@
  */
 void NmMessageEnvelope::clearCcRecipients()
 {
+    NM_FUNCTION;
+    
     d->mCcRecipients.clear();
 }
 
@@ -409,6 +493,8 @@
  */
 QList<NmAddress>& NmMessageEnvelope::bccRecipients() const
 {
+    NM_FUNCTION;
+    
     return d->mBccRecipients;
 }
 
@@ -417,6 +503,8 @@
  */
 void NmMessageEnvelope::setBccRecipients(QList<NmAddress> bccRecipients)
 {
+    NM_FUNCTION;
+    
     clearBccRecipients();
     d->mBccRecipients = bccRecipients;
 }
@@ -426,6 +514,8 @@
  */
 void NmMessageEnvelope::clearBccRecipients()
 {
+    NM_FUNCTION;
+    
     d->mBccRecipients.clear();
 }
 
--- a/emailservices/nmailbase/src/nmmessagepart.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmailbase/src/nmmessagepart.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
 *
 */
 
+#include "emailtrace.h"
+
 #include "nmmessagepart.h"
 #include "nmmessageenvelope.h"
 
@@ -24,8 +26,9 @@
  */
 NmMessagePartPrivate::NmMessagePartPrivate()
 		: mPartId(0), mSize(0), mFetchedSize(0),
-		mTextContent(0)
+		mTextContent()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -33,6 +36,7 @@
  */
 NmMessagePartPrivate::~NmMessagePartPrivate() 
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -41,6 +45,8 @@
  */
 bool NmMessagePartPrivate::isMessage() const
 {
+    NM_FUNCTION;
+    
     bool isMessage = false;
     if (!mContentType.isEmpty()) {
 		if (mContentType.contains(NmContentTypeTypeMessage, Qt::CaseInsensitive)) {
@@ -56,6 +62,8 @@
  */
 bool NmMessagePartPrivate::isTextContent() const
 {
+    NM_FUNCTION;
+    
 	bool isText = false;
 	if (!mContentType.isEmpty()) {
 		if (mContentType.contains(NmContentTypeTextPlain, Qt::CaseInsensitive) ||
@@ -77,6 +85,8 @@
  */
 NmMessagePart::NmMessagePart()
 {
+    NM_FUNCTION;
+    
     d = new NmMessagePartPrivate();
 }
 
@@ -85,6 +95,8 @@
  */
 NmMessagePart::NmMessagePart(const NmId &partId)
 {
+    NM_FUNCTION;
+    
     d = new NmMessagePartPrivate();
     d->mPartId = partId;
 }
@@ -95,6 +107,8 @@
 NmMessagePart::NmMessagePart(
         QExplicitlySharedDataPointer<NmMessagePartPrivate> nmPrivateMessagePart)
 {
+    NM_FUNCTION;
+    
 	d = nmPrivateMessagePart;
 }
 
@@ -103,6 +117,7 @@
  */
 NmMessagePart::NmMessagePart(const NmMessagePart &part) : d(part.d)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -110,6 +125,8 @@
  */
 NmMessagePart &NmMessagePart::operator=(const NmMessagePart &part)
 {
+    NM_FUNCTION;
+    
 	if (this != &part) {
 		d = part.d;
 	}
@@ -121,6 +138,8 @@
  */
 NmMessagePart::~NmMessagePart()
 {
+    NM_FUNCTION;
+    
 	for (int i = 0; i < d->mChildParts.count(); i++) {
 		delete d->mChildParts[i];
 	}
@@ -132,6 +151,8 @@
  */
 NmId NmMessagePart::partId() const
 {
+    NM_FUNCTION;
+    
     return d->mPartId;
 }
 
@@ -140,6 +161,8 @@
  */
 void NmMessagePart::setPartId(const NmId &id)
 {
+    NM_FUNCTION;
+    
     d->mPartId = id;
 }
 
@@ -148,6 +171,8 @@
  */
 quint32 NmMessagePart::size() const
 {
+    NM_FUNCTION;
+    
     return d->mSize;
 }
 
@@ -156,6 +181,8 @@
  */
 void NmMessagePart::setSize(quint32 size)
 {
+    NM_FUNCTION;
+    
     d->mSize = size;
 }
 
@@ -164,6 +191,8 @@
  */
 quint32 NmMessagePart::fetchedSize() const
 {
+    NM_FUNCTION;
+    
     return d->mFetchedSize;
 }
 
@@ -172,6 +201,8 @@
  */
 void NmMessagePart::setFetchedSize(quint32 fetchedSize)
 {
+    NM_FUNCTION;
+    
     d->mFetchedSize = fetchedSize;
 }
 
@@ -180,6 +211,8 @@
  */
 bool NmMessagePart::isMessage() const
 {
+    NM_FUNCTION;
+    
 	return d->isMessage();
 }
 
@@ -191,6 +224,8 @@
     const QString &content,
     const QString &contentType)
 {
+    NM_FUNCTION;
+    
     d->mTextContent = content;
     d->mContentType = contentType;
     d->mBinaryContent.clear();
@@ -201,6 +236,8 @@
  */
 const QString &NmMessagePart::textContent() const
 {
+    NM_FUNCTION;
+    
     return d->mTextContent;
 }
 
@@ -210,6 +247,8 @@
  */
 void NmMessagePart::setContentType(const QString &contentType)
 {
+    NM_FUNCTION;
+    
     d->mContentType = contentType;
 }
 
@@ -218,6 +257,8 @@
  */
 QString NmMessagePart::contentType() const
 {
+    NM_FUNCTION;
+    
     return d->mContentType;
 }
 
@@ -226,6 +267,8 @@
  */
 void NmMessagePart::setContentDescription(const QString &contentDescription)
 {
+    NM_FUNCTION;
+    
     d->mContentDescription = contentDescription;
 }
 
@@ -234,6 +277,8 @@
  */
 QString NmMessagePart::contentDescription() const
 {
+    NM_FUNCTION;
+    
     return d->mContentDescription;
 }
 
@@ -242,6 +287,8 @@
  */
 void NmMessagePart::setContentDisposition(const QString &contentDisposition)
 {
+    NM_FUNCTION;
+    
     d->mContentDisposition = contentDisposition;
 }
 
@@ -250,6 +297,8 @@
  */
 QString NmMessagePart::contentDisposition() const
 {
+    NM_FUNCTION;
+    
     return d->mContentDisposition;
 }
 
@@ -258,6 +307,8 @@
  */
 void NmMessagePart::setContentId(const QString &contentId)
 {
+    NM_FUNCTION;
+    
     d->mContentId = contentId;
 }
 
@@ -266,6 +317,8 @@
  */
 QString NmMessagePart::contentId()
 {
+    NM_FUNCTION;
+    
     return d->mContentId;
 }
 
@@ -275,7 +328,8 @@
  */
 void NmMessagePart::setChildParts(QList<NmMessagePart*> parts)
 {
-
+    NM_FUNCTION;
+    
     if (d->mChildParts.count() > 0) {
         for (int i = 0; i < d->mChildParts.count(); i++) {
             delete d->mChildParts[i];
@@ -295,6 +349,8 @@
  */
 QList<NmMessagePart*>& NmMessagePart::childParts() const
 {
+    NM_FUNCTION;
+    
     return d->mChildParts;
 }
 
@@ -305,6 +361,8 @@
  */
 void NmMessagePart::addChildPart(NmMessagePart *part)
 {
+    NM_FUNCTION;
+    
     if (!part) {
         return;
     }
@@ -317,6 +375,8 @@
  */
 void NmMessagePart::removeChildPart(const NmId &partId)
 {
+    NM_FUNCTION;
+    
     for (int i = 0; i < d->mChildParts.count(); i++) {
         if (d->mChildParts[i]->partId() == partId) {
             delete d->mChildParts[i];
@@ -331,6 +391,8 @@
  */
 void NmMessagePart::removeAllChildParts()
 {
+    NM_FUNCTION;
+    
     while (!d->mChildParts.isEmpty()) {
         delete d->mChildParts.takeFirst();
     }
@@ -343,6 +405,8 @@
     const QByteArray &content,
     const QString &contentType)
 {
+    NM_FUNCTION;
+    
     d->mBinaryContent = content;
     d->mContentType = contentType;
     d->mTextContent.clear();
@@ -353,6 +417,8 @@
  */
 const QByteArray &NmMessagePart::binaryContent() const
 {
+    NM_FUNCTION;
+    
     return d->mBinaryContent;
 }
 
@@ -364,6 +430,8 @@
    */      
 void NmMessagePart::setAttachmentName(const QString &filePath)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(filePath);
 }
 
@@ -373,6 +441,8 @@
  */
 QString NmMessagePart::attachmentName() const
 {
+    NM_FUNCTION;
+    
     // Look first from Content-Type param "name"
     QString content = contentType();
     int ptr = content.indexOf(NmContentTypeParamName);
@@ -400,6 +470,8 @@
  */
 const NmMessagePart *NmMessagePart::findContentPart(const QString &contentType) const
 {
+    NM_FUNCTION;
+    
     const NmMessagePart *ret = NULL;
 
     if (!d->mContentType.isEmpty() && d->mContentType.startsWith(contentType)) {
@@ -417,6 +489,8 @@
  */
 NmMessagePart *NmMessagePart::findContentPart(const QString &contentType)
 {
+    NM_FUNCTION;
+    
     NmMessagePart *ret = NULL;
 
     if (!d->mContentType.isEmpty() && d->mContentType.startsWith(contentType)) {
@@ -436,6 +510,8 @@
  */
 void NmMessagePart::appendAttachments(QList<NmMessagePart*> &attachments) const
 {
+    NM_FUNCTION;
+    
     QList<NmMessagePart*> messageParts = childParts();
 
     int messagePartCount = messageParts.count();
--- a/emailservices/nmclientapi/bwins/nmailclientapiu.def	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/bwins/nmailclientapiu.def	Thu Jul 22 16:30:28 2010 +0100
@@ -187,4 +187,59 @@
 	?setParentFolderId@NmApiFolder@EmailClientApi@@QAEX_K@Z @ 186 NONAME ; void EmailClientApi::NmApiFolder::setParentFolderId(unsigned long long)
 	?start@NmApiFolderListing@EmailClientApi@@UAE_NXZ @ 187 NONAME ; bool EmailClientApi::NmApiFolderListing::start(void)
 	?cancel@NmApiFolderListing@EmailClientApi@@UAEXXZ @ 188 NONAME ; void EmailClientApi::NmApiFolderListing::cancel(void)
+	?metaObject@NmApiMessageManager@EmailClientApi@@UBEPBUQMetaObject@@XZ @ 189 NONAME ; struct QMetaObject const * EmailClientApi::NmApiMessageManager::metaObject(void) const
+	?tr@NmApiMessageManager@EmailClientApi@@SA?AVQString@@PBD0H@Z @ 190 NONAME ; class QString EmailClientApi::NmApiMessageManager::tr(char const *, char const *, int)
+	?createReplyMessage@NmApiMessageManager@EmailClientApi@@QAE_NPBVQVariant@@_N@Z @ 191 NONAME ; bool EmailClientApi::NmApiMessageManager::createReplyMessage(class QVariant const *, bool)
+	?saveMessage@NmApiMessageManager@EmailClientApi@@QAE_NABUNmApiMessage@@@Z @ 192 NONAME ; bool EmailClientApi::NmApiMessageManager::saveMessage(struct NmApiMessage const &)
+	?messagesCopied@NmApiMessageManager@EmailClientApi@@IAEXH@Z @ 193 NONAME ; void EmailClientApi::NmApiMessageManager::messagesCopied(int)
+	??_ENmApiMessageManager@EmailClientApi@@UAE@I@Z @ 194 NONAME ; EmailClientApi::NmApiMessageManager::~NmApiMessageManager(unsigned int)
+	?tr@NmApiMailboxSettings@EmailClientApi@@SA?AVQString@@PBD0H@Z @ 195 NONAME ; class QString EmailClientApi::NmApiMailboxSettings::tr(char const *, char const *, int)
+	?loadSettings@NmApiMailboxSettings@EmailClientApi@@QAE_N_KAAVNmApiMailboxSettingsData@2@@Z @ 196 NONAME ; bool EmailClientApi::NmApiMailboxSettings::loadSettings(unsigned long long, class EmailClientApi::NmApiMailboxSettingsData &)
+	?removeAttachment@NmApiMessageManager@EmailClientApi@@QAE_NAAVNmApiEmailMessage@@_K@Z @ 197 NONAME ; bool EmailClientApi::NmApiMessageManager::removeAttachment(class NmApiEmailMessage &, unsigned long long)
+	?copyMessages@NmApiMessageManager@EmailClientApi@@QAE_NV?$QList@_K@@_K1@Z @ 198 NONAME ; bool EmailClientApi::NmApiMessageManager::copyMessages(class QList<unsigned long long>, unsigned long long, unsigned long long)
+	??1NmApiMessageManager@EmailClientApi@@UAE@XZ @ 199 NONAME ; EmailClientApi::NmApiMessageManager::~NmApiMessageManager(void)
+	?tr@NmApiMessageManager@EmailClientApi@@SA?AVQString@@PBD0@Z @ 200 NONAME ; class QString EmailClientApi::NmApiMessageManager::tr(char const *, char const *)
+	?listSettings@NmApiMailboxSettingsData@EmailClientApi@@QBE?AV?$QList@H@@XZ @ 201 NONAME ; class QList<int> EmailClientApi::NmApiMailboxSettingsData::listSettings(void) const
+	?trUtf8@NmApiMessageManager@EmailClientApi@@SA?AVQString@@PBD0@Z @ 202 NONAME ; class QString EmailClientApi::NmApiMessageManager::trUtf8(char const *, char const *)
+	?mailboxDeleted@NmApiMailboxSettings@EmailClientApi@@IAEXH@Z @ 203 NONAME ; void EmailClientApi::NmApiMailboxSettings::mailboxDeleted(int)
+	?staticMetaObject@NmApiMailboxSettings@EmailClientApi@@2UQMetaObject@@B @ 204 NONAME ; struct QMetaObject const EmailClientApi::NmApiMailboxSettings::staticMetaObject
+	?messagesDeleted@NmApiMessageManager@EmailClientApi@@IAEXH@Z @ 205 NONAME ; void EmailClientApi::NmApiMessageManager::messagesDeleted(int)
+	??0NmApiMailboxSettingsData@EmailClientApi@@QAE@XZ @ 206 NONAME ; EmailClientApi::NmApiMailboxSettingsData::NmApiMailboxSettingsData(void)
+	?trUtf8@NmApiMessageManager@EmailClientApi@@SA?AVQString@@PBD0H@Z @ 207 NONAME ; class QString EmailClientApi::NmApiMessageManager::trUtf8(char const *, char const *, int)
+	?metaObject@NmApiMailboxSettings@EmailClientApi@@UBEPBUQMetaObject@@XZ @ 208 NONAME ; struct QMetaObject const * EmailClientApi::NmApiMailboxSettings::metaObject(void) const
+	?messagesMoved@NmApiMessageManager@EmailClientApi@@IAEXH@Z @ 209 NONAME ; void EmailClientApi::NmApiMessageManager::messagesMoved(int)
+	?saveSettings@NmApiMailboxSettings@EmailClientApi@@QAE_NABVNmApiMailboxSettingsData@2@@Z @ 210 NONAME ; bool EmailClientApi::NmApiMailboxSettings::saveSettings(class EmailClientApi::NmApiMailboxSettingsData const &)
+	?fetch@NmApiMessageManager@EmailClientApi@@QAE_NABUNmApiMessage@@@Z @ 211 NONAME ; bool EmailClientApi::NmApiMessageManager::fetch(struct NmApiMessage const &)
+	?createMailbox@NmApiMailboxSettings@EmailClientApi@@QAE_NABVQString@@AAVNmApiMailboxSettingsData@2@@Z @ 212 NONAME ; bool EmailClientApi::NmApiMailboxSettings::createMailbox(class QString const &, class EmailClientApi::NmApiMailboxSettingsData &)
+	?qt_metacast@NmApiMessageManager@EmailClientApi@@UAEPAXPBD@Z @ 213 NONAME ; void * EmailClientApi::NmApiMessageManager::qt_metacast(char const *)
+	??0NmApiMessageManager@EmailClientApi@@QAE@_KPAVQObject@@@Z @ 214 NONAME ; EmailClientApi::NmApiMessageManager::NmApiMessageManager(unsigned long long, class QObject *)
+	?getValue@NmApiMailboxSettingsData@EmailClientApi@@QBE_NHAAVQVariant@@@Z @ 215 NONAME ; bool EmailClientApi::NmApiMailboxSettingsData::getValue(int, class QVariant &) const
+	?tr@NmApiMailboxSettings@EmailClientApi@@SA?AVQString@@PBD0@Z @ 216 NONAME ; class QString EmailClientApi::NmApiMailboxSettings::tr(char const *, char const *)
+	?moveMessages@NmApiMessageManager@EmailClientApi@@QAE_NV?$QList@_K@@_K1@Z @ 217 NONAME ; bool EmailClientApi::NmApiMessageManager::moveMessages(class QList<unsigned long long>, unsigned long long, unsigned long long)
+	??1NmApiMailboxSettingsData@EmailClientApi@@QAE@XZ @ 218 NONAME ; EmailClientApi::NmApiMailboxSettingsData::~NmApiMailboxSettingsData(void)
+	?validateData@NmApiMailboxSettingsData@EmailClientApi@@QBE_NXZ @ 219 NONAME ; bool EmailClientApi::NmApiMailboxSettingsData::validateData(void) const
+	?trUtf8@NmApiMailboxSettings@EmailClientApi@@SA?AVQString@@PBD0H@Z @ 220 NONAME ; class QString EmailClientApi::NmApiMailboxSettings::trUtf8(char const *, char const *, int)
+	?createForwardMessage@NmApiMessageManager@EmailClientApi@@QAE_NPBVQVariant@@@Z @ 221 NONAME ; bool EmailClientApi::NmApiMessageManager::createForwardMessage(class QVariant const *)
+	?listMailboxIds@NmApiMailboxSettings@EmailClientApi@@QAE_NAAV?$QList@_K@@@Z @ 222 NONAME ; bool EmailClientApi::NmApiMailboxSettings::listMailboxIds(class QList<unsigned long long> &)
+	??_ENmApiMailboxSettings@EmailClientApi@@UAE@I@Z @ 223 NONAME ; EmailClientApi::NmApiMailboxSettings::~NmApiMailboxSettings(unsigned int)
+	?getStaticMetaObject@NmApiMailboxSettings@EmailClientApi@@SAABUQMetaObject@@XZ @ 224 NONAME ; struct QMetaObject const & EmailClientApi::NmApiMailboxSettings::getStaticMetaObject(void)
+	?deleteMessages@NmApiMessageManager@EmailClientApi@@QAE_NV?$QList@_K@@@Z @ 225 NONAME ; bool EmailClientApi::NmApiMessageManager::deleteMessages(class QList<unsigned long long>)
+	?createDraftMessage@NmApiMessageManager@EmailClientApi@@QAE_NPBVQVariant@@@Z @ 226 NONAME ; bool EmailClientApi::NmApiMessageManager::createDraftMessage(class QVariant const *)
+	??0NmApiMailboxSettings@EmailClientApi@@QAE@PAVQObject@@@Z @ 227 NONAME ; EmailClientApi::NmApiMailboxSettings::NmApiMailboxSettings(class QObject *)
+	?qt_metacast@NmApiMailboxSettings@EmailClientApi@@UAEPAXPBD@Z @ 228 NONAME ; void * EmailClientApi::NmApiMailboxSettings::qt_metacast(char const *)
+	?qt_metacall@NmApiMessageManager@EmailClientApi@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 229 NONAME ; int EmailClientApi::NmApiMessageManager::qt_metacall(enum QMetaObject::Call, int, void * *)
+	??1NmApiMailboxSettings@EmailClientApi@@UAE@XZ @ 230 NONAME ; EmailClientApi::NmApiMailboxSettings::~NmApiMailboxSettings(void)
+	?deleteMailbox@NmApiMailboxSettings@EmailClientApi@@QAE_N_K@Z @ 231 NONAME ; bool EmailClientApi::NmApiMailboxSettings::deleteMailbox(unsigned long long)
+	?send@NmApiMessageManager@EmailClientApi@@QAE_NABUNmApiMessage@@@Z @ 232 NONAME ; bool EmailClientApi::NmApiMessageManager::send(struct NmApiMessage const &)
+	?trUtf8@NmApiMailboxSettings@EmailClientApi@@SA?AVQString@@PBD0@Z @ 233 NONAME ; class QString EmailClientApi::NmApiMailboxSettings::trUtf8(char const *, char const *)
+	?createAttachment@NmApiMessageManager@EmailClientApi@@QAE_NAAVNmApiEmailMessage@@ABVQVariant@@@Z @ 234 NONAME ; bool EmailClientApi::NmApiMessageManager::createAttachment(class NmApiEmailMessage &, class QVariant const &)
+	?messagesCreated@NmApiMessageManager@EmailClientApi@@IAEXH@Z @ 235 NONAME ; void EmailClientApi::NmApiMessageManager::messagesCreated(int)
+	?setMailboxId@NmApiMailboxSettingsData@EmailClientApi@@QAEX_K@Z @ 236 NONAME ; void EmailClientApi::NmApiMailboxSettingsData::setMailboxId(unsigned long long)
+	?populateDefaultSettings@NmApiMailboxSettings@EmailClientApi@@QAE_NABVQString@@AAVNmApiMailboxSettingsData@2@@Z @ 237 NONAME ; bool EmailClientApi::NmApiMailboxSettings::populateDefaultSettings(class QString const &, class EmailClientApi::NmApiMailboxSettingsData &)
+	?clearSettings@NmApiMailboxSettingsData@EmailClientApi@@QAEXXZ @ 238 NONAME ; void EmailClientApi::NmApiMailboxSettingsData::clearSettings(void)
+	?setValue@NmApiMailboxSettingsData@EmailClientApi@@QAEXHABVQVariant@@@Z @ 239 NONAME ; void EmailClientApi::NmApiMailboxSettingsData::setValue(int, class QVariant const &)
+	?mailboxId@NmApiMailboxSettingsData@EmailClientApi@@QBE_KXZ @ 240 NONAME ; unsigned long long EmailClientApi::NmApiMailboxSettingsData::mailboxId(void) const
+	?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 * *)
 
--- a/emailservices/nmclientapi/eabi/nmailclientapiu.def	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/eabi/nmailclientapiu.def	Thu Jul 22 16:30:28 2010 +0100
@@ -211,4 +211,61 @@
 	_ZTVN14EmailClientApi19NmApiMailboxListingE @ 210 NONAME
 	_ZTVN14EmailClientApi20NmApiEnvelopeListingE @ 211 NONAME
 	_ZTVN14EmailClientApi20NmApiMessageEnvelopeE @ 212 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager11qt_metacallEN11QMetaObject4CallEiPPv @ 213 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager11qt_metacastEPKc @ 214 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager11saveMessageERK12NmApiMessage @ 215 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager12copyMessagesE5QListIyEyy @ 216 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager12moveMessagesE5QListIyEyy @ 217 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager13messagesMovedEi @ 218 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager14deleteMessagesE5QListIyE @ 219 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager14messagesCopiedEi @ 220 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager15messagesCreatedEi @ 221 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager15messagesDeletedEi @ 222 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager16createAttachmentER17NmApiEmailMessageRK8QVariant @ 223 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager16removeAttachmentER17NmApiEmailMessagey @ 224 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager16staticMetaObjectE @ 225 NONAME DATA 16
+	_ZN14EmailClientApi19NmApiMessageManager18createDraftMessageEPK8QVariant @ 226 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager18createReplyMessageEPK8QVariantb @ 227 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager19getStaticMetaObjectEv @ 228 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager20createForwardMessageEPK8QVariant @ 229 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager4sendERK12NmApiMessage @ 230 NONAME
+	_ZN14EmailClientApi19NmApiMessageManager5fetchERK12NmApiMessage @ 231 NONAME
+	_ZN14EmailClientApi19NmApiMessageManagerC1EyP7QObject @ 232 NONAME
+	_ZN14EmailClientApi19NmApiMessageManagerC2EyP7QObject @ 233 NONAME
+	_ZN14EmailClientApi19NmApiMessageManagerD0Ev @ 234 NONAME
+	_ZN14EmailClientApi19NmApiMessageManagerD1Ev @ 235 NONAME
+	_ZN14EmailClientApi19NmApiMessageManagerD2Ev @ 236 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettings11qt_metacallEN11QMetaObject4CallEiPPv @ 237 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettings11qt_metacastEPKc @ 238 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettings12loadSettingsEyRNS_24NmApiMailboxSettingsDataE @ 239 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettings12saveSettingsERKNS_24NmApiMailboxSettingsDataE @ 240 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettings13createMailboxERK7QStringRNS_24NmApiMailboxSettingsDataE @ 241 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettings13deleteMailboxEy @ 242 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettings14listMailboxIdsER5QListIyE @ 243 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettings14mailboxDeletedEi @ 244 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettings16staticMetaObjectE @ 245 NONAME DATA 16
+	_ZN14EmailClientApi20NmApiMailboxSettings19getStaticMetaObjectEv @ 246 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettings23populateDefaultSettingsERK7QStringRNS_24NmApiMailboxSettingsDataE @ 247 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettingsC1EP7QObject @ 248 NONAME
+	_ZN14EmailClientApi20NmApiMailboxSettingsC2EP7QObject @ 249 NONAME
+	_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
 
--- a/emailservices/nmclientapi/inc/nmapicommonheader.h	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * 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:
- *
- */
-
-#ifndef NMAPICOMMONHEADER_H
-#define NMAPICOMMONHEADER_H
-
-#include <nmapiemailaddress.h>
-#include <nmapimessagebody.h>
-#include <nmapidef.h>
-#include <nmapimailbox.h>
-#include <nmapifolder.h>
-#include <nmapimessageenvelope.h>
-
-#endif /* NMAPICOMMONHEADER_H */
--- a/emailservices/nmclientapi/inc/nmapienvelopelisting_p.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/inc/nmapienvelopelisting_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -29,20 +29,21 @@
 
 class NmApiEnvelopeListingPrivate : public QObject
 {
+    Q_OBJECT
+    
 public:
-
-    NmApiEnvelopeListingPrivate(QObject *parent = 0);
+    NmApiEnvelopeListingPrivate(const quint64 folderId, const quint64 mailboxId, QObject *parent = 0);
     virtual ~NmApiEnvelopeListingPrivate();
+    bool envelopes(QList<EmailClientApi::NmApiMessageEnvelope> &envelopes);
+    qint32 listEnvelopes();
+    bool isRunning() const;
+    void cancel();
 
-    bool initializeEngine();
-    void releaseEngine();
-    qint32 grabEnvelopes();
-
+private:
+    quint64 mFolderId;
+    quint64 mMailboxId;
     bool mIsRunning;
-    quint64 folderId;
-    quint64 mailboxId;
     NmApiEngine *mEngine;
-
     QList<EmailClientApi::NmApiMessageEnvelope> mEnvelopes;
 };
 }
--- a/emailservices/nmclientapi/inc/nmapieventnotifier_p.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/inc/nmapieventnotifier_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -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"
@@ -18,6 +18,7 @@
 #ifndef NMAPIEVENTNOTIFIERPRIVATE_H
 #define NMAPIEVENTNOTIFIERPRIVATE_H
 
+#include <QObject>
 #include "nmapiprivateclasses.h"
 #include <nmapicommon.h>
 
@@ -34,18 +35,22 @@
     NmApiEventNotifierPrivate(QObject *parent = 0);
     virtual ~NmApiEventNotifierPrivate();
 
-    bool initializeEngine();
-    void releaseEngine();
     void cancel();
-
+    bool isRunning() const;
+    bool start();
+    void stop();
+    void events(QList<NmApiMessage> &events);
 public slots:
     void emailStoreEvent(const NmApiMessage &events);
 
-public:
+signals:
+    void timedOut();
+
+private:
     QTimer *mEmitSignals;
     NmApiEngine *mEngine;
+    bool mIsRunning;
     QList<NmApiMessage> mBufferOfEvents;
-    bool mIsRunning;
 };
 
 }
--- a/emailservices/nmclientapi/inc/nmapifolder_p.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/inc/nmapifolder_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -15,8 +15,8 @@
  *
  */
 
-#ifndef NMAPIMAILBOX_P_H
-#define NMAPIMAILBOX_P_H
+#ifndef NMAPIFOLDER_P_H
+#define NMAPIFOLDER_P_H
 
 #include <nmapicommon.h>
 
@@ -45,4 +45,4 @@
 
 }
 
-#endif /* NMAPIMAILBOX_P_H_ */
+#endif /* NMAPIFOLDER_P_H */
--- a/emailservices/nmclientapi/inc/nmapifolderlisting_p.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/inc/nmapifolderlisting_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -17,6 +17,8 @@
 #ifndef NMAPIFOLDERLISTINGPRIVATE_H
 #define NMAPIFOLDERLISTINGPRIVATE_H
 
+#include <QObject>
+
 class NmApiEngine;
 
 namespace EmailClientApi
@@ -26,19 +28,21 @@
 
 class NmApiFolderListingPrivate : public QObject
 {
+    Q_OBJECT
+    
 public:
 
-    NmApiFolderListingPrivate(QObject *parent = 0);
+    NmApiFolderListingPrivate(quint64 mailboxId, QObject *parent = 0);
     virtual ~NmApiFolderListingPrivate();
-
-    bool initializeEngine();
-    void releaseEngine();
-    qint32 grabFolders();
-
-    QList<EmailClientApi::NmApiFolder> mFolders;//!<List of folders \sa getFolder \sa QSharedData \sa EmailClientApi::NmApiFolder
-    NmApiEngine *mEngine;//!<Pointer to engine instance \sa NmUiEngine
-    bool mIsRunning;//!<Keep info if folder listing is running \sa isRunning
-    quint64 mMailboxId;//!<Keep info about mailbox id for foler
+    qint32 listFolders();
+    bool folders(QList<EmailClientApi::NmApiFolder> &folders);
+    void cancel();
+    bool isRunning() const;
+private:
+	  quint64 mMailboxId;
+    NmApiEngine *mEngine;
+    bool mIsRunning;
+    QList<EmailClientApi::NmApiFolder> mFolders;
 };
 }
 #endif /* NMAPIFOLDERLISTINGPRIVATE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/inc/nmapiheaders.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,102 @@
+/*
+* 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: 
+*
+*/
+
+#ifndef NMAPIHEADERS_H
+#define NMAPIHEADERS_H
+
+// Qt
+#include <QObject>
+#include <QVariant>
+#include <QString>
+#include <QHash>
+#include <QList>
+#include <QPluginLoader>
+#include <QDir>
+#include <QApplication>
+#include <QLocale>
+#include <QList>
+#include <QTimer>
+#include <QDateTime>
+#include <QExplicitlySharedDataPointer>
+#include <QSharedData>
+
+#include <imapset.h>
+#include <pop3set.h>
+#include <iapprefs.h>
+#include <cemailaccounts.h>
+
+
+#include <SMTPSET.H>
+
+#include <xqconversions.h>
+
+#include <nmdataplugininterface.h>
+
+#include <nmmailbox.h>
+#include <nmmessage.h>
+#include <nmfolder.h>
+#include <nmmessagepart.h>
+#include <nmcommon.h>
+
+#include <nmoperation.h>
+
+#include <emailtrace.h>
+
+
+
+// nmail_settings_api
+#include <nmapimailboxsettings.h>
+#include <nmapimailboxsettingsdata.h>
+
+// nmail_client_api
+#include <nmapicommon.h>
+#include <nmapidef.h>
+#include <nmapiemailaddress.h>
+#include <nmapiemailservice.h>
+#include <nmapienvelopelisting.h>
+#include <nmapieventnotifier.h>
+#include <nmapifolder.h>
+#include <nmapifolderlisting.h>
+#include <nmapimailbox.h>
+#include <nmapimailboxlisting.h>
+#include <nmapimessagebody.h>
+#include <nmapimessageenvelope.h>
+#include <nmapimessagetask.h>
+#include <nmapimessagemanager.h>
+
+
+// own headers
+#include "nmapidatapluginfactory.h"
+#include "nmapiemailaddress_p.h"
+#include "nmapiengine.h"
+#include "nmapienvelopelisting_p.h"
+#include "nmapieventnotifier_p.h"
+#include "nmapifolder_p.h"
+#include "nmapifolderlisting_p.h"
+#include "nmapimailbox_p.h"
+#include "nmapimailboxlisting_p.h"
+#include "nmapimailboxsettings_p.h"
+#include "nmapimailboxsettingsdata_p.h"
+#include "nmapimessagebody_p.h"
+#include "nmapimessageenvelope_p.h"
+#include "nmapimessagemanager_p.h"
+#include "nmapipopimapsettingsmanager.h"
+#include "nmapiprivateclasses.h"
+#include "nmapitypesconverter.h"
+
+
+#endif // NMAPIHEADERS_H
--- a/emailservices/nmclientapi/inc/nmapimailbox_p.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/inc/nmapimailbox_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -18,8 +18,7 @@
 #ifndef NMAPIMAILBOX_P_H
 #define NMAPIMAILBOX_P_H
 
-#include <nmapicommon.h>
-
+#include <QSharedData>
 
 namespace EmailClientApi
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/inc/nmapimailboxsettings_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,61 @@
+/*
+ * 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 NMAPIMAILBOXSETTINGS_P_H_
+#define NMAPIMAILBOXSETTINGS_P_H_
+
+#include <QObject>
+#include <qpointer.h>
+#include <nmapimailboxsettings.h>
+#include <nmoperation.h>
+
+class NmApiDataPluginFactory;
+class NmOperation;
+
+namespace EmailClientApi
+{
+class NmApiMailboxSettingsData;
+
+class NmApiMailboxSettingsPrivate : public QObject
+{
+    Q_OBJECT
+public:
+    NmApiMailboxSettingsPrivate(QObject *parent = 0);
+    ~NmApiMailboxSettingsPrivate();
+
+    bool listMailboxIds(QList<quint64> &idList);
+    bool loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data);
+    bool saveSettings(const NmApiMailboxSettingsData &data);
+    bool createMailbox(const QString &mailboxType, NmApiMailboxSettingsData &data);
+    bool deleteMailbox(quint64 mailboxId);
+    bool populateDefaultSettings(const QString &mailboxType, NmApiMailboxSettingsData &data);
+
+signals:
+    void mailboxDeleted(int result = 0);
+    
+private:
+    void createPopImapMailbox(const QString &type, NmApiMailboxSettingsData &data);
+
+    
+private:
+    NmApiDataPluginFactory *mFactory;
+    QPointer<NmOperation> mDeleteMailboxOperation; // not owned
+};
+
+}
+
+#endif /* NMAPIMAILBOXSETTINGS_P_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/inc/nmapimailboxsettingsdata_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,63 @@
+/*
+ * 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 _NMAPI_MAILBOX_SETTINGS_DATA_PRIVATE_
+#define _NMAPI_MAILBOX_SETTINGS_DATA_PRIVATE_
+
+#include <QObject>
+#include <QScopedPointer>
+#include <QHash>
+
+namespace EmailClientApi
+{
+class NmApiMailboxSettingsDataPrivate
+{
+public:
+    NmApiMailboxSettingsDataPrivate();
+    virtual ~NmApiMailboxSettingsDataPrivate();
+    void setMailboxId(quint64 mailboxId);
+    quint64 mailboxId() const;
+    void setValue(int key, const QVariant &settingValue);
+    bool getValue(int key, QVariant &settingValue) const;
+    bool validateData() const;
+    QList<int> listSettings() const;
+	void clearSettings();
+    
+private:
+    bool validateString(int key, QVariant& val, bool& validated) const;
+    bool validateStringValue(int key, QString& val) const;
+    bool validateStringGeneral(int key, QString& val, bool& handled) const;
+    bool validateEmailAddress(int key, QString& val, bool& handled) const;
+    bool validateUsesAuthentication(int key, QString& val, bool& handled) const;
+    bool validateSecurityType(int key, QString& val, bool& handled) const;
+    bool validateAOLState(int key, QString& val, bool& handled) const;
+    bool validateInteger(int key, QVariant& val, bool& validated) const;
+    bool validateIntVal(int key, int val) const;
+    bool validateIntGeneral(int key, int val, bool& handled) const;
+    bool validateOnOffValue(int key, int val, bool& handled) const;
+    bool validateWeekdayMask(int key, int val, bool& handled) const;
+    bool validateHoursInDay(int key, int val, bool& handled) const;
+    bool validateBool(int key, QVariant& val, bool& validated) const;
+    bool validateDateTime(int key, QVariant& val, bool& validated) const;
+
+private:
+    quint64 mId;
+    QScopedPointer<QHash<int, QVariant> > mSettings;
+
+};
+}//end namespace
+
+#endif //_NMAPI_MAILBOX_SETTINGS_DATA_PRIVATE_
--- a/emailservices/nmclientapi/inc/nmapimessagebody_p.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/inc/nmapimessagebody_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -17,7 +17,7 @@
 #ifndef NMAPIMESSAGEBODY_P_H_
 #define NMAPIMESSAGEBODY_P_H_
 
-#include <QString>;
+#include <QString>
 
 namespace EmailClientApi
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/inc/nmapimessagemanager_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,82 @@
+/*
+ * 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:
+ *     Email message related operations
+ */
+
+#ifndef NMAPIMESSAGEMANAGER_P_H_
+#define NMAPIMESSAGEMANAGER_P_H_
+
+#include <QObject>
+#include <nmapimessagemanager.h>
+#include <nmapifolder.h>
+#include <NmApiDataPluginFactory.h>
+#include <nmcommon.h>
+#include <nmapifolder.h>
+#include <nmapiprivateclasses.h>
+
+
+class NmApiEmailMessage;
+
+namespace EmailClientApi
+{
+
+class NmApiMessageManagerPrivate : public QObject
+{
+ Q_OBJECT  
+public:
+    NmApiMessageManagerPrivate(quint64 mailboxId,QObject *parent = 0);
+    virtual ~NmApiMessageManagerPrivate();
+    
+private:
+    enum EState {
+        EIdle = 0,
+        ECopyPending,
+        EMovePending,
+        EDeletePending        
+    };
+    
+public slots: 
+    bool moveMessages(const QList<quint64> messageIds,
+                    quint64 sourceFolderId,
+                    quint64 targetFolderId);
+
+    bool copyMessages(const QList<quint64> messageIds, 
+                   quint64 sourceFolder,
+                   quint64 targetFolder);
+    
+	void messageEventHandler(NmMessageEvent event,
+								const NmId &folder,
+								const QList<NmId> &messages,
+								const NmId &mailBox);
+								
+signals:
+	void messagesCopied(int result);
+	void messagesCreated(int result);
+	void messagesMoved(int result);
+	void messagesDeleted(int result);
+
+
+private:    
+    NmApiMessageManagerPrivate::EState mState;
+    QList<quint64> mMessages;
+    NmId mTarget;
+    NmId mMailboxId; 
+    NmApiDataPluginFactory *mFactory;
+    QObject *mPlugin;
+};
+
+}
+
+#endif /*NMAPIMESSAGEMANAGER_P_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/inc/nmapipopimapsettingsmanager.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* 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 NMAPIPOPIMAPSETTINGSMANAGER_H
+#define NMAPIPOPIMAPSETTINGSMANAGER_H
+
+#include <nmapimailboxsettingsdata.h>
+
+namespace EmailClientApi {
+
+class NmApiPopImapSettingsManager 
+{
+public:       
+    NmApiPopImapSettingsManager();
+    virtual ~NmApiPopImapSettingsManager();
+    bool populateDefaults(const QString &mailboxType, NmApiMailboxSettingsData &data);
+
+private:
+    void populateImapDefs(NmApiMailboxSettingsData &data);
+    void populatePopDefs(NmApiMailboxSettingsData &data);
+    
+};
+}//namespace
+
+#endif // NMAPIPOPIMAPSETTINGSMANAGER_H
--- a/emailservices/nmclientapi/inc/nmapiprivateheaders.h	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
-* 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: 
-*
-*/
-
-#ifndef NMAPIPRIVATEHEADERS_H
-#define NMAPIPRIVATEHEADERS_H
-
-#include "nmmailbox.h"
-#include "nmmessage.h"
-#include "nmfolder.h"
-#include "nmmessagePart.h"
-
-#endif // NMAPIPRIVATEHEADERS_H
--- a/emailservices/nmclientapi/nmclientapi.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/nmclientapi.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -26,78 +26,80 @@
 
 INCLUDEPATH +=  inc \
                 ../../email_plat/nmail_client_api \
-                ../../inc 
+                ../../email_plat/nmail_settings_api \
+                ../../inc
                 
-DEPENDPATH += src \
-              inc \
-              ../../email_plat/nmail_client_api \
-              ../../inc 
+DEPENDPATH +=  ../../email_plat/nmail_client_api \
+                ../../email_plat/nmail_settings_api \
+
 
 MOC_DIR = tmp
 
+# public headers 
+HEADERS += nmapicommon.h \
+           nmapidef.h \
+           nmapiemailaddress.h \
+           nmapiemailservice.h \
+           nmapienvelopelisting.h \
+           nmapieventnotifier.h \
+           nmapifolder.h \
+           nmapifolderlisting.h \
+           nmapimailbox.h \
+           nmapimailboxlisting.h \
+           nmapimessagebody.h \
+           nmapimessageenvelope.h \
+           nmapimessagetask.h \
+           nmapimessagemanager.h \
+           nmapimailboxsettings.h
 
-#headers  and sources outside api
-HEADERS   += nmapiprivateheaders.h \
-             nmapitypesconverter.h \ 
-             nmapiprivateclasses.h \
-             nmdataplugininterface.h \
-             nmapidatapluginfactory.h \
-             nmapiengine.h \
-             nmmessagepart.h  \
-             nmapicommon.h
-             
-#headers  and sources from api             
-SOURCES   += nmapitypesconverter.cpp \
-             nmapidatapluginfactory.cpp \
-             nmapiemailservice.cpp \
-             nmapiengine.cpp 
+# private headers 
+HEADERS += inc/nmapidatapluginfactory.h \
+           inc/nmapiemailaddress_p.h \
+           inc/nmapiengine.h \
+           inc/nmapienvelopelisting_p.h \
+           inc/nmapieventnotifier_p.h \
+           inc/nmapifolder_p.h \
+           inc/nmapifolderlisting_p.h \
+           inc/nmapimailbox_p.h \
+           inc/nmapimailboxlisting_p.h \
+           inc/nmapimailboxsettings_p.h \
+           inc/nmapimailboxsettingsdata_p.h \
+           inc/nmapimessagebody_p.h \
+           inc/nmapimessageenvelope_p.h \
+           inc/nmapimessagemanager_p.h \
+           inc/nmapipopimapsettingsmanager.h \
+           inc/nmapiprivateclasses.h \
+           inc/nmapitypesconverter.h \
+           inc/nmapiheaders.h 
+                        
+SOURCES += src/nmapidatapluginfactory.cpp \
+           src/nmapiemailaddress.cpp \
+           src/nmapiemailservice.cpp \
+           src/nmapiengine.cpp \
+           src/nmapienvelopelisting_p.cpp \
+           src/nmapienvelopelisting.cpp \ 
+           src/nmapieventnotifier_p.cpp \
+           src/nmapieventnotifier.cpp \
+           src/nmapifolder.cpp \
+           src/nmapifolderlisting_p.cpp \
+           src/nmapifolderlisting.cpp \
+           src/nmapimailbox.cpp \
+           src/nmapimailboxlisting_p.cpp \
+           src/nmapimailboxlisting.cpp \
+           src/nmapimessagetask.cpp \
+           src/nmapimailboxsettingsdata_p.cpp \
+           src/nmapimailboxsettingsdata.cpp \
+           src/nmapimailboxsettings_p.cpp \
+           src/nmapimailboxsettings.cpp \
+           src/nmapimessagebody.cpp \
+           src/nmapimessageenvelope.cpp \
+           src/nmapipopimapsettingsmanager.cpp \
+	         src/nmapimessagemanager_p.cpp \
+			     src/nmapimessagemanager.cpp \
+           src/nmapitypesconverter.cpp 
 
 
 
-HEADERS   += nmapicommonheader.h \
-             nmapiemailservice.h \
-             nmapimessagetask.h \
-             nmapimailboxlisting_p.h \
-             nmapimailboxlisting.h \
-             nmapifolderlisting_p.h \
-             nmapifolderlisting.h \
-             nmapienvelopelisting_p.h \
-             nmapienvelopelisting.h \
-	     nmapiemailaddress_p.h \
-	     nmapiemailaddress.h \
-	     nmapieventnotifier_p.h \
-	     nmapieventnotifier.h \
-	     nmapifolder_p.h \
-	     nmapifolder.h \
-	     nmapimailbox_p.h \
-	     nmapimailbox.h \
-	     nmapimessagebody_p.h \
-	     nmapimessagebody.h \
-	     nmapimessageenvelope_p.h \
-	     nmapimessageenvelope.h
-			 
-LIBS += -leuser
-LIBS += -llibc			
-
-
-SOURCES   += nmapimessagetask.cpp \
-	     nmapimailboxlisting_p.cpp \
-             nmapimailboxlisting.cpp \
-             nmapifolderlisting_p.cpp \
-             nmapifolderlisting.cpp \
-             nmapienvelopelisting_p.cpp \
-             nmapienvelopelisting.cpp \ 
-	     nmapiemailaddress.cpp \
-	     nmapieventnotifier_p.cpp \
-	     nmapieventnotifier.cpp \
-	     nmapifolder.cpp \
-	     nmapimailbox.cpp \
-	     nmapimessagebody.cpp \
-	     nmapimessageenvelope.cpp
-
-
-             
-             
 
 symbian*: { 
     TARGET.EPOCALLOWDLLDATA = 1
@@ -107,8 +109,13 @@
     TARGET.UID3 = 0x2002C366
     
     INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
 	
-	 LIBS += -lnmailbase
+	 LIBS += -lnmailbase \
+	 -limcm \
+	 -lxqsettingsmanager \
+	 -lxqutils \
+	 -lnmailuiengine
 				   
     defBlock = \      
       "$${LITERAL_HASH}if defined(MARM)" \
@@ -125,10 +132,3 @@
 
 }
 
-win32 {
-   DESTDIR = ../../bin
-   OBJECTS_DIR = tmp 
-}
-
-
-
--- a/emailservices/nmclientapi/src/nmapidatapluginfactory.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapidatapluginfactory.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,23 +15,9 @@
  *
  */
 
-#include "nmdataplugininterface.h"
-#include "nmapidatapluginfactory.h"
+#include "nmapiheaders.h"
 
-// Qt
-#include <QPluginLoader>
-#include <QDir>
-#include <QApplication>
-#include <QLocale>
-#include <QObject>
 
-// nmailbase
-#include "nmcommon.h"
-#include "nmmailbox.h"
-#include "nmmessageenvelope.h"
-#include "nmmessage.h"
-#include "nmmessagepart.h"
-#include "nmfolder.h"
 
 /*!
  \class NmApiDataPluginFactory
@@ -48,7 +34,7 @@
  */
 NmApiDataPluginFactory::NmApiDataPluginFactory()
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -56,6 +42,8 @@
  */
 NmApiDataPluginFactory::~NmApiDataPluginFactory()
 {
+    NM_FUNCTION;
+    
     if (mPlugin) {
         delete mPlugin;
         mPlugin = NULL;
@@ -72,6 +60,8 @@
  */
 NmApiDataPluginFactory *NmApiDataPluginFactory::instance()
 {
+    NM_FUNCTION;
+    
     if (!mInstance) {
         mInstance = new NmApiDataPluginFactory();
     }
@@ -84,6 +74,8 @@
  */
 void NmApiDataPluginFactory::releaseInstance(NmApiDataPluginFactory *&instance)
 {
+    NM_FUNCTION;
+    
     //can't have passed out instances if we don't have any
     if (mInstance) {
         if (instance == mInstance) {
@@ -103,6 +95,8 @@
  */
 NmDataPluginInterface *NmApiDataPluginFactory::interfaceInstance()
 {
+    NM_FUNCTION;
+    
     if (!mPlugin) {
         mPlugin = loadPlugin();
     }
@@ -114,6 +108,8 @@
  */
 QObject *NmApiDataPluginFactory::loadPlugin()
 {
+    NM_FUNCTION;
+    
     if (!mPluginLoader) {
         const QString KPluginDirectory = "c:\\resource\\plugins";
         QDir pluginDir = QDir(KPluginDirectory);
@@ -135,6 +131,8 @@
 
 QObject *NmApiDataPluginFactory::plugin()
 {
+    NM_FUNCTION;
+    
     if (!mPlugin) {
         mPlugin = loadPlugin();
     }
--- a/emailservices/nmclientapi/src/nmapiemailaddress.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapiemailaddress.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,8 +15,8 @@
  *
  */
 
-#include <nmapiemailaddress.h>
-#include "nmapiemailaddress_p.h"
+#include "nmapiheaders.h"
+
 
 namespace EmailClientApi
 {
@@ -26,7 +26,7 @@
 NmApiEmailAddress::NmApiEmailAddress(const NmApiEmailAddress &envelope) :
     d(envelope.d)
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -34,6 +34,8 @@
  */
 NmApiEmailAddress::NmApiEmailAddress()
 {
+    NM_FUNCTION;
+    
     d = new NmApiEmailAddressPrivate();
 }
 
@@ -42,7 +44,7 @@
  */
 NmApiEmailAddress::~NmApiEmailAddress()
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -50,6 +52,8 @@
  */
 NmApiEmailAddress &NmApiEmailAddress::operator=(const NmApiEmailAddress &addr)
 {
+    NM_FUNCTION;
+    
     if (this != &addr) {
         d = addr.d;
     }
@@ -61,6 +65,8 @@
  */
 bool NmApiEmailAddress::operator==(const NmApiEmailAddress &addr)
 {
+    NM_FUNCTION;
+    
     bool retVal = false;
     if (this->d == addr.d) {
         retVal = true;
@@ -73,6 +79,8 @@
  */
 QString NmApiEmailAddress::displayName() const
 {
+    NM_FUNCTION;
+    
     return d->displayName;
 }
 
@@ -81,6 +89,8 @@
  */
 QString NmApiEmailAddress::address() const
 {
+    NM_FUNCTION;
+    
     return d->address;
 }
 
@@ -89,6 +99,8 @@
  */
 void NmApiEmailAddress::setDisplayName(const QString &displayName)
 {
+    NM_FUNCTION;
+    
     d->displayName = displayName;
 }
 
@@ -97,6 +109,8 @@
  */
 void NmApiEmailAddress::setAddress(const QString &address)
 {
+    NM_FUNCTION;
+    
     d->address = address;
 }
 }
--- a/emailservices/nmclientapi/src/nmapiemailservice.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapiemailservice.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,11 +15,8 @@
  *
  */
 
-#include <nmapiemailservice.h>
-#include "nmapiengine.h"
+#include "nmapiheaders.h"
 
-#include <nmapimailbox.h>
-#include <nmapimessageenvelope.h>
 
 namespace EmailClientApi
 {
@@ -30,7 +27,7 @@
 NmApiEmailService::NmApiEmailService(QObject *parent) :
     QObject(parent), mEngine(NULL), mIsRunning(false)
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -38,6 +35,8 @@
  */
 NmApiEmailService::~NmApiEmailService()
 {
+    NM_FUNCTION;
+    
     if (mEngine) {
         uninitialise();
     }
@@ -52,6 +51,8 @@
     const quint64 envelopeId,
     EmailClientApi::NmApiMessageEnvelope &envelope)
 {
+    NM_FUNCTION;
+    
     if (!mEngine) {
         return false;
     }
@@ -63,6 +64,8 @@
  */
 bool NmApiEmailService::getMailbox(const quint64 mailboxId, EmailClientApi::NmApiMailbox &mailboxInfo)
 {
+    NM_FUNCTION;
+    
     if (!mEngine) {
         return false;
     }
@@ -75,6 +78,8 @@
  */
 void NmApiEmailService::initialise()
 {
+    NM_FUNCTION;
+    
     if (!mEngine) {
         mEngine = NmApiEngine::instance();
     }
@@ -93,6 +98,8 @@
  */
 void NmApiEmailService::uninitialise()
 {
+    NM_FUNCTION;
+    
     NmApiEngine::releaseInstance(mEngine);
     mIsRunning = false;
 }
@@ -102,6 +109,8 @@
  */
 bool NmApiEmailService::isRunning() const
 {
+    NM_FUNCTION;
+    
     return mIsRunning;
 }
 
--- a/emailservices/nmclientapi/src/nmapiengine.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapiengine.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,18 +15,8 @@
  *
  */
 
-
-#include <nmapicommonheader.h>
+#include "nmapiheaders.h"
 
-#include "nmapitypesconverter.h"
-#include "nmdataplugininterface.h"
-#include "nmapidatapluginfactory.h"
-#include "nmapiengine.h"
-
-/*!
-    from nmailbase
-*/
-#include "nmapiprivateheaders.h"
 
 NmApiEngine *NmApiEngine::mInstance = NULL;
 quint32 NmApiEngine::mReferenceCount = 0;
@@ -43,6 +33,8 @@
 NmApiEngine::NmApiEngine() :
     mFactory(NULL)
 {
+    NM_FUNCTION;
+    
     mFactory = NmApiDataPluginFactory::instance();
 }
 
@@ -51,6 +43,8 @@
  */
 NmApiEngine::~NmApiEngine()
 {
+    NM_FUNCTION;
+    
     NmApiDataPluginFactory::releaseInstance(mFactory);
 }
 
@@ -63,6 +57,8 @@
  */
 NmApiEngine *NmApiEngine::instance()
 {
+    NM_FUNCTION;
+    
     if (!mInstance) {
         mInstance = new NmApiEngine();
     }
@@ -75,6 +71,8 @@
  */
 void NmApiEngine::startCollectingEvents()
 {
+    NM_FUNCTION;
+    
     QObject *plugin = mFactory->plugin();
     if(plugin){
         connect(plugin, SIGNAL(messageEvent(NmMessageEvent, NmId, QList<NmId> , NmId)), this,
@@ -94,15 +92,25 @@
  */
 void NmApiEngine::mailboxChangedArrived(NmMailboxEvent mailboxEvent, const QList<NmId> &mailboxIds)
 {
+    NM_FUNCTION;
+    
     NmApiMessage message;
     message.objectType = EMailbox;
     switch (mailboxEvent) {
         case NmMailboxCreated: {
             message.action = ENew;
+            // subscribe all events also for these new mailboxes
+            for(int i=0; i<mailboxIds.count(); i++) {
+                mFactory->interfaceInstance()->subscribeMailboxEvents(mailboxIds[i]);
+            }
         }
             break;
         case NmMailboxDeleted: {
             message.action = EDeleted;
+            // unsubscribe all events from deleted mailboxes
+            for(int i=0; i<mailboxIds.count(); i++) {
+                mFactory->interfaceInstance()->unsubscribeMailboxEvents(mailboxIds[i]);
+            }
         }
             break;
         case NmMailboxChanged: {
@@ -138,6 +146,8 @@
     const QList<NmId> &messageIds,
     const NmId &mailboxId)
 {
+    NM_FUNCTION;
+    
     NmApiMessage message;
     message.objectType = EMessage;
     switch (messageEvent) {
@@ -175,6 +185,8 @@
  */
 void NmApiEngine::releaseInstance(NmApiEngine *&instance)
 {
+    NM_FUNCTION;
+    
     //can't have passed out instances if we don't have any
     if (mInstance) {
         if (instance == mInstance) {
@@ -196,6 +208,8 @@
  */
 void NmApiEngine::listMailboxes(QList<EmailClientApi::NmApiMailbox> &mailboxList)
 {
+    NM_FUNCTION;
+    
     QList<NmMailbox*> mailboxFromPlugin;
 
     NmDataPluginInterface *instance =  mFactory->interfaceInstance();
@@ -205,7 +219,13 @@
 
     while (mailboxFromPlugin.isEmpty() == false) {
         NmMailbox* tempNmMailbox = mailboxFromPlugin.takeLast();
+
+        // subscribe all events also for these new mailboxes
+        instance->subscribeMailboxEvents(tempNmMailbox->id());
+
+        // construct mailboxlist to platform api
         mailboxList << NmToApiConverter::NmMailbox2NmApiMailbox(*tempNmMailbox);
+
         delete tempNmMailbox;
     }
 }
@@ -219,6 +239,8 @@
  */
 void NmApiEngine::listFolders(const quint64 mailboxId, QList<EmailClientApi::NmApiFolder> &folderList)
 {
+    NM_FUNCTION;
+    
     QList<NmFolder*> folderFromPlugin;
     NmDataPluginInterface *instance = mFactory->interfaceInstance();
     if (instance) {
@@ -243,6 +265,8 @@
 void NmApiEngine::listEnvelopes(const quint64 mailboxId, const quint64 folderId, 
                     QList<EmailClientApi::NmApiMessageEnvelope> &messageEnvelopeList)
 {
+    NM_FUNCTION;
+    
     QList<NmMessage*> messages;
     NmDataPluginInterface *instance = mFactory->interfaceInstance();
     if (instance) {
@@ -287,6 +311,8 @@
     const quint64 envelopeId,
     EmailClientApi::NmApiMessageEnvelope &envelope)
 {
+    NM_FUNCTION;
+    
     //flag indicating that envelope with given id was found
     bool found = false;
     NmDataPluginInterface *instance = mFactory->interfaceInstance();
@@ -310,7 +336,6 @@
             envelope.setTotalSize(message->size());
 
             found = true;
-            delete plainTextPart;
         }
         delete message;
     }
@@ -327,6 +352,8 @@
  */
 bool NmApiEngine::getMailboxById(const quint64 mailboxId, EmailClientApi::NmApiMailbox &mailbox)
 {
+    NM_FUNCTION;
+    
     //flag indicating that mailbox with given id was found
     bool found = false;
     NmDataPluginInterface *instance = mFactory->interfaceInstance();
--- a/emailservices/nmclientapi/src/nmapienvelopelisting.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapienvelopelisting.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -14,16 +14,8 @@
  * Description:
  *
  */
-
-
-#include <nmapienvelopelisting.h>
-#include "nmapienvelopelisting_p.h"
-
-#include <nmapicommonheader.h>
-
-#include "nmapiengine.h"
-
-
+ 
+#include "nmapiheaders.h"
 
 namespace EmailClientApi
 {
@@ -36,27 +28,21 @@
     const quint64 mailboxId) :
     NmApiMessageTask(parent)
 {
-    mListingPrivate = new NmApiEnvelopeListingPrivate(this);
-    mListingPrivate->mailboxId = mailboxId;
-    mListingPrivate->folderId = folderId;
-    mListingPrivate->mIsRunning = false;
+    NM_FUNCTION;
+    mListingPrivate = new NmApiEnvelopeListingPrivate(folderId, mailboxId, this);
 }
 
 /*!
-   Destructor of class. It release engine to be safe if manual releasing won't work.
+   Destructor of class. 
  */
 NmApiEnvelopeListing::~NmApiEnvelopeListing()
 {
-    if (mListingPrivate->mIsRunning) {
-        mListingPrivate->releaseEngine();
-    }
+    NM_FUNCTION;
 }
 
 /*!
-   \brief Starts gathering envelopes list.
-   
-   In first turn it will get whole folderlist. 
-   If start works, it do nothing.
+   \brief Fetches envelope list. Emits envelopesListed signal when ready.
+   Results can be fetched with getEnvelopes.
    
    To asynchronous operation ce be used \sa QTimer::singleShot on this method.
    Example:
@@ -67,72 +53,38 @@
  */
 bool NmApiEnvelopeListing::start()
 {
-    bool result = false;
-
-    if (mListingPrivate->mIsRunning) {
-        result = true;
-    }
-    else {
+    NM_FUNCTION;
 
-        bool started = mListingPrivate->initializeEngine();
-        if (!started) {
-            QMetaObject::invokeMethod(this, "envelopesListed", Qt::QueuedConnection, Q_ARG(qint32,
-                (qint32) EnvelopeListingFailed));
-            result = false;
-        }
-        else {
-            qint32 envelopesCount = mListingPrivate->grabEnvelopes();
-
-            mListingPrivate->mIsRunning = true;
-            QMetaObject::invokeMethod(this, "envelopesListed", Qt::QueuedConnection, Q_ARG(qint32,
+    qint32 envelopesCount = mListingPrivate->listEnvelopes();
+    QMetaObject::invokeMethod(this, "envelopesListed", Qt::QueuedConnection, Q_ARG(qint32,
                 envelopesCount));
-            result = true;
-        }
-    }
-    return result;
+    return true;
 }
 
 /*!
    \brief Stop gathering envelope list.
-   
-   In first it change state of listing.
-   Then it release engine.
-   On end it clears list of envelopes and emits \sa NmApiMessageTask::canceled() signal.
+
+   Clears list of envelopes and emits \sa NmApiMessageTask::canceled() signal.
  */
 void NmApiEnvelopeListing::cancel()
 {
-    if (mListingPrivate->mIsRunning) {
-        mListingPrivate->mIsRunning = false;
-        mListingPrivate->releaseEngine();
-        mListingPrivate->mEnvelopes.clear();
+    NM_FUNCTION;
+    mListingPrivate->cancel();
+    emit canceled();
 
-        emit canceled();
-    }
 }
 
 /*! 
    \brief Returns results after envelopesListed signal is received.
    
     Caller gets ownership of envelopes. Returns true if results were available.
-    Before calling cancel and start should be called,
-    because after second calling it return empty list.
-    It also at start clear inputlist of NmMessageEnvelope.
+    Before calling start should be called, otherwise will return empty list.
+    It also clears inputlist of NmMessageEnvelope.
  */
 bool NmApiEnvelopeListing::getEnvelopes(QList<EmailClientApi::NmApiMessageEnvelope> &envelopes)
 {
-    envelopes.clear();
-
-    bool result = false;
-
-    if (!mListingPrivate->mIsRunning) {
-        result = false;
-    }
-    else {
-        envelopes = mListingPrivate->mEnvelopes;
-        mListingPrivate->mEnvelopes.clear();
-        result = true;
-    }
-    return result;
+    NM_FUNCTION;
+    return mListingPrivate->envelopes(envelopes);
 }
 
 /*!
@@ -140,7 +92,8 @@
  */
 bool NmApiEnvelopeListing::isRunning() const
 {
-    return mListingPrivate->mIsRunning;
+    NM_FUNCTION;
+    return mListingPrivate->isRunning();
 }
 
 }
--- a/emailservices/nmclientapi/src/nmapienvelopelisting_p.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapienvelopelisting_p.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -14,67 +14,77 @@
  * Description:
  *
  */
-#include "nmapiengine.h"
-#include "nmapienvelopelisting_p.h"
 
-#include <nmapimailbox.h>
-#include <nmapimessageenvelope.h>
+#include "nmapiheaders.h"
 
 
 
 namespace EmailClientApi
 {
-NmApiEnvelopeListingPrivate::NmApiEnvelopeListingPrivate(QObject *parent) :
-    QObject(parent), mEngine(NULL)
+NmApiEnvelopeListingPrivate::NmApiEnvelopeListingPrivate(const quint64 folderId, const quint64 mailboxId, QObject *parent)
+:QObject(parent),
+mFolderId(folderId), 
+mMailboxId(mailboxId), 
+mIsRunning(false),
+mEngine(NULL)
 {
-
+    NM_FUNCTION;
+    mEngine = NmApiEngine::instance();
+    Q_CHECK_PTR(mEngine);
 }
 
 NmApiEnvelopeListingPrivate::~NmApiEnvelopeListingPrivate()
 {
-    releaseEngine();
+    NM_FUNCTION;
+    NmApiEngine::releaseInstance(mEngine);
 }
 
-/*!
-   \brief It initialize engine for email operations. 
+/*! 
+   \brief Fills envelopes to the input parameter.
    
-   When use initializeEngine need to remember release it.
-   It return value if initialization go good.
-   \sa releaseEngine 
+    Caller gets ownership of envelopes. Returns true if results were available.
  */
-bool NmApiEnvelopeListingPrivate::initializeEngine()
+bool NmApiEnvelopeListingPrivate::envelopes(QList<EmailClientApi::NmApiMessageEnvelope> &envelopes)
 {
-    mEngine = NmApiEngine::instance();
-    return mEngine ? true : false;
+    NM_FUNCTION;
+    bool ret(mIsRunning);
+    envelopes.clear();
+    while (!mEnvelopes.isEmpty()) {
+        envelopes << mEnvelopes.takeFirst();
+    }
+    mIsRunning = false;
+    return ret;
 }
 
 /*!
-   \brief It release engine for email operations.
+   \brief It fetches envelopes from engine. 
    
-   \sa initializeEngine
- */
-void NmApiEnvelopeListingPrivate::releaseEngine()
-{
-    NmApiEngine::releaseInstance(mEngine);
-}
-
-/*!
-   \brief It grab envelopes from engine. 
-   
-   When it start grabing, it release all old.
    Because it uses NmApiMessageEnvelope with sharedData we don't need care about release memory.
    
-   \return Count of envelopes or "-1" if there is no engine initialised
+   \return Count of envelopes 
  */
-qint32 NmApiEnvelopeListingPrivate::grabEnvelopes()
+qint32 NmApiEnvelopeListingPrivate::listEnvelopes()
 {
-    if(!mEngine){
-        return -1;
-    }
-    
+    NM_FUNCTION;
+    mIsRunning = true;
     mEnvelopes.clear();
-    mEngine->listEnvelopes(mailboxId, folderId, mEnvelopes);
+    mEngine->listEnvelopes(mMailboxId, mFolderId, mEnvelopes);
     return mEnvelopes.count();
 }
+/*!
+   \brief Return info if listing is running
+ */
+bool NmApiEnvelopeListingPrivate::isRunning() const
+{
+    return mIsRunning;
+}
+/*!
+   \brief Clears list of envelopes.
+ */
+void NmApiEnvelopeListingPrivate::cancel() 
+{
+    mIsRunning = false;
+    mEnvelopes.clear();
+}
 }
 
--- a/emailservices/nmclientapi/src/nmapieventnotifier.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapieventnotifier.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -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"
@@ -15,31 +15,22 @@
  *
  */
 
-#include <QList>
-#include <QVariant>
-#include <QString>
-#include <QTimer>
+#include "nmapiheaders.h"
 
-#include "nmapiengine.h"
-#include <nmapieventnotifier.h>
-#include "nmapieventnotifier_p.h"
 
-const quint32 IntervalEmitingSignals = 10000;
 
 namespace EmailClientApi
 {
 /*!
    Constructor
  */
-NmApiEventNotifier::NmApiEventNotifier(QObject *parent) :
-    NmApiMessageTask(parent)
-
+NmApiEventNotifier::NmApiEventNotifier(QObject *parent) 
+:NmApiMessageTask(parent)
 {
-    //set timer
+    NM_FUNCTION;
+    
     mNmApiEventNotifierPrivate = new NmApiEventNotifierPrivate(this);
-    mNmApiEventNotifierPrivate->mEmitSignals = new QTimer(this);
-    mNmApiEventNotifierPrivate->mEmitSignals->setInterval(IntervalEmitingSignals);
-    connect(mNmApiEventNotifierPrivate->mEmitSignals, SIGNAL(timeout()), this, SLOT(
+    connect(mNmApiEventNotifierPrivate, SIGNAL(timedOut()), this, SLOT(
         sendEventsFromBuffer()), Qt::QueuedConnection);
 
 }
@@ -49,8 +40,9 @@
  */
 NmApiEventNotifier::~NmApiEventNotifier()
 {
-    if (mNmApiEventNotifierPrivate->mIsRunning) {
-        mNmApiEventNotifierPrivate->releaseEngine();
+    NM_FUNCTION;
+    if (mNmApiEventNotifierPrivate) {
+        mNmApiEventNotifierPrivate->stop();
     }
 }
 
@@ -61,38 +53,21 @@
  */
 bool NmApiEventNotifier::start()
 {
-    bool result = false;
-
-    if (mNmApiEventNotifierPrivate->mIsRunning) {
-        result = true;
-    }
-    else
-        if (!mNmApiEventNotifierPrivate->initializeEngine()) {
-            mNmApiEventNotifierPrivate->mIsRunning = false;
-            result = false;
-        }
-        else {
-            qRegisterMetaType<QList<quint64> > ("QList<quint64>");
-            qRegisterMetaType<NmApiMessage> ("NmApiMessage");
-
-            connect(mNmApiEventNotifierPrivate->mEngine, SIGNAL(emailStoreEvent(NmApiMessage)), mNmApiEventNotifierPrivate,
-                SLOT(emailStoreEvent(NmApiMessage)), Qt::QueuedConnection);
-
-            mNmApiEventNotifierPrivate->mEmitSignals->start();
-            mNmApiEventNotifierPrivate->mIsRunning = true;
-            result = true;
-        }
-    return result;
+    NM_FUNCTION;
+    
+    return mNmApiEventNotifierPrivate->start();
 }
 
 /*!
    Cancels monitoring.
    
    In user responsibility is to cancel monitoring.
-   On end it clear buffer events and emits \sa NmApiMessageTask::canceled() signal.
+   On end it clears buffer events and emits \sa NmApiMessageTask::canceled() signal.
  */
 void NmApiEventNotifier::cancel()
 {
+    NM_FUNCTION;
+    
     mNmApiEventNotifierPrivate->cancel();
     emit canceled();
 }
@@ -102,66 +77,58 @@
  */
 bool NmApiEventNotifier::isRunning() const
 {
-    return mNmApiEventNotifierPrivate->mIsRunning;
+    NM_FUNCTION;
+    
+    return mNmApiEventNotifierPrivate->isRunning();
 }
 
 /*!
-   It check each object in buffer and emit signal with it.
-   
-   After end of work of this function buffer is empty.
-   It is called by timeout signal from timer.
+   Checks each object in buffer and emits corresponding signal.
+   Uses scheduled transmission. Can be called also directly to force the 
+   signal sending.
  */
 void NmApiEventNotifier::sendEventsFromBuffer()
 {
+    NM_FUNCTION;
+    
     qRegisterMetaType<EmailClientApi::NmApiMailboxEvent> ("EmailClientApi::NmApiMailboxEvent");
     qRegisterMetaType<EmailClientApi::NmApiMessageEvent> ("EmailClientApi::NmApiMessageEvent");
-    NmApiMessage events;
-    while (!mNmApiEventNotifierPrivate->mBufferOfEvents.isEmpty()) {
-        events = mNmApiEventNotifierPrivate->mBufferOfEvents.takeFirst();
-        switch (events.objectType) {
+    
+    QList<NmApiMessage> events;
+    mNmApiEventNotifierPrivate->events(events);
+    while (!events.isEmpty()) {
+        NmApiMessage event = events.takeFirst();
+        switch (event.objectType) {
             case EMailbox:
-                switch (events.action) {
-                    case ENew:
-                        emit mailboxEvent(MailboxCreated, events.objectIds);
-                        break;
-                    case EChange:
-
-                        break;
-                    case EDeleted:
-                        emit mailboxEvent(MailboxDeleted, events.objectIds);
-                        break;
-                    default:
-                        break;
-                }
-                break;
-            case EFolder:
-                switch (events.action) {
-                    case ENew:
-
-                        break;
-                    case EChange:
-
-                        break;
-                    case EDeleted:
-
-                        break;
+                switch (event.action) {
+                    case ENew: {
+                        emit mailboxEvent(MailboxCreated, event.objectIds);
+                    } 
+                    break;
+                    case EDeleted: {
+                        emit mailboxEvent(MailboxDeleted, event.objectIds);
+                    }
+                    break;
                     default:
                         break;
                 }
                 break;
             case EMessage:
-                switch (events.action) {
-                    case ENew:
-                        emit messageEvent(MessageCreated, events.mailboxId, events.folderId,
-                            events.objectIds);
+                switch (event.action) {
+                    case ENew: {
+                        emit messageEvent(MessageCreated, event.mailboxId, event.folderId,
+                            event.objectIds);
+                        }
                         break;
-                    case EChange:
-                        emit messageEvent(MessageChanged, events.mailboxId, events.folderId,
-                            events.objectIds);
+                    case EChange: {
+                        emit messageEvent(MessageChanged, event.mailboxId, event.folderId,
+                            event.objectIds);
+                        }
                         break;
-                    case EDeleted:
-                        emit messageEvent(MessageDeleted, events.mailboxId, events.folderId,
-                            events.objectIds);
+                    case EDeleted: {
+                        emit messageEvent(MessageDeleted, event.mailboxId, event.folderId,
+                            event.objectIds);
+                        }
                         break;
                     default:
                         break;
@@ -171,6 +138,7 @@
                 break;
         }
     }
+    events.clear();
 }
 
 } //End of EmailClientApi
--- a/emailservices/nmclientapi/src/nmapieventnotifier_p.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapieventnotifier_p.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -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"
@@ -15,20 +15,24 @@
  *
  */
 
-#include "nmapiengine.h"
-#include "nmapieventnotifier_p.h"
-
-#include <QTimer>
+#include "nmapiheaders.h"
 
 namespace EmailClientApi
 {
+const quint32 IntervalEmitingSignals = 10000;
+
 /*!
    Constructor
  */
 NmApiEventNotifierPrivate::NmApiEventNotifierPrivate(QObject *parent) :
     QObject(parent), mEmitSignals(NULL), mEngine(NULL), mIsRunning(false)
 {
-
+    NM_FUNCTION;
+    mEmitSignals = new QTimer(this);
+    mEmitSignals->setInterval(IntervalEmitingSignals);
+    connect(mEmitSignals, SIGNAL(timeout()), this, SIGNAL(
+        timedOut()));
+    mEngine = NmApiEngine::instance();
 }
 
 /*!
@@ -36,38 +40,66 @@
  */
 NmApiEventNotifierPrivate::~NmApiEventNotifierPrivate()
 {
+    NM_FUNCTION;
+    mEmitSignals->stop();
+    NmApiEngine::releaseInstance(mEngine);
+}
 
+/*!
+   Returns true if the 
+ */
+bool NmApiEventNotifierPrivate::isRunning() const
+{
+    return mIsRunning;
 }
 
 /*!
-   \brief It initialize engine for email operations. 
+   Start monitoring email events
    
-   When use initializeEngine need to remember release it.
-   It return value if initialization go good.
-   \sa releaseEngine 
-   \return Return true if engine works.
+   \return Value tells about monitoring system running
  */
-bool NmApiEventNotifierPrivate::initializeEngine()
+bool NmApiEventNotifierPrivate::start()
 {
-    if (!mEngine) {
-        mEngine = NmApiEngine::instance();
+    NM_FUNCTION;
+    
+    bool result(false);
+
+    if (mIsRunning) {
+        result = true;
     }
+    else {
+        qRegisterMetaType<QList<quint64> > ("QList<quint64>");
+        qRegisterMetaType<NmApiMessage> ("NmApiMessage");
 
-    return mEngine ? true : false;
+        connect(mEngine, SIGNAL(emailStoreEvent(NmApiMessage)), this,
+                SLOT(emailStoreEvent(NmApiMessage)));
+            
+        mEngine->startCollectingEvents();
+            
+        mEmitSignals->start();
+        mIsRunning = true;
+        result = true;
+    }
+    return result;
+}
+/*!
+   \brief Stop listening events.
+ */
+void NmApiEventNotifierPrivate::stop()
+{
+    mIsRunning = false;
+    mEmitSignals->stop();
+    disconnect(mEngine, SIGNAL(emailStoreEvent(NmApiMessage)), this,
+            SLOT(emailStoreEvent(NmApiMessage)));
 }
 
 /*!
-   \brief It release engine for email operations.
-   
-   \sa initializeEngine
+    Returns event buffer, after function call the buffer is empty
  */
-void NmApiEventNotifierPrivate::releaseEngine()
+void NmApiEventNotifierPrivate::events(QList<NmApiMessage> &events)
 {
-    if (mIsRunning) {
-        cancel();
-    }
-    else {
-        NmApiEngine::releaseInstance(mEngine);
+    while (!mBufferOfEvents.isEmpty()) {
+        events << mBufferOfEvents.takeFirst();
     }
 }
 
@@ -80,11 +112,14 @@
  */
 void NmApiEventNotifierPrivate::emailStoreEvent(const NmApiMessage &events)
 {
+    NM_FUNCTION;
     mBufferOfEvents << events;
 }
 
 void NmApiEventNotifierPrivate::cancel()
 {
+    NM_FUNCTION;
+    
     if (!mIsRunning) {
         return;
     }
@@ -92,12 +127,8 @@
     mIsRunning = false;
     mEmitSignals->stop();
 
-    if (mEngine) {
-        disconnect(mEngine, SIGNAL(emailStoreEvent(NmApiMessage)), this,
+    disconnect(mEngine, SIGNAL(emailStoreEvent(NmApiMessage)), this,
             SLOT(emailStoreEvent(NmApiMessage)));
-    }
-
-    releaseEngine();
 
     mBufferOfEvents.clear();
 }
--- a/emailservices/nmclientapi/src/nmapifolder.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapifolder.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -14,9 +14,9 @@
  * Description: 
  *
  */
+ 
+#include "nmapiheaders.h"
 
-#include <nmapifolder.h>
-#include "nmapifolder_p.h"
 
 namespace EmailClientApi
 {
@@ -26,6 +26,8 @@
  */
 NmApiFolder::NmApiFolder()
 {
+    NM_FUNCTION;
+    
     d = new NmApiFolderPrivate();
 }
 
@@ -35,7 +37,7 @@
 NmApiFolder::NmApiFolder(const NmApiFolder &nmApiFolder)
 : d(nmApiFolder.d)
 {
-    
+    NM_FUNCTION;
 }
 
 /*!
@@ -43,7 +45,7 @@
  */
 NmApiFolder::~NmApiFolder()
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -51,6 +53,8 @@
  */
 NmApiFolder &NmApiFolder::operator=(const NmApiFolder &folder)
 {
+    NM_FUNCTION;
+    
     if (this != &folder) {
         d = folder.d;
     }
@@ -62,6 +66,8 @@
  */
 bool NmApiFolder::operator==(const NmApiFolder &folder)
 {
+    NM_FUNCTION;
+    
     bool returnValue = false;
     if (d == folder.d) {
         returnValue = true;
@@ -74,6 +80,8 @@
  */
 quint64 NmApiFolder::id() const
 {
+    NM_FUNCTION;
+    
     return d->id;
 }
 
@@ -82,6 +90,8 @@
  */
 QString NmApiFolder::name() const
 {
+    NM_FUNCTION;
+    
     return d->name;
 }
 
@@ -90,6 +100,8 @@
  */
 EmailClientApi::NmApiEmailFolderType NmApiFolder::folderType() const
 {
+    NM_FUNCTION;
+    
     return d->folderType;
 }
 
@@ -98,6 +110,8 @@
  */
 void NmApiFolder::setName(const QString& name)
 {
+    NM_FUNCTION;
+    
     d->name = name;
 }
 
@@ -106,6 +120,8 @@
  */
 void NmApiFolder::setId(quint64 id)
 {
+    NM_FUNCTION;
+    
     d->id = id;
 }
 
@@ -114,6 +130,8 @@
  */
 void NmApiFolder::setFolderType(EmailClientApi::NmApiEmailFolderType folderType)
 {
+    NM_FUNCTION;
+    
     d->folderType = folderType;
 }
 
@@ -122,6 +140,8 @@
  */
 void NmApiFolder::setParentFolderId(quint64 parentId)
 {
+    NM_FUNCTION;
+    
     d->parentId = parentId;
 }
 
@@ -130,6 +150,8 @@
  */
 void NmApiFolder::setChildFolderIds(QList<quint64> &childFolderIds)
 {
+    NM_FUNCTION;
+    
     d->childFolderIds = childFolderIds;
 }
 
@@ -139,6 +161,8 @@
  */
 void NmApiFolder::getChildFolderIds(QList<quint64> &childFolderIds)
 {
+    NM_FUNCTION;
+    
     childFolderIds = d->childFolderIds;
 }
 
@@ -148,6 +172,8 @@
  */
 quint64 NmApiFolder::parentFolderId() const
 {
+    NM_FUNCTION;
+    
     return d->parentId;
 }
 }
--- a/emailservices/nmclientapi/src/nmapifolderlisting.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapifolderlisting.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,12 +15,8 @@
  *
  */
 
+#include "nmapiheaders.h"
 
-#include <nmapifolderlisting.h>
-#include "nmapifolderlisting_p.h"
-
-#include <nmapimailbox.h>
-#include <nmapifolder.h>
 
 namespace EmailClientApi
 {
@@ -32,12 +28,11 @@
 /*!
    Constructor of class. It set start values.
  */
-NmApiFolderListing::NmApiFolderListing(QObject *parent, const quint64 &nmMailboxId) :
+NmApiFolderListing::NmApiFolderListing(QObject *parent, const quint64 &mailboxId) :
     NmApiMessageTask(parent)
 {
-    mFolderListing = new NmApiFolderListingPrivate(this);
-    mFolderListing->mIsRunning = false;
-    mFolderListing->mMailboxId = nmMailboxId;
+    NM_FUNCTION;
+    mFolderListing = new NmApiFolderListingPrivate(mailboxId, this);
 }
 
 /*!
@@ -45,9 +40,7 @@
  */
 NmApiFolderListing::~NmApiFolderListing()
 {
-    if (mFolderListing->mIsRunning) {
-        mFolderListing->releaseEngine();
-    }
+    NM_FUNCTION;
 }
 
 /*! 
@@ -59,13 +52,8 @@
  */
 bool NmApiFolderListing::getFolders(QList<EmailClientApi::NmApiFolder> &folders)
 {
-    folders.clear();
-    if (!mFolderListing->mIsRunning || mFolderListing->mFolders.isEmpty()) {
-        return false;
-    }
-    folders = mFolderListing->mFolders;
-    mFolderListing->mFolders.clear();
-    return true;
+    NM_FUNCTION;
+    return mFolderListing->folders(folders);
 }
 
 /*!
@@ -83,19 +71,8 @@
  */
 bool NmApiFolderListing::start()
 {
-    if (mFolderListing->mIsRunning) {
-        return true;
-    }
-
-    if (!mFolderListing->initializeEngine()) {
-        QMetaObject::invokeMethod(this, "foldersListed", Qt::QueuedConnection, Q_ARG(qint32,
-            (qint32) FolderListingFailed));
-        return false;
-    }
-
-    qint32 folderCount = mFolderListing->grabFolders();
-
-    mFolderListing->mIsRunning = true;
+    NM_FUNCTION;
+    qint32 folderCount = mFolderListing->listFolders();
     QMetaObject::invokeMethod(this, "foldersListed", Qt::QueuedConnection,
         Q_ARG(qint32, folderCount));
 
@@ -111,14 +88,9 @@
  */
 void NmApiFolderListing::cancel()
 {
-    if (!mFolderListing->mIsRunning) {
-        return;
-    }
-
-    mFolderListing->mIsRunning = false;
-    mFolderListing->releaseEngine();
-    mFolderListing->mFolders.clear();
-
+    NM_FUNCTION;
+    
+    mFolderListing->cancel(); 
     emit canceled();
 }
 
@@ -127,9 +99,10 @@
  */
 bool NmApiFolderListing::isRunning() const
 {
-    return mFolderListing->mIsRunning;
+    NM_FUNCTION;
+    return mFolderListing->isRunning();
 }
 
 }
 
-#include "moc_nmapifolderlisting.cpp"
+
--- a/emailservices/nmclientapi/src/nmapifolderlisting_p.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapifolderlisting_p.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -14,10 +14,9 @@
  * Description:
  *
  */
-#include "nmapiengine.h"
-#include "nmapifolderlisting_p.h"
 
-#include <nmapifolder.h>
+#include "nmapiheaders.h"
+
 
 namespace EmailClientApi
 {
@@ -25,10 +24,15 @@
 /*!
    Constructor form NmApiFolderListingPrivate
  */
-NmApiFolderListingPrivate::NmApiFolderListingPrivate(QObject *parent) :
-    QObject(parent), mEngine(NULL)
+NmApiFolderListingPrivate::NmApiFolderListingPrivate(quint64 mailboxId, QObject *parent) 
+:QObject(parent), 
+mMailboxId(mailboxId),
+mEngine(NULL),
+mIsRunning(false)
 {
-
+    NM_FUNCTION;
+    mEngine = NmApiEngine::instance();
+    Q_CHECK_PTR(mEngine);
 }
 
 /*!
@@ -36,53 +40,60 @@
  */
 NmApiFolderListingPrivate::~NmApiFolderListingPrivate()
 {
-    releaseEngine();
-}
-
-/*!
-   \brief It initialize engine for email operations. 
-   
-   When use initializeEngine need to remember release it.
-   It return value if initialization go good.
-   \sa releaseEngine 
- */
-bool NmApiFolderListingPrivate::initializeEngine()
-{
-    if (!mEngine) {
-        mEngine = NmApiEngine::instance();
-    }
-
-    return mEngine ? true : false;
-}
-
-/*!
-   \brief It release engine for email operations.
-   
-   \sa initializeEngine
- */
-void NmApiFolderListingPrivate::releaseEngine()
-{
+    NM_FUNCTION;
     NmApiEngine::releaseInstance(mEngine);
 }
 
 /*!
-   \brief It grab folders from engine. 
+   \brief Fetch folders from engine. 
    
-   When it start grabing, it release all old.
    Because it uses NmFolder with sharedData we don't need care about release memory.
    
-   \return Count of folders or "-1" if there is no engine initialised
+   \return Count of folders
  */
-qint32 NmApiFolderListingPrivate::grabFolders()
+qint32 NmApiFolderListingPrivate::listFolders()
 {
-    if (!mEngine) {
-        return -1;
-    }
-    
+    NM_FUNCTION;
+    mIsRunning = true;
     mFolders.clear();
     mEngine->listFolders(mMailboxId, mFolders);
     return mFolders.count();
 }
 
+/*! 
+   \brief Returns results after listFolders is called.
+   
+    Caller gets ownership of messages. Returns true if results were available.
+    It clears list of folders after be called.
+    It also at start clear inputlist of NmFolder.
+ */
+bool NmApiFolderListingPrivate::folders(QList<EmailClientApi::NmApiFolder> &folders)
+{
+    NM_FUNCTION;
+    bool ret(mIsRunning);
+    folders.clear();
+    while (!mFolders.isEmpty()) {
+        folders << mFolders.takeFirst();
+    }
+    mIsRunning = false;
+    return ret;
 }
 
+/*!
+   \brief Return info if listing is running
+ */
+bool NmApiFolderListingPrivate::isRunning() const
+{
+    NM_FUNCTION;
+    return mIsRunning;
+}
+/*!
+   \brief Clears list of folders.
+ */
+void NmApiFolderListingPrivate::cancel() 
+{
+    mIsRunning = false;
+    mFolders.clear();
+}
+}
+
--- a/emailservices/nmclientapi/src/nmapimailbox.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapimailbox.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,10 +15,7 @@
  *
  */
 
-#include <nmapimailbox.h>
-#include "nmapimailbox_p.h"
-
-#include <QString>
+#include "nmapiheaders.h"
 
 namespace EmailClientApi
 {
@@ -28,6 +25,8 @@
  */
 NmApiMailbox::NmApiMailbox()
 {
+    NM_FUNCTION;
+    
     d = new NmApiMailboxPrivate();
 }
 
@@ -37,7 +36,7 @@
 NmApiMailbox::NmApiMailbox(const NmApiMailbox &nmApiMailbox)
 : d(nmApiMailbox.d)
 {
-    
+    NM_FUNCTION;
 }
 
 /*!
@@ -45,7 +44,7 @@
  */
 NmApiMailbox::~NmApiMailbox()
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -53,6 +52,8 @@
  */
 NmApiMailbox &NmApiMailbox::operator=(const NmApiMailbox &mailbox)
 {
+    NM_FUNCTION;
+    
     if (this != &mailbox) {
         d = mailbox.d;
     }
@@ -64,6 +65,8 @@
  */
 bool NmApiMailbox::operator==(const NmApiMailbox &mailbox)
 {
+    NM_FUNCTION;
+    
     bool returnValue = false;
     if (d == mailbox.d) {
         returnValue = true;
@@ -76,6 +79,8 @@
  */
 quint64 NmApiMailbox::id() const
 {
+    NM_FUNCTION;
+    
     return d->id;
 }
 
@@ -84,6 +89,8 @@
  */
 QString NmApiMailbox::address() const
 {
+    NM_FUNCTION;
+    
     return d->address;
 }
 
@@ -92,6 +99,8 @@
  */
 QString NmApiMailbox::name() const
 {
+    NM_FUNCTION;
+    
     return d->name;
 }
 
@@ -100,6 +109,8 @@
  */
 void NmApiMailbox::setId(quint64 id)
 {
+    NM_FUNCTION;
+    
     d->id = id;
 }
 
@@ -108,6 +119,8 @@
  */
 void NmApiMailbox::setAddress(const QString &address)
 {
+    NM_FUNCTION;
+    
     d->address = address;
 }
 
@@ -116,6 +129,8 @@
  */
 void NmApiMailbox::setName(const QString &name)
 {
+    NM_FUNCTION;
+    
     d->name = name;
 }
 
--- a/emailservices/nmclientapi/src/nmapimailboxlisting.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapimailboxlisting.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,14 +15,7 @@
  *
  */
 
-#include <nmapimailboxlisting.h>
-
-#include <QObject>
-
-#include <nmapimailbox.h>
-#include "nmapiengine.h"
-#include "nmapimailboxlisting_p.h"
-
+#include "nmapiheaders.h"
 
 namespace EmailClientApi
 {
@@ -37,6 +30,8 @@
 NmApiMailboxListing::NmApiMailboxListing(QObject *parent) :
     NmApiMessageTask(parent)
 {
+    NM_FUNCTION;
+    
     mNmApiMailboxListingPrivate = new NmApiMailboxListingPrivate(this);
     mNmApiMailboxListingPrivate->mIsRunning = false;
 }
@@ -46,6 +41,8 @@
  */
 NmApiMailboxListing::~NmApiMailboxListing()
 {
+    NM_FUNCTION;
+    
     if (mNmApiMailboxListingPrivate->mIsRunning) {
         mNmApiMailboxListingPrivate->releaseEngine();
     }
@@ -63,6 +60,8 @@
  */
 bool NmApiMailboxListing::getMailboxes(QList<EmailClientApi::NmApiMailbox> &mailboxes)
 {
+    NM_FUNCTION;
+    
     mailboxes.clear();
 
     bool result = false;
@@ -101,6 +100,8 @@
  */
 bool NmApiMailboxListing::start()
 {
+    NM_FUNCTION;
+    
     bool result = false;
     if (mNmApiMailboxListingPrivate->mIsRunning) {
         result = true;
@@ -133,6 +134,8 @@
  */
 void NmApiMailboxListing::cancel()
 {
+    NM_FUNCTION;
+    
     if (mNmApiMailboxListingPrivate->mIsRunning) {
 
         mNmApiMailboxListingPrivate->mIsRunning = false;
@@ -150,9 +153,10 @@
  */
 bool NmApiMailboxListing::isRunning() const
 {
+    NM_FUNCTION;
+    
     return mNmApiMailboxListingPrivate->mIsRunning;
 }
 
 }
 
-#include "moc_nmapimailboxlisting.cpp"
--- a/emailservices/nmclientapi/src/nmapimailboxlisting_p.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapimailboxlisting_p.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -14,22 +14,21 @@
  * Description:
  *
  */
-#include "nmapiengine.h"
-#include "nmapimailboxlisting_p.h"
 
-#include <nmapimailbox.h>
+#include "nmapiheaders.h"
+
 
 namespace EmailClientApi
 {
 NmApiMailboxListingPrivate::NmApiMailboxListingPrivate(QObject *parent) :
     QObject(parent), mNmApiEngine(NULL)
 {
-
+    NM_FUNCTION;
 }
 
 NmApiMailboxListingPrivate::~NmApiMailboxListingPrivate()
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -42,6 +41,8 @@
  */
 bool NmApiMailboxListingPrivate::initializeEngine()
 {
+    NM_FUNCTION;
+    
     if (!mNmApiEngine) {
         mNmApiEngine = NmApiEngine::instance();
     }
@@ -56,6 +57,8 @@
  */
 void NmApiMailboxListingPrivate::releaseEngine()
 {
+    NM_FUNCTION;
+    
     NmApiEngine::releaseInstance(mNmApiEngine);
 }
 
@@ -69,6 +72,8 @@
  */
 qint32 NmApiMailboxListingPrivate::grabMailboxes()
 {
+    NM_FUNCTION;
+    
     if (!mNmApiEngine) {
         return -1;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimailboxsettings.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,95 @@
+/*
+ * 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 "nmapiheaders.h"
+
+
+namespace EmailClientApi {
+
+
+NmApiMailboxSettings::NmApiMailboxSettings(QObject *parent)
+   :QObject(parent)
+{
+   d = new NmApiMailboxSettingsPrivate(this); 
+   connect(d, SIGNAL(mailboxDeleted(int)),this,SIGNAL(mailboxDeleted(int)));
+}
+
+NmApiMailboxSettings::~NmApiMailboxSettings()
+{
+    delete d;
+}
+
+/*!
+ \fn listMailboxIds
+ \param idList - QList consists of ids as quint64.
+ \return true is successful, otherwise return false
+
+ Lists ids of mailboxes
+ */
+bool NmApiMailboxSettings::listMailboxIds(QList<quint64> &idList)
+{
+    return d->listMailboxIds(idList);
+}
+
+bool NmApiMailboxSettings::loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data)
+{
+	return d->loadSettings(mailboxId, data);
+}
+
+bool NmApiMailboxSettings::saveSettings(const NmApiMailboxSettingsData &data)
+{
+	return d->saveSettings(data);
+}
+
+/*!
+ \fn createMailbox
+ \param mailboxType - mailbox type as QString
+ \param data - mailbox settings data
+
+ Creates a mailbox
+ */
+bool NmApiMailboxSettings::createMailbox(const QString &mailboxType, NmApiMailboxSettingsData &data)
+{
+    return d->createMailbox(mailboxType, data);
+}
+
+/*!
+ \fn deleteMailbox
+ \param mailboxId - mailbox id.
+ \return quint64 - the mailbox id.
+ 
+ Deletes mailbox with specific id.
+ */
+bool NmApiMailboxSettings::deleteMailbox(quint64 mailboxId)
+{
+    return d->deleteMailbox(mailboxId);
+}
+
+/*!
+ \fn populateDefaultSettings
+ \param mailboxType - mailbox type as QString
+ \param data - mailbox settings data, on return contains dafault settings for mailbox protocol
+ \return true if default settings are set, otherwise false
+ 
+ Populates NmApiMailboxSettingsData with protocol specific settings data.
+ */
+bool NmApiMailboxSettings::populateDefaultSettings(const QString &mailboxType, NmApiMailboxSettingsData &data)
+{
+    return d->populateDefaultSettings(mailboxType, data);
+}
+
+}//end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimailboxsettings_p.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,139 @@
+/*
+ * 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 "nmapiheaders.h"
+
+
+namespace EmailClientApi
+{
+NmApiMailboxSettingsPrivate::NmApiMailboxSettingsPrivate(QObject *parent) : 
+    QObject(parent), 
+    mFactory(NULL),
+    mDeleteMailboxOperation(NULL)
+{
+    NM_FUNCTION;
+    mFactory = NmApiDataPluginFactory::instance();
+    Q_CHECK_PTR(mFactory);
+}
+
+NmApiMailboxSettingsPrivate::~NmApiMailboxSettingsPrivate()
+{
+    NM_FUNCTION;
+    NmApiDataPluginFactory::releaseInstance(mFactory);
+    if(mDeleteMailboxOperation && mDeleteMailboxOperation->isRunning()) {
+        mDeleteMailboxOperation->cancelOperation();        
+    }
+}
+
+bool NmApiMailboxSettingsPrivate::listMailboxIds(QList<quint64> &idList)
+{
+    NM_FUNCTION; 
+    QList<NmId> mailboxIds;
+    bool ret = false;
+    idList.clear();
+    
+    NmDataPluginInterface *instance = mFactory->interfaceInstance();
+    if (instance) {
+        if (instance->listMailboxIds(mailboxIds) == KErrNone) {
+            
+            foreach (NmId boxId, mailboxIds) {
+                        idList.append(boxId.id());
+                    }
+            
+            ret = true;   
+            }
+        } 
+     
+    return ret;
+}
+
+bool NmApiMailboxSettingsPrivate::loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data)
+{
+    NM_FUNCTION;
+    Q_UNUSED(mailboxId);
+    Q_UNUSED(data);
+    return false;
+}
+
+bool NmApiMailboxSettingsPrivate::saveSettings(const NmApiMailboxSettingsData &data)
+{
+    NM_FUNCTION;
+    Q_UNUSED(data);
+    return false;
+}
+
+bool NmApiMailboxSettingsPrivate::createMailbox(
+    const QString &mailboxType,
+    NmApiMailboxSettingsData &data)
+{
+    NM_FUNCTION;
+    Q_UNUSED(mailboxType);
+    Q_UNUSED(data);
+    bool ret = false;
+    
+    /*QT_TRY {
+        if (mailboxType==NmApiMailboxTypePop || mailboxType==NmApiMailboxTypeImap) {
+            QScopedPointer<NmApiPopImapSettingsManager> popImapManager(new NmApiPopImapSettingsManager());  
+            popImapManager->createMailbox(mailboxType, data);
+            ret = true;
+        }
+        else {
+            ret = false;
+        }
+        //TODO store cenrep stuff here
+    }
+    QT_CATCH(...){
+        ret = false;
+    }*/
+    
+    return ret;
+}
+
+bool NmApiMailboxSettingsPrivate::deleteMailbox(quint64 mailboxId)
+{
+    NM_FUNCTION;
+    bool ret = false;
+    NmDataPluginInterface *instance = mFactory->interfaceInstance();
+    if (instance) {
+        if (mDeleteMailboxOperation && mDeleteMailboxOperation->isRunning()) {
+            mDeleteMailboxOperation->cancelOperation();
+        }
+        mDeleteMailboxOperation = instance->deleteMailboxById(NmId(mailboxId));
+        
+        if (mDeleteMailboxOperation) {
+            ret = true;
+            connect(mDeleteMailboxOperation, 
+                    SIGNAL(operationCompleted(int)), 
+                    this, 
+                    SIGNAL(mailboxDeleted(int)));
+        }
+    }
+    return ret;
+}
+
+bool NmApiMailboxSettingsPrivate::populateDefaultSettings(
+    const QString &mailboxType, NmApiMailboxSettingsData &data) 
+{
+    NM_FUNCTION;
+    Q_UNUSED(mailboxType);
+    Q_UNUSED(data);
+    /*QScopedPointer<NmApiPopImapSettingsManager> popImapManager(new NmApiPopImapSettingsManager());  
+    return popImapManager->populateDefaults(mailboxType, data);*/
+    return true;
+}
+
+}// namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimailboxsettingsdata.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,114 @@
+/*
+ * 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 "nmapiheaders.h"
+
+
+namespace EmailClientApi
+{
+
+NmApiMailboxSettingsData::NmApiMailboxSettingsData()
+{
+    d = new NmApiMailboxSettingsDataPrivate();
+    Q_CHECK_PTR(d);
+}
+
+NmApiMailboxSettingsData::~NmApiMailboxSettingsData()
+{
+    delete d;
+}
+
+/*!
+ \fn setMailboxId 
+ \param mailboxId - valid mailbox id as quint64.
+ 
+ Sets the mailbox id               
+ */
+void NmApiMailboxSettingsData::setMailboxId(quint64 mailboxId)
+{
+    d->setMailboxId(mailboxId);
+}
+
+/*!
+ \fn mailboxId
+ \return quint64 - the mailbox id.
+ 
+ Gets the mailbox id.              
+ */
+quint64 NmApiMailboxSettingsData::mailboxId() const
+{
+    return d->mailboxId();
+}
+
+/*!
+ \fn setValue 
+ \param key - setting data to be set.
+ \param settingValue - Value to be set as QVariant.
+ 
+ Sets individual setting value.        
+ */
+void NmApiMailboxSettingsData::setValue(int key, const QVariant &settingValue)
+{
+    d->setValue(key, settingValue);
+}
+
+/*!
+ \fn getValue
+ \param key - setting data to get.
+ \param settingValue - On return holds as QVariant.
+ \return true if successfull, false otherwise.
+ 
+ Get individual setting value.        
+ */
+bool NmApiMailboxSettingsData::getValue(int key, QVariant &settingValue) const
+{
+    return d->getValue(key, settingValue);
+}
+
+/*!
+ \fn validateData
+ \return boolean - true, everything validated OK, false otherwise
+ 
+ Validates data in this container. 
+ */
+bool NmApiMailboxSettingsData::validateData() const
+{
+    return d->validateData();
+}
+
+/*!
+ \fn listSettings
+ \return QList<int> - ,on return contains use key values for settingsdata
+ 
+ Validates data in this container. 
+ */
+QList<int> NmApiMailboxSettingsData::listSettings() const
+{
+	return d->listSettings();
+}
+
+/*!
+ \fn clearSettings 
+ 
+ Resets data in this container.
+ */
+void NmApiMailboxSettingsData::clearSettings()
+{
+	d->clearSettings();
+}
+
+}//end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimailboxsettingsdata_p.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,757 @@
+/*
+ * 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 "nmapiheaders.h"
+
+
+
+
+namespace EmailClientApi
+{
+
+NmApiMailboxSettingsDataPrivate::NmApiMailboxSettingsDataPrivate() :
+    mId(0), mSettings(new QHash<int, QVariant>())
+{
+    NM_FUNCTION;
+    Q_CHECK_PTR( mSettings );
+}
+
+NmApiMailboxSettingsDataPrivate::~NmApiMailboxSettingsDataPrivate()
+{
+    NM_FUNCTION;
+}
+
+/*!
+ \fn setMailboxId 
+ \param mailboxId - valid mailbox id as quint64.
+ 
+ Sets the mailbox id               
+ */
+void NmApiMailboxSettingsDataPrivate::setMailboxId(quint64 mailboxId)
+{
+    NM_FUNCTION;
+    mId = mailboxId;
+}
+
+/*!
+ \fn mailboxId
+ \return quint64 - the mailbox id.
+ 
+ Gets the mailbox id.              
+ */
+quint64 NmApiMailboxSettingsDataPrivate::mailboxId() const
+{
+    NM_FUNCTION;
+    return mId;
+}
+
+/*!
+ \fn setValue 
+ \param key - setting data to be set.
+ \param settingValue - Value to be set as QVariant.
+
+ Sets individual setting value.        
+ */
+void NmApiMailboxSettingsDataPrivate::setValue(int key, const QVariant &settingValue)
+{
+    NM_FUNCTION;
+    (*mSettings)[key] = settingValue;
+}
+
+/*!
+ \fn getValue
+ \param key - setting data to get.
+ \param settingValue - On return holds as QVariant.
+ \return true if succesfull, false otherwise.
+ 
+ Get individual setting value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::getValue(int key, QVariant &settingValue) const
+{
+    NM_FUNCTION;
+    if (mSettings->contains(key)) {
+        settingValue = (*mSettings)[key];
+        return true;
+    }
+    return false;
+}
+
+/*!
+ \fn validateString
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - if this key was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual string type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateString(int key, QVariant& val, bool& validated) const
+{
+    NM_FUNCTION;
+    bool ret = true;
+    switch (key) {     
+     case OutgoingPassword:
+     case IncomingPassword:     
+     case FolderPath: 
+     case IncomingLoginName:
+     case MailboxName:
+     case MyName:
+     case ReceptionActiveProfile:
+     case IncomingMailServer:
+     case OutgoingMailServer:
+     case OutgoingLoginName:
+     case EmailAddress:
+     case ReplyAddress:
+     case EmailAlias:               
+     case IncomingMailUsesAuthentication:
+     case OutgoingMailUsesAuthentication:
+     case IncomingMailSecurityType:
+     case OutgoingMailSecurityType:
+     case EmailNotificationState:         
+     case AlwaysOnlineState:{
+         validated=true;
+         if (val.type() != QVariant::String) {
+             ret = false;
+             break;
+         }
+
+         QString sz = val.toString();                   
+         ret = validateStringValue(key, sz);
+         break;
+     }
+         
+     default: {
+         validated = false;
+         ret = false;
+         break;
+         }
+    }    
+    return ret;
+}
+
+/*!
+ \fn validateStringValue
+ \param key - setting data to validate.
+ \param val - value to validate. 
+ \return true if valid value, false otherwise.
+ 
+ validates individual string type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateStringValue(int key, QString& val) const
+{
+    NM_FUNCTION;
+    int ret = true;
+    bool valid = true, validated = false;
+    
+    valid = validateStringGeneral(key ,val, validated);
+    if (validated && !valid) {
+            ret = false;
+    }
+    
+    if( !validated ) {
+        valid = validateEmailAddress(key ,val, validated);
+        if (validated && !valid) {
+            ret = false;
+        }
+    }
+    
+    if( !validated ) {
+        valid = validateUsesAuthentication(key ,val, validated);
+        if (validated && !valid) {
+            ret = false;
+        }
+    }
+    
+    if( !validated ) {
+        valid = validateSecurityType(key ,val, validated);
+        if (validated && !valid) {
+            ret = false;
+        }
+    }
+    
+    if( !validated ) {
+        valid = validateAOLState(key ,val, validated);
+        if (validated && !valid) {
+            ret = false;
+        }
+    }        
+    return ret;
+}
+
+/*!
+ \fn validateStringGeneral
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param handled - true if method value was handled by method.
+ \return true if valid value, false otherwise.
+ 
+ validates individual string type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateStringGeneral(int key, QString& /*val*/, bool& handled) const
+{
+    NM_FUNCTION;
+    int ret = true;
+    switch (key) {     
+         case OutgoingPassword:
+         case IncomingPassword:     
+         case FolderPath:
+         case IncomingLoginName:
+         case MailboxName:
+         case MyName:
+         case ReceptionActiveProfile:
+         case IncomingMailServer:
+         case OutgoingMailServer:
+         case OutgoingLoginName: {
+             // Allready validated that values are string, 
+             // otherwise method is not called
+             handled = true;         
+             break;
+         }
+         default: {
+             handled = false;
+             ret = false;
+             break;
+         }    
+    } 
+    return ret;
+}
+         
+/*!
+ \fn validateEmailAddress
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param handled - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual string type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateEmailAddress(int key, QString& val, bool& handled) const
+{
+    NM_FUNCTION;
+    int ret = true;
+    switch (key) {        
+        case EmailAddress:
+        case ReplyAddress: {
+            handled = true;
+            if (val.size() == 0) {             
+                 ret = false;
+                 break;
+            }
+            if (!(val.contains("@"))) {
+               ret = false;
+            }
+            break;
+        }
+        case EmailAlias:  {
+            handled = true;            
+            break;
+        }
+        default: {
+            handled = false;
+            ret = false;
+            break;
+        }
+    }
+    return ret;
+}
+     
+/*!
+ \fn validateUsesAuthentication
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param handled - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual string type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateUsesAuthentication(int key, QString& val, bool& handled) const
+{ 
+    NM_FUNCTION;
+    int ret = true;
+    switch (key) { 
+        case IncomingMailUsesAuthentication:
+        case OutgoingMailUsesAuthentication: {
+            handled = true;
+            if (val.size() == 0) {
+                ret = false;
+                break;
+            }
+            if (!(val.contains("none") ||
+              val.contains("UserAuthentication") ||
+                  (key == OutgoingMailUsesAuthentication &&
+                   val.contains("SameAsIncoming")) )) {
+                ret = false;
+            }
+            break;
+        }
+        default: {
+            handled = false;
+            ret = false;
+            break;
+        }
+    }
+    return ret;
+}
+        
+/*!
+ \fn validateSecurityType
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual string type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateSecurityType(int key, QString& val, bool& handled) const
+{ 
+    NM_FUNCTION;
+    int ret = true;
+    switch (key) {
+         case IncomingMailSecurityType:
+         case OutgoingMailSecurityType: {
+            handled = true;
+            if (val.size() == 0) {
+                ret = false;
+                break;
+            }
+            if (!(val.contains("StartTls") || 
+                  val.contains("SSLTls") || 
+                  val.contains("none"))) {
+                ret = false;
+            }
+            break;
+         }
+         default: {
+             handled = false;
+             ret = false;
+             break;
+         }
+     }
+     return ret;
+}
+
+/*!
+ \fn validateAOLState
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual string type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateAOLState(int key, QString& val, bool& handled) const
+{ 
+    NM_FUNCTION;
+    int ret = true;
+    switch (key) {
+        case EmailNotificationState:         
+        case AlwaysOnlineState:{
+         handled = true;
+         if (val.size() == 0) {
+              ret = false;
+              break;
+          }
+          if (!( (val.contains("always") && key == AlwaysOnlineState) || 
+                 (val.contains("automatic") && key == EmailNotificationState) || 
+                  val.contains("homeOnly") || 
+                  val.contains("off"))) {
+              ret = false;
+          }
+          break;
+        }
+        default: {
+            handled = false;
+            ret = false;
+            break;
+        }
+    }
+    return ret;
+}
+
+/*!
+ \fn validateInteger
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual integer type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateInteger(int key, QVariant& val, bool& validated) const
+{
+    NM_FUNCTION;
+    bool ret = true;
+    switch (key) { 
+        case DownloadPictures:
+        case MessageDivider:
+        case UserNameHidden:
+        case FirstEmnReceived:
+        case EmnReceivedNotSynced:
+        case AoLastUpdateFailed:
+        case AoUpdateSuccessfulWithCurSettings:
+        case ReceptionUserDefinedProfile:
+        case ReceptionInboxSyncWindow:
+        case ReceptionGenericSyncWindowInMessages:
+        case IncomingPort:
+        case OutgoingPort:
+        case ReceptionWeekDays:
+        case ReceptionDayStartTime:
+        case ReceptionDayEndTime:
+        case ReceptionRefreshPeriodDayTime:
+        case ReceptionRefreshPeriodOther: {
+            validated = true;
+            if (!(val.type() == QVariant::Int ||
+                  val.type() == QVariant::UInt ||
+                  val.type() == QVariant::LongLong  ||
+                  val.type() == QVariant::ULongLong ||
+                  val.type() == QVariant::Double)) {
+                ret = false;
+                break;
+            }            
+            int ival = val.toInt();
+            ret = validateIntVal(key,ival);
+            break;
+        }
+        default: {
+            validated = false;
+            ret = false;
+            break;
+        }
+     }
+     return ret;
+}
+
+/*!
+ \fn validateIntVal
+ \param key - setting data to validate.
+ \param val - value to validate. 
+ \return true if valid value, false otherwise.
+ 
+ validates individual integer type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateIntVal(int key, int val) const
+{
+    NM_FUNCTION;
+    int ret = true;
+    bool valid = true, validated = false;
+
+    valid = validateIntGeneral(key ,val, validated);
+    if (validated && !valid) {
+           ret = false;
+    }
+    
+    if( !validated ) {
+       valid = validateOnOffValue(key ,val, validated);
+       if (validated && !valid) {
+           ret = false;
+       }
+    }
+    
+    if( !validated ) {
+       valid = validateWeekdayMask(key ,val, validated);
+       if (validated && !valid) {
+           ret = false;
+       }
+    }
+    
+    if( !validated ) {
+       valid = validateHoursInDay(key ,val, validated);
+       if (validated && !valid) {
+           ret = false;
+       }
+    }
+    return ret;
+}
+
+/*!
+ \fn validateOnOffValue
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual integer type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateOnOffValue(int key, int val, bool& handled) const
+{
+    NM_FUNCTION;
+    bool ret = true;
+    switch (key) {   
+        // Integer: 0=Off, 1=On    
+        case DownloadPictures:
+        case MessageDivider:
+        case UserNameHidden:
+        
+        // Integer: 0=false,1=true
+        case FirstEmnReceived:
+        case EmnReceivedNotSynced:
+        case AoLastUpdateFailed:
+        case AoUpdateSuccessfulWithCurSettings:
+        
+        // Integer: 0=Disabled, 1=Enabled
+        case ReceptionUserDefinedProfile: {
+            handled = true;
+            if (!(0 <= val && val <= 1)) {
+                ret = false;
+            }
+            break;
+        }
+        default: {
+            handled = false;
+            ret = false;
+            break;
+        }
+    }
+    return ret;
+}
+
+/*!
+ \fn validateIntGeneral
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual integer type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateIntGeneral(int key, int /*val*/, bool& handled) const
+{ 
+    NM_FUNCTION;
+    bool ret = true;
+    switch (key) {         
+        // Integer: 5,15,60,240,0="When open mailbox"
+        case ReceptionRefreshPeriodDayTime:
+        case ReceptionRefreshPeriodOther:
+            
+        // Integer: 0=All messages
+        case ReceptionInboxSyncWindow:
+        case ReceptionGenericSyncWindowInMessages:
+            
+        // Integer
+        case IncomingPort:
+        case OutgoingPort: {
+            // Allready valid thate these are integers
+            handled = true;
+            break;
+        }
+        default: {
+            handled = false;
+            ret = false;
+            break;
+        }
+    }
+    return ret;
+}
+
+/*!
+ \fn validateWeekDayMask
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual integer type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateWeekdayMask(int key, int val, bool& handled) const
+{
+    NM_FUNCTION;
+    bool ret = true;
+    switch (key) {
+        // Integer bitmask of weekdays: 0x01=Mon,0x02=Tue,0x04=Wed,0x08=Thu,0x10=Fri,0x20=Sat,0x40=Sun
+        case ReceptionWeekDays: {
+            handled = true;
+            int wkdmask = Mon | Tue | Wed | Thu | Fri | Sat | Sun;
+            if ((val & wkdmask) != val) {
+                ret = false;
+            }
+            break;
+        }
+        default: {
+            handled = false;
+            ret = false;
+            break;
+        }
+    }
+    return ret;
+}
+
+/*!
+ \fn validateHoursInDay
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual integer type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateHoursInDay(int key, int val, bool& handled) const
+{ 
+    NM_FUNCTION;
+    bool ret = true;
+    switch (key) {
+        // Integer: 0-23
+        case ReceptionDayStartTime:
+        case ReceptionDayEndTime: {
+            handled = true;
+            if (!(0 <= val && val <= 23)) { 
+                ret = false;
+            }
+            break;
+        }
+        default: {
+            handled = false;
+            ret = false;
+            break;
+        }
+    }
+    return ret;
+}
+
+/*!
+ \fn validateBool
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual bool type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateBool(int key, QVariant& val, bool& validated) const
+{
+    NM_FUNCTION;
+    bool ret = true;
+    switch (key) {    
+        
+        // Boolean
+        case IncomingSecureSockets:
+        case IncomingSSLWrapper:
+        case UseOutgoingAuthentication:
+        case OutgoingSecureSockets:
+        case OutgoingSSLWrapper: {
+            validated = true;
+            if (val.type() != QVariant::Bool)
+                ret = false;
+            break;
+        }
+        default: {
+            validated = false;
+            ret = false;
+            break;
+        }
+    }
+    return ret;
+}
+
+/*!
+ \fn validateDateTime
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+ 
+ validates individual QDateTime type value.        
+ */
+bool NmApiMailboxSettingsDataPrivate::validateDateTime(int key, QVariant& val, bool& validated) const
+{
+    NM_FUNCTION;
+    switch(key) {
+        case AoLastSuccessfulUpdate: {
+            if (val.type() != QVariant::DateTime) {
+                validated = true;
+                return false;
+            }
+            return true;
+        }
+        default: {
+            validated = false;
+            return false;
+        }
+    }
+}
+
+/*!
+ \fn validateData
+ \return boolean - true, everything validated OK, false otherwise
+ 
+ Validates data in this container. 
+ */   
+bool NmApiMailboxSettingsDataPrivate::validateData() const
+{
+    NM_FUNCTION;
+    QHash<int, QVariant>::const_iterator i = mSettings->constBegin();
+    while (i != mSettings->constEnd()) {
+        
+        bool validated = false;
+        bool valid = false;        
+        
+        int key = i.key();
+        QVariant val = i.value();
+        
+        ++i;
+        
+        valid = validateString(key ,val, validated);
+        if (validated) {
+            if (!valid){
+                return valid;
+            }
+            continue;
+        }
+        
+        valid = validateInteger(key ,val, validated);
+        if (validated) {
+            if (!valid){
+                return valid;
+            }
+            continue;
+        }
+         
+        valid = validateBool(key ,val, validated);
+        if (validated) {
+            if (!valid){
+                return valid;
+            }
+            continue;
+        } 
+         
+        valid = validateDateTime(key ,val, validated);
+        if (validated) {
+            if (!valid){
+                return valid;
+            }
+            continue;
+        }
+     }
+     return true;
+}
+
+QList<int> NmApiMailboxSettingsDataPrivate::listSettings() const
+{
+    NM_FUNCTION;
+    return mSettings->keys();
+}
+
+/*!
+ \fn clearSettings 
+ 
+ Resets data in this container. 
+ */
+void NmApiMailboxSettingsDataPrivate::clearSettings()
+{
+	mSettings->clear();
+}
+
+}//end namespace
--- a/emailservices/nmclientapi/src/nmapimessagebody.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapimessagebody.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -14,9 +14,9 @@
  * Description: 
  *
  */
+ 
+#include "nmapiheaders.h"
 
-#include <nmapimessagebody.h>
-#include "nmapimessagebody_p.h"
 
 namespace EmailClientApi
 {
@@ -26,6 +26,8 @@
  */
 NmApiMessageBody::NmApiMessageBody()
 {
+    NM_FUNCTION;
+    
     d = new NmApiMessageBodyPrivate();
 }
 
@@ -34,7 +36,7 @@
  */
 NmApiMessageBody::NmApiMessageBody(const NmApiMessageBody &apiMessageBody) : d(apiMessageBody.d)
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -42,6 +44,8 @@
  */
 NmApiMessageBody& NmApiMessageBody::operator=(const NmApiMessageBody &apiMessageBody)
 {
+    NM_FUNCTION;
+    
 	if (this != &apiMessageBody) 
 	{
 		d = apiMessageBody.d;
@@ -54,6 +58,8 @@
  */    
 bool NmApiMessageBody::operator==(const NmApiMessageBody &apiMessageBody)
 {
+    NM_FUNCTION;
+    
     bool retVal = false;
     if (this->d == apiMessageBody.d)
     {
@@ -67,13 +73,15 @@
  */
 NmApiMessageBody::~NmApiMessageBody()
 {
-
+    NM_FUNCTION;
 }
 /*!
    getter for total size of message body in bytes
  */
 quint64 NmApiMessageBody::totalSize() const
 {
+    NM_FUNCTION;
+    
     return d->totalSize;
 }
 
@@ -82,6 +90,8 @@
  */
 quint64 NmApiMessageBody::fetchedSize() const
 {
+    NM_FUNCTION;
+    
     return d->fetchedSize;
 }
 
@@ -90,6 +100,8 @@
  */
 QString NmApiMessageBody::content() const
 {
+    NM_FUNCTION;
+    
     return d->content;
 }
 
@@ -98,6 +110,8 @@
  */
 void NmApiMessageBody::setTotalSize(quint64 size)
 {
+    NM_FUNCTION;
+    
     d->totalSize = size;
 }
 
@@ -106,6 +120,8 @@
  */
 void NmApiMessageBody::setFetchedSize(quint64 size)
 {
+    NM_FUNCTION;
+    
     d->fetchedSize = size;
 }
 
@@ -114,6 +130,8 @@
  */
 void NmApiMessageBody::setContent(const QString& content)
 {
+    NM_FUNCTION;
+    
     d->content = content;
 }
 }
--- a/emailservices/nmclientapi/src/nmapimessageenvelope.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapimessageenvelope.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,14 +15,9 @@
  *
  */
 
-#include <QString>
-#include <QDateTime>
+#include "nmapiheaders.h"
 
-#include <nmapimessageenvelope.h>
-#include "nmapimessageenvelope_p.h"
 
-#include <nmapiemailaddress.h>
-#include <nmapimessagebody.h>
 
 namespace EmailClientApi
 {
@@ -32,7 +27,7 @@
 NmApiMessageEnvelope::NmApiMessageEnvelope(const NmApiMessageEnvelope &envelope) :
     d(envelope.d)
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -40,6 +35,8 @@
  */
 NmApiMessageEnvelope::NmApiMessageEnvelope()
 {
+    NM_FUNCTION;
+    
     d = new NmApiMessageEnvelopePrivate();
 }
 
@@ -48,7 +45,7 @@
  */
 NmApiMessageEnvelope::~NmApiMessageEnvelope()
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -56,6 +53,8 @@
  */
 NmApiMessageEnvelope &NmApiMessageEnvelope::operator=(const NmApiMessageEnvelope &envelope)
 {
+    NM_FUNCTION;
+    
     if (this != &envelope) {
         d = envelope.d;
     }
@@ -67,6 +66,8 @@
  */
 bool NmApiMessageEnvelope::operator==(const NmApiMessageEnvelope &envelope)
 {
+    NM_FUNCTION;
+    
     bool retVal = false;
     if (this->d == envelope.d) {
         retVal = true;
@@ -79,6 +80,8 @@
  */
 quint64 NmApiMessageEnvelope::id() const
 {
+    NM_FUNCTION;
+    
     return d->id;
 }
 
@@ -87,6 +90,8 @@
  */
 quint64 NmApiMessageEnvelope::parentFolder() const
 {
+    NM_FUNCTION;
+    
     return d->parentFolder;
 }
 
@@ -95,6 +100,8 @@
  */
 QString NmApiMessageEnvelope::subject() const
 {
+    NM_FUNCTION;
+    
     return d->subject;
 }
 
@@ -103,6 +110,8 @@
  */
 QString NmApiMessageEnvelope::sender() const
 {
+    NM_FUNCTION;
+    
     return d->sender;
 }
 
@@ -111,6 +120,8 @@
  */
 void NmApiMessageEnvelope::getToRecipients(QList<EmailClientApi::NmApiEmailAddress> &toRecipients)
 {
+    NM_FUNCTION;
+    
     toRecipients = d->toRecipients;
 }
 
@@ -119,6 +130,8 @@
  */
 void NmApiMessageEnvelope::getCcRecipients(QList<EmailClientApi::NmApiEmailAddress> &ccRecipients)
 {
+    NM_FUNCTION;
+    
     ccRecipients = d->ccRecipients;
 }
 
@@ -127,6 +140,8 @@
  */
 QDateTime NmApiMessageEnvelope::sentTime() const
 {
+    NM_FUNCTION;
+    
     return d->sentTime;
 }
 
@@ -135,6 +150,8 @@
  */
 bool NmApiMessageEnvelope::isRead() const
 {
+    NM_FUNCTION;
+    
     return d->read;
 }
 
@@ -143,6 +160,8 @@
  */
 bool NmApiMessageEnvelope::hasAttachments() const
 {
+    NM_FUNCTION;
+    
     return d->attachments;
 }
 
@@ -151,6 +170,8 @@
  */
 bool NmApiMessageEnvelope::isForwarded() const
 {
+    NM_FUNCTION;
+    
     return d->forwarded;
 }
 
@@ -159,6 +180,8 @@
  */
 bool NmApiMessageEnvelope::isReplied() const
 {
+    NM_FUNCTION;
+    
     return d->replied;
 }
 
@@ -167,6 +190,8 @@
  */
 QString NmApiMessageEnvelope::contentType() const
 {
+    NM_FUNCTION;
+    
     return d->contentType;
 }
 
@@ -175,6 +200,8 @@
  */
 void NmApiMessageEnvelope::getPlainTextBody(EmailClientApi::NmApiMessageBody &body)
 {
+    NM_FUNCTION;
+    
     body.setContent(d->plainText);
     body.setFetchedSize(d->fetchedSize);
     body.setTotalSize(d->totalSize);
@@ -185,6 +212,8 @@
  */
 void NmApiMessageEnvelope::setId(quint64 id)
 {
+    NM_FUNCTION;
+    
     d->id = id;
 }
 
@@ -193,6 +222,8 @@
  */
 void NmApiMessageEnvelope::setParentFolder(quint64 parentFolder)
 {
+    NM_FUNCTION;
+    
     d->parentFolder = parentFolder;
 }
 
@@ -201,6 +232,8 @@
  */
 void NmApiMessageEnvelope::setSubject(const QString &subject)
 {
+    NM_FUNCTION;
+    
     d->subject = subject;
 }
 
@@ -209,6 +242,8 @@
  */
 void NmApiMessageEnvelope::setSender(const QString &sender)
 {
+    NM_FUNCTION;
+    
     d->sender = sender;
 }
 
@@ -218,6 +253,8 @@
 void NmApiMessageEnvelope::setToRecipients(
     const QList<EmailClientApi::NmApiEmailAddress> &toRecipients)
 {
+    NM_FUNCTION;
+    
     d->toRecipients = toRecipients;
 }
 
@@ -227,6 +264,8 @@
 void NmApiMessageEnvelope::setCcRecipients(
     const QList<EmailClientApi::NmApiEmailAddress> &ccRecipients)
 {
+    NM_FUNCTION;
+    
     d->ccRecipients = ccRecipients;
 }
 
@@ -235,6 +274,8 @@
  */
 void NmApiMessageEnvelope::setSentTime(QDateTime sentTime)
 {
+    NM_FUNCTION;
+    
     d->sentTime = sentTime;
 }
 
@@ -243,6 +284,8 @@
  */
 void NmApiMessageEnvelope::setIsRead(bool isRead)
 {
+    NM_FUNCTION;
+    
     d->read = isRead;
 }
 
@@ -251,6 +294,8 @@
  */
 void NmApiMessageEnvelope::setHasAttachments(bool hasAttachments)
 {
+    NM_FUNCTION;
+    
     d->attachments = hasAttachments;
 }
 
@@ -259,6 +304,8 @@
  */
 void NmApiMessageEnvelope::setIsForwarded(bool isForwarded)
 {
+    NM_FUNCTION;
+    
     d->forwarded = isForwarded;
 }
 
@@ -267,6 +314,8 @@
  */
 void NmApiMessageEnvelope::setIsReplied(bool isReplied)
 {
+    NM_FUNCTION;
+    
     d->replied = isReplied;
 }
 
@@ -275,6 +324,8 @@
  */
 void NmApiMessageEnvelope::setContentType(const QString &contentType)
 {
+    NM_FUNCTION;
+    
     d->contentType = contentType;
 }
 
@@ -283,6 +334,8 @@
  */
 void NmApiMessageEnvelope::setPlainText(const QString &plainText)
 {
+    NM_FUNCTION;
+    
     d->plainText = plainText;
 }
 
@@ -291,6 +344,8 @@
  */
 void NmApiMessageEnvelope::setTotalSize(quint64 totalSize)
 {
+    NM_FUNCTION;
+    
     d->totalSize = totalSize;
 }
 
@@ -299,6 +354,8 @@
  */
 void NmApiMessageEnvelope::setFetchedSize(quint64 fetchedSize)
 {
+    NM_FUNCTION;
+    
     d->fetchedSize = fetchedSize;
 }
 
@@ -307,6 +364,8 @@
  */
 QString NmApiMessageEnvelope::plainText() const
 {
+    NM_FUNCTION;
+    
     return d->plainText;
 }
 
@@ -315,6 +374,8 @@
  */
 quint64 NmApiMessageEnvelope::totalSize() const
 {
+    NM_FUNCTION;
+    
     return d->totalSize;
 }
 
@@ -323,6 +384,8 @@
  */
 quint64 NmApiMessageEnvelope::fetchedSize() const
 {
+    NM_FUNCTION;
+    
     return d->fetchedSize;
 }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimessagemanager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,165 @@
+/*
+ * 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:
+ *     Email message related operations
+ */
+ 
+#include "nmapiheaders.h"
+
+
+/*!
+    \class NmApiMessageManager
+    \brief A class for performing various operations on messages.
+ */
+ 
+ 
+namespace EmailClientApi
+{
+
+ NmApiMessageManager::NmApiMessageManager(quint64 mailboxId,QObject *parent)
+	:QObject(parent)
+{
+	d = new NmApiMessageManagerPrivate(mailboxId,this);	
+	connect(d, SIGNAL(messagesCopied(int)),this,SIGNAL(messagesCopied(int)));
+	connect(d, SIGNAL(messagesCreated(int)),this,SIGNAL(messagesCreated(int)));
+	connect(d, SIGNAL(messagesMoved(int)),this,SIGNAL(messagesMoved(int)));
+	connect(d, SIGNAL(messagesDeleted(int)),this,SIGNAL(messagesDeleted(int)));	
+}
+
+NmApiMessageManager::~NmApiMessageManager()
+{
+	delete d;
+}
+   
+
+    // creates a new email message
+    // signaled with draftMessageCreated(NmApiMessage *message,int result) 
+    //    * ownership transferred
+bool NmApiMessageManager::createDraftMessage(const QVariant *initData)
+{
+    NM_FUNCTION;
+    Q_UNUSED(initData);
+	return false;
+}
+    
+    // creates fw message
+    // signaled with forwardMessageCreated(NmApiMessage *message,int result) 
+    //    * ownership transferred
+ bool NmApiMessageManager::createForwardMessage(const QVariant *initData)
+ {
+    NM_FUNCTION;
+    Q_UNUSED(initData);
+	return false;
+ }
+    
+    // creates reply message
+    // signaled with replyMessageCreated(NmApiMessage *message,int result) 
+    //    * ownership transferred
+bool NmApiMessageManager::createReplyMessage(const QVariant *initData,
+													bool replyAll)
+{
+    NM_FUNCTION;
+    Q_UNUSED(initData);
+    Q_UNUSED(replyAll);
+	return false;
+}
+ 
+/*!
+ \fn moveMessages 
+ \param messageIds Id list of source messages.
+ \param sourceFolderId Id of the source folder.
+ \param targetFolderId Id of the target folder.
+ \return true if operation was successfully started.
+ 
+ Starts async move operation for given messages.  
+ Completion signalled with messagesMoved(int result).
+ */
+bool NmApiMessageManager::moveMessages(const QList<quint64> messageIds,
+									quint64 sourceFolderId,
+									quint64 targetFolderId)
+{    
+	return d->moveMessages(messageIds,sourceFolderId,targetFolderId);
+}
+
+/*!
+ \fn copyMessages 
+ \param messageIds Id list of source messages.
+ \param sourceFolder Id of the source folder.
+ \param targetFolder Id of the target folder.
+ \return true if operation was successfully started.
+ 
+ Starts async copy operation for given messages.  
+ Completion signalled with messagesCopied(int result).
+ */
+bool NmApiMessageManager::copyMessages(const QList<quint64> messageIds,								
+									quint64 sourceFolder,
+									quint64 targetFolder)
+{
+	return d->copyMessages(messageIds, sourceFolder, targetFolder);
+}
+    
+// signaled with messageSaved(quint64 messageId, int result)
+bool NmApiMessageManager::saveMessage(const NmApiMessage &message)
+{
+    Q_UNUSED(message);
+	return false;
+}
+    
+// deletes message
+// signaled with messagesDeleted(int result)
+bool NmApiMessageManager::deleteMessages(const QList<quint64> messageIds)
+{
+    Q_UNUSED(messageIds);
+	return false;
+}
+    
+    // starts fetching rest of message body from server
+    // signaled with messageFetched(quint64 messageId, int result)
+bool NmApiMessageManager::fetch(const NmApiMessage &message)
+{
+    Q_UNUSED(message);
+	return false;
+}
+    
+    // moves message to outbox. Actual sending time may be immediate or scheduled
+    // signaled with messageSent(quint64 messageId, int result)
+bool NmApiMessageManager::send(const NmApiMessage &message)
+{
+    Q_UNUSED(message);
+	return false;
+}
+
+// creates new attachment for a message. Currently attachment can be specified as file name (attachmentSpec is QString)
+// signaled with attachmentCreated(quint64 attachemntId)
+//  * 
+bool NmApiMessageManager::createAttachment(NmApiEmailMessage &message,
+										const QVariant &attachmenSpec)
+{
+    Q_UNUSED(message);
+    Q_UNUSED(attachmenSpec);
+    return false;
+}
+                                                      
+// removes attachment from a message
+// signaled with attachmentRemoved(int result)
+bool NmApiMessageManager::removeAttachment(NmApiEmailMessage &message,
+quint64 /*attachmentId*/)
+{    
+    Q_UNUSED(message);
+    return false;
+}
+ 
+} // namespace EmailClientApi
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimessagemanager_p.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,165 @@
+/*
+ * 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:
+ *     Email message related operations
+ */
+ 
+#include "nmapiheaders.h"
+
+
+namespace EmailClientApi
+{
+
+NmApiMessageManagerPrivate::NmApiMessageManagerPrivate(quint64 mailboxId,QObject *parent)
+: QObject(parent),
+  mState(NmApiMessageManagerPrivate::EIdle), mMailboxId(mailboxId)
+{
+    NM_FUNCTION;	
+	
+    mFactory = NmApiDataPluginFactory::instance();
+    mPlugin = mFactory->plugin();    
+    if(mPlugin) {
+        connect(mPlugin,
+                SIGNAL(messageEvent(NmMessageEvent,
+                                    const NmId&,
+                                    const QList<NmId>&,
+                                    const NmId&)),
+                this,
+                SLOT(messageEventHandler(NmMessageEvent,
+                                    const NmId&,
+                                    const QList<NmId>&,
+                                    const NmId&)));
+    }				
+    NmDataPluginInterface *interface = mFactory->interfaceInstance();
+    interface->subscribeMailboxEvents(mailboxId);
+	
+}
+
+NmApiMessageManagerPrivate::~NmApiMessageManagerPrivate()
+{
+    NM_FUNCTION;
+    NmDataPluginInterface *interface = mFactory->interfaceInstance();
+    interface->unsubscribeMailboxEvents(mMailboxId);
+    NmApiDataPluginFactory::releaseInstance(mFactory);
+}
+    
+/*!
+ \fn moveMessages 
+ \param messageIds Id list of source messages.
+ \param sourceFolderId Id of the source folder.
+ \param targetFolderId Id of the target folder.
+ \return true if operation was successfully started.
+ 
+ Starts async move operation for given messages.  
+ Completion signalled with messagesMoved(int result).
+ */
+bool NmApiMessageManagerPrivate::moveMessages(const QList<quint64> messageIds,
+											quint64 sourceFolder,
+											quint64 targetFolder)
+{
+    NM_FUNCTION;
+    Q_UNUSED(messageIds);
+    Q_UNUSED(sourceFolder);
+    Q_UNUSED(targetFolder);
+    return false;
+}
+    
+/*!
+ \fn copyMessages 
+ \param messageIds Id list of source messages.
+ \param sourceFolder Id of the source folder.
+ \param targetFolder Id of the target folder.
+ \return true if operation was successfully started.
+ 
+ Starts async copy operation for given messages.  
+ Completion signalled with messagesCopied(int result).
+ */
+bool NmApiMessageManagerPrivate::copyMessages(const QList<quint64> messageIds,
+                                            const quint64 sourceFolder,
+											const quint64 targetFolder)
+{
+    NM_FUNCTION;
+    bool ret = false;
+    NmId targetFolderNmId(targetFolder);
+	NmId sourceFolderNmId(sourceFolder);
+	mTarget = targetFolderNmId;
+	mMessages = messageIds;
+	
+	NmDataPluginInterface *interface = mFactory->interfaceInstance();
+	
+    if (interface) {
+        mState = NmApiMessageManagerPrivate::ECopyPending;
+        if (interface->copyMessages(mMailboxId,
+                                  messageIds,
+                                  sourceFolderNmId,
+                                  targetFolderNmId)==0) {			
+            ret = true;
+        }        
+    }
+	mState = NmApiMessageManagerPrivate::EIdle;
+	return ret;
+}
+  
+/*!
+ \fn messageEventHandler 
+ \param event Event type.
+ \param folder Folder id.
+ \param messages Id list of messages involved.
+ \param mailBox Id of mailbox.
+  
+ Handler for plugin originated messageEvent.
+ */
+void NmApiMessageManagerPrivate::messageEventHandler(NmMessageEvent event,
+												const NmId &folder,
+												const QList<NmId> &messages,
+												const NmId &mailBox)
+{	
+	if(mMailboxId == mailBox &&
+	   mTarget == folder) {	
+        switch(event)
+        {
+            case NmMessageCreated: {
+                if (mState==NmApiMessageManagerPrivate::ECopyPending) {
+                    if(messages.count()==mMessages.count()) {
+                        emit messagesCopied(0);
+                    }
+                    else {
+                        emit messagesCopied(-1);
+                    }
+                }
+                break;			
+            }
+            
+            case NmMessageChanged: {
+                break;		
+            }
+            
+            case NmMessageDeleted: {            
+                break;
+            }
+                
+            case NmMessageFound: {
+                break;
+            }
+            
+            default: {
+                break;
+            }
+        }
+        mState = NmApiMessageManagerPrivate::EIdle;
+	}
+}
+} //namespace
+
+
--- a/emailservices/nmclientapi/src/nmapimessagetask.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapimessagetask.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,7 +15,9 @@
  *
  */
 
-#include <nmapimessagetask.h>
+#include "nmapiheaders.h"
+
+
 
 /*!
    Constructor for NmApiMessageTask
@@ -23,6 +25,7 @@
 NmApiMessageTask::NmApiMessageTask(QObject *parent)
 : QObject(parent)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -30,6 +33,6 @@
  */
 NmApiMessageTask::~NmApiMessageTask()
 {
-
+    NM_FUNCTION;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapipopimapsettingsmanager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,126 @@
+/*
+* 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 "nmapiheaders.h"
+
+
+
+
+static const int DefaultPopPort = 110;
+static const int DefaultImapPort = 993;
+
+using namespace EmailClientApi;
+    
+NmApiPopImapSettingsManager::NmApiPopImapSettingsManager()
+{    
+}
+
+NmApiPopImapSettingsManager::~NmApiPopImapSettingsManager()
+{   
+}
+
+bool NmApiPopImapSettingsManager::populateDefaults(const QString &mailboxType, NmApiMailboxSettingsData &data)
+{
+    bool ret = false;
+    
+    QT_TRY {
+        if (mailboxType==NmApiMailboxTypePop) {
+            populatePopDefs(data);
+            ret = true;
+        }
+        else if (mailboxType==NmApiMailboxTypeImap) {
+            populateImapDefs(data);
+            ret = true;
+        }
+        else {
+            ret = false;
+        }
+    }
+    QT_CATCH(...){
+        ret = false;
+    }
+    
+    return ret;
+}
+
+void NmApiPopImapSettingsManager::populateImapDefs(NmApiMailboxSettingsData &data)
+{
+    QScopedPointer<CImImap4Settings> imapSettings(new CImImap4Settings());
+    
+    QScopedPointer<CImIAPPreferences> iapPref;
+    QT_TRAP_THROWING(iapPref.reset(CImIAPPreferences::NewLC());
+            CleanupStack::Pop(iapPref.data()));  
+        
+    QScopedPointer<CEmailAccounts> mailAccounts;
+    QT_TRAP_THROWING(mailAccounts.reset(CEmailAccounts::NewL()));
+        
+    QT_TRAP_THROWING( mailAccounts->PopulateDefaultImapSettingsL(*imapSettings,*iapPref));
+    
+    data.setValue(IncomingLoginName, 
+                           XQConversions::s60Desc8ToQString(imapSettings->LoginName()));
+
+    data.setValue(IncomingPassword, 
+                           XQConversions::s60Desc8ToQString(imapSettings->Password()));
+       
+    data.setValue(IncomingMailServer, 
+                           XQConversions::s60DescToQString(imapSettings->ServerAddress()));
+         
+   if (imapSettings->Port()) {
+       data.setValue(IncomingPort, imapSettings->Port());
+       }
+   else {
+       data.setValue(IncomingPort, DefaultImapPort);
+   }
+   
+   data.setValue(OutgoingSecureSockets, imapSettings->SecureSockets());
+   data.setValue(OutgoingSSLWrapper, imapSettings->SSLWrapper());  
+}
+
+void NmApiPopImapSettingsManager::populatePopDefs(NmApiMailboxSettingsData &data)
+{
+    QScopedPointer<CImPop3Settings> popSettings(new CImPop3Settings());
+   
+    QScopedPointer<CImIAPPreferences> iapPref;
+    QT_TRAP_THROWING(iapPref.reset(CImIAPPreferences::NewLC());
+        CleanupStack::Pop(iapPref.data()));
+ 
+    QScopedPointer<CEmailAccounts> mailAccounts;
+    QT_TRAP_THROWING(mailAccounts.reset(CEmailAccounts::NewL()));
+    
+    QT_TRAP_THROWING( mailAccounts->PopulateDefaultPopSettingsL(*popSettings,*iapPref));
+    
+    data.setValue(IncomingLoginName, 
+                        XQConversions::s60Desc8ToQString(popSettings->LoginName()));
+   
+    data.setValue(IncomingPassword, 
+                        XQConversions::s60Desc8ToQString(popSettings->Password()));
+     
+    data.setValue(IncomingMailServer, 
+                        XQConversions::s60DescToQString(popSettings->ServerAddress()));
+    
+    if (popSettings->Port()) {
+        data.setValue(IncomingPort, popSettings->Port());
+        }
+    else {
+        data.setValue(IncomingPort, DefaultPopPort);
+    }
+    
+    data.setValue(OutgoingSecureSockets, popSettings->SecureSockets());
+    data.setValue(OutgoingSSLWrapper, popSettings->SSLWrapper());
+}
+
+
--- a/emailservices/nmclientapi/src/nmapitypesconverter.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmclientapi/src/nmapitypesconverter.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,17 +15,15 @@
  *
  */
 
-#include "nmapitypesconverter.h"
-
-#include <nmapicommonheader.h>
-
-#include <nmapiprivateheaders.h>
+#include "nmapiheaders.h"
 
 /*!
    converts nmmailbox to client api NmApiMailbox
  */
 EmailClientApi::NmApiMailbox NmToApiConverter::NmMailbox2NmApiMailbox(const NmMailbox &mailbox)
 {
+    NM_FUNCTION;
+    
     EmailClientApi::NmApiMailbox api_mailbox;
     api_mailbox.setId(mailbox.id().id());
     api_mailbox.setName(mailbox.name());
@@ -39,6 +37,8 @@
  */
 EmailClientApi::NmApiFolder NmToApiConverter::NmFolder2NmApiFolder(const NmFolder &folder)
 {
+    NM_FUNCTION;
+    
     EmailClientApi::NmApiFolder api_folder;
 
     api_folder.setParentFolderId(folder.parentId().id());
@@ -54,6 +54,8 @@
 EmailClientApi::NmApiMessageEnvelope NmToApiConverter::NmMessageEnvelope2NmApiMessageEnvelope(
     const NmMessageEnvelope &envelope)
 {
+    NM_FUNCTION;
+    
     EmailClientApi::NmApiMessageEnvelope api_env;
     
     QList<NmAddress> to = envelope.toRecipients();
@@ -84,6 +86,8 @@
 QList<EmailClientApi::NmApiEmailAddress> NmToApiConverter::NmAddress2QString(
     const QList<NmAddress> &addresses)
 {
+    NM_FUNCTION;
+    
     QList<EmailClientApi::NmApiEmailAddress> nmAddresses;
     for (int i = 0; i < addresses.count(); i++) {
         EmailClientApi::NmApiEmailAddress addr;
--- a/emailservices/nmregister/inc/nmmailboxregisterinterface_p.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmregister/inc/nmmailboxregisterinterface_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -22,13 +22,7 @@
 //  INCLUDES
 #include <QObject>
 #include <qmobilityglobal.h>
-
-#ifdef Q_OS_SYMBIAN
 #include <xqserviceprovider.h>
-#else
-#include <QVariant>
-#endif
-
 
 //  FORWARD DECLARATIONS
 class QString;
@@ -40,12 +34,7 @@
 
 QTM_USE_NAMESPACE
 
-
-#ifdef Q_OS_SYMBIAN
 class NmMailboxRegisterInterfacePrivate : public XQServiceProvider
-#else
-class NmMailboxRegisterInterfacePrivate : public QObject
-#endif
 {
     Q_OBJECT
 
@@ -68,6 +57,8 @@
     bool pushWidgetToHomescreen(quint64 a, QString accountIconName);
     
     QString formLaunchUri(quint64 accountId) const;
+    
+    bool loadMenuClientService();
 
 private: 
     QServiceManager* mManager;
--- a/emailservices/nmregister/nmregister.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmregister/nmregister.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -21,7 +21,6 @@
 MOBILITY = serviceframework
 TARGET = nmregister
 QT += core
-#RESOURCES += nmregister.qrc
 LIBS += -lxqservice \
         -lnmailuiengine \
         -leuser \
@@ -35,10 +34,6 @@
 pluginDep.path = $$QT_PLUGINS_BASE_DIR
 DEPLOYMENT += pluginDep
 
-#addFiles.sources += ./resources/nmregister.xml
-#addFiles.path = xmldata
-#DEPLOYMENT += addFiles
-
 BLD_INF_RULES.prj_exports += "resource/nmregister.xml 			z:/private/2002DD16/nmregister.xml"
 BLD_INF_RULES.prj_exports += "rom/nmregister.iby		CORE_APP_LAYER_IBY_EXPORT_PATH(nmregister.iby)"
 BLD_INF_RULES.prj_exports += "rom/nmregisterlanguage.iby 		LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(nmregisterlanguage.iby)"
@@ -57,5 +52,4 @@
 INCLUDEPATH += ../../inc
 
 DEPENDPATH += .
-#commented out until MCL has nmregister files in place here: epoc32/include/platform/qt/translations/
-#TRANSLATIONS = nmregister.ts
+TRANSLATIONS = nmregister.ts
--- a/emailservices/nmregister/rom/nmregister.iby	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmregister/rom/nmregister.iby	Thu Jul 22 16:30:28 2010 +0100
@@ -21,6 +21,6 @@
 #include <bldvariant.hrh>
 
 file=ABI_DIR\BUILD_DIR\nmregister.dll                         SHARED_LIB_DIR\nmregister.dll
-data=\epoc32\data\z\resource\qt\plugins\nmregister.qtplugin   resource\qt\plugins\nmregister.qtplugin
+data=ZRESOURCE\qt\plugins\nmregister.qtplugin   RESOURCE_FILES_DIR\qt\plugins\nmregister.qtplugin
 data=ZPRIVATE\2002DD16\nmregister.xml      					  private\2002DD16\nmregister.xml
 #endif  // __NMREGISTER_IBY__
--- a/emailservices/nmregister/src/nmmailboxregisterinterface.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmregister/src/nmmailboxregisterinterface.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,9 +15,11 @@
  *
  */
 
+#include "emailtrace.h"
+
 #include <qservicemanager.h>
 #include <qserviceinterfacedescriptor.h>
-#include <HbIcon>
+#include <hbicon.h>
 #include <HbApplication>
 #include <QTranslator>
 #include "nmicons.h"
@@ -25,284 +27,321 @@
 #include "nmmailboxregisterinterface_p.h" 
 
 //mandatory keys 
-const QString hsItemName          ("item:name"); 
-const QString hsitemLaunchUri     ("item:launchuri"); 
-const QString hsitemPublisherId   ("item:publisherId"); 
+const QString hsItemName("item:name");
+const QString hsitemLaunchUri("item:launchuri");
+const QString hsitemPublisherId("item:publisherId");
 //not mandatory 
-const QString hsItemWidgetUri     ("widget:uri"); 
-const QString hsItemDescription   ("item:description"); 
+const QString hsItemWidgetUri("widget:uri");
+const QString hsItemDescription("item:description");
+const QString hsItemLocDescription("item:locdescription");
 //for icon - not mandatory 
-const QString hsIconFileName      ("icon:filename");//to display specific icon from file 
-const QString hsIconName          ("icon:name");// HbIcon 
-const QString hsIconApplicationId ("icon:applicationid"); // icon from associated application 
+const QString hsIconFileName("icon:filename");//to display specific icon from file 
+const QString hsIconName("icon:name");// HbIcon 
+const QString hsIconApplicationId("icon:applicationid"); // icon from associated application 
 
 //Custom for nmHsWidgets
 //NmHsWidgetParamAccountId is used to identify what email account will be monitored by 
 //the registered hs widget
-const QString NmHsWidgetParamAccountId     ("widgetparam:accountId");
+const QString NmHsWidgetParamAccountId("widgetparam:accountId");
 //same as above but for pushing the widget to homescreen
-const QString NmHsAccountId       ("accountId");
+const QString NmHsAccountId("accountId");
 //NmHsWidgetParamAccountIconName is used to identify mailbox icon in application library
-const QString NmHsWidgetParamAccountIconName     ("widgetparam:accountIconName");
+const QString NmHsWidgetParamAccountIconName("widgetparam:accountIconName");
 //same as above but for pushing the widget to homescreen
-const QString NmHsAccountIconName  ("accountIconName");
+const QString NmHsAccountIconName("accountIconName");
 //This is used to identify nmhswidget in homescreen
-const QString NmHsWidget          ("nmhswidget");
+const QString NmHsWidget("nmhswidget");
 
 //parameter values
-const QString NmPublisherName     ("NmMailboxRegisterInterface");
-const QString NmLaunchUri         ("appto://0x200255BA?activityname=EmailInboxView&accountId=");
+const QString NmPublisherName("NmMailboxRegisterInterface");
+const QString NmLaunchUri("appto://0x200255BA?activityname=EmailInboxView&accountId=");
 //URI for the defined service
 const QLatin1String interfaceUri("com.nokia.symbian.IEmailRegisterAccount");
 
 /** Localization file name*/
 const QString KNmRegisterLocFileName = "nmregister_";
 /** Localization file location*/
-const QString KNmRegisterLocLocation = "z:/resource/qt/translations/";
+const QString KNmRegisterLocLocation = "/translations/";
 
 /*!
-    Constructor
-*/
+ Constructor
+ */
 NmMailboxRegisterInterface::NmMailboxRegisterInterface(QObject *parent) :
-    QObject(parent), m_d( new NmMailboxRegisterInterfacePrivate(this) )
-    {
-    }
+    QObject(parent), m_d(new NmMailboxRegisterInterfacePrivate(this))
+{
+    NM_FUNCTION;
+}
 
 /*!
-    Destructor
-*/
+ Destructor
+ */
 NmMailboxRegisterInterface::~NmMailboxRegisterInterface()
-    {
+{
+    NM_FUNCTION;
+    
     delete m_d;
-    }
+}
 
 /*!
-    registerNewMailbox
-*/
-bool NmMailboxRegisterInterface::registerNewMailbox(quint64 accountId, 
-        QString accountName, QString accountIconName)
-    {
-    return m_d->registerNewMailbox( accountId, accountName, accountIconName );
-    }
+ registerNewMailbox
+ */
+bool NmMailboxRegisterInterface::registerNewMailbox(
+    quint64 accountId,
+    QString accountName,
+    QString accountIconName)
+{
+    NM_FUNCTION;
+    
+    return m_d->registerNewMailbox(accountId, accountName, accountIconName);
+}
 
 /*!
-    updateMailboxName
-*/
-bool NmMailboxRegisterInterface::updateMailboxName(quint64 accountId, 
-        QString newName)
-    {
-    return m_d->updateMailboxName( accountId, newName );
-    }
-
+ updateMailboxName
+ */
+bool NmMailboxRegisterInterface::updateMailboxName(quint64 accountId, QString newName)
+{
+    NM_FUNCTION;
+    
+    return m_d->updateMailboxName(accountId, newName);
+}
 
 /*!
-    unregisterMailbox
-*/
+ unregisterMailbox
+ */
 bool NmMailboxRegisterInterface::unregisterMailbox(quint64 accountId)
-    {
-    return m_d->unregisterMailbox( accountId );
-    }
+{
+    NM_FUNCTION;
+    
+    return m_d->unregisterMailbox(accountId);
+}
 
-
-
-
+/*!
+ Constructor
+ */
+NmMailboxRegisterInterfacePrivate::NmMailboxRegisterInterfacePrivate(QObject *parent) :
+    XQServiceProvider(interfaceUri, parent), 
+    mManager(new QServiceManager()), 
+    mService(0),
+    mTranslator(new QTranslator())
+{
+    NM_FUNCTION;
+}
 
 /*!
-    Constructor
-*/
-NmMailboxRegisterInterfacePrivate::NmMailboxRegisterInterfacePrivate(QObject *parent) :
-    XQServiceProvider(interfaceUri, parent ), 
-    mManager(0),
-    mService(0),
-    mTranslator(0)
-    {
-    //commented out until MCL has nmregister files in place here: epoc32/include/platform/qt/translations/
-    /*mTranslator = new QTranslator();
-    QString lang = QLocale::system().name();
-    bool loadSucceed = mTranslator->load(KNmRegisterLocFileName + lang, KNmRegisterLocLocation);
-    qDebug() << "NmMailboxRegisterInterfacePrivate mTranslator->load loadSucceed:"<<loadSucceed;
-    QCoreApplication::installTranslator(mTranslator);*/
+ loadMenuClientService()
+ Loads the Menu client service to mService. 
+ \return true if mService exists or is succesfully loaded, otherwise false.
+ */
+bool NmMailboxRegisterInterfacePrivate::loadMenuClientService()
+{
+    if (mService){ 
+        return true; //service is already loaded
+    }
     
-    mManager = new QServiceManager();
     QServiceFilter filter("com.nokia.symbian.IMenuClient");
     QList<QServiceInterfaceDescriptor> interfaces = mManager->findInterfaces(filter);
-    mService = mManager->loadInterface(interfaces.first()); 
+    if(interfaces.isEmpty()){
+        return false; //no maching interfaces available
     }
+    
+    mService = mManager->loadInterface(interfaces.first());
+    if(!mService){
+        return false; //loading interface failed
+    }
+    
+    return true; //succesfully loaded the service
+}
 
 /*!
-    Destructor
-*/
+ Destructor
+ */
 NmMailboxRegisterInterfacePrivate::~NmMailboxRegisterInterfacePrivate()
-    {
-    if(mTranslator){
-        delete mTranslator;
-        mTranslator = NULL;
+{
+    NM_FUNCTION;
+
+    delete mTranslator;
+    mTranslator = NULL;
+
+    delete mService;
+    mService = NULL;
+
+    delete mManager;
+    mManager = NULL;
+}
+
+bool NmMailboxRegisterInterfacePrivate::registerNewMailbox(
+    quint64 accountId,
+    QString accountName,
+    QString accountIconName)
+{
+    NM_FUNCTION;
+	
+    if(!loadMenuClientService()){
+        NM_ERROR(1,"loadService() failed!");
+        return false; 
     }
-    if (mService) 
-        {
-        delete mService;
-        }
-    if (mManager) 
-        {
-        delete mManager;
-        }
+    
+    //localization
+    QString lang = QLocale::system().name();
+    bool loadSucceed = mTranslator->load(KNmRegisterLocFileName + lang, KNmRegisterLocLocation);
+    QCoreApplication::installTranslator(mTranslator);
+    
+    //check that accountIconName is valid otherwise pass default mailbox icon
+    HbIcon mailBoxIcon(accountIconName);
+    if (mailBoxIcon.pixmap().height() == 0) {
+        mailBoxIcon = NmIcons::getIcon(NmIcons::NmIconDefaultMailbox);
+        accountIconName = mailBoxIcon.iconName();
     }
 
+    QMap<QString, QVariant> map;
+    //------------------------------
+    map[hsItemName] = accountName;
+    map[hsitemLaunchUri] = formLaunchUri(accountId);
+    map[hsitemPublisherId] = NmPublisherName;
+    map[hsItemWidgetUri] = NmHsWidget;
+    map[hsItemLocDescription] = "loc://" + KNmRegisterLocFileName + "/txt_mail_widget_dblist_preview_of_recent_mail";
+    map[hsIconFileName] = accountIconName;
+    // to add widget params that are mapped to widgets properties
+    map[NmHsWidgetParamAccountId] = QString::number(accountId);
+    map[NmHsWidgetParamAccountIconName] = accountIconName;
+    //------------------------------
 
-bool NmMailboxRegisterInterfacePrivate::registerNewMailbox(quint64 accountId,
-        QString accountName, QString accountIconName)
-    {
-    //check that accountIconName is valid otherwise pass default mailbox icon
-    HbIcon mailBoxIcon(accountIconName);
-    if(mailBoxIcon.pixmap().height() == 0){
-        mailBoxIcon = NmIcons::getIcon(NmIcons::NmIconDefaultMailbox);
-        accountIconName = mailBoxIcon.iconName();
+    bool retVal(false);
+    bool ret(false);
+    ret = QMetaObject::invokeMethod( mService,"add",
+        Qt::DirectConnection,
+        Q_RETURN_ARG(bool, retVal),
+        Q_ARG(QVariantMap, map));
+
+    //Push the registered widget also to homescreen right away
+    bool pushRetVal = pushWidgetToHomescreen(accountId, accountIconName);
+
+    return (retVal && ret && pushRetVal);
+}
+
+bool NmMailboxRegisterInterfacePrivate::updateMailboxName(quint64 accountId, QString newName)
+{
+    NM_FUNCTION;
+
+    if(!loadMenuClientService()){
+    	NM_ERROR(1,"loadService() failed!");
+        return false; 
     }
     
     QMap<QString, QVariant> map;
     //------------------------------
-    map[hsItemName]        = accountName;
-    map[hsitemLaunchUri]   = formLaunchUri(accountId);
+    map[hsitemLaunchUri] = formLaunchUri(accountId);
     map[hsitemPublisherId] = NmPublisherName;
-    map[hsItemWidgetUri]   = NmHsWidget;
-    //commented out until MCL has nmregister files in place here: epoc32/include/platform/qt/translations/
-    //map[hsItemDescription] = hbTrId("txt_mail_widget_dblist_preview_of_recent_mail");
-    map[hsItemDescription] = "test description for widget";
-    map[hsIconFileName]    = accountIconName;
-    // to add widget params that are mapped to widgets properties
-    map[NmHsWidgetParamAccountId]   = QString::number(accountId);
-    map[NmHsWidgetParamAccountIconName]   = accountIconName;
+    map[hsItemWidgetUri] = NmHsWidget;
+    map[NmHsWidgetParamAccountId] = QString::number(accountId);
     //------------------------------
-    
+
+    QList<QVariantMap> list; //list of items that mach the query
     bool retVal(false);
+    bool ret(false);
+    ret = QMetaObject::invokeMethod(mService, "getList", 
+        Qt::DirectConnection, 
+        Q_RETURN_ARG(QList<QVariantMap> , list),
+        Q_ARG(QVariantMap, map));
+
+    //Normally there should be only one instance, but just in case
+    while (!list.isEmpty()) {
+        //update the account name
+        list.first()[hsItemName] = newName;
+        //commit changes
+        ret = QMetaObject::invokeMethod( mService,"add",
+            Qt::DirectConnection,
+            Q_RETURN_ARG(bool, retVal),
+            Q_ARG(QVariantMap, list.first()));
+        list.removeFirst();
+    }
+    //if either invoke or "getList" or "add" return failure
+    return (retVal && ret);
+}
+
+bool NmMailboxRegisterInterfacePrivate::unregisterMailbox(quint64 accountId)
+{
+    NM_FUNCTION;
+
+    if(!loadMenuClientService()){
+    	NM_ERROR(1,"loadService() failed!");
+        return false; 
+    }
     
-    bool ret = QMetaObject::invokeMethod(  mService,"add",
-                    Qt::DirectConnection,
-                    Q_RETURN_ARG(bool, retVal),
-                    Q_ARG(QVariantMap, map)); 
+    QMap<QString, QVariant> map;
+    //------------------------------
+    map[hsitemLaunchUri] = formLaunchUri(accountId);
+    map[hsitemPublisherId] = NmPublisherName;
+    map[hsItemWidgetUri] = NmHsWidget;
+    map[NmHsWidgetParamAccountId] = QString::number(accountId);
+    //------------------------------
 
-    //Push the registered widget also to homescreen right away
-    bool pushRetVal = pushWidgetToHomescreen(accountId, accountIconName);
-    
-    return (retVal && ret && pushRetVal);
+    QList<QVariantMap> list; //list of items that mach the query
+    bool retVal(false);
+    bool ret(false);
+    ret = QMetaObject::invokeMethod(mService, "getList", 
+        Qt::DirectConnection, 
+        Q_RETURN_ARG(QList<QVariantMap> , list), 
+        Q_ARG(QVariantMap, map));
+
+    //Normally there should be only one instance, but just in case
+    //Otherwise there will be ghost instances in the application list
+    while (!list.isEmpty()) {
+
+        //commit changes
+        ret = QMetaObject::invokeMethod( mService,"remove",
+            Qt::DirectConnection,
+            Q_RETURN_ARG(bool, retVal),
+            Q_ARG(QVariantMap, list.first()));
+        list.removeFirst();
     }
 
-bool NmMailboxRegisterInterfacePrivate::updateMailboxName(quint64 accountId,
-        QString newName)
-    {
-    QMap<QString, QVariant> map;
-     //------------------------------
-     map[hsitemLaunchUri]   = formLaunchUri(accountId);
-     map[hsitemPublisherId] = NmPublisherName;
-     map[hsItemWidgetUri]   = NmHsWidget;
-     map[NmHsWidgetParamAccountId]   = QString::number(accountId);
-     //------------------------------
-     
-     QList<QVariantMap> list; //list of items that mach the query
-     bool retVal(false);
-     bool ret = QMetaObject::invokeMethod(  mService,"getList",
-                     Qt::DirectConnection,
-                     Q_RETURN_ARG(QList<QVariantMap>, list),
-                     Q_ARG(QVariantMap, map)); 
-
-     
-     //Normally there should be only one instance, but just in case
-     while( !list.isEmpty() ) 
-         {  
-         //update the account name
-         list.first()[hsItemName] = newName;
-         //commit changes
-         ret = QMetaObject::invokeMethod(  mService,"add",
-                         Qt::DirectConnection,
-                         Q_RETURN_ARG(bool, retVal),
-                         Q_ARG(QVariantMap, list.first()));  
-         list.removeFirst();
-         }
-     //if either invoke or "getList" or "add" return failure
-     return (retVal && ret);
-    }
+    return (retVal && ret);
+}
 
-bool NmMailboxRegisterInterfacePrivate::unregisterMailbox(quint64 accountId)
-    {
-    
-    QMap<QString, QVariant> map;
-     //------------------------------
-     map[hsitemLaunchUri]   = formLaunchUri(accountId);
-     map[hsitemPublisherId] = NmPublisherName;
-     map[hsItemWidgetUri]   = NmHsWidget;
-     map[NmHsWidgetParamAccountId]     = QString::number(accountId);
-     //------------------------------
-     
-     QList<QVariantMap> list; //list of items that mach the query
-     bool retVal(false);
-     bool ret = QMetaObject::invokeMethod(  mService,"getList",
-                     Qt::DirectConnection,
-                     Q_RETURN_ARG(QList<QVariantMap>, list),
-                     Q_ARG(QVariantMap, map)); 
-    
+bool NmMailboxRegisterInterfacePrivate::pushWidgetToHomescreen(
+    quint64 accountId,
+    QString accountIconName)
+{
+    NM_FUNCTION;
     
-    //Normally there should be only one instance, but just in case
-    //Otherwise there will be ghost instances in the application list
-     while( !list.isEmpty() ) 
-         {  
-
-         //commit changes
-         ret = QMetaObject::invokeMethod(  mService,"remove",
-                         Qt::DirectConnection,
-                         Q_RETURN_ARG(bool, retVal),
-                         Q_ARG(QVariantMap, list.first()));  
-         list.removeFirst();
-         }
-
-     return (retVal && ret);
-    }
-
-bool NmMailboxRegisterInterfacePrivate::pushWidgetToHomescreen( quint64 accountId, QString accountIconName )
-    {
     // load plugin
     QServiceManager manager;
     QServiceFilter filter("com.nokia.symbian.IHomeScreenClient");
     filter.setServiceName("hshomescreenclientplugin");
     QList<QServiceInterfaceDescriptor> interfaces = manager.findInterfaces(filter);
-    
-    if(interfaces.isEmpty()) 
-        {
-        QServiceManager::Error errori = manager.error();
+
+    if (interfaces.isEmpty()) {
         return false;
-        }
-    QObject* service = manager.loadInterface( interfaces.first() );
-    if(!service){qDebug() << "service is null ";}
-    
+    }
+    QObject* service = manager.loadInterface(interfaces.first());
+    if (!service) {
+        NM_ERROR(1,"service is null ");
+        return false;
+    }
+
     //--------------------------------
     QVariantHash map;
     map[NmHsAccountId] = QString::number(accountId);
     map[NmHsAccountIconName] = accountIconName;
     //--------------------------------
-    
+
     // invoke function synchronously
     bool retVal(false);
-    bool ret = QMetaObject::invokeMethod(  service, "addWidget",
-                    Qt::DirectConnection,
-                    Q_RETURN_ARG(bool, retVal),
-                    Q_ARG(QString, NmHsWidget),
-                    Q_ARG(QVariantHash, map));
-   
-    if(!ret){
-        qDebug()<< "method invoke failed!";
-    }
-    if(!retVal){
-        qDebug() << "addWidget() failed!!";
-    }
-    
-    if(service)
-        {
-        delete service;
-        }
-    
+    bool ret(false);
+    ret = QMetaObject::invokeMethod( service, "addWidget",
+        Qt::DirectConnection,
+        Q_RETURN_ARG(bool, retVal),
+        Q_ARG(QString, NmHsWidget),
+        Q_ARG(QVariantHash, map));
+
+    delete service;
+    service = NULL;
+
     return (retVal && ret);
-    }
+}
 
 QString NmMailboxRegisterInterfacePrivate::formLaunchUri(quint64 accountId) const
-    {
+{
     return NmLaunchUri + QString::number(accountId);
-    }
+}
--- a/emailservices/nmregister/src/nmmailboxregisterinterfaceplugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmregister/src/nmmailboxregisterinterfaceplugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
 *
 */
 
+#include "emailtrace.h"
+
 #include <qserviceinterfacedescriptor.h>
 #include <qabstractsecuritysession.h>
 #include <qservicecontext.h>
@@ -30,17 +32,23 @@
                                                 QServiceContext *context,
                                                 QAbstractSecuritySession *session)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(context);
     Q_UNUSED(session);
-
+    
     if (descriptor.interfaceName() == QLatin1String("com.nokia.symbian.IEmailRegisterAccount")) {
-        return new NmMailboxRegisterInterface(this);
+        QT_TRY{
+            return new NmMailboxRegisterInterface(this);
+        }QT_CATCH(...){
+            return 0;
+        }
     } else {
         return 0;
     }
 }
 
-Q_EXPORT_PLUGIN2(hsmenucontentpublishplugin, NmMailboxRegisterInterfacePlugin)
+Q_EXPORT_PLUGIN2(nmregister, NmMailboxRegisterInterfacePlugin)
 
 #ifdef COVERAGE_MEASUREMENT
 #pragma CTC ENDSKIP
--- a/emailservices/nmregister/translations/nmregister.ts	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmregister/translations/nmregister.ts	Thu Jul 22 16:30:28 2010 +0100
@@ -3,23 +3,23 @@
 <TS version="3.0" sourcelanguage="en_GB">
 <context>
 <message numerus="no" id="txt_mail_widget_l_dblist_preview_of_recent_mail">
-    <comment>Custom layout ID parent (no children). Descriptive text of mail widget in application library, landscape</comment>        
+    <comment>Descriptive text of mail widget in application library, landscape</comment>        
     <source>Preview of recent mail</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_widget_l_dblist_preview_of_recent_mail</extra-loc-layout_id>    
+    <extra-loc-layout_id>qtl_list_sec2_large_graphic</extra-loc-layout_id>    
     <extra-loc-viewid>Mail Widget_L07</extra-loc-viewid>
     <extra-loc-positionid>dblist_1_val</extra-loc-positionid>
-    <extra-loc-feature>Mail Widget</extra-loc-feature>
+    <extra-loc-feature>Ma</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_widget_dblist_preview_of_recent_mail">
-    <comment>Custom layout ID parent (no children). Descriptive text of mail widget in application library, portrait</comment>        
+    <comment>Descriptive text of mail widget in application library, portrait</comment>        
     <source>Preview of recent mail</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_widget_dblist_preview_of_recent_mail</extra-loc-layout_id>    
+    <extra-loc-layout_id>qtl_list_sec_large_graphic</extra-loc-layout_id>    
     <extra-loc-viewid>Mail Widget_P07</extra-loc-viewid>
     <extra-loc-positionid>dblist_1_val</extra-loc-positionid>
-    <extra-loc-feature>Mail Widget</extra-loc-feature>
+    <extra-loc-feature>Ma</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 </context>
Binary file emailservices/nmutilities/data/2001E277.txt has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmutilities/data/icons/aol.svg	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="44" height="44" viewBox="0 0 44 44">
+<rect fill="none" height="44" width="44"/>
+<circle cx="16.782" cy="22.024" fill="#0360A8" r="9.291"/>
+<path d="M4.518,17.73c0.18,0.019,0.272-0.093,0.379-0.323c0.119-0.258,0.648-1.375,0.735-1.551 c0.231-0.471,1.167-1.821,1.349-2.031c0.863-1.013,1.889-1.956,3.134-2.73c1.509-0.926,3.344-1.63,5.262-1.864 c0.462-0.061,1.577-0.099,1.793-0.087c0.427,0.012,1.587,0.132,1.617,0.131c0.085,0.004,0.271-0.014,0.313-0.167 c0.016-0.052-0.005-0.125-0.032-0.156c-0.004-0.004-0.012-0.015-0.014-0.02c-0.019-0.028-0.09-0.087-0.104-0.098 c-0.138-0.105-1.564-0.922-1.657-0.977c-1.035-0.593-9.261-5.346-9.288-5.362C7.279,2.08,6.6,1.943,6.048,2.021 c-0.405,0.057-0.777,0.255-1.045,0.55C4.74,2.853,4.545,3.249,4.441,3.717C4.385,3.978,4.356,4.3,4.356,4.615 c0,0.485-0.01,12.065-0.006,12.406C4.353,17.416,4.326,17.697,4.518,17.73z" fill="#0360A8"/>
+<path d="M19.096,34.852c-0.078-0.121-0.215-0.131-0.438-0.109c-0.053,0-0.107,0.014-0.155,0.018 c-1.094,0.143-2.195,0.131-3.269-0.012c-1.696-0.223-3.345-0.786-4.828-1.652c-1.494-0.877-2.82-2.066-3.885-3.531 c-0.253-0.356-0.496-0.729-0.715-1.111C5.504,27.93,4.97,26.734,4.94,26.669c-0.065-0.136-0.055-0.131-0.143-0.278 c-0.042-0.06-0.091-0.101-0.154-0.117c-0.062-0.017-0.1-0.012-0.135-0.004c-0.079,0.026-0.097,0.045-0.124,0.135 c-0.005,0.029-0.009,0.113-0.017,0.193c-0.002,0.029-0.004,0.135-0.007,0.262c-0.005,0.205-0.003,0.16-0.003,0.355 c0,0.165,0,0.328,0,0.495c0,0.181,0,0.358,0,0.537c0,0.106,0,0.219,0,0.333c0,0.466,0,0.938,0.005,1.411c0,0.725,0,1.446,0,2.174 c0,1.194,0,2.388,0.003,3.58c0,1.196,0,2.392,0,3.584c0,0.034,0,0.065,0,0.103c0,1.418,0.623,2.315,1.571,2.524 c0.376,0.08,0.797,0.06,1.25-0.088c0.256-0.078,0.525-0.199,0.798-0.354c0.427-0.244,10.373-5.979,10.896-6.285 c0.016-0.004,0.068-0.045,0.122-0.097C19.067,35.061,19.154,34.964,19.096,34.852z" fill="#0360A8"/>
+<path d="M26.605,30.391c-0.17-0.162-0.008-0.394,0.256-0.738c0.143-0.188,0.679-0.938,0.773-1.09 c0.336-0.537,0.648-1.09,0.912-1.662c0.123-0.264,0.232-0.531,0.326-0.807c0.456-1.345,0.786-2.753,0.786-4.181 c-0.015-1.726-0.251-3.33-0.929-5.03c-0.158-0.406-0.66-1.395-0.722-1.507c-0.223-0.418-0.538-0.869-0.884-1.364 c-0.282-0.362-0.24-0.553-0.137-0.604c0.021-0.012,0.078-0.031,0.152-0.009c0.03,0.009,0.09,0.021,0.192,0.077 c0.071,0.033,0.205,0.105,0.325,0.174c0.135,0.081,1.1,0.656,1.195,0.708c1.027,0.604,2.023,1.21,3.054,1.812 c1.036,0.596,6.225,3.678,6.251,3.693c0.722,0.426,1.178,0.953,1.373,1.472c0.143,0.379,0.154,0.779,0.031,1.16 c-0.111,0.366-0.349,0.724-0.701,1.044c-0.199,0.184-0.44,0.35-0.715,0.506c-0.422,0.242-10.662,6.021-10.969,6.189 C26.891,30.393,26.738,30.503,26.605,30.391z" fill="#0360A8"/>
+<path d="M15.184,40.294c0,0.92,0.72,1.646,1.634,1.646c0.895,0,1.644-0.752,1.644-1.646 c0-0.938-0.706-1.647-1.644-1.647C15.918,38.646,15.184,39.387,15.184,40.294z M15.435,40.275c0-0.77,0.624-1.393,1.383-1.393 c0.759,0,1.382,0.637,1.382,1.424c0,0.771-0.623,1.396-1.382,1.396C16.069,41.704,15.435,41.051,15.435,40.275z" fill="#0360A8"/>
+<path d="M17.127,40.645l-0.215-0.31l0.05-0.008c0.289-0.031,0.464-0.224,0.464-0.515 c0-0.293-0.201-0.441-0.592-0.441c0,0-0.479,0-0.532,0v1.816h0.301c0-0.059-0.004-0.84-0.004-0.84l0.026,0.006l0.529,0.834 c0,0,0.25,0.006,0.327,0.004C17.432,41.111,17.127,40.645,17.127,40.645z M16.592,40.145v-0.518c0.044,0,0.209,0.005,0.209,0.005 c0.241,0,0.286,0.077,0.286,0.222c0,0.071-0.027,0.295-0.366,0.295C16.721,40.148,16.624,40.145,16.592,40.145z" fill="#0360A8"/>
+</svg>
\ No newline at end of file
Binary file emailservices/nmutilities/data/nmutilities.confml has changed
--- a/emailservices/nmutilities/inc/emailmailboxinfo_p.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmutilities/inc/emailmailboxinfo_p.h	Thu Jul 22 16:30:28 2010 +0100
@@ -63,11 +63,6 @@
      */
     QString mTempIcon;
     QString mTempName;
-
-    /*! 
-         information about success or failure during resource file load
-     */
-    bool mIsResourceLoaded;
     
     /*!
          Map of already imported branding keys
--- a/emailservices/nmutilities/nmutilities.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmutilities/nmutilities.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -26,8 +26,9 @@
 MOBILITY += systeminfo
 
 INCLUDEPATH += inc \
+               ../../inc \
                ../../../inc \
-               $$MW_LAYER_SYSTEMINCLUDE 
+               $$MW_LAYER_SYSTEMINCLUDE
 
 DEPENDPATH += src \
               inc \
@@ -73,12 +74,28 @@
 }
 
 #creating rcc file from qrc
-system(rcc -binary data/email_brand.qrc -o data/email_brand.rcc)
+#system(rcc -binary data/email_brand.qrc -o data/email_brand.rcc)
+#RESOURCES += data/email_brand.qrc
+#"data/email_brand.rcc                  /epoc32/data/Z/resource/apps/email_brand.rcc" \
 
 # Build.inf rules  
 BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>" \
                              "rom/nmutilities.iby $$CORE_APP_LAYER_IBY_EXPORT_PATH(nmutilities.iby)" \
-                             "data/email_brand.rcc                  /epoc32/data/Z/resource/apps/email_brand.rcc" \
+                             "data/icons/gmail.svg                  /epoc32/release/winscw/udeb/z/resource/apps/gmail.svg" \
+                             "data/icons/gmail.svg                  /epoc32/release/winscw/urel/z/resource/apps/gmail.svg" \
+                             "data/icons/gmail.svg                  /epoc32/data/z/resource/apps/gmail.svg" \
+                             "data/icons/microsoft.svg              /epoc32/release/winscw/udeb/z/resource/apps/microsoft.svg" \
+                             "data/icons/microsoft.svg              /epoc32/release/winscw/urel/z/resource/apps/microsoft.svg" \
+                             "data/icons/microsoft.svg              /epoc32/data/z/resource/apps/microsoft.svg" \
+                             "data/icons/ovi.svg                    /epoc32/release/winscw/udeb/z/resource/apps/ovi.svg" \
+                             "data/icons/ovi.svg                    /epoc32/release/winscw/urel/z/resource/apps/ovi.svg" \
+                             "data/icons/ovi.svg                    /epoc32/data/z/resource/apps/ovi.svg" \
+                             "data/icons/yahoo.svg                  /epoc32/release/winscw/udeb/z/resource/apps/yahoo.svg" \
+                             "data/icons/yahoo.svg                  /epoc32/release/winscw/urel/z/resource/apps/yahoo.svg" \
+                             "data/icons/yahoo.svg                  /epoc32/data/z/resource/apps/yahoo.svg" \
+                             "data/icons/aol.svg                    /epoc32/release/winscw/udeb/z/resource/apps/aol.svg" \
+                             "data/icons/aol.svg                    /epoc32/release/winscw/urel/z/resource/apps/aol.svg" \
+                             "data/icons/aol.svg                    /epoc32/data/z/resource/apps/aol.svg" \
                              "data/2001E277.txt                     /epoc32/release/winscw/udeb/z/private/10202be9/2001E277.txt" \
                              "data/2001E277.txt                     /epoc32/release/winscw/urel/z/private/10202be9/2001E277.txt" \
                              "data/2001E277.txt                     /epoc32/data/z/private/10202be9/2001E277.txt" \
--- a/emailservices/nmutilities/rom/nmutilities.iby	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmutilities/rom/nmutilities.iby	Thu Jul 22 16:30:28 2010 +0100
@@ -20,5 +20,10 @@
 #include <bldvariant.hrh>
 
 file=ABI_DIR\BUILD_DIR\nmutilities.dll SHARED_LIB_DIR\nmutilities.dll   PAGED
+data=DATAZ_\APP_BITMAP_DIR\ovi.svg     APP_BITMAP_DIR\ovi.svg 
+data=DATAZ_\APP_BITMAP_DIR\gmail.svg   APP_BITMAP_DIR\gmail.svg 
+data=DATAZ_\APP_BITMAP_DIR\microsoft.svg    APP_BITMAP_DIR\microsoft.svg 
+data=DATAZ_\APP_BITMAP_DIR\yahoo.svg   APP_BITMAP_DIR\yahoo.svg 
+data=DATAZ_\APP_BITMAP_DIR\aol.svg   APP_BITMAP_DIR\aol.svg 
 
 #endif // __NMUTILITIES_IBY__
--- a/emailservices/nmutilities/src/emailmailboxinfo.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmutilities/src/emailmailboxinfo.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
  *
  */
 
+#include "emailtrace.h"
+
 #include "emailmailboxinfo.h"
 #include "emailmailboxinfo_p.h"
 
@@ -23,6 +25,8 @@
  */
 EmailMailboxInfo::EmailMailboxInfo()
 {
+    NM_FUNCTION;
+    
     d = EmailMailboxInfoPrivate::getInstance();
 }
 
@@ -31,6 +35,8 @@
  */
 EmailMailboxInfo::~EmailMailboxInfo()
 {
+    NM_FUNCTION;
+    
     EmailMailboxInfoPrivate::releaseInstance(d);
 }
 
@@ -41,6 +47,8 @@
  */
 QString EmailMailboxInfo::mailboxIcon(const QVariant &identifier) const
 {
+    NM_FUNCTION;
+    
     return d->icon(identifier);
 }
 
@@ -51,6 +59,8 @@
  */
 QString EmailMailboxInfo::mailboxName(const QVariant &identifier) const
 {
+    NM_FUNCTION;
+    
     return d->name(identifier);
 }
 
--- a/emailservices/nmutilities/src/emailmailboxinfo_p.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailservices/nmutilities/src/emailmailboxinfo_p.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
  *
  */
 
+#include "emailtrace.h"
+
 #include "emailmailboxinfo_p.h"
 #include "nmutilitiescommonheaders.h"
 #include "nmcenrepkeys.h"
@@ -44,28 +46,23 @@
      private constructor
  */
 EmailMailboxInfoPrivate::EmailMailboxInfoPrivate() :
-    QObject(NULL), 
-	mIsResourceLoaded(false)
+    QObject(NULL)
 {
+    NM_FUNCTION;
+    
     XQSettingsManager manager;
     XQCentralRepositorySettingsKey rccKey(EMAIL_CENREP, RCC_PATH);
 
     XQCentralRepositorySettingsKey wlbKey(EMAIL_CENREP, WLB_BRAND_NAME);
 
-    mWlbDomainName = manager.readItemValue(wlbKey, XQSettingsManager::TypeString).value<QString> ();
-
-    QString pathToRcc =
-        manager.readItemValue(rccKey, XQSettingsManager::TypeString).value<QString> ();
-    if (!mIsResourceLoaded) {
-        mIsResourceLoaded = QResource::registerResource(pathToRcc);
-    }
+    mWlbDomainName = manager.readItemValue(wlbKey, XQSettingsManager::TypeString).value<QString> ();    
 }
 /*!
      private destructor
  */
 EmailMailboxInfoPrivate::~EmailMailboxInfoPrivate()
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -74,6 +71,8 @@
  */
 EmailMailboxInfoPrivate* EmailMailboxInfoPrivate::getInstance()
 {
+    NM_FUNCTION;
+    
     if (!mSelf) {
         mSelf = new EmailMailboxInfoPrivate();
     }
@@ -87,6 +86,8 @@
  */
 void EmailMailboxInfoPrivate::releaseInstance(EmailMailboxInfoPrivate *&instance)
 {
+    NM_FUNCTION;
+    
     if (instance) {
         mReferenceCount--;
         instance = NULL;
@@ -104,6 +105,8 @@
  */
 QString EmailMailboxInfoPrivate::name(const QVariant &identifier)
 {
+    NM_FUNCTION;
+    
     QString returnValue = "";
     QString domainName = "";
     if (identifier.canConvert<QString> ()) {
@@ -127,10 +130,16 @@
  */
 QString EmailMailboxInfoPrivate::icon(const QVariant &identifier)
 {
+    NM_FUNCTION;
+    
     QString returnValue = "";
     QString domainName = "";
     if (identifier.canConvert<QString> ()) {
         domainName = identifier.value<QString> ();
+        int delimIndex = domainName.lastIndexOf('@');
+        if(delimIndex >= 0) {
+            domainName = domainName.mid(delimIndex + 1);
+        }
     }
 
     if (domainName.length() > 0){
@@ -147,6 +156,8 @@
  */
 void EmailMailboxInfoPrivate::processCenRepRecords(const QString &brandingId)
 {
+    NM_FUNCTION;
+    
     bool found = false;
     QString name;
     QString icon;
@@ -198,13 +209,13 @@
 
             if (regExp.exactMatch(brandingId)) { //match
                 found = true;
-                icon = ":/" + cenRepRecord.at(3);
+                icon = "z:/resource/apps/" + cenRepRecord.at(3) + ".svg";
                 name = cenRepRecord.at(2);
                 break;
             }
         }
     }
-    if (!found || !mIsResourceLoaded) {
+    if (!found ) { 
         //get default icon and name
         icon = "qtg_large_email";
         QStringList domain = brandingId.split(".");
@@ -222,6 +233,8 @@
  */
 quint8 EmailMailboxInfoPrivate::getCurrentCountryL() const
 {
+    NM_FUNCTION;
+    
     CTzLocalizer* localizer = CTzLocalizer::NewLC();
 
     CTzLocalizedCity* city = localizer->GetFrequentlyUsedZoneCityL(
@@ -246,6 +259,8 @@
  */
 bool EmailMailboxInfoPrivate::verifyTimeZone() const
 {
+    NM_FUNCTION;
+    
     quint8 timeZone = 0;
     bool retVal = false;
     TRAPD(err, timeZone = getCurrentCountryL());
@@ -262,6 +277,8 @@
  */
 void EmailMailboxInfoPrivate::verifyMailAccountName(QString &brandingName) const
 {
+    NM_FUNCTION;
+    
     QSystemNetworkInfo *networkInfo = new QSystemNetworkInfo();
     QString currentMCC = networkInfo->currentMobileCountryCode();
 
--- a/emailuis/nmailcpplugin/inc/nmsettingsplugin.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailcpplugin/inc/nmsettingsplugin.h	Thu Jul 22 16:30:28 2010 +0100
@@ -18,17 +18,17 @@
 #ifndef NMSETTINGSPLUGIN_H
 #define NMSETTINGSPLUGIN_H
 
-#include <cppluginplatinterface.h>
+#include <cpplugininterface.h>
 #include <qobject.h>
 
 class CpSettingFormItemData;
 class CpItemDataHelper;
 class QTranslator;
 
-class NmSettingsPlugin : public QObject, public CpPluginPlatInterface
+class NmSettingsPlugin : public QObject, public CpPluginInterface
     {
     Q_OBJECT
-    Q_INTERFACES(CpPluginPlatInterface)
+    Q_INTERFACES(CpPluginInterface)
 
 public:
 
@@ -36,7 +36,7 @@
 
     virtual ~NmSettingsPlugin();
 
-    virtual CpSettingFormItemData *createSettingFormItemData(
+    virtual QList<CpSettingFormItemData*> createSettingFormItemData(
         CpItemDataHelper &itemDataHelper) const;
 
 private:
--- a/emailuis/nmailcpplugin/src/nmsettingsplugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailcpplugin/src/nmsettingsplugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
 *
 */
 
+#include "emailtrace.h"
+
 #include <cpsettingformentryitemdataimpl.h>
 #include <HbApplication>
 #include <QTranslator>
@@ -25,7 +27,7 @@
 
 /*!
     \class NmSettingsPlugin
-    \brief The class implements CpPluginPlatInterface which is an interface
+    \brief The class implements CpPluginInterface which is an interface
            for plug-ins that are displayed in the control panel application.
            The class works as an entry point for NMail settings.
 
@@ -39,6 +41,8 @@
 NmSettingsPlugin::NmSettingsPlugin()
 : mTranslator(0)
 {
+    NM_FUNCTION;
+    
     mTranslator = new QTranslator();
     QString lang = QLocale::system().name();
     QString appName = "mail_";
@@ -52,6 +56,8 @@
 */
 NmSettingsPlugin::~NmSettingsPlugin()
 {
+    NM_FUNCTION;
+    
     delete mTranslator;
 }
 
@@ -61,17 +67,20 @@
     \param itemDataHelper Helper class that helps control panel plug-ins to
            connect slots to inner widgets of the setting items.
 
-    \return Instance of CpSettingFormItemData.
-            Caller is the owner of the returned instance.
+    \return List of CpSettingFormItemData items.
 */
-CpSettingFormItemData *NmSettingsPlugin::createSettingFormItemData(
+QList<CpSettingFormItemData*> NmSettingsPlugin::createSettingFormItemData(
     CpItemDataHelper &itemDataHelper) const
 {
+    NM_FUNCTION;
+    
     HbIcon icon("qtg_large_email");
+    QList<CpSettingFormItemData*> list;
 
-    return new NmSettingsViewFactory(itemDataHelper,
-        hbTrId("txt_mail_title_control_panel"), "",
-        icon);
+    CpSettingFormItemData* viewFactory = new NmSettingsViewFactory(itemDataHelper,
+        hbTrId("txt_mail_title_control_panel"), "", icon);
+    list.append(viewFactory);
+    return list;
 }
 
 Q_EXPORT_PLUGIN2(nmsettingsplugin, NmSettingsPlugin);
--- a/emailuis/nmailui/conf/nmeditorview.docml	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/conf/nmeditorview.docml	Thu Jul 22 16:30:28 2010 +0100
@@ -1,131 +1,133 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hbdocument version="1.0">
+<hbdocument version="1.1">
     <widget name="editorview" type="HbView">
         <widget name="content" role="HbView:widget" type="HbWidget">
             <widget name="scrollArea" plugin="nmailuiwidgetsplugin" type="NmBaseViewScrollArea">
                 <widget name="scrollAreaContents" role="HbScrollArea:contents" type="HbWidget">
-                    <widget name="container" type="HbWidget">
-                        <widget name="HeaderLayout" type="HbWidget">
-                            <widget name="ToHorizontalLayout" type="HbWidget">
-                                <widget name="EditorHeaderToLabel" type="HbLabel">
-                                    <sizehint height="5un" type="PREFERRED" width="10un"/>
-                                    <sizehint height="5un" type="MINIMUM" width="1.89552un"/>
-                                    <string locid="txt_mail_editor_to" name="plainText" value="To:"/>
-                                    <fontspec name="fontSpec" role="Secondary" textheight="23.45"/>
-                                </widget>
-                                <widget name="EditorHeaderToEdit" plugin="nmailuiwidgetsplugin" type="NmRecipientLineEdit">
-                                    <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-                                    <sizehint height="5un" type="PREFERRED" width="8.26269un"/>
-                                    <sizehint height="5un" type="MINIMUM" width="0un"/>
-                                    <fontspec name="fontSpec" role="Secondary" textheight="3.5un"/>
-                                    <integer name="maxRows" value="256"/>
-                                    <string name="alignment" value="AlignAbsolute"/>
-                                    <string name="text" value=""/>
-                                </widget>
-                                <widget name="EditorHeaderToButton" type="HbPushButton">
-                                    <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-                                    <sizehint height="5un" type="FIXED" width="9.5un"/>
-                                    <sizehint height="5un" type="MINIMUM" width="9.5un"/>
-                                    <sizehint height="5un" type="MAXIMUM" width="9.5un"/>
-                                    <string name="text" value=""/>
-                                </widget>
-                                <real name="z" value="0"/>
-                                <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Minimum" verticalStretch="0"/>
-                                <sizehint height="5un" type="MINIMUM" width="23.8806un"/>
-                                <layout orientation="Horizontal" spacing="1un" type="linear">
-                                    <contentsmargins bottom="0un" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="0un"/>
-                                    <linearitem itemname="EditorHeaderToLabel"/>
-                                    <linearitem itemname="EditorHeaderToEdit"/>
-                                    <linearitem itemname="EditorHeaderToButton"/>
-                                </layout>
-                            </widget>
-                            <widget name="EditorHeaderRecipientGB" type="HbGroupBox">
-                                <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Minimum" verticalStretch="0"/>
-                                <bool name="collapsable" value="FALSE"/>
-                                <bool name="collapsed" value="FALSE"/>
-                                <fontspec name="fontSpec" role="Secondary" textheight="23.45"/>
-                            </widget>
-                            <widget name="SubjectHorizontalLayout" type="HbWidget">
-                                <widget name="EditorHeaderSubjectLabel" type="HbLabel">
-                                    <sizehint height="5un" type="PREFERRED" width="11un"/>
-                                    <string locid="txt_mail_editor_subject" name="plainText" value="Subject:"/>
-                                    <fontspec name="fontSpec" role="Secondary" textheight="23.45"/>
-                                </widget>
-                                <widget name="EditorHeaderSubjectEdit" plugin="nmailuiwidgetsplugin" type="NmHtmlLineEdit">
-                                    <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-                                    <sizehint height="5un" type="PREFERRED" width="8.26269un"/>
-                                    <sizehint height="5un" type="MINIMUM" width="0un"/>
-                                    <fontspec name="fontSpec" role="Secondary" textheight="3.5un"/>
-                                    <integer name="maxRows" value="256"/>
-                                    <string name="alignment" value="AlignAbsolute"/>
-                                    <string name="text" value=""/>
-                                </widget>
-                                <widget name="labelPriorityIcon" type="HbLabel">
-                                    <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
-                                    <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-                                    <sizehint height="5un" type="MINIMUM" width="0un"/>
-                                    <sizehint height="5un" type="MAXIMUM" width="0un"/>
-                                </widget>
-                                <real name="z" value="0"/>
-                                <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Minimum" verticalStretch="0"/>
-                                <sizehint height="5un" type="MINIMUM" width="23.8806un"/>
-                                <layout orientation="Horizontal" spacing="0un" type="linear">
-                                    <contentsmargins bottom="0un" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="0un"/>
-                                    <linearitem itemname="EditorHeaderSubjectLabel"/>
-                                    <linearitem itemname="EditorHeaderSubjectEdit"/>
-                                    <linearitem itemname="labelPriorityIcon"/>
-                                </layout>
-                            </widget>
-                            <widget name="attachmentListWidget" plugin="nmailuiwidgetsplugin" type="NmAttachmentListWidget">
-                                <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="MinimumExpanding" verticalStretch="0"/>
-                                <sizehint height="0.1un" type="MINIMUM" width="25.6194un"/>
-                                <contentsmargins bottom="var(hb-param-margin-gene-middle-vertical)" left="0un" right="0un" top="0un"/>
-                                <sizehint height="0.1un" type="MAXIMUM"/>
-                            </widget>
-                            <real name="z" value="1"/>
-                            <sizepolicy horizontalPolicy="Minimum" horizontalStretch="0" verticalPolicy="Minimum" verticalStretch="0"/>
-                            <sizehint height="18un" type="MINIMUM" width="53.73134un"/>
-                            <sizehint height="200un" type="MAXIMUM" width="2504062.01158un"/>
-                            <layout orientation="Vertical" spacing="1un" type="linear">
-                                <contentsmargins bottom="0un" left="0un" right="0un" top="var(hb-param-margin-gene-top)"/>
-                                <linearitem itemname="ToHorizontalLayout"/>
-                                <linearitem itemname="EditorHeaderRecipientGB"/>
-                                <linearitem itemname="SubjectHorizontalLayout"/>
-                                <linearitem itemname="attachmentListWidget"/>
-                            </layout>
+                    <widget name="editorToField" type="HbWidget">
+                        <widget name="editorToLabel" type="HbLabel">
+                            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                            <sizehint height="7.5un" type="FIXED" width="12.5un"/>
+                            <string locid="txt_mail_editor_to" name="plainText"/>
+                            <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
+                        </widget>
+                        <widget name="editorToEdit" plugin="nmailuiwidgetsplugin" type="NmRecipientLineEdit"/>
+                        <widget name="editorToButton" type="HbPushButton">
+                            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                            <sizehint height="7.5un" type="FIXED" width="9.5un"/>
+                        </widget>
+                        <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
+                        <sizehint type="PREFERRED" width="expr(var(hb-param-screen-width) )"/>
+                        <layout orientation="Horizontal" spacing="var(hb-param-margin-gene-middle-horizontal)" type="linear">
+                            <contentsmargins bottom="0un" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="0un"/>
+                            <linearitem itemname="editorToLabel"/>
+                            <linearitem itemname="editorToEdit"/>
+                            <linearitem itemname="editorToButton"/>
+                        </layout>
+                    </widget>
+                    <widget name="editorCcField" type="HbWidget">
+                        <widget name="editorCcLabel" type="HbLabel">
+                            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                            <sizehint height="7.5un" type="FIXED" width="12.5un"/>
+                            <string locid="txt_mail_editor_cc" name="plainText"/>
+                            <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
+                        </widget>
+                        <widget name="editorCcEdit" plugin="nmailuiwidgetsplugin" type="NmRecipientLineEdit"/>
+                        <widget name="editorCcButton" type="HbPushButton">
+                            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                            <sizehint height="7.5un" type="FIXED" width="9.5un"/>
+                        </widget>
+                        <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
+                        <sizehint type="PREFERRED" width="expr(var(hb-param-screen-width) )"/>
+                        <layout orientation="Horizontal" spacing="var(hb-param-margin-gene-middle-horizontal)" type="linear">
+                            <contentsmargins bottom="0un" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="0un"/>
+                            <linearitem itemname="editorCcLabel"/>
+                            <linearitem itemname="editorCcEdit"/>
+                            <linearitem itemname="editorCcButton"/>
+                        </layout>
+                    </widget>
+                    <widget name="editorBccField" type="HbWidget">
+                        <widget name="editorBccLabel" type="HbLabel">
+                            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                            <sizehint height="7.5un" type="FIXED" width="12.5un"/>
+                            <string locid="txt_mail_editor_bcc" name="plainText"/>
+                            <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
                         </widget>
+                        <widget name="editorBccEdit" plugin="nmailuiwidgetsplugin" type="NmRecipientLineEdit"/>
+                        <widget name="editorBccButton" type="HbPushButton">
+                            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                            <sizehint height="7.5un" type="FIXED" width="9.5un"/>
+                        </widget>
+                        <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
+                        <sizehint type="PREFERRED" width="expr(var(hb-param-screen-width) )"/>
+                        <layout orientation="Horizontal" spacing="var(hb-param-margin-gene-middle-horizontal)" type="linear">
+                            <contentsmargins bottom="0un" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="0un"/>
+                            <linearitem itemname="editorBccLabel"/>
+                            <linearitem itemname="editorBccEdit"/>
+                            <linearitem itemname="editorBccButton"/>
+                        </layout>
+                    </widget>
+                    <widget name="editorSubjectField" type="HbWidget">
+                        <widget name="editorSubjectLabel" type="HbLabel">
+                            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                            <sizehint height="7.5un" type="FIXED" width="12.5un"/>
+                            <string locid="txt_mail_editor_subject" name="plainText"/>
+                            <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
+                        </widget>
+                        <widget name="editorSubjectEdit" plugin="nmailuiwidgetsplugin" type="NmHtmlLineEdit"/>
+                        <widget name="editPriorityIcon" type="HbLabel">
+                            <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+                            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                            <sizehint height="var(hb-param-graphic-size-secondary)" type="FIXED" width="var(hb-param-graphic-size-secondary)"/>
+                        </widget>
+                        <widget name="editFollowUpIcon" type="HbLabel">
+                            <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+                            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                            <sizehint height="var(hb-param-graphic-size-secondary)" type="FIXED" width="var(hb-param-graphic-size-secondary)"/>
+                        </widget>
+                        <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
+                        <sizehint type="PREFERRED" width="expr(var(hb-param-screen-width) )"/>
+                        <layout orientation="Horizontal" spacing="var(hb-param-margin-gene-middle-horizontal)" type="linear">
+                            <contentsmargins bottom="0un" left="var(hb-param-margin-gene-left)" right="var(hb-param-margin-gene-right)" top="0un"/>
+                            <linearitem itemname="editorSubjectLabel"/>
+                            <linearitem itemname="editorSubjectEdit"/>
+                            <linearitem itemname="editPriorityIcon" spacing="0.5un"/>
+                            <linearitem itemname="editFollowUpIcon"/>
+                        </layout>
+                    </widget>
+                    <widget name="attachmentListWidget" plugin="nmailuiwidgetsplugin" type="NmAttachmentListWidget">
+                        <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
+                        <sizehint type="PREFERRED" width="expr(var(hb-param-screen-width) )"/>
+                    </widget>
+                    <widget name="BodyTextEditContainer" type="HbWidget">
                         <widget name="BodyTextEdit" plugin="nmailuiwidgetsplugin" type="NmEditorTextEdit">
-                            <real name="z" value="2"/>
-                            <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
-                            <contentsmargins bottom="0un" left="1un" right="1un" top="0un"/>
-                            <fontspec name="fontSpec" role="Secondary" textheight="3.5un"/>
-                            <string name="plainText" value=""/>
+                            <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
+                            <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+                            <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
+                            <string name="plainText"/>
                         </widget>
                         <real name="z" value="0"/>
                         <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
-                        <sizehint height="23.8806un" type="PREFERRED" width="23.8806un"/>
+                        <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
                         <layout type="anchor">
-                            <anchoritem dst="HeaderLayout" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                            <anchoritem dst="HeaderLayout" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                            <anchoritem dst="HeaderLayout" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
-                            <anchoritem dst="BodyTextEdit" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                            <anchoritem dst="BodyTextEdit" dstEdge="TOP" spacing="0un" src="HeaderLayout" srcEdge="BOTTOM"/>
-                            <anchoritem dst="BodyTextEdit" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+                            <anchoritem dst="BodyTextEdit" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
                             <anchoritem dst="BodyTextEdit" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                            <anchoritem dst="BodyTextEdit" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                            <anchoritem dst="BodyTextEdit" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
                         </layout>
                     </widget>
                     <real name="z" value="0"/>
-                    <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
-                    <sizehint height="88un" type="PREFERRED" width="54un"/>
-                    <layout type="anchor">
-                        <anchoritem dst="container" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                        <anchoritem dst="container" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                        <anchoritem dst="container" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
-                        <anchoritem dst="container" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                    <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
+                    <layout orientation="Vertical" spacing="var(hb-param-margin-gene-middle-vertical)" type="linear">
+                        <contentsmargins bottom="0un" left="0un" right="0un" top="var(hb-param-margin-gene-top)"/>
+                        <linearitem itemname="editorToField"/>
+                        <linearitem itemname="editorCcField"/>
+                        <linearitem itemname="editorBccField"/>
+                        <linearitem itemname="editorSubjectField"/>
+                        <linearitem itemname="attachmentListWidget"/>
+                        <linearitem itemname="BodyTextEditContainer"/>
                     </layout>
                 </widget>
-                <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
-                <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
             </widget>
             <layout type="anchor">
                 <anchoritem dst="scrollArea" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
@@ -134,9 +136,9 @@
                 <anchoritem dst="scrollArea" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
             </layout>
         </widget>
-        <string name="title" value=""/>
+        <string name="title"/>
     </widget>
-    <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
     </metadata>
 </hbdocument>
--- a/emailuis/nmailui/conf/nmmailboxlistview.docml	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/conf/nmmailboxlistview.docml	Thu Jul 22 16:30:28 2010 +0100
@@ -1,19 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hbdocument version="0.4">
+<hbdocument version="1.1">
     <widget name="NmMailboxListView" type="HbView">
         <widget name="content" role="HbView:widget" type="HbWidget">
             <widget name="MailboxListWidget" type="HbListView">
-                <sizehint height="85.67164422993572un" type="PREFERRED" width="53.7313448132001un"/>
-                <zvalue value="1.0E-4"/>
             </widget>
-            <layout type="anchor" widget="content">
-                <anchoritem dst="MailboxListWidget" dstEdge="TOP" spacing="0.0un" src="" srcEdge="TOP"/>
-                <anchoritem dst="MailboxListWidget" dstEdge="LEFT" spacing="0.0un" src="" srcEdge="LEFT"/>
-                <anchoritem dst="MailboxListWidget" dstEdge="BOTTOM" spacing="0.0un" src="" srcEdge="BOTTOM"/>
-                <anchoritem dst="MailboxListWidget" dstEdge="RIGHT" spacing="0.0un" src="" srcEdge="RIGHT"/>
+            <layout type="anchor">
+                <anchoritem dst="MailboxListWidget" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                <anchoritem dst="MailboxListWidget" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="MailboxListWidget" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                <anchoritem dst="MailboxListWidget" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
             </layout>
         </widget>
         <string name="title" value="View"/>
     </widget>
-    <metadata display="QHD portrait" unit="un"/>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+        <dummydata objectName="MailboxListWidget" section="#common" value="app_list_template5"/>
+    </metadata>
 </hbdocument>
--- a/emailuis/nmailui/conf/nmmailviewer.docml	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/conf/nmmailviewer.docml	Thu Jul 22 16:30:28 2010 +0100
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hbdocument version="1.0">
+<hbdocument version="1.1">
     <widget name="nmailViewerView" type="HbView">
         <widget name="content" role="HbView:widget" type="HbWidget">
-            <widget name="viewerScrollArea" type="NmBaseViewScrollArea">
+            <widget name="viewerScrollArea" type="HbScrollArea">
                 <widget name="viewerScrollAreaContents" role="HbScrollArea:contents" type="HbWidget">
                     <widget name="viewerHeader" type="NmViewerHeader">
                         <bool name="visible" value="TRUE"/>
@@ -30,9 +30,9 @@
                 <anchoritem dst="viewerScrollArea" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
             </layout>
         </widget>
-        <string name="title" value=""/>
+        <string name="title"/>
     </widget>
-    <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
     </metadata>
 </hbdocument>
--- a/emailuis/nmailui/conf/nmmessagelistview.docml	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/conf/nmmessagelistview.docml	Thu Jul 22 16:30:28 2010 +0100
@@ -1,35 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hbdocument version="1.0">
+<hbdocument version="1.1">
     <widget name="NmMessageListView" type="HbView">
         <widget name="content" role="HbView:widget" type="HbWidget">
             <widget name="MessageTreeList" type="HbTreeView">
-                <real name="z" value="1"/>
-                <sizehint height="76.71642un" type="PREFERRED" width="53.73134un"/>
                 <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
             </widget>
             <widget name="MessageListNoMessages" type="HbLabel">
                 <enums name="alignment" value="AlignLeft|AlignVCenter|AlignHCenter|AlignLeading"/>
-                <real name="z" value="2"/>
-                <sizehint height="4.47761un" type="PREFERRED" width="28.65672un"/>
                 <string locid="txt_mail_dblist_no_messages" name="plainText"/>
                 <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
             </widget>
             <widget name="labelGroupBox" type="HbGroupBox">
-                <real name="z" value="3"/>
-                <sizepolicy horizontalPolicy="MinimumExpanding" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
                 <sizehint height="6un" type="PREFERRED" width="52un"/>
                 <bool name="collapsable" value="FALSE"/>
-            </widget>
-            <widget name="syncIcon" type="HbLabel">
-                <real name="z" value="6"/>
-                <sizehint type="PREFERRED" width="expr(var(hb-param-graphic-size-primary-small) )"/>
-            </widget>
-            <widget name="folderLabel" type="HbLabel">
-                <real name="z" value="5"/>
-                <sizepolicy horizontalPolicy="Preferred" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
-                <sizehint type="PREFERRED" width="45.97015un"/>
-                <string name="plainText" value="Folder"/>
-                <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
+                <bool name="enabled" value="FALSE"/>
             </widget>
             <real name="z" value="0"/>
             <layout type="anchor">
@@ -43,18 +27,11 @@
                 <anchoritem dst="MessageTreeList" dstEdge="TOP" spacing="0un" src="labelGroupBox" srcEdge="BOTTOM"/>
                 <anchoritem dst="MessageTreeList" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
                 <anchoritem dst="MessageTreeList" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
-                <anchoritem dst="folderLabel" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
-                <anchoritem dst="folderLabel" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                <anchoritem dst="folderLabel" dstEdge="BOTTOM" spacing="0un" src="labelGroupBox" srcEdge="BOTTOM"/>
-                <anchoritem dst="folderLabel" dstEdge="RIGHT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="syncIcon" srcEdge="LEFT"/>
-                <anchoritem dst="syncIcon" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                <anchoritem dst="syncIcon" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="syncIcon" dstEdge="BOTTOM" spacing="0un" src="labelGroupBox" srcEdge="BOTTOM"/>
             </layout>
         </widget>
         <string name="title" value="View"/>
     </widget>
-    <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
         <dummydata objectName="MessageTreeList" section="#common" value="0"/>
     </metadata>
--- a/emailuis/nmailui/conf/nmmessagesearchlistview.docml	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/conf/nmmessagesearchlistview.docml	Thu Jul 22 16:30:28 2010 +0100
@@ -1,62 +1,51 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hbdocument version="1.0">
-    <widget name="NmMessageListView" type="HbView">
+<hbdocument version="1.1">
+    <widget name="NmMessageSearchListView" type="HbView">
         <widget name="content" role="HbView:widget" type="HbWidget">
-            <widget name="MessageTreeList" type="HbTreeView">
-                <real name="z" value="4"/>
-                <sizehint height="67.7612un" type="PREFERRED"/>
+            <widget name="LineEdit" type="HbLineEdit">
+                <fontspec name="fontSpec" role="Primary" textheight="26.8"/>
+                <sizehint height="8un" type="PREFERRED"/>
+            </widget>
+            <widget name="PushButton" type="HbPushButton">
+                <sizehint height="8un" type="PREFERRED" width="9un"/>
+                <sizehint type="MAXIMUM" width="9un"/>
+            </widget>
+            <widget name="LabelGroupBox" type="HbGroupBox">
+                <sizehint height="6un" type="PREFERRED" width="52un"/>
+                <bool name="collapsable" value="FALSE"/>
+                <bool name="enabled" value="FALSE"/>
             </widget>
             <widget name="MessageListNoMessages" type="HbLabel">
-                <real name="z" value="5"/>
-                <string locid="txt_mail_dblist_no_messages" name="plainText"/>
+                <enums name="textWrapping" value="TextWordWrap"/>
+                <enums name="alignment" value="AlignLeft|AlignVCenter|AlignHCenter|AlignLeading"/>
+                <string locid="txt_mail_dblist_no_messages_matched_your_search" name="plainText"/>
+                <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
             </widget>
-            <widget name="SearchBarContainer" type="HbWidget">
-                <widget name="LineEdit" type="HbLineEdit">
-                    <real name="z" value="10"/>
-                    <sizehint type="PREFERRED" width="51.04478un"/>
-                    <string name="text" value="" />
-                </widget>
-                <widget name="PushButton" type="HbPushButton">
-                    <real name="z" value="11"/>
-                    <sizehint type="PREFERRED" width="18.50746un"/>
-                    <string name="text" locid="txt_mail_list_search" />
-                </widget>
-                <real name="z" value="8"/>
-                <sizehint height="8un" type="PREFERRED" width="54.62687un"/>
-                <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
-                <sizehint height="4un" type="MINIMUM"/>
-                <sizehint height="15un" type="MAXIMUM"/>
-                <layout orientation="Horizontal" type="linear">
-                    <linearitem itemname="LineEdit"/>
-                    <linearitem itemname="PushButton"/>
-                </layout>
-            </widget>
-            <widget name="InfoLabel" type="HbLabel">
-                <real name="z" value="9"/>
-                <string name="plainText" value="Label"/>
-                <sizehint height="4.62687un" type="PREFERRED" width="53.8806un"/>
-                <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Minimum" verticalStretch="0"/>
+            <widget name="MessageTreeList" type="HbTreeView">
+                <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
             </widget>
             <real name="z" value="0"/>
             <layout type="anchor">
-                <anchoritem dst="InfoLabel" dstEdge="LEFT" spacing="0" src="" srcEdge="LEFT"/>
-                <anchoritem dst="InfoLabel" dstEdge="TOP" spacing="0" src="SearchBarContainer" srcEdge="BOTTOM"/>
-                <anchoritem dst="InfoLabel" dstEdge="RIGHT" spacing="0" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="MessageListNoMessages" dstEdge="LEFT" spacing="4.77612un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="MessageListNoMessages" dstEdge="TOP" spacing="2.54478un" src="LabelGroupBox" srcEdge="BOTTOM"/>
+                <anchoritem dst="MessageListNoMessages" dstEdge="RIGHT" spacing="-5.22388un" src="" srcEdge="RIGHT"/>
                 <anchoritem dst="MessageTreeList" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                <anchoritem dst="MessageTreeList" dstEdge="TOP" spacing="0un" src="InfoLabel" srcEdge="BOTTOM"/>
+                <anchoritem dst="MessageTreeList" dstEdge="TOP" spacing="0un" src="LabelGroupBox" srcEdge="BOTTOM"/>
                 <anchoritem dst="MessageTreeList" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
                 <anchoritem dst="MessageTreeList" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
-                <anchoritem dst="MessageListNoMessages" dstEdge="LEFT" spacing="12.14925un" src="" srcEdge="LEFT"/>
-                <anchoritem dst="MessageListNoMessages" dstEdge="TOP" spacing="10un" src="MessageTreeList" srcEdge="TOP"/>
-                <anchoritem dst="MessageListNoMessages" dstEdge="RIGHT" spacing="-11.82089un" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="SearchBarContainer" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                <anchoritem dst="SearchBarContainer" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                <anchoritem dst="SearchBarContainer" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="LabelGroupBox" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="LabelGroupBox" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="LineEdit" srcEdge="BOTTOM"/>
+                <anchoritem dst="LabelGroupBox" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="LineEdit" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="LineEdit" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="" srcEdge="TOP"/>
+                <anchoritem dst="LineEdit" dstEdge="RIGHT" spacing="expr(-var(hb-param-margin-gene-middle-horizontal) )" src="PushButton" srcEdge="LEFT"/>
+                <anchoritem dst="PushButton" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="" srcEdge="TOP"/>
+                <anchoritem dst="PushButton" dstEdge="RIGHT" spacing="expr(-var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
             </layout>
         </widget>
-        <string name="title" value="View"/>
+        <string name="title" value="Search"/>
     </widget>
-    <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
         <dummydata objectName="MessageTreeList" section="#common" value="0"/>
     </metadata>
--- a/emailuis/nmailui/inc/nmaction.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmaction.h	Thu Jul 22 16:30:28 2010 +0100
@@ -40,7 +40,7 @@
     };
     
     inline NmAction(int priorityIndex);
-    inline void setPriorityIndex(int priorityIndex);
+    inline void setPriorityIndex(const int priorityIndex);
     inline int priorityIndex() const;
     inline void setAvailabilityCondition(NmAvailabilityCondition condition);
     inline NmAvailabilityCondition availabilityCondition() const;
--- a/emailuis/nmailui/inc/nmactionrequest.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmactionrequest.h	Thu Jul 22 16:30:28 2010 +0100
@@ -45,8 +45,6 @@
 	NmActionContextViewMessageSearchList,
 	NmActionContextViewViewer,
 	NmActionContextViewEditor
-    // Add more view id's when
-    // funtionality is added
 };
 
 /*!
@@ -58,9 +56,7 @@
 	NmActionContextDataNone=0,
 	NmActionContextDataMailbox,
 	NmActionContextDataFolder,
-	NmActionContextDataMessage,
-    //Add more context menu types
-    //when functionality is added
+	NmActionContextDataMessage
 };
 
 
@@ -77,7 +73,7 @@
 class NmActionRequest
 {
 public:
-    inline NmActionRequest(NmActionObserver* observer,
+    inline NmActionRequest(NmActionObserver *observer,
 		NmActionContextMenuType menuType=NmActionOptionsMenu,
 		NmActionContextView contextView=NmActionContextViewNone,
 		NmActionContextDataType contextDataType=NmActionContextDataNone,
@@ -95,7 +91,7 @@
     mMessageId(messageId),
     mRequestData(requestData){};
 
-    inline NmActionObserver* observer() const {return mObserver;}
+    inline NmActionObserver *observer() const {return mObserver;}
     inline NmActionContextMenuType menuType() const {return mMenuType;}
     inline NmActionContextView contextView() const {return mContextView;}
     inline NmActionContextDataType contextDataType() const {return mContextDataType;}
--- a/emailuis/nmailui/inc/nmactionresponse.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmactionresponse.h	Thu Jul 22 16:30:28 2010 +0100
@@ -44,7 +44,8 @@
     NmActionResponseCommandRemoveAttachment,
     NmActionResponseCommandOpenAttachment,
     NmActionResponseCommandSearch,
-    NmActionResponseCommandSwitchFolder
+    NmActionResponseCommandSwitchFolder,
+    NmActionResponseCommandSettings
 };
 
 
--- a/emailuis/nmailui/inc/nmapplication.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmapplication.h	Thu Jul 22 16:30:28 2010 +0100
@@ -30,6 +30,7 @@
 class HbAction;
 class NmUiExtensionManager;
 class NmSendServiceInterface;
+class NmUriServiceInterface;
 class NmMailboxServiceInterface;
 class NmViewerServiceInterface;
 class NmViewerViewNetManager;
@@ -37,12 +38,13 @@
 class NmAttachmentManager;
 class NmSettingsViewLauncher;
 class NmUiEffects;
+class HbMessageBox;
 
 class NmApplication : public QObject
 {
     Q_OBJECT
 public:
-    NmApplication(QObject *parent);
+    NmApplication(QObject *parent, quint32 accountId=0);
     ~NmApplication();
     void enterNmUiView(NmUiStartParam *startParam);
     HbMainWindow* mainWindow();
@@ -50,40 +52,45 @@
     NmViewerViewNetManager &networkAccessManager();
     QSize screenSize();
     bool eventFilter(QObject *obj, QEvent *event);
-
+    bool updateVisibilityState();
 
 public slots:
+    void prepareForPopView();
     void popView();
     void exitApplication();
     void delayedExitApplication();
     void handleOperationCompleted(const NmOperationCompletionEvent &event);
     void viewReady();
+    void launchSettings(HbAction *action);
     
 private:
     void createMainWindow();
     void pushView(NmBaseView *view);
     void resetViewStack();
-    void launchSettings(const NmId &mailboxId);
 
 private:
-    HbMainWindow *mMainWindow;              // Not owned
+    HbMainWindow *mMainWindow;              // Owned
     QStack<NmBaseView*> *mViewStack;        // Owned
     NmUiViewId mActiveViewId;
-    NmUiEngine *mUiEngine;                  // Owned
+    NmUiEngine *mUiEngine;                  // Not owned, singleton instance
     HbAction *mBackAction;                  // Owned
     NmUiExtensionManager *mExtensionManager;// Owned
     NmSendServiceInterface *mSendServiceInterface;       // Owned
     NmSendServiceInterface *mSendServiceInterface2;      // Owned
+    NmUriServiceInterface *mUriServiceInterface;         // Owned
     NmMailboxServiceInterface *mMailboxServiceInterface; // Owned
     NmViewerServiceInterface *mViewerServiceInterface;   // Owned
     NmMailboxListModel *mMbListModel;       // Not owned
     NmUiViewId mServiceViewId;
     NmViewerViewNetManager *mNetManager;    // Owned
-    bool mForegroundService;	
+    bool mForegroundService;
     NmUiEffects *mEffects;                  // Owned
     NmAttachmentManager *mAttaManager;      // Owned
     NmSettingsViewLauncher* mSettingsViewLauncher; // Owned
     bool mViewReady;
+    NmId mLastOperationMailbox;
+    HbMessageBox *mQueryDialog;             // Owned
+    bool mBackButtonPressed;
 };
 
 #endif // NMAPPLICATION_H
--- a/emailuis/nmailui/inc/nmattachmentlist.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmattachmentlist.h	Thu Jul 22 16:30:28 2010 +0100
@@ -47,11 +47,7 @@
 
 private:
     QString fullNameToDisplayName(const QString &fullName);
-    void updateLayout();
     
-private slots:
-    void delayedLayoutChangeInfo();
-
 signals:
     void attachmentListLayoutChanged();
     
--- a/emailuis/nmailui/inc/nmattachmentmanager.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmattachmentmanager.h	Thu Jul 22 16:30:28 2010 +0100
@@ -26,6 +26,7 @@
 class NmUiEngine;
 class NmOperation;
 class NmAttachmentFetchObserver;
+class NmMessage;
 
 class NmAttachmentManager : public QObject
 {
@@ -38,6 +39,15 @@
             const NmId &folderId, 
             const NmId &messageId, 
             const NmId &messagePartId);
+    bool fetchAttachments(
+            const NmId &mailboxId, 
+            const NmId &folderId, 
+            const NmId &messageId,
+            QList<NmId> &messagePartIds);
+    void fetchAllMessageParts(
+            const NmId &mailboxId, 
+            const NmId &folderId, 
+            const NmId &messageId);
     bool isFetching() const;
     NmId partIdUnderFetch() const;
     int progressValue() const;
@@ -47,12 +57,15 @@
     
 private slots:
     void changeProgress(int value);
-    void attachmentFetchCompleted(int result);
-    
+    void completeAttachmentFetch(int result);
+    void completeMessageFetch(int result);
+
 private:
     NmUiEngine &mUiEngine;
     QPointer<NmOperation> mFetchOperation;      // Not owned
+    QPointer<NmOperation> mMsgFetchOperation;      // Not owned
     NmAttachmentFetchObserver *mFetchObserver;  // Not owned
+    NmMessage *mFetchMsg;
     NmId mAttaId;
     int mProgressValue;
     bool mIsFetching;
--- a/emailuis/nmailui/inc/nmattachmentpicker.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmattachmentpicker.h	Thu Jul 22 16:30:28 2010 +0100
@@ -20,12 +20,6 @@
 
 #include <QObject>
 
-#define IMAGE_FETCHER_INTERFACE "Image"
-#define AUDIO_FETCHER_INTERFACE "com.nokia.services.media.Music"
-
-#define IMAGE_FETCHER_OPERATION "fetch(QVariantMap,QVariant)"
-#define AUDIO_FETCHER_OPERATION "fetch(QString)"
-
 class XQAiwRequest;
 
 /**
@@ -37,21 +31,25 @@
     Q_OBJECT
 
 public:
-    NmAttachmentPicker(QObject* parent = 0);
+    NmAttachmentPicker(QObject *parent = 0);
     ~NmAttachmentPicker();
         
 public slots:
     void fetchImage();
     void fetchAudio();    
     void fetchVideo();
-    void fetchOther();       
+    void fetchOther();  
+    void fetchCameraStill();
+    void fetchCameraVideo();
 
 signals:
-    void attachmentsFetchOk(const QVariant& fileNames);
-    void attachmentsFetchError(int errorCode, const QString& errorMessage);
+    void attachmentsFetchOk(const QVariant &fileNames);
+    void attachmentsFetchError(int errorCode, const QString &errorMessage);
     
 private:   
-    void fetch(const QString& interface, const QString& operation); 
+    void fetch(const QString &interface, const QString &operation, 
+                const QList<QVariant> *args = 0); 
+    void fetchFromCamera(int mode);
     
 private:
     XQAiwRequest *mRequest;    
--- a/emailuis/nmailui/inc/nmbaseview.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmbaseview.h	Thu Jul 22 16:30:28 2010 +0100
@@ -34,12 +34,13 @@
 {
 	Q_OBJECT
 public:
-    NmBaseView(NmUiStartParam* startParam,
+    NmBaseView(NmUiStartParam *startParam,
+               NmApplication &application,
                QGraphicsItem *parent = 0);
     virtual ~NmBaseView();
-    virtual void reloadViewContents(NmUiStartParam* startParam) = 0;
+    virtual void reloadViewContents(NmUiStartParam *startParam) = 0;
     virtual NmUiViewId nmailViewId() const = 0;
-    virtual bool okToExitView();
+    virtual void okToExitView();
     virtual void aboutToExitView();
     virtual void viewReady();
     virtual void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
@@ -54,7 +55,8 @@
     virtual void loadViewLayout() = 0;
 
 protected:
-    NmUiStartParam* mStartParam;   // Owned
+    NmUiStartParam *mStartParam;   // Owned
+    NmApplication &mApplication;
 };
 
 
--- a/emailuis/nmailui/inc/nmeditorcontent.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmeditorcontent.h	Thu Jul 22 16:30:28 2010 +0100
@@ -21,52 +21,60 @@
 #include <hbwidget.h>
 #include "nmuiviewids.h"
 
-enum MessageBodyType { PlainText, HTMLText };
-
 class HbAnchorLayout;
 class HbTextEdit;
 class HbDocumentLoader;
 class NmBaseViewScrollArea;
-class NmEditorView;
 class NmMessage;
 class NmMessageEnvelope;
 class NmEditorHeader;
 class NmEditorTextEdit;
 class QNetworkAccessManager;
+class NmApplication;
 
-class NmEditorContent : public HbWidget
+class NmEditorContent : public QObject
 {
 Q_OBJECT
 
 public:
-    NmEditorContent(QGraphicsItem *parent,
-                    NmEditorView *parentView,
+    NmEditorContent(QObject *parent,
                     HbDocumentLoader *documentLoader,
-                    QNetworkAccessManager &manager);
+                    QNetworkAccessManager &manager,
+                    NmApplication &application);
+
     virtual ~NmEditorContent();
 
-    void setMessageData(const NmMessage &message, 
-                        NmMessageEnvelope *replyMsgEnvelope=0);
+    void setMessageData(const NmMessage &originalMessage,
+                        NmUiEditorStartMode &editorStartMode);
+
     NmEditorTextEdit* editor() const;
+
     NmEditorHeader* header() const;
-
+    
 private:
     void createConnections();
+    void removeEmbeddedImages(QString &bodyContent);
 
 signals:
     void setPlainText(const QString&);
+
     void setHtml(const QString&);
 
 public slots:
     void setEditorContentHeight();
+    void ensureCursorVisibility();
+
+private:
+    enum MessageBodyType { NmPlainText, NmHTMLText };
 
 private:
-    NmEditorHeader *mHeaderWidget;   // Owned
-    NmEditorView *mParentView;       // Not owned
-    HbAnchorLayout *mEditorLayout;   // Not owned
+    NmEditorHeader *mHeader; // Not owned
     MessageBodyType mMessageBodyType;
     NmEditorTextEdit *mEditorWidget; // Not owned
-    NmBaseViewScrollArea *mBackgroundScrollArea;
+    NmBaseViewScrollArea *mScrollArea; // Not owned
+    HbWidget *mScrollAreaContents; // Not owned
+    QPointF mScrollPosition;
+    NmApplication &mApplication;
 };
 
 #endif /* NMEDITORCONTENT_H_ */
--- a/emailuis/nmailui/inc/nmeditorheader.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmeditorheader.h	Thu Jul 22 16:30:28 2010 +0100
@@ -20,16 +20,6 @@
 
 #include <hbwidget.h>
 #include "nmactionresponse.h"
-// Header widget fields
-enum
-{
-    EEditorToLine=0,
-    EEditorGroupBoxRecipient,
-    EEditorCcLine,
-    EEditorBccLine,
-    EEditorSubjectLine,
-    EEditorAttachmentLine
-};
 
 class HbGroupBox;
 class HbLabel;
@@ -38,73 +28,70 @@
 class NmRecipientLineEdit;
 class QGraphicsLinearLayout;
 class NmRecipientField;
-class NmAttachmentList;
+class NmAttachmentList; 
 
-class NmEditorHeader : public HbWidget
+class NmEditorHeader : public QObject
 {
 Q_OBJECT
 
 public:
-    NmEditorHeader(HbDocumentLoader *documentLoader, QGraphicsItem *parent=0);
+    NmEditorHeader(QObject *parent, HbDocumentLoader *documentLoader);
     virtual ~NmEditorHeader();
-    int headerHeight() const;
-    NmHtmlLineEdit* subjectField() const;
-    NmRecipientLineEdit* toField() const;
-    NmRecipientLineEdit* ccField() const;
-    NmRecipientLineEdit* bccField() const;
+    qreal headerHeight() const;
+    NmHtmlLineEdit *subjectEdit() const;
+    NmRecipientLineEdit *toEdit() const;
+    NmRecipientLineEdit *ccEdit() const;
+    NmRecipientLineEdit *bccEdit() const;
     void setPriority(NmMessagePriority priority=NmMessagePriorityNormal);
     void setPriority(NmActionResponseCommand prio=NmActionResponseCommandNone);
-    void setGroupBoxCollapsed( bool collapsed );
     void addAttachment(const QString &fileName, const QString &fileSize, const NmId &nmid);
     void removeAttachment(const QString &fileName);
     void removeAttachment(const NmId &nmid);
-    void launchAttachment(const NmId &nmid);
     void setAttachmentParameters(
         const QString &fileName,
         const NmId &msgPartId,
         const QString &fileSize,
         int result);
+    void setFieldVisibility(bool isVisible);
 
 private:
     void loadWidgets();
-    void rescaleHeader();
     void createConnections();
-    HbWidget* createRecipientGroupBoxContentWidget();
 
 signals:
     void headerHeightChanged(int);
     void recipientFieldsHaveContent(bool recipientFieldsHaveContent);
     void attachmentLongPressed(NmId attachmentPartId, QPointF point);
+    void attachmentShortPressed(NmId attachmentId);
 
 public slots:
+	void sendDelayedHeaderHeightChanged();
     void sendHeaderHeightChanged();
     void editorContentChanged();
-    void groupBoxExpandCollapse();
     void attachmentActivated(int arrayIndex);
     void attachmentLongPressed(int arrayIndex, QPointF point);
 
 private:
     HbDocumentLoader* mDocumentLoader;  // Not owned
-    int mHeaderHeight;
-    HbLabel *mSubjectLabel;
-    HbLabel *mPriorityIconLabel;
+    qreal mHeaderHeight;
+    HbLabel *mPriorityIcon; // Not owned
+    HbLabel *mFollowUpIcon; // Not owned
     bool mIconVisible;
-    NmRecipientLineEdit *mToEdit;
-    NmHtmlLineEdit *mSubjectEdit;
+    NmRecipientLineEdit *mToEdit; // Not owned
+    NmRecipientLineEdit *mCcEdit; // Not owned
+    NmRecipientLineEdit *mBccEdit; // Not owned
+    NmHtmlLineEdit *mSubjectEdit; // Not owned
     bool mRecipientFieldsEmpty;
-
-    // Recipient GroupBox related
-    HbGroupBox *mGroupBoxRecipient;          // Owned
-    HbWidget *mGroupBoxRecipientContent;     // Not owned
-    QGraphicsLinearLayout *mGbVerticalLayout;// Not owned
-    QGraphicsLinearLayout *mCcFieldLayout;   // Not owned
-    QGraphicsLinearLayout *mBccFieldLayout;  // Not owned
-
-    NmRecipientField *mToField;    // owned
+    QGraphicsLinearLayout *mLayout; // Not owned
+    NmAttachmentList *mAttachmentList; // Not owned
+    NmRecipientField *mToField;    // Not owned
     NmRecipientField *mCcField;    // Not owned
+    HbWidget *mCcWidget;    // Not owned
     NmRecipientField *mBccField;   // Not owned
-
-    NmAttachmentList *mAttachmentList;
+    HbWidget *mBccWidget;    // Not owned
+    HbWidget *mSubjectWidget;    // Not owned
+    QGraphicsLinearLayout *mSubjectLayout; // Not owned
+    bool mCcBccFieldVisible;
 };
 
 #endif /* NMEDITORHEADER_H_ */
--- a/emailuis/nmailui/inc/nmeditortextdocument.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmeditortextdocument.h	Thu Jul 22 16:30:28 2010 +0100
@@ -19,7 +19,7 @@
 #ifndef NMEDITORTEXTDOCUMENT_H_
 #define NMEDITORTEXTDOCUMENT_H_
 
-#include <qtextdocument>
+#include <QTextDocument>
 
 class QNetworkAccessManager;
 class QNetworkReply;
--- a/emailuis/nmailui/inc/nmeditorview.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmeditorview.h	Thu Jul 22 16:30:28 2010 +0100
@@ -23,8 +23,8 @@
 #include "nmbaseview.h"
 #include "nmactionobserver.h"
 #include "nmactionresponse.h"
+#include "nmattachmentfetchobserver.h"
 
-class QGraphicsLinearLayout;
 class HbTextEdit;
 class HbDocumentLoader;
 class HbProgressDialog;
@@ -41,70 +41,75 @@
 class NmOperation;
 class NmMessageCreationOperation;
 class NmAddAttachmentsOperation;
-class NmCheckOutboxOperation;
 class NmAttachmentPicker;
+class HbMessageBox;
+class NmAttachmentManager;
+class HbVkbHost;
 
-
-class NmEditorView : public NmBaseView, public NmActionObserver
+class NmEditorView : public NmBaseView,
+                     public NmActionObserver,
+                     public NmAttachmentFetchObserver
 {
     Q_OBJECT
 
 public:
-
     NmEditorView(NmApplication &application,
-                 NmUiStartParam* startParam,
+                 NmUiStartParam *startParam,
                  NmUiEngine &uiEngine,
+                 NmAttachmentManager &attaManager,
                  QGraphicsItem *parent = 0);
     ~NmEditorView();
 
 
 public:
-
     void reloadViewContents(NmUiStartParam* startParam);
     NmUiViewId nmailViewId() const;
     HbWidget* scrollAreaContents();
-    bool okToExitView();
+    void okToExitView();
     void aboutToExitView();
     void viewReady();
-
+    void handleActionCommand(NmActionResponse &menuResponse);
+    void progressChanged(int value);
+    void fetchCompleted(int result);
+    
 public slots:
-
     void orientationChanged(Qt::Orientation orientation);
     void createOptionsMenu();
     void setButtonsDimming(bool enabled);
     void attachmentLongPressed(NmId attachmentPartId, QPointF point);
-
-
-public: // From NmActionObserver
-
-    void handleActionCommand(NmActionResponse &menuResponse);
-
+    void invalidAddressQuery(HbAction* action);
+    void okToExitQuery(HbAction* action);
+    void sendProgressDialogCancelled();
+    
+protected:
+    void resizeEvent(QGraphicsSceneResizeEvent *event);
 
 private slots:
-
     void messageCreated(int result);
-    void adjustViewDimensions();
     void oneAttachmentAdded(const QString &fileName,
                             const NmId &msgPartId,
                             int result);
-
     void allAttachmentsAdded(int result);
     void attachmentRemoved(int result);
-    void outboxChecked(int result);
     void removeAttachmentTriggered();
     void handleSendOperationCompleted();
-    void openAttachmentTriggered();  
+    void openAttachmentTriggered( NmId attachmentId );  
     void onAttachmentReqCompleted(const QVariant &value);
+    void onAttachmentsFetchError(int errorCode, const QString& errorMessage);
+    void switchCcBccFieldVisibility();
+	void fetchProgressDialogCancelled();
+	void vkbOpened();
+	void vkbClosed();
 
 private:
-
     void loadViewLayout();
     void setMailboxName();
-    void setMessageData();
-    void startMessageCreation(NmUiEditorStartMode startMode);
+    void fetchProgressDialogShow();
+    void fetchMessageIfNeeded(NmUiStartParam &startParam);
+    void startMessageCreation(NmUiStartParam &startParam);
     void startSending();
+    void finalizeSending();
     void createToolBar();
-    QPointF viewCoordinateToEditCoordinate(QPointF orgPoint);
     void updateMessageWithEditorContents();
     void fillEditorWithMessageContents();
     void initializeVKB();
@@ -114,41 +119,32 @@
     QString addressListToString(const QList<NmAddress*> &list) const;
     QString addressListToString(const QList<NmAddress> &list) const;
     void enableToolBarAttach(bool enable);
-
-
-public slots:
+    void showChrome(bool show);
 
-    void sendMousePressEventToScroll(QGraphicsSceneMouseEvent *event);
-    void sendMouseReleaseEventToScroll(QGraphicsSceneMouseEvent *event);
-    void sendMouseMoveEventToScroll(QGraphicsSceneMouseEvent *event);
-    void sendLongPressGesture(const QPointF &point);
-    void contextButton(NmActionResponse &result);
-
-
+signals:
+    void sizeChanged();
+    
 private: // Data
-
     NmApplication &mApplication;
     NmUiEngine &mUiEngine;
+    NmAttachmentManager  &mAttaManager;
     HbDocumentLoader *mDocumentLoader;  // Owned
     QObjectList mWidgetList;            // Owned
-    NmBaseViewScrollArea *mScrollArea;  // Not owned
-    HbWidget *mScrollAreaContents;      // Not owned
-    NmEditorTextEdit *mEditWidget;      // Not owned
     NmEditorHeader *mHeaderWidget;      // Not owned
     NmMessage *mMessage;                // Owned
-    NmEditorContent *mContentWidget;    // Owned
+    NmEditorContent *mContent;          // Not owned
     HbMenu *mPrioritySubMenu;           // Owned
     HbMenu *mAttachmentListContextMenu; // Owned
     NmId mSelectedAttachment;
-
+    HbVkbHost *mVkbHost;                // Not owned
     QPointer<NmMessageCreationOperation> mMessageCreationOperation;  // Not owned
     QPointer<NmAddAttachmentsOperation> mAddAttachmentOperation;     // Not owned 
     QPointer<NmOperation> mRemoveAttachmentOperation;                // Not owned 
-    QPointer<NmCheckOutboxOperation> mCheckOutboxOperation;          // Not owned 
-
-    HbProgressDialog *mWaitDialog; // Owned.
-    
-    NmAttachmentPicker* mAttachmentPicker;    // Owned    
+    HbProgressDialog *mWaitDialog;         // Owned.    
+    HbMessageBox* mQueryDialog;            // Owned
+    NmAttachmentPicker* mAttachmentPicker; // Owned    
+    bool mCcBccFieldVisible;
+    QPointer<HbProgressDialog> mServiceSendingDialog; // Owned.
 };
 
 
--- a/emailuis/nmailui/inc/nmmailboxlistview.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmmailboxlistview.h	Thu Jul 22 16:30:28 2010 +0100
@@ -33,7 +33,7 @@
 class HbAbstractViewItem;
 class NmAction;
 
-class NmMailboxListView : public NmBaseView, public NmActionObserver
+class NmMailboxListView : public NmBaseView
 {
     Q_OBJECT
 public:
@@ -49,14 +49,9 @@
     NmUiViewId nmailViewId() const;
     void viewReady();
 
-public: // From NmActionObserver
-    void handleActionCommand(NmActionResponse &menuResponse);
-
 public slots:
     void itemActivated(const QModelIndex &index);
     void openSelectedMailBox();
-    void showItemContextMenu(HbAbstractViewItem *item, const QPointF &coords);
-    void contextButton(NmActionResponse &result);
 
 private slots:
     void refreshList();
--- a/emailuis/nmailui/inc/nmmailboxlistviewitem.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmmailboxlistviewitem.h	Thu Jul 22 16:30:28 2010 +0100
@@ -33,7 +33,6 @@
     HbListViewItem *createItem();
     void updateChildItems();
     bool canSetModelIndex(const QModelIndex &index);
-    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
 
 protected:
     void polishEvent();
--- a/emailuis/nmailui/inc/nmmessagelistview.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmmessagelistview.h	Thu Jul 22 16:30:28 2010 +0100
@@ -35,6 +35,7 @@
 class NmActionResponse;
 class NmMessageListModelItem;
 class HbIconItem;
+class HbGroupBox;
 
 class NmMessageListView : public NmBaseView, public NmActionObserver
 {
@@ -45,12 +46,14 @@
         NmUiStartParam *startParam,
         NmUiEngine &uiEngine,
         NmMailboxListModel &mailboxListModel,
-        NmMessageListModel &messageListModel,
+        NmMessageListModel *messageListModel,
         HbDocumentLoader *documentLoader,
         QGraphicsItem *parent = 0);
     ~NmMessageListView();
     NmUiViewId nmailViewId() const;
     void viewReady();
+    NmFolderType folderType();
+    void okToExitView();
     
 public: // From NmActionObserver
     void handleActionCommand(NmActionResponse &menuResponse);
@@ -58,7 +61,6 @@
 public slots:
     void reloadViewContents(NmUiStartParam *startParam);
     void refreshList();
-    void contextButton(NmActionResponse &result);
     
 private slots:
     void showItemContextMenu(HbAbstractViewItem *index, const QPointF &coords);
@@ -68,9 +70,9 @@
     void itemsAdded(const QModelIndex &parent, int start, int end);
     void itemsRemoved();
     void showNoMessagesText();
+    void hideNoMessagesText();
     void handleSyncStateEvent(NmSyncState syncState, const NmId & mailboxId);
-    void handleConnectionEvent(NmConnectState connectState, const NmId &mailboxId);
-    void folderSelected(NmId mailbox, NmId folder);
+    void folderSelected();
     
 private:
     void loadViewLayout();
@@ -85,16 +87,21 @@
     QObjectList mWidgetList;
     NmUiEngine &mUiEngine;
     NmMailboxListModel &mMailboxListModel;
-    NmMessageListModel &mMessageListModel;
+    NmMessageListModel *mMessageListModel;  // Not owned
     HbDocumentLoader *mDocumentLoader;      // Owned
     HbMenu *mItemContextMenu;               // Owned
     NmMessageListModelItem *mLongPressedItem;  // Not owned
     HbLabel *mNoMessagesLabel;              // Not owned
-    HbLabel *mFolderLabel;                  // Not owned
+    HbGroupBox *mFolderLabel;               // Not owned
     HbLabel *mSyncIcon;                     // Not owned
     QModelIndex mActivatedIndex;
     bool mViewReady;
     NmFolderType mCurrentFolderType;
+    bool mSettingsLaunched;
+    NmId mSelectedFolderId;
+    NmId mSelectedMailboxId;
+    int mPreviousModelCount;
+    bool mIsFirstSyncInMessageList;
 };
 
 #endif /* NMMESSAGELISTVIEW_H_ */
--- a/emailuis/nmailui/inc/nmmessagelistviewitem.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmmessagelistviewitem.h	Thu Jul 22 16:30:28 2010 +0100
@@ -23,10 +23,6 @@
 class HbLabel;
 class HbTextItem;
 class HbFrameItem;
-class QStyleOptionGraphicsItem;
-class QGraphicsLayoutItem;
-class HbWidgetBase;
-class HbStyleOptionAbstractViewItem;
 class NmMessageListModel;
 class NmMessageListModelItem;
 class NmMessageEnvelope;
@@ -43,7 +39,6 @@
     void updateChildItems();
     HbTreeViewItem *createItem();
     bool canSetModelIndex(const QModelIndex &index) const;
-    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
     QRectF contiguousSelectionArea() const { return QRectF(); };
 
 private:
@@ -51,8 +46,9 @@
     void setContentsToMessageItem(const NmMessageEnvelope &envelope, bool dividersActive);
     void setFontsRead();
     void setFontsUnread();
-    void setFonts(const QColor &colorRole, HbFontSpec &spekki);
+    void setFonts(const QColor &colorRole, HbFontSpec &fontSpec);
     void getFontSizes();    
+    QString senderFieldText(const NmMessageEnvelope &envelope);
 
 private:
     HbTextItem *mSender;                   // Owned
--- a/emailuis/nmailui/inc/nmmessagesearchlistview.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmmessagesearchlistview.h	Thu Jul 22 16:30:28 2010 +0100
@@ -24,6 +24,7 @@
 
 class HbAbstractViewItem;
 class HbDocumentLoader;
+class HbGroupBox;
 class HbLabel;
 class HbLineEdit;
 class HbMenu;
@@ -32,8 +33,8 @@
 
 class NmActionResponse;
 class NmApplication;
+class NmMessageListModel;
 class NmMessageListModelItem;
-class NmMessageSearchListModel;
 class NmUiEngine;
 class NmUiStartParam;
 
@@ -47,7 +48,7 @@
     NmMessageSearchListView(NmApplication &application,
                             NmUiStartParam *startParam,
                             NmUiEngine &uiEngine,
-                            NmMessageSearchListModel &searchListModel,
+                            NmMessageListModel &msglistModel,
                             HbDocumentLoader *documentLoader,
                             QGraphicsItem *parent = 0);
     ~NmMessageSearchListView();
@@ -79,17 +80,18 @@
     void initTreeView();
     void setViewTitle();
     void noMessagesLabelVisibility(bool visible);
+    void updateSearchResultCountInfo();
     void setSearchInputMode(NmSearchInputMode mode);
 
 
 public slots:
 
     void reloadViewContents(NmUiStartParam *startParam);
-    void contextButton(NmActionResponse &result);
 
 
 private slots:
 
+    void criteriaChanged(QString text);
     void showItemContextMenu(HbAbstractViewItem *index, const QPointF &coords);
     void itemActivated(const QModelIndex &index);
     void handleSelection();
@@ -98,19 +100,19 @@
     void refreshList();
     void toggleSearch();
     void handleSearchComplete();
-    void criteriaChanged(QString text);
+
 
 private: // Data
 
     NmApplication &mApplication;
     NmUiEngine &mUiEngine;
-    NmMessageSearchListModel &mSearchListModel;
+    NmMessageListModel &mMsgListModel;
     HbDocumentLoader *mDocumentLoader; // Owned
     QObjectList mWidgetList;
     HbMenu *mItemContextMenu; // Owned
     HbTreeView *mMessageListWidget; // Not owned
+    HbGroupBox *mInfoLabel; // Not owned
     HbLabel *mNoMessagesLabel; // Not owned
-    HbLabel *mInfoLabel; // Not owned
     HbLineEdit *mLineEdit; // Not owned
     HbPushButton *mPushButton; // Not owned
     NmMessageListModelItem *mLongPressedItem; // Not owned
--- a/emailuis/nmailui/inc/nmrecipientfield.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmrecipientfield.h	Thu Jul 22 16:30:28 2010 +0100
@@ -25,17 +25,13 @@
 class NmRecipientLineEdit;
 class HbPushButton;
 class HbIconItem;
+class HbDocumentLoader;
 
-class NmRecipientField : public HbWidget
+class NmRecipientField : public QObject
 {
     Q_OBJECT
 public:
-    NmRecipientField(
-    HbLabel *label,
-    NmRecipientLineEdit *edit,
-    HbPushButton *button,
-    QGraphicsItem *parent = 0);
-    NmRecipientField(const QString &labelString = "", QGraphicsItem *parent = 0);
+    NmRecipientField(QObject *parent, HbDocumentLoader &docLoader, const QString &objPrefix);
     virtual ~NmRecipientField();
     qreal height();
     void createConnections();
@@ -53,17 +49,15 @@
 
 public slots:
     void setText(const QString &text);
-#ifdef Q_OS_SYMBIAN
     void launchContactsPicker();
-#endif
 
 private:
-    QGraphicsLinearLayout *mLayoutHorizontal;
-    HbLabel *mLabel;
-    NmRecipientLineEdit *mRecipientsEditor;
-    HbPushButton *mLaunchContactsPickerButton;
-    HbIconItem *mAddButtonIcon;
-    bool mOwned;
+    HbDocumentLoader &mDocumentLoader;
+    const QString mObjectPrefix;
+    HbWidget *mWidget; // Not owned
+    HbLabel *mLabel; // Not owned
+    NmRecipientLineEdit *mRecipientsEditor; // Not owned
+    HbPushButton *mLaunchContactsPickerButton; // Not owned
 };
 
 #endif   // NMRECIPIENTFIELD_H_
--- a/emailuis/nmailui/inc/nmsendserviceinterface.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmsendserviceinterface.h	Thu Jul 22 16:30:28 2010 +0100
@@ -23,11 +23,7 @@
 #include <QObject>
 #include <QVariant>
 
-#ifdef Q_OS_SYMBIAN
 #include <xqserviceprovider.h>
-#else
-#define NM_WINS_ENV
-#endif
 
 //  FORWARD DECLARATIONS
 class NmDataManager;
@@ -41,11 +37,7 @@
 
 
 class NmSendServiceInterface
-#ifndef NM_WINS_ENV
     : public XQServiceProvider
-#else
-    : public QObject
-#endif
 {
     Q_OBJECT
 
@@ -69,11 +61,11 @@
 
 private: // Data
 
-    NmApplication *mApplication; // Not owned
+    NmApplication *mApplication;    // Not owned
     NmUiEngine &mUiEngine;
     int mAsyncReqId;
-    NmUiStartParam *mStartParam;
-    NmMailboxSelectionDialog *mSelectionDialog;
+    NmUiStartParam *mStartParam;    // Owned
+    NmMailboxSelectionDialog *mSelectionDialog; // Owned
     HbView *mCurrentView;
 };
 
--- a/emailuis/nmailui/inc/nmuidocumentloader.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmuidocumentloader.h	Thu Jul 22 16:30:28 2010 +0100
@@ -28,9 +28,9 @@
 {
 public:
     NmUiDocumentLoader(const HbMainWindow *window);
-    virtual ~NmUiDocumentLoader();
+    ~NmUiDocumentLoader();
 protected:
-    virtual QObject *createObject(const QString& type, const QString &name);
+    QObject *createObject(const QString& type, const QString &name);
 
 };
 
--- a/emailuis/nmailui/inc/nmuieffects.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmuieffects.h	Thu Jul 22 16:30:28 2010 +0100
@@ -55,7 +55,7 @@
 
 private:
     HbMainWindow &mMainWindow;
-    QGraphicsPixmapItem *mSendAnimationScreenShot; // Owned
+    QGraphicsPixmapItem *mSendAnimationScreenShot; // Not owned.
     bool mDoSendAnimation;
 };
 
--- a/emailuis/nmailui/inc/nmuiheaders.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmuiheaders.h	Thu Jul 22 16:30:28 2010 +0100
@@ -1,19 +1,19 @@
 /*
-* 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:
-*
-*/
+ * 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 NMUIHEADERS_H_
 #define NMUIHEADERS_H_
@@ -42,6 +42,9 @@
 #include <QNetworkDiskCache>
 #include <QWebSettings>
 #include <QPointer>
+#include <QTapGesture>
+#include <QPinchGesture>
+#include <QInputContext>
 
 // Orbit
 #include <hbapplication.h>
@@ -84,18 +87,22 @@
 #include <hbinstance.h>
 #include <hbeffect.h>
 #include <hbmodeliterator.h>
+#include <hbscrollarea.h>
+#include <hbinputvkbhost.h>
+#include <hbindicator.h>
+#include <hbformatdialog.h>
+#include <hbshrinkingvkbhost.h>
 
-#ifdef Q_OS_SYMBIAN
 #include <cntservicescontact.h>
 #include <xqservicerequest.h>
 #include <qtcontacts.h>
 #include <qmobilityglobal.h>
-#include <mobcntmodel.h>
 #include <xqserviceutil.h>
 #include <xqappmgr.h>
 #include <xqserviceipcmarshal.h>
 #include <xqsharablefile.h>
-#endif
+#include <fmfiledialog.h>
+#include <xqaiwdecl.h>
 
 #include <nmcommon.h>
 
@@ -106,17 +113,18 @@
 #include <nmmailboxlistmodel.h>
 #include <nmmessagelistmodel.h>
 #include <nmmessagelistmodelitem.h>
-#include <nmmessagesearchlistmodel.h>
 #include <nmmessage.h>
 #include <nmaddress.h>
 #include <nmoperation.h>
 #include <nmmessagecreationoperation.h>
 #include <nmaddattachmentsoperation.h>
 #include <nmicons.h>
-#include <nmcheckoutboxoperation.h>
 #include <emailmailboxinfo.h>
 #include <email_services_api.h>
 
+// other
+#include <math.h>
+
 // nmailui
 #include "nmhtmllineedit.h"
 #include "nmaction.h"
@@ -147,6 +155,7 @@
 #include "nmrecipientlineedit.h"
 #include "nmstoreenvelopesoperation.h"
 #include "nmsendserviceinterface.h"
+#include "nmuriserviceinterface.h"
 #include "nmmailboxselectiondialog.h"
 #include "nmuidocumentloader.h"
 #include "nmmailboxserviceinterface.h"
--- a/emailuis/nmailui/inc/nmuiviewids.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmuiviewids.h	Thu Jul 22 16:30:28 2010 +0100
@@ -185,6 +185,16 @@
     {
         mMailboxId = mailboxId;
     }
+    
+    inline void setFolderId(NmId folderId) 
+    {
+        mFolderId = folderId;
+    }
+    
+    inline void setMessageId(NmId messageId) 
+    {
+        mMessageId = messageId;
+    }
 
 private: // Data
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmailui/inc/nmuriserviceinterface.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* 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: NMail Application service interface used for interfacing between
+*              QT highway and other applications
+*
+*/
+
+#ifndef NMURISERVICEINTERFACE_H_
+#define NMURISERVICEINTERFACE_H_
+
+//  INCLUDES
+#include <QObject>
+#include <QVariant>
+#include <xqserviceprovider.h>
+
+//  FORWARD DECLARATIONS
+class NmUiEngine;
+class NmApplication;
+class NmUiStartParam;
+class NmMailboxSelectionDialog;
+class NmId;
+class HbView;
+
+class NmUriServiceInterface : public XQServiceProvider
+{
+    Q_OBJECT
+public:
+    NmUriServiceInterface(QObject *parent,
+                          NmUiEngine &uiEngine,
+                          NmApplication *application);
+    virtual ~NmUriServiceInterface();
+
+public slots:
+    bool view(const QString& uri);
+    void selectionDialogClosed(NmId &mailboxId);
+
+private:
+    void launchEditorView(NmId mailboxId);
+    void cancelService();
+
+private: // Data
+    NmApplication *mApplication;                // Not owned
+    NmUiEngine &mUiEngine;
+    int mAsyncReqId;
+    NmUiStartParam *mStartParam;                // Owned
+    NmMailboxSelectionDialog *mSelectionDialog; //Owned
+    HbView *mCurrentView;
+};
+
+#endif /* NMURISERVICEINTERFACE_H_ */
+
+// End of file.
--- a/emailuis/nmailui/inc/nmutilities.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmutilities.h	Thu Jul 22 16:30:28 2010 +0100
@@ -23,10 +23,8 @@
 class NmMessage;
 class NmMessageEnvelope;
 class NmAddress;
-class NmOperationCompletionEvent;
-class QFile;
 class XQSharableFile;
-class NmOperationCompletionEvent;
+class HbMessageBox;
 
 /*!
 	UI utilities class
@@ -36,39 +34,28 @@
     Q_OBJECT
 public:
     enum NmAddressValidationType {
-        ValidAddress,
-        InvalidAddress,
-        Default
+        NmValidAddress,
+        NmInvalidAddress,
+        NmDefault
     };
-    
     static void getRecipientsFromMessage( const NmMessage &message, 
         QList<NmAddress> &recipients,
-        NmAddressValidationType type = Default );
-    
+        NmAddressValidationType type = NmDefault );
     static bool isValidEmailAddress( const QString &emailAddress );
-    
     static QString addressToDisplayName( const NmAddress &address );
-    
     static bool parseEmailAddress( const QString &emailAddress, NmAddress &address );
-    
     static QString cleanupDisplayName( const QString &displayName );     
-
-    static int openFile(QFile &file);
-    
-    static int openFile(XQSharableFile &file);
-    
+    static int openFile(XQSharableFile &file); 
     static QString truncate( const QString &string, int length );
-
     static QString attachmentSizeString(const int sizeInBytes);
-
     static void displayErrorNote(QString noteText); 
-
-    static bool displayQuestionNote(QString noteText);
-    
-    static void displayWarningNote(QString noteText);
-
-    static bool displayOperationCompletionNote(const NmOperationCompletionEvent &event);
-
+    static HbMessageBox *displayQuestionNote(QString noteText,
+                                             QObject *receiver = 0,
+                                             const char *member = 0);
+   
+    static HbMessageBox *displayWarningNote(QString noteText,
+                                            QObject *receiver = 0,
+                                            const char *member = 0);
     static QString createReplyHeader(const NmMessageEnvelope &env);
 };
 
--- a/emailuis/nmailui/inc/nmviewerheader.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmviewerheader.h	Thu Jul 22 16:30:28 2010 +0100
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description:
+* Description: NMail viewer view header widget definition
 *
 */
 
@@ -54,7 +54,7 @@
     QString formatRecipientList(const QString &sender,
                                 const QList<NmAddress> &to,
                                 const QList<NmAddress> &cc);
-    QString addressToDisplayInHtml(const NmAddress &addr);
+    QString addressToDisplay(const NmAddress &addr);
     
 private:
     NmMessage *mMessage;                 // Not owned
--- a/emailuis/nmailui/inc/nmviewerserviceinterface.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmviewerserviceinterface.h	Thu Jul 22 16:30:28 2010 +0100
@@ -21,44 +21,27 @@
 
 //  INCLUDES
 #include <QObject>
-#ifdef Q_OS_SYMBIAN
 #include <xqserviceprovider.h>
-#else
-#define NM_WINS_ENV
-#include <QVariant>
-#endif
-
 
 //  FORWARD DECLARATIONS
-class HbView;
 class NmApplication;
 class NmUiEngine;
 class NmId;
 
-#ifndef NM_WINS_ENV
 class NmViewerServiceInterface : public XQServiceProvider
-#else
-class NmViewerServiceInterface : public QObject
-#endif
 {
     Q_OBJECT
-
 public:
-
     NmViewerServiceInterface(QObject *parent,
                               NmApplication *application,
                               NmUiEngine &uiEngine);
-
     ~NmViewerServiceInterface();
 
 
 public slots:
-
     void viewMessage(QVariant mailboxId, QVariant folderId, QVariant messageId);
 
-
 private:
-
     NmApplication *mApplication; // Not owned
     NmUiEngine &mUiEngine;
     int mAsyncReqId;
--- a/emailuis/nmailui/inc/nmviewerview.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmviewerview.h	Thu Jul 22 16:30:28 2010 +0100
@@ -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 NMVIEWERVIEW_H_
 #define NMVIEWERVIEW_H_
@@ -24,18 +24,17 @@
 #include "nmactionobserver.h"
 #include "nmattachmentfetchobserver.h"
 
-class QGraphicsLinearLayout;
 class QWebPage;
 
 class HbWidget;
 class HbMainWindow;
+class HbScrollArea;
 
 class NmApplication;
 class NmUiEngine;
 class NmUiStartParam;
 class NmMailViewerWK;
 class NmMessage;
-class NmBaseViewScrollArea;
 class NmViewerViewNetManager;
 class NmViewerHeader;
 class NmMailViewerWK;
@@ -44,6 +43,8 @@
 class HbProgressDialog;
 class NmAttachmentListWidget;
 class NmAttachmentManager;
+class HbMessageBox;
+class NmMessagePart;
 
 class NmViewerView : public NmBaseView, public NmActionObserver, public NmAttachmentFetchObserver
 {
@@ -54,13 +55,14 @@
 				NmUiStartParam* startParam,
 				NmUiEngine &uiEngine,
 				HbMainWindow *mainWindow,
-            NmAttachmentManager &attaManager,
-            bool toolbar = false,
+				NmAttachmentManager &attaManager,
+				bool toolbar = false,
 				QGraphicsItem *parent = NULL);
     ~NmViewerView();
     void reloadViewContents(NmUiStartParam* startParam);
     NmUiViewId nmailViewId() const;
     NmMailViewerWK* webView();
+    NmMessage* message();
     void viewReady();
     void aboutToExitView();
     
@@ -72,12 +74,9 @@
     void adjustViewDimensions();
     void linkClicked(const QUrl& link);
     void contentScrollPositionChanged(const QPointF &newPosition);
-    void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
-    void handleMousePressEvent(QGraphicsSceneMouseEvent *event);
     void fetchMessage();
     void openAttachment(int index);
 	void createOptionsMenu();
-	void deleteButton(HbAction* result);
 
 private slots:
     void setMessageData();
@@ -96,47 +95,48 @@
     void fetchCompleted(int result);
 
 private:
+    void deleteMessage();
     void loadMessage();
     void loadViewLayout();
     QString formatMessage();
+    QString formatHtmlMessage(NmMessagePart *html);
+    QString formatPlainTextMessage(NmMessagePart *plain);
     bool eventOnTopOfHeaderArea(QGraphicsSceneMouseEvent *event);
     void changeMessageReadStatus(bool read);
     void setMailboxName();
     void createToolBar();
     void setAttachmentList();
+    void createAndShowWaitDialog();
 
 private:
     NmApplication &mApplication;
     NmUiEngine &mUiEngine;
-    HbMainWindow *mMainWindow;               // Not owned
+    HbMainWindow *mMainWindow;                       // Not owned
     NmAttachmentManager  &mAttaManager;
-    bool mToolbarEnabled;					 // is toolbar or options menu in use
-    NmMessage* mMessage;                     // Owned
-    NmBaseViewScrollArea *mScrollArea;       // Not owned
-    HbWidget *mViewerContent;                // Not owned
-    NmMailViewerWK *mWebView;                // Not owned
-    NmViewerHeader *mHeaderWidget;           // Not owned
-    NmAttachmentListWidget *mAttaListWidget;  // Not owned
+    bool mToolbarEnabled;					         // is toolbar or options menu in use
+    NmMessage* mMessage;                             // Owned
+    HbScrollArea *mScrollArea;                       // Not owned
+    HbWidget *mViewerContent;                        // Not owned
+    NmMailViewerWK *mWebView;                        // Not owned
+    NmViewerHeader *mHeaderWidget;                   // Not owned
+    NmAttachmentListWidget *mAttaListWidget;         // Not owned
     QPointF mHeaderStartScenePos;
-    QGraphicsLinearLayout *mViewerContentLayout; // Not owned
-    QPointer<NmOperation> mMessageFetchingOperation;   // Not owned 
+    QPointer<NmOperation> mMessageFetchingOperation; // Not owned 
     QPointF mLatestScrollPos;
     bool mDisplayingPlainText;
     QObjectList mWidgetList;
-    NmUiDocumentLoader *mDocumentLoader;
-    HbWidget *mScrollAreaContents;
-    HbWidget *mViewerHeaderContainer;
+    NmUiDocumentLoader *mDocumentLoader;             // Owned
+    HbWidget *mScrollAreaContents;                   // Not owned
     QSize mScreenSize;
-    HbProgressDialog *mWaitDialog;            // owned
+    HbProgressDialog *mWaitDialog;                   // Owned
     bool webFrameloadingCompleted;
     QSize mLatestLoadingSize;
     QList<NmId> mAttaIdList;
     int mAttaIndexUnderFetch;
-    NmAttachmentListWidget *mAttaWidget;      // Not owned
+    NmAttachmentListWidget *mAttaWidget;             // Not owned
     bool mViewReady;
     bool mWaitNoteCancelled;
-    HbAction* mOkAction;                        //owned
-    HbAction* mCancelAction;                    //owned
+    HbMessageBox *mErrorNote;                       // Owned
 };
 
 #endif /* NMVIEWERVIEW_H_ */
--- a/emailuis/nmailui/inc/nmviewerviewnetmanager.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmviewerviewnetmanager.h	Thu Jul 22 16:30:28 2010 +0100
@@ -23,18 +23,20 @@
 
 class QNetworkRequest;
 class NmViewerView;
+class NmUiEngine;
 
 class NmViewerViewNetManager : public QNetworkAccessManager
 {
     Q_OBJECT
 public:
-    NmViewerViewNetManager();
+    NmViewerViewNetManager(NmUiEngine &uiEngine);
     ~NmViewerViewNetManager();
     void setView(NmViewerView *viewerView);
     QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
                                  QIODevice *outgoingData);
 
 private:
+	NmUiEngine &mUiEngine;
 	NmViewerView *mMessageView;    // Not owned
 
 };
--- a/emailuis/nmailui/inc/nmviewerviewnetreply.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmviewerviewnetreply.h	Thu Jul 22 16:30:28 2010 +0100
@@ -20,12 +20,20 @@
 #define NMVIEWERVIEWNETREPLY_H_
 
 #include <QNetworkReply>
+#include "nmcommon.h"
+
+class NmOperation;
+class NmMessage;
+class NmUiEngine;
 
 class NmViewerViewNetReply : public QNetworkReply
 {
     Q_OBJECT
 public:
-    NmViewerViewNetReply(QVariant data);
+    NmViewerViewNetReply(QVariant data, NmUiEngine &uiEngine);
+    NmViewerViewNetReply(QVariant data, NmUiEngine &uiEngine, 
+            const NmId &mailboxId, const NmId &folderId, const NmId &messageId, 
+            const NmId &messagePartId);
     ~NmViewerViewNetReply();
     void setOriginalRequest(const QNetworkRequest &request);
     qint64 readData(char *data, qint64 maxlen);
@@ -36,9 +44,17 @@
 
 public slots:
     void signalReady();
+    void fetchCompleted(int result);
+    void fetchCancelled();
 
 private:
     QByteArray mDataArray;
+    NmUiEngine &mUiEngine;
+    NmId mMailboxId;
+    NmId mFolderId;
+    NmId mMessageId;
+    NmId mMessagePartId;
+    NmOperation *mOperation;    // Not owned
     qint64 mReadIndex;
 };
 
--- a/emailuis/nmailui/inc/nmviewerwebview.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/inc/nmviewerwebview.h	Thu Jul 22 16:30:28 2010 +0100
@@ -1,45 +1,63 @@
 /*
-* 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 NMVIEWERWEBVIEW_H_
 #define NMVIEWERWEBVIEW_H_
 
 #include <QGraphicsWebView>
 
+#include "nmcommon.h"
+
 class NmViewerView;
 class NmMessage;
+class QGestureEvent;
 
-class QMouseEvent;
+class NmMailViewerWkContentItem
+{
+public:
+    NmMailViewerWkContentItem() 
+        : mData(0), mPartId(0), mIsFetched(false) {}
+    NmMailViewerWkContentItem(QVariant data, NmId partId, bool isFetched) 
+        : mData(data), mPartId(partId), mIsFetched(isFetched) {}
+    QVariant mData;
+    NmId     mPartId;
+    bool     mIsFetched;
+};
 
 class NmMailViewerWK : public QGraphicsWebView
 {
     Q_OBJECT
 public:
-	NmMailViewerWK();
-	~NmMailViewerWK();
-    virtual QVariant loadResource ( int type, const QUrl & name );
-    void setParentView(NmViewerView *parentView);
-    void addContent(QString key, QVariant val);
-    void sendMousePressEvent(QGraphicsSceneMouseEvent *event);
-    void sendMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
-
+    NmMailViewerWK();
+    ~NmMailViewerWK();
+    virtual QVariant loadResource (int type, const QUrl &name, NmId &partId, bool &isFetched);
+    void addContent(QString key, QVariant val, NmId partId, bool isFetched);
+    bool event(QEvent* event);
+    
+protected:
+    void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
+    void gestureEvent(QGestureEvent* event);
+    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
+    void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
+    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
+    
 private:
-    QMap<QString,QVariant> mContent;
-    NmViewerView *mParentView;      // Not owned
+    QMap<QString,NmMailViewerWkContentItem> mContent;
+    bool mSuppressRelease;
 };
 
 #endif /* NMVIEWERWEBVIEW_H_*/
--- a/emailuis/nmailui/nmailui.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/nmailui.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -47,7 +47,7 @@
     LIBS += -lxqservice \
         -lxqserviceutil \
         -lqtcontacts \
-        -lmobcntmodel
+        -lfmfiledialog
 }
 
 HEADERS += inc/nmeditorcontent.h \
@@ -76,6 +76,7 @@
     inc/nmuidef.h \
     inc/nmrecipientfield.h \
     inc/nmsendserviceinterface.h \
+    inc/nmuriserviceinterface.h \
     inc/nmmailboxselectiondialog.h \
     inc/nmuidocumentloader.h \
     inc/nmmailboxserviceinterface.h \
@@ -107,6 +108,7 @@
     src/nmuiextensionmanager.cpp \
     src/nmrecipientfield.cpp \
     src/nmsendserviceinterface.cpp \
+    src/nmuriserviceinterface.cpp \
     src/nmmailboxselectiondialog.cpp \
     src/nmuidocumentloader.cpp \
     src/nmmailboxserviceinterface.cpp \
--- a/emailuis/nmailui/service_conf.xml	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/service_conf.xml	Thu Jul 22 16:30:28 2010 +0100
@@ -13,6 +13,12 @@
     <customproperty key="aiw_action_icon">qtg_large_email</customproperty>
   </interface>
   <interface>
+    <name>com.nokia.symbian.IUriView</name>
+    <version>1.0</version>
+    <description>Uri interface</description>
+    <customproperty key="schemes">mailto</customproperty>
+  </interface>
+  <interface>
     <name>com.nokia.symbian.IEmailMessageSend</name>
     <version>1.0</version>
     <description>Send interface</description>
--- a/emailuis/nmailui/src/main.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/main.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -1,49 +1,53 @@
 /*
-* 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:
+ *
+ */
 
 #include "nmuiheaders.h"
 
+const QString NmActivityName("EmailInboxView");
+
 /*!
-	int main
-*/
+    The main function.
+ */
 int main(int argc, char *argv[])
 {
-    HbApplication app(argc, argv);
- 
+    HbApplication app(argc,argv,Hb::NoSplash);
+    
     // Load the translation file.
     QTranslator translator;
-
-#ifdef Q_OS_SYMBIAN
     QString lang = QLocale::system().name();
     QString appName = "mail_";
     QString path = "Z:/resource/qt/translations/";
-#else
-    QString lang;
-    QString appName = "mail";
-    QString path = ":/translations";
-#endif
     translator.load(appName + lang, path);
     app.installTranslator(&translator);
-
+    
     app.setApplicationName(hbTrId("txt_mail_title_mail"));
-
-    NmApplication *nmApplication = new NmApplication(&app);
-
+    
+    NmApplication *nmApplication = NULL;
+    quint32 accountId = 0;
+    if (app.activateReason() == Hb::ActivationReasonActivity &&
+        app.activateId() == NmActivityName) {
+        QVariant data = app.activateParams().take("accountId");
+        QString accountIdString = data.toString();
+        accountId = accountIdString.toULongLong();
+        nmApplication = new NmApplication(&app,accountId);
+    } else {
+        nmApplication = new NmApplication(&app);
+    }
+    
     int ret = app.exec();
     delete nmApplication;
     return ret;
--- a/emailuis/nmailui/src/nmapplication.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmapplication.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -1,213 +1,243 @@
 /*
-* 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:
-*
-*/
+ * 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"
-#ifdef Q_OS_SYMBIAN
 #include <email_services_api.h>
 #include <e32base.h>
-#else
-#define NM_WINS_ENV
-#endif
 
 static const QString NmSendServiceName = "nmail.com.nokia.symbian.IFileShare";
 
 /*!
-	\class NmApplication
-	\brief Application class, creates main window and handles view switching
+    \class NmApplication
+    \brief Application class, creates main window and handles view switching.
 */
 
 /*!
-    Constructor
+    Constructor.
 */
-NmApplication::NmApplication(QObject *parent)
-:QObject(parent),
-mMainWindow(NULL),
-mViewStack(NULL),
-mActiveViewId(NmUiViewNone),
-mUiEngine(NULL),
-mBackAction(NULL),
-mExtensionManager(NULL),
-mMbListModel(NULL),
-mServiceViewId(NmUiViewNone),
-mForegroundService(false),
-mEffects(NULL),
-mAttaManager(NULL),
-mSettingsViewLauncher(NULL),
-mViewReady(false)
+NmApplication::NmApplication(QObject *parent, quint32 accountId)
+: QObject(parent),
+  mMainWindow(NULL),
+  mViewStack(NULL),
+  mActiveViewId(NmUiViewNone),
+  mUiEngine(NULL),
+  mBackAction(NULL),
+  mExtensionManager(NULL),
+  mMbListModel(NULL),
+  mServiceViewId(NmUiViewNone),
+  mForegroundService(false),
+  mEffects(NULL),
+  mAttaManager(NULL),
+  mSettingsViewLauncher(NULL),
+  mViewReady(false),
+  mQueryDialog(NULL),
+  mBackButtonPressed(false)
 {
+    TRAP_IGNORE(mUiEngine = NmUiEngine::instance());
+    
     // Create network access manager and cache for application use.
-    mNetManager = new NmViewerViewNetManager();
+    mNetManager = new NmViewerViewNetManager(*mUiEngine);
     QNetworkDiskCache *cache = new QNetworkDiskCache();
-    cache->setCacheDirectory(QDesktopServices::storageLocation(QDesktopServices::CacheLocation));
+    cache->setCacheDirectory(
+        QDesktopServices::storageLocation(QDesktopServices::CacheLocation));
     mNetManager->setCache(cache);
-
-    // TEMPORARY WORKAROUND TO PREVENT PANIC User panic 66, where there is
-    // a PushL call to cleanup stack without any TRAP.
-    #ifdef Q_OS_SYMBIAN
-    TRAP_IGNORE(mUiEngine = NmUiEngine::instance());
-    #else
-    mUiEngine = NmUiEngine::instance();
-    #endif
+    
     createMainWindow();
-
-    // attachment manager can be shared between viewer and editor, ownership in application class
+    
+    // Attachment manager can be shared between viewer and editor.
+    // The application class has the ownership.
     mAttaManager = new NmAttachmentManager(*mUiEngine);
-
-#ifndef NM_WINS_ENV
+    
     mSendServiceInterface =
-            new NmSendServiceInterface(NmSendServiceName, NULL, *mUiEngine, this);
+        new NmSendServiceInterface(NmSendServiceName, NULL, *mUiEngine, this);
     mSendServiceInterface2 =
-            new NmSendServiceInterface(emailFullServiceNameSend, NULL, *mUiEngine, this);
+        new NmSendServiceInterface(emailFullServiceNameSend, NULL, *mUiEngine, this);
+    mUriServiceInterface =
+        new NmUriServiceInterface(NULL, *mUiEngine, this);
     mMailboxServiceInterface =
-            new NmMailboxServiceInterface(NULL, *mUiEngine, this);
+        new NmMailboxServiceInterface(NULL, *mUiEngine, this);
     mViewerServiceInterface =
-            new NmViewerServiceInterface(NULL, this, *mUiEngine);
-#endif
-
+        new NmViewerServiceInterface(NULL, this, *mUiEngine);
+    
+    if(accountId != 0) {
+        QVariant mailbox;
+        mailbox.setValue(mUiEngine->getPluginIdByMailboxId(accountId).id());
+        mMailboxServiceInterface->displayInboxByMailboxId(mailbox);
+    }
+    
     mEffects = new NmUiEffects(*mMainWindow);
 }
 
 /*!
-    Destructor
+    Destructor.
 */
 NmApplication::~NmApplication()
 {
-#ifndef NM_WINS_ENV
-	delete mSendServiceInterface;
-	delete mSendServiceInterface2;
-	delete mMailboxServiceInterface;
-	delete mViewerServiceInterface;
-#endif
-
-	resetViewStack();
+    if (mQueryDialog) {
+        delete mQueryDialog;
+        mQueryDialog = NULL;
+    }
+    
+    delete mSendServiceInterface;
+    delete mSendServiceInterface2;
+    delete mUriServiceInterface;
+    delete mMailboxServiceInterface;
+    delete mViewerServiceInterface;
+    
+    resetViewStack();
     delete mViewStack;
+    
     NmIcons::freeIcons();
     NmUiEngine::releaseInstance(mUiEngine);
     mUiEngine = NULL;
+    
     delete mBackAction;
+    
+    // Workaround: the main window has to be closed (hidden) before deleting
+    // the extension manager in order to prevent the main window's title bar
+    // from showing when the application is closed.
+    if (mMainWindow) {
+        // Workaround: assert failure may happen if an open main window is
+        // deleted.
+        mMainWindow->close();
+    }
+    
     delete mExtensionManager;
-    if (mNetManager){
-        if (mNetManager->cache()){
+    
+    if (mNetManager) {
+        if (mNetManager->cache()) {
             mNetManager->cache()->clear();
         }
     delete mNetManager;
-    mNetManager=NULL;
+    mNetManager = NULL;
     }
+    
+    // Effects need to be deleted before MainWindow.
+    delete mEffects;
     delete mMainWindow;
     delete mAttaManager;
-    delete mEffects;
     delete mSettingsViewLauncher;
 }
 
 /*!
-    Main application window creation
+    Main application window creation.
 */
 void NmApplication::createMainWindow()
 {
-    NMLOG("nmailui: createMainWindow enter");
-
-#ifndef NM_WINS_ENV
+    NM_FUNCTION;
+    
     bool service = XQServiceUtil::isService();
-    if (service && !XQServiceUtil::isEmbedded()) {
-        // If started as service, keep it hidden until everything is initialised
-        // In embedded mode, the client app should not get hidden
-        XQServiceUtil::toBackground(true);
-    }
-#else
-    bool service = false;
-#endif
-
-    // Register custom widget files
+    
+    // Register custom widget files.
     HbStyleLoader::registerFilePath(":nmmessagelistviewitem.widgetml");
     HbStyleLoader::registerFilePath(":nmmessagelistviewitem.css");
     HbStyleLoader::registerFilePath(":nmviewerheader.widgetml");
     HbStyleLoader::registerFilePath(":nmviewerheader.css");
-
-    // Create main window
+    
+    // Create main window.
     mMainWindow = new HbMainWindow();
-
-    // Connect to lazy loading signal
+    
+    // Connect to lazy loading signal.
     QObject::connect(mMainWindow, SIGNAL(viewReady ()),
                      this, SLOT(viewReady()));
-
-    // Create extension manager
+    
+    // Create extension manager.
     mExtensionManager = new NmUiExtensionManager();
-
-    // Create view stack
+    
+    // Create view stack.
     mViewStack = new QStack<NmBaseView*>;
-
-    // Create back action and connect it to popView()
+    
+    // Create back action and connect it to prepareForPopView().
     if (mMainWindow) {
         mBackAction = new HbAction(Hb::BackNaviAction,this);
-        connect(mBackAction, SIGNAL(triggered()), this, SLOT(popView()));
-        // Show mainwindow
-        mMainWindow->show();
+        connect(mBackAction,
+                SIGNAL(triggered()),
+                this,
+                SLOT(prepareForPopView()));
+        
+        // Show mainwindow.
+        // Services will active it when the view is ready.
+        if (!service) {
+            mMainWindow->show();
+        }
     }
-
-    // async operation completion related notifications
-    connect(
-        mUiEngine, SIGNAL(operationCompleted(const NmOperationCompletionEvent &)),
-        this, SLOT(handleOperationCompleted(const NmOperationCompletionEvent &)));
-
+    
+    // Asynchronous operation completion related notifications.
+    connect(mUiEngine,
+            SIGNAL(operationCompleted(const NmOperationCompletionEvent &)),
+            this,
+            SLOT(handleOperationCompleted(const NmOperationCompletionEvent &)));
+    
     mMbListModel = &mUiEngine->mailboxListModel();
-
-    // Start application to mailbox view
-    // If started as service, there is no need to create views
+    
+    // ----------------------------------------------------------------------
+    // TODO: Remove or comment out the following code block when the mail
+    //       wizard starts to work with Mfe.
+    // ----------------------------------------------------------------------
+    // Start application to mailbox view. If started as service, there is no
+    // need to create views.
     if (!service) {
         NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMailboxList);
         enterNmUiView(startParam);
     }
-
-    // Start to filter main window events to get "end key" event in all possible situations. Using
-    // event() is not enough to catch the event as it is only called if the view widget has the 
-    // focus. Note: if key capturing (xqkeycapture.h) is required it is probably best to implement 
-    // an own QMainWindow class and do the capturing there, not in the views.
-    mMainWindow->installEventFilter(this);
+    // ----------------------------------------------------------------------
+    
+    if (mMainWindow) {
+        // Start to filter main window events to get "end key" event in all
+        // possible situations. Using event()is not enough to catch the event
+        // as it is only called if the view widget has the focus. Note: if
+        // key capturing (xqkeycapture.h) is required it is probably best to
+        // implement an own QMainWindow class and do the capturing there, not
+        // in the views.
+        mMainWindow->installEventFilter(this);
+        // Optimize the custom paint functions.
+        // Currently effects to NmViewerHeader::paint() and
+        // NmAttachmentListWidget::paint().
+        mMainWindow->setOptimizationFlag(QGraphicsView::DontSavePainterState);    
+    }
 }
 
 /*!
-    Slot. React to view ready signal and call
-    current view method.
+    Slot. React to view ready signal and call current view method.
 */
 void NmApplication::viewReady()
 {
     mViewReady = true;
-    if (!mViewStack->isEmpty()) {
+    if (mViewStack && !mViewStack->isEmpty()) {
     	NmBaseView *currentView = mViewStack->top();
-        if (currentView){
+        if (currentView) {
             currentView->viewReady();
         }
     }
 }
 
 /*!
-    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 of the or the app is exited by default.
 */
 bool NmApplication::eventFilter(QObject *obj, QEvent *event)
 {
-    bool consumed = false;
+    bool consumed(false);
     
     if (obj && obj == mMainWindow && event && event->type() == QEvent::KeyPress) {
         QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
-        
-        if (keyEvent->key() == Qt::Key_No) { // end key, the "red" key
-            
-            // exit application if no pending operations are on-going
+        if (keyEvent->key() == Qt::Key_No) {
+            // End key, the "red" key.
+            // Exit application if no pending operations are on-going.
         }
     }
     
@@ -219,47 +249,73 @@
 }
 
 /*!
-    Push view to view stack
+    Push view to view stack.
 */
 void NmApplication::pushView(NmBaseView *newView)
 {
-    NMLOG("nmailui: pushView enter");
-    if (newView) {
-        NMLOG("nmailui: view exists");
+    if (newView && mViewStack) {
+        NM_COMMENT("NmApplication::pushView() : view exists.");
         newView->setNavigationAction(mBackAction);
-
-        // Store view to be hidden
+        
+        // Store view to be hidden.
         NmBaseView *hideView(NULL);
         if (!mViewStack->isEmpty()) {
             hideView = mViewStack->top();
         }
 		else {
-			// viewReady should be informed immediatelly
+			// viewReady should be informed immediately.
 			if (mViewReady) {
 				newView->viewReady();
 			}
 		}
-
-        // activate new view
-    	NMLOG("nmailui: addView");
+        
+        // Activate new view.
+    	NM_COMMENT("NmApplication::pushView() : add view.");
         mMainWindow->addView(newView);
         mViewStack->push(newView);
         mMainWindow->setCurrentView(newView);
         mActiveViewId=newView->nmailViewId();
-
-        // Set toolbars orientation
+        
+        // Set toolbars orientation.
         HbToolBar *tb = newView->toolBar();
-        if(tb){
+        if (tb) {
             tb->setOrientation(Qt::Horizontal);
         }
-
-        // hide old view
-        NMLOG("nmailui: removeView");
-        if (hideView){
+        
+        // Hide old view.
+        NM_COMMENT("NmApplication::pushView() : remove view.");
+        if (hideView) {
             mMainWindow->removeView(hideView);
         }
+    }
+}
 
-        NMLOG("nmailui: pushView done");
+/*!
+    Ask from view that is it ok to pop view. This kind of 2-phase popView is
+    needed because view may show query dialog for user response.
+ */
+void NmApplication::prepareForPopView()
+{
+    if (mViewStack && mViewStack->size() > 0) {
+        // Get view pointer.
+        NmBaseView *view = mViewStack->top();
+        if (view){
+			NmUiViewId topViewId = view->nmailViewId();
+			
+			// We must know in popView, are we coming with back button from
+			// message view to prevent the send animation.
+			if (topViewId == NmUiViewMessageEditor) {
+				mBackButtonPressed = true;
+			}
+            
+            // View will call/signal popView if exitting is ok.
+            view->okToExitView();        
+        }
+    }
+    // If the view stack is now empty quit the app. This happens also when
+    // the app has been started as a service
+    else if (mViewStack && mViewStack->size() == 0) {
+        exitApplication();
     }
 }
 
@@ -268,27 +324,30 @@
 */
 void NmApplication::popView()
 {
-    NMLOG("nmailui: popView enter");
-    if (mViewStack->size() > 0) {
-        // Get view pointer
-        NmBaseView *view = mViewStack->top();
-
-        // ask view if it's ok to exit
-        if (view->okToExitView()) {
+    if (mViewStack && mViewStack->size() > 0) {
+        NmBaseView *view = mViewStack->top();    
+        if (view) {
+            // Get top view id.
             NmUiViewId topViewId = view->nmailViewId();
-
-            // Prepare for send animation if returing from editor and message has been sent.
+            
+            // Prepare for send animation if returing from editor and message
+            // has been sent.
             if (topViewId == NmUiViewMessageEditor && mUiEngine->isSendingMessage()) {
-                mEffects->prepareEffect(NmUiEffects::NmEditorSendMessageAnimation);
-            }
+				// If we are coming from message editor with back button.
+				// do not prepare the send animation.
+				if (!mBackButtonPressed) {
+					mEffects->prepareEffect(NmUiEffects::NmEditorSendMessageAnimation);
+				}
+	        }
+            mBackButtonPressed = false;
             mViewStack->pop();
-            // Call custom exit function
+            // Call custom exit function.
             view->aboutToExitView();
             // Remove view from stack.
             mMainWindow->removeView(view);
-
-            // if we were in editor and sent a message, pop viewer from stack first
-            // so we can go straight to mail list
+            
+            // If we were in editor and sent a message, pop viewer from stack
+            // first so we can go straight to mail list.
             if (!mViewStack->isEmpty() && topViewId == NmUiViewMessageEditor &&
                 mUiEngine->isSendingMessage() &&
                 mViewStack->top()->nmailViewId() == NmUiViewMessageViewer) {
@@ -297,41 +356,40 @@
                 delete tmpView;
                 tmpView = NULL;
             }
-
+            
             if (!mViewStack->isEmpty()) {
-                // Activate next view in stack
+                // Activate next view in stack.
                 NmBaseView *showView = mViewStack->top();
                 mMainWindow->addView(showView);
                 mMainWindow->setCurrentView(showView);
-                // Store activated view id
+                // Store activated view id.
                 mActiveViewId=showView->nmailViewId();
                 // Perform send animation if requested.
                 mEffects->startEffect(NmUiEffects::NmEditorSendMessageAnimation);
             }
-
+            
             delete view;
             view = NULL;
-
-#ifndef NM_WINS_ENV
-            // If view was started as service, move the app now
-            // to the background, unless it was started when the app
-            // was already in foreground..
+            
+            // If view was started as service, move the app now to the
+            // background, unless it was started when the app was already in
+            // foreground.
             if (mServiceViewId == topViewId) {
                 mServiceViewId = NmUiViewNone;
-
-                // if started as embedded, do not hide the app
-		        if (!XQServiceUtil::isEmbedded() &&
-		            !mForegroundService) {
-		            XQServiceUtil::toBackground(true);
+                NM_COMMENT("NmApplication::popView() : returned from service view.");
+                // If started as embedded or while the app was in foreground,
+                // do not hide the app.
+                if (!XQServiceUtil::isEmbedded() &&
+                    !mForegroundService) {
+                    XQServiceUtil::toBackground(true);
                 }
             }
-#endif
         }
     }
-
-    // If the view stack is now empty quit the app
-    // This happens also when the app has been started as a service
-    if (mViewStack->size()==0) {
+    
+    // If the view stack is now empty quit the app. This happens also when
+    // the app has been started as a service.
+    if (mViewStack && mViewStack->size() == 0) {
         exitApplication();
     }
 }
@@ -341,56 +399,60 @@
 */
 void NmApplication::resetViewStack()
 {
-    NMLOG("nmailui: resetViewStack enter");
     if (mViewStack && !mViewStack->isEmpty()) {
 	    int viewCount = mViewStack->count();
         // Pop and destroy all views
-	    for (int i=0;i<viewCount;i++) {
+	    for (int i=0 ; i < viewCount ; i++) {
 		    NmBaseView *view = mViewStack->pop();
             mMainWindow->removeView(view);
             delete view;
         }
-	    mActiveViewId=NmUiViewNone;
+	    mActiveViewId = NmUiViewNone;
     }
 }
 
 /*!
-    Function activates view based on viewId parameter.
-    If requested view is already open, it is requested to reload.
-    Otherwise view object is created and pushed to view stack
+    Function activates view based on viewId parameter. If requested view is
+    already open, it is requested to reload. Otherwise view object is created
+    and pushed to view stack.
 */
-void NmApplication::enterNmUiView(NmUiStartParam* startParam)
+void NmApplication::enterNmUiView(NmUiStartParam *startParam)
 {
-    // Check the validity of start parameter object
+    NM_FUNCTION;
+    
+    // Check the validity of start parameter object.
     if (startParam) {
-
+        
         if (startParam->service() && mMainWindow) {
-			// Store the visibility state when the service was launched
-			mForegroundService = mMainWindow->isVisible();
-
-			// When the message list is started as a service previous views are removed
-			// from the stack. Open editors are not closed.
-			// Also if the view is same than the new one, keep it open (reload the content).
-
-		    // at least one view must remain in the stack
-			while (mViewStack->count()>1) {
+			// When the message list is started as a service previous views
+            // are removed from the stack. Open editors are not closed. Also
+            // if the view is same than the new one, keep it open (reload the
+            // content).
+            
+		    // Reset the foreground service flag while popping the views.
+		    bool previousForegroundService = mForegroundService;
+		    mForegroundService = true;
+		    
+		    // At least one view must remain in the stack.
+			while (mViewStack->count( )> 1) {
 			    NmUiViewId topId = mViewStack->top()->nmailViewId();
-			    if (topId!=NmUiViewMessageEditor &&
-			        topId!=NmUiViewMailboxList &&
-			        topId!=startParam->viewId()) {
-			        popView();
+			    if (topId != NmUiViewMessageEditor &&
+			        topId != NmUiViewMailboxList &&
+			        topId != startParam->viewId()) {
+			        prepareForPopView();
 			    }
 			    else {
 			        // Editor or mailbox list in the top. Stop the loop.
 			        break;
 			    }
 			}
+			mForegroundService = previousForegroundService;
         }
-
-        // Check whether requested view is already active
-        // and if so, ask it to reload contents with new start parameter data
-        // Do not reuse the view if started as service to editor view (ShareUI)
-        if (mActiveViewId==startParam->viewId() &&
+        
+        // Check whether requested view is already active and if so, ask it
+        // to reload contents with new start parameter data. Do not reuse the
+        // view if started as service to editor view (ShareUI).
+        if (mActiveViewId == startParam->viewId() &&
         	(!startParam->service() || mActiveViewId!=NmUiViewMessageEditor)) {
             mViewStack->top()->reloadViewContents(startParam);
         }
@@ -407,12 +469,12 @@
                 case NmUiViewMessageList:
                 {
                     // Check the topmost view. If it is an editor, do not open
-                    // a new mail list view
+                    // a new mail list view.
                     if (startParam->service() && !mViewStack->isEmpty() &&
                         mViewStack->top()->nmailViewId()==NmUiViewMessageEditor) {
                         break;
                     }
-                    NmMessageListModel &messageListModel = mUiEngine->messageListModel(
+                    NmMessageListModel *messageListModel = &mUiEngine->messageListModel(
                                                 startParam->mailboxId(), startParam->folderId());
                     NmMessageListView *msgList =new NmMessageListView(
                     		*this, startParam, *mUiEngine, *mMbListModel, messageListModel,
@@ -424,107 +486,101 @@
                 {
                     // Check the topmost view. If it is an editor, do not open
                     // a new mail search list view.
-                    if (startParam->service() && !mViewStack->isEmpty() && 
+                    if (startParam->service() && !mViewStack->isEmpty() &&
                         mViewStack->top()->nmailViewId() == NmUiViewMessageEditor) {
                         break;
                     }
-
-                    NmMessageListModel &messageListModel =
-                        mUiEngine->messageListModel(startParam->mailboxId(),
-                                                    startParam->folderId());
-
-                    NmMessageSearchListModel &searchListModel =
-                        mUiEngine->messageSearchListModel(&messageListModel);
-
+                    
+                    NmMessageListModel &model =
+                        mUiEngine->messageListModelForSearch(startParam->mailboxId());
+                    
                     NmMessageSearchListView *searchListView = new NmMessageSearchListView(
-                        *this, startParam, *mUiEngine, searchListModel,
+                        *this, startParam, *mUiEngine, model,
                         new HbDocumentLoader(mMainWindow));
-
+                    
                     pushView(searchListView);
                 }
                 break;
                 case NmUiViewMessageViewer:
-                    pushView(new NmViewerView(*this, startParam, *mUiEngine, 
+                    pushView(new NmViewerView(*this, startParam, *mUiEngine,
                             mMainWindow, *mAttaManager));
                     break;
                 case NmUiViewMessageEditor:
-                    pushView(new NmEditorView(*this, startParam, *mUiEngine));
+                    pushView(new NmEditorView(*this, startParam, *mUiEngine, *mAttaManager));
                     break;
                 default:
-                    // Reset view stack and exit application
+                    // Reset view stack and exit application.
                     delete startParam;
-                    startParam=NULL;
+                    startParam = NULL;
                     resetViewStack();
                     break;
             }
-
-            if (startParam && startParam->service()) {
-				// Store the view id that was launched as service
-        		mServiceViewId = mActiveViewId;
-			}
         }
+        
+        if (startParam && startParam->service()) {
+            // Store the view id that was launched as service.
+            mServiceViewId = mActiveViewId;
+		}
     }
 }
 
 /*!
-    Function can be used from views to exit the application
-    View stack is cleared. Views can connect exit menu
-    selection to this slot.
+    Function can be used from views to exit the application. View stack is
+    cleared. Views can connect exit menu selection to this slot.
 */
 void NmApplication::exitApplication()
 {
-	NMLOG("NmApplication::exitApplication");
-#ifndef NM_WINS_ENV
+    NM_FUNCTION;
+    
     delete mSendServiceInterface;
     mSendServiceInterface = NULL;
     delete mSendServiceInterface2;
     mSendServiceInterface2 = NULL;
+    delete mUriServiceInterface;
+    mUriServiceInterface = NULL;
     delete mMailboxServiceInterface;
     mMailboxServiceInterface = NULL;
     delete mViewerServiceInterface;
     mViewerServiceInterface = NULL;
-#endif
     resetViewStack();
-    // Do housekeeping if needed.
     qApp->quit();
 }
 
 /*!
-   Exit the application in the next event loop
+   Exit the application in the next event loop.
 */
 void NmApplication::delayedExitApplication()
 {
-    NMLOG("NmApplication::delayedExitApplication");
-    // Exit the application in the next event loop
-    QTimer::singleShot(0, this, SLOT(exitApplication()));
+    // Exit the application in the next event loop.
+    QMetaObject::invokeMethod(this, "exitApplication", Qt::QueuedConnection);
 }
 
 /*!
     Getter for main window instance.
 */
-HbMainWindow* NmApplication::mainWindow()
+HbMainWindow *NmApplication::mainWindow()
 {
     return mMainWindow;
 }
 
 /*!
-    Getter for main UI extension manager
+    Getter for main UI extension manager.
 */
-NmUiExtensionManager& NmApplication::extManager()
+NmUiExtensionManager &NmApplication::extManager()
 {
     return *mExtensionManager;
 }
 
 /*!
-    Getter for network access manager
+    Getter for network access manager.
 */
-NmViewerViewNetManager& NmApplication::networkAccessManager()
+NmViewerViewNetManager &NmApplication::networkAccessManager()
 {
     return *mNetManager;
 }
 
 /*!
-    screen size. Function returns curtent screen size
+    Get the screen size. Function returns curtent screen size.
 */
 QSize NmApplication::screenSize()
 {
@@ -534,9 +590,9 @@
         HbDeviceProfile altP(currentP.alternateProfileName());
         QSize curPSize = currentP.logicalSize();
         QSize altPSize = altP.logicalSize();
-        if (mMainWindow->orientation()==Qt::Horizontal){
-            // Get wide profile size in landscape
-            if (curPSize.width()>altPSize.width()){
+        if (mMainWindow->orientation() == Qt::Horizontal) {
+            // Get wide profile size in landscape.
+            if (curPSize.width() > altPSize.width()) {
                 ret = curPSize;
             }
             else{
@@ -544,8 +600,8 @@
             }
         }
         else {
-            // Get narrow profile size in portrait
-            if (curPSize.width()<altPSize.width()){
+            // Get narrow profile size in portrait.
+            if (curPSize.width() < altPSize.width()) {
                 ret = curPSize;
             }
             else{
@@ -557,32 +613,65 @@
 }
 
 /*!
-    handles all asynchronous operation's completions at UI level
+    Handles all asynchronous operation's completions at UI level.
 */
 void NmApplication::handleOperationCompleted(const NmOperationCompletionEvent &event)
 {
-    bool openSettings = NmUtilities::displayOperationCompletionNote(event);
-    if(openSettings) {
-        launchSettings(event.mMailboxId);
+    if (event.mCompletionCode != NmNoError && event.mCompletionCode != NmCancelError) {
+        if (event.mOperationType == Synch && event.mCompletionCode == NmAuthenticationError) {
+            mLastOperationMailbox = event.mMailboxId;
+            if (mQueryDialog) {
+                delete mQueryDialog;
+                mQueryDialog = NULL;
+            }
+            mQueryDialog = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_address_or_password_incorrect"),
+                                                    this, SLOT(launchSettings(HbAction*)));
+        }
+        if (event.mOperationType == Synch && event.mCompletionCode == NmServerConnectionError) {
+            mLastOperationMailbox=event.mMailboxId;
+            if (mQueryDialog) {
+                delete mQueryDialog;
+                mQueryDialog = NULL;
+            }
+            mQueryDialog = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_server_settings_incorrect"),
+                                                    this, SLOT(launchSettings(HbAction*)));
+        }
+        // Following applies to all operation/event types.
+        if (event.mCompletionCode == NmConnectionError) {
+            NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_mail_connection_error"));
+        }
     }
 }
 
 /*!
-    launches settings view of the specified mailbox
+    Launches settings view of the specified mailbox.
 */
-void NmApplication::launchSettings(const NmId &mailboxId)
+void NmApplication::launchSettings(HbAction* action)
 {
-    // create settingslauncher if doesn't exist
-    if(!mSettingsViewLauncher) {
-        mSettingsViewLauncher = new NmSettingsViewLauncher();
-        }
-
-    if(mSettingsViewLauncher) {
-        // mailboxname required
-        NmMailboxMetaData *mailboxMetaData = mUiEngine->mailboxById(mailboxId); // no ownership
+    // Check whether yes button was pressed.
+    if (mQueryDialog&& action == mQueryDialog->actions().at(0)) {
+        // Create settingslauncher if doesn't exist.
+        if(!mSettingsViewLauncher) {
+            mSettingsViewLauncher = new NmSettingsViewLauncher();
+            }
+        // Mailboxname required.
+        NmMailboxMetaData *mailboxMetaData = mUiEngine->mailboxById(mLastOperationMailbox); // No ownership.
         if( mailboxMetaData ) {
-            // launch
-            mSettingsViewLauncher->launchSettingsView(mailboxId, mailboxMetaData->name());
+            // Launch.
+            mSettingsViewLauncher->launchSettingsView(mLastOperationMailbox, mailboxMetaData->name());
         }
     }
 }
+
+/*!
+	Stores the visibility state, e.g. when the service was launched.
+	\return true if the app was visible.
+*/
+bool NmApplication::updateVisibilityState()
+{
+    // At the moment there is no good way to check the foreground state.
+    QWindowSurface *surface = mMainWindow->windowSurface();
+	mForegroundService = (surface != 0);
+	NM_COMMENT(QString("NmApplication::updateVisibilityState() : mForegroundService == %1").arg(mForegroundService));
+	return mForegroundService;
+}
--- a/emailuis/nmailui/src/nmattachmentlist.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmattachmentlist.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -28,7 +28,7 @@
 NmAttachmentList::NmAttachmentList(NmAttachmentListWidget &listWidget)
 : mListWidget(listWidget)
 {
-    updateLayout();
+    NM_FUNCTION;
 }
 
 /*!
@@ -36,17 +36,19 @@
 */
 NmAttachmentList::~NmAttachmentList()
 { 
-    clearList();
+    NM_FUNCTION;
 }
 
 /*!
-    Insert new list item. Returns the count of the attachment in list
+    Insert new list item. Returns the index of the attachment in list
 */
 int NmAttachmentList::insertAttachment(
     const QString &fullFileName,
     const QString &fileSize,
     const NmId &attachmentPartId)
 {
+    NM_FUNCTION;
+    
     QString displayName = fullNameToDisplayName(fullFileName);
     mFullFileName.append(fullFileName);
     mDisplayFileName.append(displayName);
@@ -56,7 +58,6 @@
         count() - 1,
         displayName, 
         NmUtilities::attachmentSizeString(fileSize.toDouble()));  
-    updateLayout();
     return count() - 1;
 }
 
@@ -67,6 +68,8 @@
 void NmAttachmentList::setAttachmentPartId(const QString fullFileName, 
                                            const NmId &attachmentPartId)
 {
+    NM_FUNCTION;
+    
     for (int i=0; i<count(); ++i) {
         if (mFullFileName.at(i) == fullFileName && mAttachmentPartId.at(i).id() == 0) {
             mAttachmentPartId.replace(i, attachmentPartId);
@@ -79,6 +82,8 @@
 */
 void NmAttachmentList::setAttachmentSize(const NmId &attachmentPartId, const QString &size)
 {
+    NM_FUNCTION;
+    
     for (int i=0; i<count(); ++i) {
         if (mAttachmentPartId.at(i) == attachmentPartId) {
             mFileSize.replace(i, size);
@@ -88,18 +93,20 @@
 }
 
 /*!
-    Remove attachment from list position
+    Removes attachment from list position
 */
 void NmAttachmentList::removeAttachment(int arrayIndex)
 {
-    if (arrayIndex < count()) {
+    NM_FUNCTION;
+    
+    if (arrayIndex < count() && 
+        arrayIndex >= 0 ) {
         // Remove UI
         mListWidget.removeAttachment(arrayIndex);
         // Remove from data structure
         mFullFileName.removeAt(arrayIndex);
         mDisplayFileName.removeAt(arrayIndex);
         mAttachmentPartId.removeAt(arrayIndex);
-        updateLayout();
     }
 }
 
@@ -108,6 +115,8 @@
 */
 QString NmAttachmentList::getFullFileNameByIndex(int arrayIndex)
 {
+    NM_FUNCTION;
+    
 	QString result;
 	
     if ( arrayIndex >= 0 && arrayIndex < mFullFileName.count() ) {
@@ -121,6 +130,8 @@
 */
 void NmAttachmentList::removeAttachment(const QString &fullFileName)
 {
+    NM_FUNCTION;
+    
     for (int i=0; i<count(); ++i) {
         if (mFullFileName.at(i) == fullFileName) {
             removeAttachment(i);
@@ -133,6 +144,8 @@
 */
 void NmAttachmentList::removeAttachment(const NmId &attachmentPartId)
 {
+    NM_FUNCTION;
+    
     for (int i=0; i<count(); ++i) {
         if (mAttachmentPartId.at(i) == attachmentPartId) {
             removeAttachment(i);
@@ -145,6 +158,8 @@
 */
 void NmAttachmentList::clearList()
 {
+    NM_FUNCTION;
+    
     for (int i=count()-1; i>=0; --i) {
         // Remove from UI
         mListWidget.removeAttachment(i);
@@ -152,7 +167,6 @@
         mFullFileName.removeAt(i);
         mDisplayFileName.removeAt(i);
         mAttachmentPartId.removeAt(i);
-        updateLayout();
     }
 }
 
@@ -161,6 +175,8 @@
 */
 NmAttachmentListWidget& NmAttachmentList::listWidget()
 {
+    NM_FUNCTION;
+    
     return mListWidget;
 }
 
@@ -169,6 +185,8 @@
 */
 int NmAttachmentList::count()
 {
+    NM_FUNCTION;
+    
     return mFullFileName.count();
 }
 
@@ -177,6 +195,8 @@
 */
 NmId NmAttachmentList::nmIdByIndex(int listIndex)
 {
+    NM_FUNCTION;
+    
     return mAttachmentPartId.at(listIndex);
 }
 
@@ -185,6 +205,8 @@
 */
 int NmAttachmentList::indexByNmId(const NmId &id)
 {
+    NM_FUNCTION;
+    
     for (int i=0; i<count(); ++i) {
         if (mAttachmentPartId.at(i) == id) {
             return i;
@@ -198,24 +220,7 @@
 */
 QString NmAttachmentList::fullNameToDisplayName(const QString &fullName)
 {
+    NM_FUNCTION;
+    
     return fullName.section('\\', -1);
 }
-
-/*!
-    Update the list layout height
-*/
-void NmAttachmentList::updateLayout()
-{
-    // Fix this when progress bar is used
-    mListWidget.setMaximumHeight(count() * 56); 
-    QTimer::singleShot(1, this, SLOT(delayedLayoutChangeInfo()));
-}
-
-/*!
-    Send delayed signal about attachment list layout change
-*/
-void NmAttachmentList::delayedLayoutChangeInfo()
-{
-    emit attachmentListLayoutChanged();
-}
-
--- a/emailuis/nmailui/src/nmattachmentmanager.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmattachmentmanager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -17,7 +17,7 @@
 
 #include "nmuiheaders.h"
 
-const int NmAttachmentManagerInitialProgressPercent = 5;
+static const int NmAttachmentManagerInitialProgressPercent = 5;
 
 /*!
     \class NmAttachmentManager
@@ -30,12 +30,14 @@
 NmAttachmentManager::NmAttachmentManager(NmUiEngine &uiEngine) :
     mUiEngine(uiEngine),
     mFetchOperation(NULL),
+    mMsgFetchOperation(NULL),
     mFetchObserver(NULL),
+    mFetchMsg(NULL),
     mAttaId(0),
     mProgressValue(0),
     mIsFetching(false)
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -43,8 +45,13 @@
 */
 NmAttachmentManager::~NmAttachmentManager()
 {
-    // cancel fetch
+    NM_FUNCTION;
+    
+    // fetch operation deleted in cancel fetch
     cancelFetch();
+    
+    delete mFetchMsg;
+    mFetchMsg = NULL;
 }
 
 /*!
@@ -57,6 +64,7 @@
         const NmId &messageId, 
         const NmId &messagePartId)
 {
+    NM_FUNCTION;
     // cancel old fetch operation, Does nothing if fetch not ongoing
     cancelFetch();
 
@@ -67,7 +75,7 @@
         mAttaId = messagePartId;
         mIsFetching = true;
         QObject::connect(mFetchOperation, SIGNAL(operationCompleted(int)),
-                this, SLOT(attachmentFetchCompleted(int)));
+                this, SLOT(completeAttachmentFetch(int)));
         
         QObject::connect(mFetchOperation, SIGNAL(operationProgressChanged(int)),
                 this, SLOT(changeProgress(int)));
@@ -77,10 +85,97 @@
 }
 
 /*!
+    Fetch attachments to a message. 
+    Set observer with setObserver method to get progress and complete events
+    
+    \return bool true if fetch started, otherwise false.
+*/
+bool NmAttachmentManager::fetchAttachments(
+        const NmId &mailboxId, 
+        const NmId &folderId, 
+        const NmId &messageId,
+        QList<NmId> &messagePartIds)
+{
+    NM_FUNCTION;
+    bool result(false);
+    // cancel old fetch operation, Does nothing if fetch not ongoing
+    cancelFetch();
+    
+    if (messagePartIds.count() > 0) {
+        mFetchOperation = mUiEngine.fetchMessageParts(
+            mailboxId,
+            folderId,
+            messageId,
+            messagePartIds);
+        
+        if (mFetchOperation) {
+            mAttaId = 0;
+            mIsFetching = true;
+            QObject::connect(mFetchOperation, SIGNAL(operationCompleted(int)),
+                    this, SLOT(completeAttachmentFetch(int)));
+            
+            QObject::connect(mFetchOperation, SIGNAL(operationProgressChanged(int)),
+                    this, SLOT(changeProgress(int)));
+        
+            result = true;
+        }
+    }
+    return result;
+}
+
+/*!
+    Fetch all message parts to a message. Fetches also message part data structure,
+    if not fetched already.
+      If earlier fetch operation exist it is cancelled and deleted.
+    Set observer with setObserver method to get progress and complete events
+*/
+void NmAttachmentManager::fetchAllMessageParts(
+        const NmId &mailboxId, 
+        const NmId &folderId, 
+        const NmId &messageId)
+{
+    NM_FUNCTION;
+    mFetchMsg = mUiEngine.message(mailboxId,folderId,messageId);
+    
+    // Check if we have part data structure.    
+    if (mFetchMsg && mFetchMsg->childParts().count() == 0 &&
+        mFetchMsg->fetchedSize() < mFetchMsg->size()) {
+
+        // cancel old fetch operation, Does nothing if fetch not ongoing
+        cancelFetch();
+        
+        // Fetch the message.
+        mMsgFetchOperation = mUiEngine.fetchMessage(
+            mFetchMsg->envelope().mailboxId(),
+            mFetchMsg->envelope().folderId(),
+            mFetchMsg->envelope().messageId());
+        
+        mAttaId = 0;
+        mIsFetching = true;
+
+        if (mMsgFetchOperation) {
+            QObject::connect(mMsgFetchOperation,
+                    SIGNAL(operationCompleted(int)),
+                    this,
+                    SLOT(completeMessageFetch(int)));
+        }
+        else {
+            completeMessageFetch(NmGeneralError);
+        }
+        
+    }
+    else {
+        completeMessageFetch(NmNoError);
+    }
+}
+
+/*!
     Retruns true if fetch operation is ongoing
 */
 bool NmAttachmentManager::isFetching() const
 {
+    NM_FUNCTION;
+    
     return mIsFetching;
 }
 
@@ -89,6 +184,8 @@
 */
 NmId NmAttachmentManager::partIdUnderFetch() const
 {
+    NM_FUNCTION;
+    
     return mAttaId;
 }
 
@@ -97,9 +194,13 @@
 */
 void NmAttachmentManager::cancelFetch()
 {
+    NM_FUNCTION;
     if (mFetchOperation && mFetchOperation->isRunning()) { 
         mFetchOperation->cancelOperation();
     }
+    if (mMsgFetchOperation && mMsgFetchOperation->isRunning()) {
+        mMsgFetchOperation->cancelOperation();
+    }
     mIsFetching = false;
     mAttaId = 0;
     mProgressValue = 0;
@@ -110,6 +211,8 @@
 */
 void NmAttachmentManager::changeProgress(int value)
 {
+    NM_FUNCTION;
+    
     if (mFetchObserver && value > mProgressValue) {
         mProgressValue = value;
         mFetchObserver->progressChanged(value);
@@ -119,8 +222,10 @@
 /*!
     Used by message part fetch operation
 */
-void NmAttachmentManager::attachmentFetchCompleted(int result)
+void NmAttachmentManager::completeAttachmentFetch(int result)
 {
+    NM_FUNCTION;
+    
     if (mFetchObserver) {
         mFetchObserver->fetchCompleted(result);
     }
@@ -130,10 +235,70 @@
 }
 
 /*!
+    Used by message fetch operation
+*/
+void NmAttachmentManager::completeMessageFetch(int result)
+{
+    NM_FUNCTION;
+    
+    if (result == NmNoError) {
+        
+        if (mFetchMsg) {
+            
+            NmId mailboxId = mFetchMsg->envelope().mailboxId();
+            NmId folderId = mFetchMsg->envelope().folderId();
+            NmId messageId = mFetchMsg->envelope().messageId();
+            
+            // Delete object
+            delete mFetchMsg;
+            mFetchMsg = NULL;
+            
+            // Reload message
+            mFetchMsg = mUiEngine.message(mailboxId,folderId,messageId);
+            
+            if (mFetchMsg) {
+                QList<NmId> partIds;
+                NmMessagePart *part;
+                foreach (part, mFetchMsg->childParts()) {
+                    if (part->size() > part->fetchedSize()) {
+                        partIds.append(part->partId());
+                    }
+                }
+                if (partIds.count() > 0) {
+                    mMsgFetchOperation = NULL;
+                    fetchAttachments(
+                        mFetchMsg->envelope().mailboxId(),
+                        mFetchMsg->envelope().folderId(),
+                        mFetchMsg->envelope().messageId(),
+                        partIds);
+                }
+                else {
+                    mFetchObserver->fetchCompleted(NmNoError);
+                }
+                // Delete object
+                delete mFetchMsg;
+                mFetchMsg = NULL;
+            }
+            else {
+                mFetchObserver->fetchCompleted(NmNotFoundError);
+            }
+        }
+        else {
+            mFetchObserver->fetchCompleted(NmNotFoundError);
+        }
+    }
+    else {
+        mFetchObserver->fetchCompleted(result);
+    }
+}
+
+/*!
     Sets fetch observer
 */
 void NmAttachmentManager::setObserver(NmAttachmentFetchObserver *observer)
 {
+    NM_FUNCTION;
+    
     mFetchObserver = observer;
     // send progress event wheng observer changes if fetch ongoing 
     // to get progress bar updating
@@ -147,6 +312,8 @@
 */
 void NmAttachmentManager::clearObserver()
 {
+    NM_FUNCTION;
+    
     mFetchObserver = NULL;
 }
 
@@ -155,6 +322,7 @@
 */
 int NmAttachmentManager::progressValue() const
 {
+    NM_FUNCTION;
+    
     return mProgressValue;
 }
-
--- a/emailuis/nmailui/src/nmattachmentpicker.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmattachmentpicker.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -17,6 +17,8 @@
 
 #include "nmuiheaders.h"
 
+static const int NmAttachmentPickerStillMode = 0;
+static const int NmAttachmentPickerVideoMode = 1;
 
 /*!
     \class NmAttachmentPicker
@@ -26,10 +28,11 @@
 /*!
     Constructor
 */
-NmAttachmentPicker::NmAttachmentPicker(QObject* parent):
+NmAttachmentPicker::NmAttachmentPicker(QObject *parent):
     QObject(parent),
     mRequest(NULL)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -37,6 +40,8 @@
 */
 NmAttachmentPicker::~NmAttachmentPicker()
 {
+    NM_FUNCTION;
+    
     delete mRequest;
 }
 
@@ -45,7 +50,9 @@
 */
 void NmAttachmentPicker::fetchImage()
 {
-    fetch(IMAGE_FETCHER_INTERFACE, IMAGE_FETCHER_OPERATION);
+    NM_FUNCTION;
+    
+    fetch(XQI_IMAGE_FETCH, XQOP_IMAGE_FETCH);
 }
 
 /*!
@@ -53,7 +60,9 @@
 */
 void NmAttachmentPicker::fetchAudio()
 {
-    fetch(AUDIO_FETCHER_INTERFACE, AUDIO_FETCHER_OPERATION);    
+    NM_FUNCTION;
+    
+    fetch(XQI_MUSIC_FETCH, XQOP_MUSIC_FETCH);    
 }
 
 /*!
@@ -61,7 +70,8 @@
 */
 void NmAttachmentPicker::fetchVideo()
 {
-
+    NM_FUNCTION;
+    fetch(XQI_VIDEO_FETCH, XQOP_VIDEO_FETCH);
 }
 
 /*!
@@ -69,22 +79,82 @@
 */
 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));    
+    }
+}
 
+/*!
+    Send request to retrieve image from camera
+*/
+void NmAttachmentPicker::fetchCameraStill()
+{
+    NM_FUNCTION;
+    fetchFromCamera(NmAttachmentPickerStillMode);
+}
+
+/*!
+    Send request to retrieve video from camera
+*/
+void NmAttachmentPicker::fetchCameraVideo()
+{
+    NM_FUNCTION;
+    fetchFromCamera(NmAttachmentPickerVideoMode);
 }
 
 /*!
-    Construct & send appmgr request to start appropriate picker   
+    Send request to retrieve image/video from camera
 */
-void NmAttachmentPicker::fetch(const QString& interface, 
-    const QString& operation)
+void NmAttachmentPicker::fetchFromCamera(int mode)
 {
+    NM_FUNCTION;
+
+    int cameraIndex(0);            //primary camera
+    int quality(0);                //default
+    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); 
+ 
+    QList<QVariant> args;
+    args << mode;
+    args << parameters;
+    
+    fetch(XQI_CAMERA_CAPTURE, "capture(int,QVariantMap)", &args);
+}
+/*!
+    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, 
+    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) {
+            mRequest->setArguments(*args);
+        }
         connect(mRequest, SIGNAL(requestOk(const QVariant&)),
                 this, SIGNAL(attachmentsFetchOk(const QVariant&)));
 
--- a/emailuis/nmailui/src/nmbaseview.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmbaseview.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -26,11 +26,14 @@
 /*!
     Constructor
 */
-NmBaseView::NmBaseView(NmUiStartParam* startParam,
+NmBaseView::NmBaseView(NmUiStartParam *startParam,
+                       NmApplication &application,
                        QGraphicsItem *parent)
 : HbView(parent),
-mStartParam(startParam)
+mStartParam(startParam),
+mApplication(application)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -38,16 +41,21 @@
 */
 NmBaseView::~NmBaseView()
 {
+    NM_FUNCTION;
+    
     delete mStartParam;
 }
 
 /*!
-    Is it ok to exit current view. Function is called when exiting the view. 
-    Views can override this function and return false to stay in current view. 
+    Is it ok to exit current view. Function is called when exiting the view.
+    Views can override this function and deside are they going to signal popView
+    or not. For example based on the user query. 
 */
-bool NmBaseView::okToExitView()
+void NmBaseView::okToExitView()
 {
-    return true;
+	NM_FUNCTION;
+	
+	mApplication.popView();
 }
 
 /*!
@@ -57,6 +65,7 @@
 */
 void NmBaseView::aboutToExitView()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -65,7 +74,8 @@
     if it makes sense to construct items after main view is shown. 
 */
 void NmBaseView::viewReady()
-{    
+{
+    NM_FUNCTION;
 }
 
 /*!
@@ -74,6 +84,7 @@
 */
 void NmBaseView::aboutToChangeOrientation()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -82,6 +93,8 @@
 */
 void NmBaseView::orientationChanged(Qt::Orientation orientation)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(orientation);
 }
 
@@ -91,6 +104,8 @@
 */
 void NmBaseView::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(event);
 }
 
@@ -100,6 +115,8 @@
 */
 void NmBaseView::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(event);
 }
 
@@ -110,6 +127,8 @@
 */
 void NmBaseView::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(event);
 }
 
--- a/emailuis/nmailui/src/nmeditorcontent.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmeditorcontent.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -19,46 +19,51 @@
 
 // Layout
 static const char *NMUI_EDITOR_BODY = "BodyTextEdit";
+static const char *NMUI_EDITOR_SCROLL_AREA = "scrollArea";
+static const char *NMUI_EDITOR_SCROLL_AREA_CONTENTS = "scrollAreaContents";
 
-static const double Un = 6.66;
-static const double HeaderAreaMarginsTotal = 3 * Un;
-
+// Regular expression for selecting img tags with "cid" in the mail.
+static const char *NMUI_EDITOR_REMOVE_EMBD_IMAGES_REG = 
+    "(<img[^<]+(src\\s*=\\s*)(.{0,1}cid)([^<]+)(>\\s*|/>\\s*|></img>\\s*))";
+	
 /*!
     Constructor
 */
-NmEditorContent::NmEditorContent(QGraphicsItem *parent,
-                                 NmEditorView *parentView,
+NmEditorContent::NmEditorContent(QObject *parent,
                                  HbDocumentLoader *documentLoader,
-                                 QNetworkAccessManager &manager) :
-    HbWidget(parent),
-    mHeaderWidget(NULL),
-    mParentView(parentView),
-    mEditorLayout(NULL),
-    mMessageBodyType(PlainText),
+                                 QNetworkAccessManager &manager,
+                                 NmApplication &application) :
+    QObject(parent),
+    mHeader(NULL),
+    mMessageBodyType(NmPlainText),
     mEditorWidget(NULL),
-    mBackgroundScrollArea((NmBaseViewScrollArea*)parent)
+    mScrollArea(NULL),
+    mScrollAreaContents(NULL),
+    mApplication(application)
 {
-    mBackgroundScrollArea->setLongPressEnabled(true);
+    NM_FUNCTION;
 
-    // Add header area handling widget into layout
-    mHeaderWidget = new NmEditorHeader(documentLoader, this);
+    // Construct container for the header widgets
+    mHeader = new NmEditorHeader(this, documentLoader);
 
     // Get pointer to body text area handling widget
     mEditorWidget = qobject_cast<NmEditorTextEdit *>(documentLoader->findWidget(NMUI_EDITOR_BODY));
-
+    
     // Set body editor to use NmEditorTextDocument
     NmEditorTextDocument *textDocument = new NmEditorTextDocument(manager);
     mEditorWidget->setDocument(textDocument); 
     textDocument->setParent(mEditorWidget); // ownership changes
 
-    mEditorWidget->init(mBackgroundScrollArea);
-    // we are interested in the editor widget's height changes
-    connect(mEditorWidget, SIGNAL(editorContentHeightChanged()), this,
-        SLOT(setEditorContentHeight()));
-
+    mScrollArea = qobject_cast<NmBaseViewScrollArea *>
+        (documentLoader->findWidget(NMUI_EDITOR_SCROLL_AREA));
+    mScrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal);
+    
     // Enable style picker menu item.
     mEditorWidget->setFormatDialog(new HbFormatDialog());
 
+    mScrollAreaContents =
+        qobject_cast<HbWidget *>(documentLoader->findWidget(NMUI_EDITOR_SCROLL_AREA_CONTENTS));
+    
     // Create signal slot connections
     createConnections();
 }
@@ -68,7 +73,7 @@
 */
 NmEditorContent::~NmEditorContent()
 {
-   delete mHeaderWidget;
+    NM_FUNCTION;
 }
 
 /*!
@@ -76,105 +81,186 @@
     present, reply header is generated and set to editor. Reply
     envelope ownership is not transferred here.
  */
-void NmEditorContent::setMessageData(const NmMessage &message,
-                                     NmMessageEnvelope *replyMsgEnvelope)
+void NmEditorContent::setMessageData(const NmMessage &originalMessage, 
+                                     NmUiEditorStartMode &editorStartMode)
 {
-    // Check which part is present. Html or plain text part
-    const NmMessagePart *htmlPart = message.htmlBodyPart();
-    const NmMessagePart *plainPart = message.plainTextBodyPart();
-
-    QList<NmMessagePart*> parts;
-    message.attachmentList(parts);
-    NmMessagePart* attachmentHtml = NULL;
-
-    foreach(NmMessagePart* part, parts) {
-        if (part->contentDescription().startsWith( NmContentDescrAttachmentHtml )) {
-                attachmentHtml = part;
-            }
+    NM_FUNCTION;
+    
+    QString bodyContent;
+    
+    // Create the "reply" header (also for forward message)
+    if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll || 
+        editorStartMode==NmUiEditorForward) {
+        bodyContent.append(NmUtilities::createReplyHeader(originalMessage.envelope()));
+    }
+    
+    // Check which part is present. Html or plain text part. We use the original message parts.
+    const NmMessagePart *htmlPart = originalMessage.htmlBodyPart();
+    const NmMessagePart *plainPart = originalMessage.plainTextBodyPart();
+ 
+    if (htmlPart) {
+        bodyContent.append(htmlPart->textContent());
+        if(editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll ) {
+            removeEmbeddedImages(bodyContent);
         }
-    
-    if (htmlPart) {	    
-        // Html part was present, set it to HbTextEdit
-        // This will generate contentsChanged() event which is used to
-        // set new height for the editor widget and content.
-        if(attachmentHtml){
-            QString htmlText = htmlPart->textContent() + attachmentHtml->textContent();
-            emit setHtml(htmlText);
-        } 
-        else{
-            emit setHtml(htmlPart->textContent());    
-        }
-        mMessageBodyType = HTMLText;
+        emit setHtml(bodyContent);
+        mMessageBodyType = NmHTMLText;
     }
     else if (plainPart) {
         // Plain text part was present, set it to HbTextEdit
-        emit setPlainText(plainPart->textContent());
-        mMessageBodyType = PlainText;
-    }
-    
-    // Original message text to editor content fiel
-    if (replyMsgEnvelope && mEditorWidget) {          
-        QTextCursor cursor = mEditorWidget->textCursor();
-        cursor.setPosition(0);
-        cursor.insertHtml(NmUtilities::createReplyHeader(*replyMsgEnvelope));
+        bodyContent.append(plainPart->textContent());
+        emit setPlainText(bodyContent);
+        mMessageBodyType = NmPlainText;
     }
 }  
 
 /*!
-   This method set new height for the editor content when header or body field
-   height has been changed.
- */
-void NmEditorContent::setEditorContentHeight()
-{
-	const QSizeF reso = HbDeviceProfile::current().logicalSize();
-    qreal containerHeight =
-        mEditorWidget->contentHeight() + mHeaderWidget->headerHeight() + HeaderAreaMarginsTotal;
-    if (containerHeight < reso.height()) {
-        //Currently content height is too long because Chrome hiding is not supported.
-        //Fix this when Chrome works.
-        containerHeight = reso.height();
-        qreal bodyContentHeight =
-            reso.height() - mHeaderWidget->headerHeight() - HeaderAreaMarginsTotal;
-        mEditorWidget->setPreferredHeight(bodyContentHeight);
-        mEditorWidget->setMaximumHeight(bodyContentHeight);
-    }
-    mParentView->scrollAreaContents()->setMinimumHeight(containerHeight);
-    mParentView->scrollAreaContents()->setMaximumHeight(containerHeight);
-    mBackgroundScrollArea->setMaximumHeight(containerHeight);
-}
-
-/*!
    This method creates all needed signal-slot connections
  */
 void NmEditorContent::createConnections()
 {
-    // Body edit widget is also interested about bg scroll position change
-    connect(mBackgroundScrollArea, SIGNAL(scrollPositionChanged(QPointF)),
-            mEditorWidget, SLOT(updateScrollPosition(QPointF)));
+    NM_FUNCTION;
+    
     // Signal for setting HbTextEdit widgets html content
     connect(this, SIGNAL(setHtml(QString)),
-            mEditorWidget, SLOT(setHtml(QString)));
+            mEditorWidget, SLOT(setHtml(QString)), Qt::QueuedConnection);
+
     // Signal for setting HbTextEdit widgets plain text content
     connect(this, SIGNAL(setPlainText(QString)),
-            mEditorWidget, SLOT(setPlainText(QString)));
+            mEditorWidget, SLOT(setPlainText(QString)), Qt::QueuedConnection);
+
     // Inform text edit widget that header height has been changed
-    connect(mHeaderWidget, SIGNAL(headerHeightChanged(int)),
-            mEditorWidget, SLOT(setHeaderHeight(int)));
+    connect(mHeader, SIGNAL(headerHeightChanged(int)), this, SLOT(setEditorContentHeight()),
+        Qt::QueuedConnection);
+
+    // we are interested in the document's height changes
+    connect(mEditorWidget->document()->documentLayout(), SIGNAL(documentSizeChanged(QSizeF)), this,
+        SLOT(setEditorContentHeight()), Qt::QueuedConnection);
+
+    // We need to update the scroll position according the editor's cursor position
+    connect(mHeader->toEdit(), SIGNAL(cursorPositionChanged(int, int)), this, 
+        SLOT(ensureCursorVisibility()), Qt::QueuedConnection);
+    connect(mHeader->ccEdit(), SIGNAL(cursorPositionChanged(int, int)), this, 
+        SLOT(ensureCursorVisibility()), Qt::QueuedConnection);
+    connect(mHeader->bccEdit(), SIGNAL(cursorPositionChanged(int, int)), this, 
+        SLOT(ensureCursorVisibility()), Qt::QueuedConnection);
+    connect(mHeader->subjectEdit(), SIGNAL(cursorPositionChanged(int, int)), this, 
+        SLOT(ensureCursorVisibility()), Qt::QueuedConnection);
+    connect(mEditorWidget, SIGNAL(cursorPositionChanged(int, int)), this, 
+        SLOT(ensureCursorVisibility()), Qt::QueuedConnection);
+
+    // 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);
 }
 
 /*!
     Return pointer to the email body text edit widget
  */
-NmEditorTextEdit* NmEditorContent::editor() const
+NmEditorTextEdit *NmEditorContent::editor() const
 {
+    NM_FUNCTION;
+    
     return mEditorWidget;
 }
 
 /*!
     Return pointer to the header widget
  */
-NmEditorHeader* NmEditorContent::header() const
+NmEditorHeader *NmEditorContent::header() const
+{
+    NM_FUNCTION;
+    
+    return mHeader;
+}
+
+/*!
+    This slot is called when header widget height has been changed. Function performs
+    the repositioning of the body field and resizing of the editor and content area.
+ */
+void NmEditorContent::setEditorContentHeight()
 {
-    return mHeaderWidget;
+    NM_FUNCTION;
+    
+    // the height of the margin between the title bar and the header
+    qreal topMargin = 0;
+    HbStyle().parameter("hb-param-margin-gene-top", topMargin);
+    
+    // header height
+    qreal headerHeight = mHeader->headerHeight();
+
+    // body area editor's document height with margins added
+    qreal documentHeightAndMargins = mEditorWidget->document()->size().height() +
+        (mEditorWidget->document()->documentMargin() * 2);
+
+    // chrome height
+    qreal chromeHeight = 0;
+    HbStyle().parameter("hb-param-widget-chrome-height", chromeHeight);
+    
+    // screen height
+    qreal screenHeight = mApplication.screenSize().height();
+
+    // set min size for the body area so that at least the screen area is always filled
+    qreal bodyAreaMinSize = screenHeight - chromeHeight - topMargin - headerHeight;
+    
+    qreal bodyAreaSize = fmax(bodyAreaMinSize, documentHeightAndMargins);
+
+    mScrollAreaContents->setPreferredHeight(topMargin + headerHeight + bodyAreaSize);
 }
 
+/*!
+    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.
+*/
+void NmEditorContent::ensureCursorVisibility()
+{
+    NM_FUNCTION;
+
+    // check which of the editors has the focus and get the x/y coordinates for the cursor position
+    QGraphicsWidget *focused = mScrollAreaContents->focusWidget();
+    
+    if (focused) {
+        QRectF localRect(0, 0, 0, 0);
+        bool notFound = false;
+        
+        if (focused == mHeader->toEdit()) {
+            localRect = mHeader->toEdit()->rectForCursorPosition();
+        }
+        else if (focused == mHeader->ccEdit()) {
+            localRect = mHeader->ccEdit()->rectForCursorPosition();
+        }
+        else if (focused == mHeader->bccEdit()) {
+            localRect = mHeader->bccEdit()->rectForCursorPosition();
+        }
+        else if (focused == mHeader->subjectEdit()) {
+            localRect = mHeader->subjectEdit()->rectForCursorPosition();
+        }
+        else if (focused == mEditorWidget) {
+            localRect = mEditorWidget->rectForCursorPosition();
+        }
+        else {
+            notFound = true;
+        }
+
+        if (!notFound) {
+            QPointF topLeftPos = focused->mapToItem(mScrollAreaContents, localRect.topLeft());
+            QPointF bottomRightPos =
+                focused->mapToItem(mScrollAreaContents, localRect.bottomRight());
+            qreal marginRight = 0;
+            HbStyle().parameter("hb-param-margin-gene-right", marginRight);
+            bottomRightPos.rx() += marginRight;
+            mScrollArea->ensureVisible(topLeftPos);
+            mScrollArea->ensureVisible(bottomRightPos);
+        }
+    }
+}
+/*!
+    Removes embedded images from the message body
+ */
+void NmEditorContent::removeEmbeddedImages(QString &bodyContent)
+{
+    NM_FUNCTION;
+ 
+    QRegExp regExp(NMUI_EDITOR_REMOVE_EMBD_IMAGES_REG, Qt::CaseInsensitive);
+    bodyContent.remove(regExp);
+}
--- a/emailuis/nmailui/src/nmeditorheader.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmeditorheader.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -11,48 +11,50 @@
 *
 * Contributors:
 *
-* Description: Message editor header widget
+* Description: Message editor header container class. Collects the header widgets.
 *
 */
 
 #include "nmuiheaders.h"
 
 // Layout
-static const char *NMUI_EDITOR_TO_LABEL = "EditorHeaderToLabel";
-static const char *NMUI_EDITOR_TO_EDIT = "EditorHeaderToEdit";
-static const char *NMUI_EDITOR_TO_BUTTON = "EditorHeaderToButton";
-static const char *NMUI_EDITOR_RECIPIENT_GB = "EditorHeaderRecipientGB";
-static const char *NMUI_EDITOR_SUBJECT_LABEL = "EditorHeaderSubjectLabel";
-static const char *NMUI_EDITOR_SUBJECT_EDIT = "EditorHeaderSubjectEdit";
-static const char *NMUI_EDITOR_PRIORITY_ICON = "labelPriorityIcon";
+// These match to the defintions in nmeditorview.docml
+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_CC_FIELD = "editorCcField";
+static const char *NMUI_EDITOR_BCC_FIELD = "editorBccField";
+static const char *NMUI_EDITOR_PRIORITY_ICON = "editPriorityIcon";
+static const char *NMUI_EDITOR_FOLLOWUP_ICON = "editFollowUpIcon";
 static const char *NMUI_EDITOR_ATTACHMENT_LIST = "attachmentListWidget";
+static const char *NMUI_EDITOR_PREFIX_TO = "editorTo";
+static const char *NMUI_EDITOR_PREFIX_CC = "editorCc";
+static const char *NMUI_EDITOR_PREFIX_BCC = "editorBcc";
 
-// Following constants are removed when header fields will offer these
-static const double Un = 6.66;
-static const double FieldHeightWhenSecondaryFont = 5 * Un;
-static const int GroupBoxTitleHeight = 42;
-static const double Margin = 2 * Un;
-static const double HeaderAreaMarginsTotal = 3 * Un;
-static const double IconFieldWidth = 5 * Un;
+static const int NmMaxRows = 10000;
 
-static const int nmLayoutSystemWaitTimer = 10;
+// this timeout seems to be long enough for all cases. see sendDelayedHeaderHeightChanged
+static const int NmLayoutSystemWaitTimer = 500; // 0.5 sec
 
 /*!
     Constructor
 */
-NmEditorHeader::NmEditorHeader(HbDocumentLoader *documentLoader, QGraphicsItem *parent) :
-    HbWidget(parent),
+NmEditorHeader::NmEditorHeader(QObject *parent, HbDocumentLoader *documentLoader) :
+    QObject(parent),
     mDocumentLoader(documentLoader),
     mHeaderHeight(0),
-    mSubjectLabel(NULL),
     mIconVisible(false),
     mSubjectEdit(NULL),
     mRecipientFieldsEmpty(true),
-    mGroupBoxRecipient(NULL),
-    mAttachmentList(NULL)
+    mAttachmentList(NULL),
+    mToField(NULL),
+    mCcField(NULL),
+    mBccField(NULL),
+    mCcBccFieldVisible(false)
 {
+    NM_FUNCTION;
+    
     loadWidgets();
-    rescaleHeader();
     createConnections();
 }
 
@@ -61,10 +63,7 @@
 */
 NmEditorHeader::~NmEditorHeader()
 {
-    if (mAttachmentList) {
-        mAttachmentList->clearList();
-        delete mAttachmentList;
-    }
+    NM_FUNCTION;
 }
 
 /*!
@@ -72,38 +71,68 @@
 */
 void NmEditorHeader::loadWidgets()
 {
-    // To: field objects
-    HbLabel *toLabel = qobject_cast<HbLabel *>
-        (mDocumentLoader->findWidget(NMUI_EDITOR_TO_LABEL));
-    NmRecipientLineEdit *toEdit = qobject_cast<NmRecipientLineEdit *>
-        (mDocumentLoader->findWidget(NMUI_EDITOR_TO_EDIT));
-    HbPushButton *toButton = qobject_cast<HbPushButton *>
-        (mDocumentLoader->findWidget(NMUI_EDITOR_TO_BUTTON));
-    mToField = new NmRecipientField(toLabel, toEdit, toButton);
+    NM_FUNCTION;
+	
+    // Load widgets from docml and construct handlers. Those widgets that are not shown by default
+    // are hidden and removed from the layout at this phase.    
+    HbWidget *contentWidget =
+        qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CONTAINER));
+    if (contentWidget) {
+        mLayout = static_cast<QGraphicsLinearLayout *>(contentWidget->layout());
+    
+        // base class QObject takes the deleting responsibility
+        mToField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_TO);
+        mCcField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_CC);
+        mBccField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_BCC);
+    
+        // Sets up editor properties like no prediction, lower case preferred etc.
+        HbEditorInterface toEditorInterface(mToField->editor());
+        HbEditorInterface ccEditorInterface(mCcField->editor());
+        HbEditorInterface bccEditorInterface(mBccField->editor());
+        toEditorInterface.setUpAsLatinAlphabetOnlyEditor();
+        ccEditorInterface.setUpAsLatinAlphabetOnlyEditor();
+        bccEditorInterface.setUpAsLatinAlphabetOnlyEditor();
 
-    // Create recipient group box which includes cc and bcc fields
-    mGroupBoxRecipient = qobject_cast<HbGroupBox *>
-        (mDocumentLoader->findWidget(NMUI_EDITOR_RECIPIENT_GB));
-    // Ownership is transfered
-    mGroupBoxRecipient->setContentWidget(createRecipientGroupBoxContentWidget());
-    mGroupBoxRecipient->setHeading(hbTrId("txt_mail_subhead_ccbcc"));
-    mGroupBoxRecipient->setCollapsable(true);
-    mGroupBoxRecipient->setCollapsed(true);
-
-    // Add Subject: field
-    mSubjectLabel = qobject_cast<HbLabel *>
-        (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_LABEL));
-    mSubjectEdit = qobject_cast<NmHtmlLineEdit *>
-        (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT));
-
-    // Add attachment list
-    NmAttachmentListWidget *attachmentList = qobject_cast<NmAttachmentListWidget *>
-        (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST));
-    // Create attachment list handling object
-    mAttachmentList = new NmAttachmentList(*attachmentList);
-
-    mPriorityIconLabel = qobject_cast<HbLabel *>
-        (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON));
+        // 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();
+        mLayout->removeItem(mCcWidget);
+          
+        // Bcc field is not shown by default. It needs to be both hidden and removed from the layout.
+        mBccWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_BCC_FIELD));
+        mBccWidget->hide();
+        mLayout->removeItem(mBccWidget);
+    
+        mSubjectWidget =
+            qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_FIELD));
+        mSubjectLayout = static_cast<QGraphicsLinearLayout *>(mSubjectWidget->layout());
+          
+        // Add Subject: field
+        mSubjectEdit = qobject_cast<NmHtmlLineEdit *>
+            (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT));
+        mSubjectEdit->setMaxRows(NmMaxRows);
+    
+        // Add attachment list
+        NmAttachmentListWidget *attachmentList = qobject_cast<NmAttachmentListWidget *>
+            (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST));
+        // Create attachment list handling object
+        mAttachmentList = new NmAttachmentList(*attachmentList);
+        mAttachmentList->setParent(this); // ownership changes
+        attachmentList->hide();
+        mLayout->removeItem(attachmentList);
+    
+        // Add priority icon
+        mPriorityIcon = qobject_cast<HbLabel *>
+            (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON));
+        mPriorityIcon->hide();
+        mSubjectLayout->removeItem(mPriorityIcon);
+    
+        // follow-up icon is not yet supported
+        HbLabel *followUpIcon = qobject_cast<HbLabel *>
+            (mDocumentLoader->findWidget(NMUI_EDITOR_FOLLOWUP_ICON));
+        followUpIcon->hide();
+        mSubjectLayout->removeItem(followUpIcon);    
+    }
 }
 
 /*!
@@ -111,6 +140,8 @@
 */
 void NmEditorHeader::createConnections()
 {
+    NM_FUNCTION;
+    
     // Signals for checking if the recipient fields have text.
     connect(mToField, SIGNAL(textChanged(const QString &)),
             this, SLOT(editorContentChanged()));
@@ -121,79 +152,100 @@
 
     // Signals for handling the recipient field expanding
     connect(mToField, SIGNAL(textChanged(const QString &)),
-            this, SLOT(sendHeaderHeightChanged()));
+            this, SLOT(sendDelayedHeaderHeightChanged()));
     connect(mCcField, SIGNAL(textChanged(const QString &)),
-            this, SLOT(sendHeaderHeightChanged()));
+            this, SLOT(sendDelayedHeaderHeightChanged()));
     connect(mBccField, SIGNAL(textChanged(const QString &)),
-            this, SLOT(sendHeaderHeightChanged()));
-    connect(mSubjectEdit, SIGNAL(contentsChanged()), this, SLOT(sendHeaderHeightChanged()));
-
-    // Signal for handling the recipient group box expanding/collapsing
-    connect(mGroupBoxRecipient, SIGNAL(toggled(bool)),
-            this, SLOT(groupBoxExpandCollapse()));
+            this, SLOT(sendDelayedHeaderHeightChanged()));
+    connect(mSubjectEdit, SIGNAL(contentsChanged()), this, SLOT(sendDelayedHeaderHeightChanged()));
 
     // Signals for handling the attachment list
     connect(&mAttachmentList->listWidget(), SIGNAL(itemActivated(int)),
             this, SLOT(attachmentActivated(int)));
     connect(&mAttachmentList->listWidget(), SIGNAL(longPressed(int, QPointF)),
             this, SLOT(attachmentLongPressed(int, QPointF)));
-    connect(mAttachmentList ,SIGNAL(attachmentListLayoutChanged()),
-            this, SLOT(sendHeaderHeightChanged()));
 }
 
 /*!
-    Function can be used to rescale the header area.
+   Show or hide recipient field
 */
-void NmEditorHeader::rescaleHeader()
+void NmEditorHeader::setFieldVisibility(bool isVisible)
 {
+	if ( mCcBccFieldVisible != isVisible ) {
+		mCcBccFieldVisible = isVisible;
+		if (mCcBccFieldVisible) {
+            mLayout->insertItem(1, mBccWidget);
+			mLayout->insertItem(1, mCcWidget);
+			mCcWidget->show();
+            mBccWidget->show();
+		}
+		else {
+            mCcWidget->hide();
+            mBccWidget->hide();
+			mLayout->removeItem(mCcWidget);
+			mLayout->removeItem(mBccWidget);
+		}
+        sendDelayedHeaderHeightChanged();
+	}
 }
 
 /*!
-    Return the height of the whole header widget.
-    (Should find beter way to get the height of the header area.)
+    Return the sum of the header widget heights. This contains all the spacings a well. 
  */
-int NmEditorHeader::headerHeight() const
+qreal NmEditorHeader::headerHeight() const
 {
-    qreal toHeight = mToField->height();
-    qreal subjectHeight = mSubjectEdit->geometry().height() + Margin;
+    NM_FUNCTION;
+
+    // get the layout's vertical spacing
+    qreal spacing = 0;
+    HbStyle().parameter("hb-param-margin-gene-middle-vertical", spacing);
 
-    // When called first time, height is wrongly 'Margin'
-    if (toHeight == Margin) {
-        toHeight = FieldHeightWhenSecondaryFont;
-        subjectHeight = FieldHeightWhenSecondaryFont;
+    // calculate the height
+    qreal height = 0;
+    
+    height += mToField->height(); // returns widget's geometry height
+    height += spacing;
+    
+    if (mCcBccFieldVisible) {
+        height += mCcField->height(); // returns widget's geometry height
+        height += spacing;
+        
+        height += mBccField->height(); // returns widget's geometry height
+        height += spacing;
     }
 
-    // Recipient GroupBox
-    qreal recipientGroupBoxHeight = GroupBoxTitleHeight;
-    if (!mGroupBoxRecipient->isCollapsed()) {
-        recipientGroupBoxHeight +=
-            mGroupBoxRecipientContent->geometry().height() + HeaderAreaMarginsTotal;
+    height += mSubjectWidget->geometry().height();
+    height += spacing;
+
+    if (mAttachmentList->listWidget().isVisible()) {
+        height += mAttachmentList->listWidget().geometry().height();
+        height += spacing;
     }
 
-    qreal attHeight = 0;
-    if (mAttachmentList && mAttachmentList->count() > 0) {
-        attHeight = mAttachmentList->listWidget().geometry().height();
-    }
-
-    return (int)(toHeight + recipientGroupBoxHeight + subjectHeight + attHeight);
+    return height;
 }
 
 /*!
-    Send signal to inform that one of the recipient fields height has been changed.
+    This is called when the contents of some of the header widgets have been changed. When the
+    contents change the widget's actual size may also change. The header area height is needed to
+    calculate the size hints of the body and the scroll area widgets. We need to use a timer to let 
+    the Orbit FW adjust the heights eg. if the subject and recipient fields are expanded by the FW.
+    It would be best to find a solution which doesn't depend on the header area's actual height size
+    information.
+ */
+void NmEditorHeader::sendDelayedHeaderHeightChanged()
+{
+    NM_FUNCTION;
+	QTimer::singleShot(NmLayoutSystemWaitTimer, this, SLOT(sendHeaderHeightChanged()));
+}
+
+/*!
+    Send a signal that the header area height has been changed if necessary. This is needed for the
+    body and scroll area widgets. See NmEditorTextEdit::setHeaderHeight for more info.
  */
 void NmEditorHeader::sendHeaderHeightChanged()
 {
-    // Adjust field heights
-    mToField->editor()->setPreferredHeight(
-        mToField->editor()->document()->size().height() + Margin);
-    mCcField->editor()->setPreferredHeight(
-        mCcField->editor()->document()->size().height() + Margin);
-    mBccField->editor()->setPreferredHeight(
-        mBccField->editor()->document()->size().height() + Margin);
-    mSubjectEdit->setPreferredHeight(
-        mSubjectEdit->document()->size().height() + Margin);
-
-    int hHeight = headerHeight();
+    qreal hHeight = headerHeight();
     if (mHeaderHeight != hHeight) {
         mHeaderHeight = hHeight;
         emit headerHeightChanged(mHeaderHeight);
@@ -201,43 +253,42 @@
 }
 
 /*!
-    This slot is called when group box state is changed. Timer is used to give some time
-    for layout system so that header hight can be recalculated correctly
+    Return pointer to to edit
  */
-void NmEditorHeader::groupBoxExpandCollapse()
+NmRecipientLineEdit* NmEditorHeader::toEdit() const
 {
-    QTimer::singleShot(nmLayoutSystemWaitTimer, this, SLOT(sendHeaderHeightChanged()));
-}
-
-/*!
-    Return pointer to to field
- */
-NmRecipientLineEdit* NmEditorHeader::toField() const
-{
+    NM_FUNCTION;
+    
     return mToField->editor();
 }
 
 /*!
-    Return pointer to cc field
+    Return pointer to cc edit
  */
-NmRecipientLineEdit* NmEditorHeader::ccField() const
+NmRecipientLineEdit* NmEditorHeader::ccEdit() const
 {
+    NM_FUNCTION;
+    
     return mCcField->editor();
 }
 
 /*!
-    Return pointer to bcc field
+    Return pointer to bcc edit
  */
-NmRecipientLineEdit* NmEditorHeader::bccField() const
+NmRecipientLineEdit* NmEditorHeader::bccEdit() const
 {
+    NM_FUNCTION;
+    
     return mBccField->editor();
 }
 
 /*!
     Return pointer to subject field
  */
-NmHtmlLineEdit* NmEditorHeader::subjectField() const
+NmHtmlLineEdit* NmEditorHeader::subjectEdit() const
 {
+    NM_FUNCTION;
+    
     return mSubjectEdit;
 }
 
@@ -247,7 +298,9 @@
 */
 void NmEditorHeader::editorContentChanged()
 {
-    bool recipientsFieldsEmpty = true;
+    NM_FUNCTION;
+    
+    bool recipientsFieldsEmpty(true);
     if (mToField->text().length()) {
         recipientsFieldsEmpty = false;
     }
@@ -264,43 +317,12 @@
 }
 
 /*!
-    This function create content widget for recipient group box.
-    When AD offers groupBox content widget handling. This function
-    need to be changed to use AD/docml
- */
-HbWidget* NmEditorHeader::createRecipientGroupBoxContentWidget()
-{
-    mGroupBoxRecipientContent = new HbWidget();
-
-    // Create layout for the widget
-    mGbVerticalLayout = new QGraphicsLinearLayout(Qt::Vertical,mGroupBoxRecipientContent);
-    mCcFieldLayout = new QGraphicsLinearLayout(Qt::Horizontal, mGbVerticalLayout);
-    mBccFieldLayout = new QGraphicsLinearLayout(Qt::Horizontal, mGbVerticalLayout);
-
-    // Add Cc: field into widget
-    mCcField = new NmRecipientField(hbTrId("txt_mail_editor_cc"));
-    if (mCcField) {
-        mCcField->setObjectName("lineEditCcField");
-        mGbVerticalLayout->insertItem(EEditorCcLine, mCcField );
-    }
-
-    // Add Bcc: field into widget
-    mBccField = new NmRecipientField(hbTrId("txt_mail_editor_bcc"));
-    if (mBccField){
-        mBccField->setObjectName("lineEditBccField");
-        mGbVerticalLayout->insertItem(EEditorBccLine, mBccField);
-    }
-    mGbVerticalLayout->setContentsMargins(0,0,0,0);
-
-    mGroupBoxRecipientContent->setLayout(mGbVerticalLayout);
-    return mGroupBoxRecipientContent;
-}
-
-/*!
     Sets the icon for priority
  */
 void NmEditorHeader::setPriority(NmMessagePriority priority)
 {
+    NM_FUNCTION;
+    
     switch (priority) {
     case NmMessagePriorityHigh:
         setPriority(NmActionResponseCommandPriorityHigh);
@@ -319,48 +341,40 @@
  */
 void NmEditorHeader::setPriority(NmActionResponseCommand prio)
 {
+    NM_FUNCTION;
+    
     switch(prio) {
     case NmActionResponseCommandPriorityHigh:
         if (!mIconVisible) {
             mIconVisible = true;
-            mPriorityIconLabel->setMaximumWidth(IconFieldWidth);
-            mSubjectEdit->setMaximumWidth(mSubjectEdit->geometry().width() - IconFieldWidth);
+            // icon widget is just after the subject line edit (see docml)
+            mSubjectLayout->insertItem(2, mPriorityIcon);
+            mPriorityIcon->show();
         }
-        mPriorityIconLabel->setIcon(
+        mPriorityIcon->setIcon(
             NmIcons::getIcon(NmIcons::NmIconPriorityHigh));
         break;
     case NmActionResponseCommandPriorityLow:
         if (!mIconVisible) {
             mIconVisible = true;
-            mPriorityIconLabel->setMaximumWidth(IconFieldWidth);
-            mSubjectEdit->setMaximumWidth(mSubjectEdit->geometry().width() - IconFieldWidth);
+            // icon widget is just after the subject line edit (see docml)
+            mSubjectLayout->insertItem(2, mPriorityIcon);
+            mPriorityIcon->show();
         }
-        mPriorityIconLabel->setIcon(
+        mPriorityIcon->setIcon(
             NmIcons::getIcon(NmIcons::NmIconPriorityLow));
         break;
     default:
         if (mIconVisible) {
             mIconVisible = false;
             HbIcon emptyIcon;
-            mPriorityIconLabel->setIcon(emptyIcon);
-            mPriorityIconLabel->setMaximumWidth(0);
-            mSubjectEdit->setMaximumWidth(mSubjectEdit->geometry().width() + IconFieldWidth);
+            mPriorityIcon->setIcon(emptyIcon);
+            mSubjectLayout->removeItem(mPriorityIcon);
+            mPriorityIcon->hide();
         }
         break;
     }
-    // Update subject field height because row amount might have been changed.
-    // Done with delayed timer so that layout system has finished before.
-    QTimer::singleShot(nmLayoutSystemWaitTimer, this, SLOT(sendHeaderHeightChanged()));
-    // This second call will set new position for body if subject field height has been changed.
-    QTimer::singleShot(nmLayoutSystemWaitTimer * 2, this, SLOT(sendHeaderHeightChanged()));
-}
-
-/*!
- * \brief Sets the groupbox to be expanded or collapsed. 
- */
-void NmEditorHeader::setGroupBoxCollapsed( bool collapsed )
-{
-    mGroupBoxRecipient->setCollapsed( collapsed );
+    sendDelayedHeaderHeightChanged();
 }
 
 /*!
@@ -369,7 +383,14 @@
 void NmEditorHeader::addAttachment(
     const QString &fileName, const QString &fileSize, const NmId &nmid)
 {
+    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();
 }
 
@@ -379,8 +400,14 @@
  */
 void NmEditorHeader::removeAttachment(const QString &fileName)
 {
+    NM_FUNCTION;
+    
     mAttachmentList->removeAttachment(fileName);
-    sendHeaderHeightChanged();
+    if (mAttachmentList->count() == 0) {
+        mAttachmentList->listWidget().hide();
+        mLayout->removeItem(&mAttachmentList->listWidget());
+    }
+    sendDelayedHeaderHeightChanged();
 }
 
 /*!
@@ -389,8 +416,14 @@
  */
 void NmEditorHeader::removeAttachment(const NmId &nmid)
 {
+    NM_FUNCTION;
+    
     mAttachmentList->removeAttachment(nmid);
-    sendHeaderHeightChanged();
+    if (mAttachmentList->count() == 0) {
+        mAttachmentList->listWidget().hide();
+        mLayout->removeItem(&mAttachmentList->listWidget());
+    }
+    sendDelayedHeaderHeightChanged();
 }
 
 /*!
@@ -402,6 +435,8 @@
     const QString &fileSize,
     int result)
 {
+    NM_FUNCTION;
+    
     if (result == NmNoError) {
         // Attachment adding succesful, set message part id and size for attachment
         mAttachmentList->setAttachmentPartId(fileName, msgPartId);
@@ -410,22 +445,13 @@
 }
 
 /*!
-   Attachment launched from attachment list by "open" menu item.
- */
-void NmEditorHeader::launchAttachment(const NmId &itemId)
-{
-    attachmentActivated(mAttachmentList->indexByNmId(itemId));
-}
-
-/*!
    Slot attachment activated from attachment list by short tap.
  */
 void NmEditorHeader::attachmentActivated(int arrayIndex)
 {
-    QFile launchFile(mAttachmentList->getFullFileNameByIndex(arrayIndex));
-    if (NmUtilities::openFile( launchFile ) == NmNotFoundError) {
-        NmUtilities::displayErrorNote(hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty")); 
-    }
+    NM_FUNCTION;
+
+    emit attachmentShortPressed(mAttachmentList->nmIdByIndex(arrayIndex));    
 }
 
 /*!
@@ -433,6 +459,8 @@
  */
 void NmEditorHeader::attachmentLongPressed(int arrayIndex, QPointF point)
 {
+    NM_FUNCTION;
+    
     // Remove selected attachment
     emit attachmentLongPressed(mAttachmentList->nmIdByIndex(arrayIndex), point);
 }
--- a/emailuis/nmailui/src/nmeditortextdocument.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmeditortextdocument.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -31,6 +31,8 @@
 NmEditorTextDocument::NmEditorTextDocument(QNetworkAccessManager &manager) :
     mManager(manager)
 {
+    NM_FUNCTION;
+    
     connect(&mManager, SIGNAL(finished(QNetworkReply*)),
         this, SLOT(replyFinished(QNetworkReply*)));
 }
@@ -40,6 +42,8 @@
 */
 NmEditorTextDocument::~NmEditorTextDocument()
 {
+    NM_FUNCTION;
+    
     foreach(QNetworkReply *reply, mReplyList) {
         if(reply) {
             reply->abort();
@@ -53,6 +57,8 @@
 */
 void NmEditorTextDocument::replyFinished(QNetworkReply *reply)
 {
+    NM_FUNCTION;
+    
     if(reply) {
         if(reply->error() == QNetworkReply::NoError) {
             QPixmap image;
@@ -61,8 +67,10 @@
                 emit documentLayoutChanged();
             }
         }
-        mReplyList.removeAll(reply);
-        reply->deleteLater();
+        // If this has created the request, then this needs to handle deletion also.
+        if (mReplyList.removeAll(reply)) {
+            reply->deleteLater();
+        }
     }
 }
 
@@ -71,6 +79,8 @@
 */
 QVariant NmEditorTextDocument::loadResource(int type, const QUrl &name)
 {
+    NM_FUNCTION;
+    
     QVariant retVal;
     
     if(type == QTextDocument::ImageResource) {    
--- a/emailuis/nmailui/src/nmeditorview.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmeditorview.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -19,12 +19,8 @@
 // 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_SCROLL_AREA = "scrollArea";
-static const char *NMUI_EDITOR_SCROLL_AREA_CONTENTS = "scrollAreaContents";
 
-static const int NmOrientationTimer=100;
-
-static const QString Delimiter("; ");
+static const QString NmDelimiter("; ");
 
 /*!
 	\class NmEditorView
@@ -38,29 +34,35 @@
     NmApplication &application,
     NmUiStartParam* startParam,
     NmUiEngine &uiEngine,
+    NmAttachmentManager &attaManager,
     QGraphicsItem *parent)
-    : NmBaseView(startParam, parent),
+    : NmBaseView(startParam, application, parent),
       mApplication(application),
       mUiEngine(uiEngine),
+      mAttaManager(attaManager),
       mDocumentLoader(NULL),
-      mScrollArea(NULL),
-      mEditWidget(NULL),
       mHeaderWidget(NULL),
       mMessage(NULL),
-      mContentWidget(NULL),
+      mContent(NULL),
       mAttachmentListContextMenu(NULL),
       mMessageCreationOperation(NULL),
       mAddAttachmentOperation(NULL),
       mRemoveAttachmentOperation(NULL),
-      mCheckOutboxOperation(NULL),
       mWaitDialog(NULL),
-      mAttachmentPicker(NULL)
+      mQueryDialog(NULL),
+      mAttachmentPicker(NULL),
+      mCcBccFieldVisible(false),
+      mServiceSendingDialog(NULL)
 {
+    NM_FUNCTION;
+    
     mDocumentLoader	= new HbDocumentLoader();
     // Set object name
     setObjectName("NmEditorView");
     // Set mailbox name to title pane
     setMailboxName();
+    // call the createToolBar on load view layout
+    createToolBar();
     // Load view layout
     loadViewLayout();
 }
@@ -70,6 +72,8 @@
 */
 NmEditorView::~NmEditorView()
 {
+    NM_FUNCTION;
+    
     if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
         mRemoveAttachmentOperation->cancelOperation();
     }
@@ -79,13 +83,9 @@
     if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) {
         mMessageCreationOperation->cancelOperation();
     }
-    if (mCheckOutboxOperation && mCheckOutboxOperation->isRunning()) {
-        mCheckOutboxOperation->cancelOperation();
-    }
     delete mMessage;
     mWidgetList.clear();
     delete mDocumentLoader;
-    delete mContentWidget;
     delete mPrioritySubMenu;
     
     if (mAttachmentListContextMenu) {
@@ -93,7 +93,18 @@
         delete mAttachmentListContextMenu;
     }
     delete mWaitDialog;
+    delete mQueryDialog;
     delete mAttachmentPicker;    
+    mAttaManager.clearObserver();
+    mAttaManager.cancelFetch();
+    
+    // make sure virtual keyboard is closed
+    QInputContext *ic = qApp->inputContext();
+    if (ic) {
+        QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
+        ic->filterEvent(closeEvent);
+        delete closeEvent;
+    }
 }
 
 /*!
@@ -101,33 +112,37 @@
 */
 void NmEditorView::loadViewLayout()
 {
+    NM_FUNCTION;
+    
     mPrioritySubMenu = NULL;
 
     // Use document loader to load the view
-    bool ok = false;
+    bool ok(false);
+
+    setObjectName(QString(NMUI_EDITOR_VIEW));
+    QObjectList objectList;
+    objectList.append(this);
+    // Pass the view to documentloader. Document loader uses this view
+    // when docml is parsed, instead of creating new view.
+    // documentloader is created in constructor
+    mDocumentLoader->setObjectTree(objectList);
+
     mWidgetList = mDocumentLoader->load(NMUI_EDITOR_VIEW_XML, &ok);
 
-    if (ok == true && mWidgetList.count()) {
-        // Set view
-        QGraphicsWidget *view = mDocumentLoader->findWidget(NMUI_EDITOR_VIEW);
-        if (view){
-            setWidget(view);
-        }
+   if (ok) {
+        mContent = new NmEditorContent(this, mDocumentLoader, 
+            mApplication.networkAccessManager(), mApplication);
 
-        mScrollArea = qobject_cast<NmBaseViewScrollArea *>
-            (mDocumentLoader->findObject(NMUI_EDITOR_SCROLL_AREA));
-        mScrollAreaContents = qobject_cast<HbWidget *>
-             (mDocumentLoader->findObject(NMUI_EDITOR_SCROLL_AREA_CONTENTS));
-
-        mContentWidget = new NmEditorContent(mScrollArea, this, mDocumentLoader, 
-            mApplication.networkAccessManager());
-        mEditWidget = mContentWidget->editor();
-        mHeaderWidget = mContentWidget->header();
+        mHeaderWidget = mContent->header();
 
         // Set default color for user - entered text if editor is in re/reAll/fw mode
-        NmUiEditorStartMode mode = mStartParam->editorStartMode();
-        if (mode == NmUiEditorReply || mode == NmUiEditorReplyAll || mode == NmUiEditorForward) {
-            mEditWidget->setCustomTextColor(true, Qt::blue);
+        if (mStartParam) {
+            NmUiEditorStartMode mode = mStartParam->editorStartMode();
+            if (mode == NmUiEditorReply
+                || mode == NmUiEditorReplyAll 
+                || mode == NmUiEditorForward) {
+                mContent->editor()->setCustomTextColor(true, Qt::blue);
+            }
         }
 
         // the rest of the view initialization is done in viewReady()
@@ -141,6 +156,8 @@
 */
 void NmEditorView::reloadViewContents(NmUiStartParam* startParam)
 {
+    NM_FUNCTION;
+    
     // Check start parameter validity.
     if (startParam&&startParam->viewId()==NmUiViewMessageEditor) {
         // Delete existing start parameter data
@@ -152,10 +169,10 @@
         // editor with new start parameters.
         // ..
         // Reload editor with new message data
-        setMessageData();
+        fetchMessageIfNeeded(*mStartParam);
     }
     else {
-        NMLOG("nmailui: Invalid editor start parameter");
+        NM_ERROR(1,"nmailui: Invalid editor start parameter");
         // Unused start parameter needs to be deleted
         delete startParam;
         startParam = NULL;
@@ -169,21 +186,41 @@
 */
 void NmEditorView::orientationChanged(Qt::Orientation orientation)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(orientation);
-    // Adjust content height
-    QTimer::singleShot(NmOrientationTimer, this, SLOT(adjustViewDimensions()));
-    QTimer::singleShot(NmOrientationTimer, mHeaderWidget, SLOT(sendHeaderHeightChanged()));
+    
+    // content widget height needs to be set according to the new orientation to get the scroll
+	// area work correctly
+	mHeaderWidget->sendDelayedHeaderHeightChanged();
+}
+
+/*!
+    This slot is signaled by VKB when it opens
+ */
+void NmEditorView::vkbOpened()
+{
+    showChrome(false);	
 }
 
 /*!
-    Set new dimensions after orientation change.
-*/
-void NmEditorView::adjustViewDimensions()
+    This slot is signaled by VKB when it closes.
+ */
+void NmEditorView::vkbClosed()
 {
-    if (mScrollAreaContents) {
-        const QSize reso = mApplication.screenSize();
-        mScrollAreaContents->setMinimumWidth(reso.width());
-        mScrollAreaContents->setMaximumWidth(reso.width());
+	showChrome(true);
+}
+
+/*!
+    Hide or show chrome.
+ */
+void NmEditorView::showChrome(bool show)
+{
+    if (show) {
+        showItems(Hb::StatusBarItem | Hb::TitleBarItem | Hb::ToolBarItem);
+    }
+    else {
+        hideItems(Hb::StatusBarItem | Hb::TitleBarItem | Hb::ToolBarItem);
     }
 }
 
@@ -192,63 +229,93 @@
 */
 NmUiViewId NmEditorView::nmailViewId() const
 {
+    NM_FUNCTION;
+    
     return NmUiViewMessageEditor;
 }
 
-/*!
-    ScrollArea contents
-*/
-HbWidget* NmEditorView::scrollAreaContents()
-{
-    return mScrollAreaContents;
-}
-
 /*
-   Query user if we want to exit the editor
+   Launch dialog for query user if we want to exit the editor
 */
-bool NmEditorView::okToExitView()
+void NmEditorView::okToExitView()
 {
-    bool okToExit = true;
-
-    NmEditorHeader *header = mContentWidget->header();
+    NM_FUNCTION;
+       
+    bool okToExit(true);
     
-    // show the query if the message has not been sent
-    if (mMessage && header) {
-        // see if editor has any content
-        int toTextLength = 0;
-        if (header->toField()) {
-            toTextLength = header->toField()->text().length();
-        }
-        
-        int ccTextLength = 0;
-        if (header->ccField()) {
-            ccTextLength = header->ccField()->text().length();
-        }
+    if (mContent) {
+        NmEditorHeader *header = mContent->header();
+        // show the query if the message has not been sent
+        if (mMessage && header) {
+            // see if editor has any content
+            int subjectLength = 0;
+            if (header->subjectEdit()) {
+                subjectLength = header->subjectEdit()->text().length();
+            }
+            
+            QList<NmMessagePart*> attachmentList;
+            mMessage->attachmentList(attachmentList);
+            
+            if (mContent->editor()) {
+                okToExit = (subjectLength == 0 && mContent->editor()->document()->isEmpty());            
+            }
+    
+            // content exists, verify exit from user
+            if (!okToExit) {
+                if (mQueryDialog) {
+                    delete mQueryDialog;
+                    mQueryDialog = 0;
+                }
+                // Launch query dialog.
+                mQueryDialog = 
+                    NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_save_message_to_drafts"),
+                                                                this,
+                                                                SLOT(okToExitQuery(HbAction*)));
+            }
+        }    
+    }
+    
+    // no need to query anything, just exit.
+    if(okToExit) {
+        QMetaObject::invokeMethod(&mApplication,
+                                  "popView",
+                                  Qt::QueuedConnection);
+    }
+}
 
-        int bccTextLength = 0;
-        if (header->bccField()) {
-            bccTextLength = header->bccField()->text().length();
-        }
-        
-        int subjectLength = 0;
-        if (header->subjectField()) {
-            subjectLength = header->subjectField()->text().length();
-        }
+/*!
+    Handle the user selection is it ok to exit.
+*/
+void NmEditorView::okToExitQuery(HbAction *action)
+{
+    NM_FUNCTION;
+    
+    HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
+    // The first action in dialogs action list is for the "Yes"-button.
+    if (action == dlg->actions().at(0)) {
         
-        QList<NmMessagePart*> attachmentList;
-        mMessage->attachmentList(attachmentList);
-                    
-        okToExit = (toTextLength == 0 && ccTextLength == 0 && bccTextLength == 0 && 
-            subjectLength == 0 && mContentWidget->editor()->document()->isEmpty() &&
-            attachmentList.count() < 1);
+        // Update draft message with content.
+        updateMessageWithEditorContents();
 
-        // content exists, verify exit from user
-        if (!okToExit) {
-            okToExit = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_delete_message"));
+        // Save message to drafts
+        QList<NmOperation *> preliminaryOperations;
+        if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
+            preliminaryOperations.append(mAddAttachmentOperation);
+        }
+        if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
+            preliminaryOperations.append(mRemoveAttachmentOperation);
         }
-    }
-
-    return okToExit;
+        // ownership of mMessage is transferred
+        // NmOperations are automatically deleted after completion
+        mUiEngine.saveDraftMessage(mMessage, preliminaryOperations);
+        mMessage = NULL;
+        preliminaryOperations.clear();
+    }    
+    
+    // Close the view
+    QMetaObject::invokeMethod(&mApplication,
+                              "popView",
+                              Qt::QueuedConnection);
 }
 
 /*!
@@ -258,39 +325,8 @@
 */
 void NmEditorView::aboutToExitView()
 {
-    if (mStartParam && mStartParam->service() && mUiEngine.isSendingMessage()) {
-        // The application was started as a service and is about to close.
-        // A message is still being sent and in order to make sure that the
-        // send operation is not cancelled, let us display a modal wait dialog.
-
-        // When the send operation is completed, the dialog is automatically
-        // closed.
-        connect(&mUiEngine, SIGNAL(sendOperationCompleted()),
-                this, SLOT(handleSendOperationCompleted()));
-
-        // Close and delete the previous wait dialog if one exists.
-        if (mWaitDialog) {
-            mWaitDialog->close();
-            delete mWaitDialog;
-        }
-
-        // Construct and setup the wait dialog.
-        mWaitDialog = new HbProgressDialog();
-        mWaitDialog->setText(hbTrId("txt_mail_shareui_sending_please_wait"));
-
-        if (!XQServiceUtil::isEmbedded()) {
-            // Hide the application.
-            XQServiceUtil::toBackground(true);
-        }
-
-        // Display the wait dialog.
-        mWaitDialog->setModal(false);
-        mWaitDialog->setBackgroundFaded(false);
-        mWaitDialog->show();
-        delete mWaitDialog;
-        mWaitDialog = NULL;
-    }
-
+    NM_FUNCTION;
+    
     // These operations need to be stopped before message can be deleted
     if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
         mAddAttachmentOperation->cancelOperation();
@@ -299,12 +335,10 @@
         mRemoveAttachmentOperation->cancelOperation();
     }
 
-    if (mMessage) { // this is NULL if sending is started
+    if (mMessage) { // this is NULL if sending or saving is started
         // Delete message from drafts
-        NmId mailboxId = mMessage->envelope().mailboxId();
-        NmId folderId = mMessage->envelope().folderId();
-        NmId msgId = mMessage->envelope().messageId();
-        mUiEngine.removeMessage(mailboxId, folderId, msgId);
+        mUiEngine.removeDraftMessage(mMessage);
+        mMessage = NULL;
     }
 }
 
@@ -313,81 +347,165 @@
 */
 void NmEditorView::viewReady()
 {
-    // Connect signals from background scroll area
-    connect(mScrollArea, SIGNAL(handleMousePressEvent(QGraphicsSceneMouseEvent*)),
-            this, SLOT(sendMousePressEventToScroll(QGraphicsSceneMouseEvent*)));
-    connect(mScrollArea, SIGNAL(handleMouseReleaseEvent(QGraphicsSceneMouseEvent*)),
-            this, SLOT(sendMouseReleaseEventToScroll(QGraphicsSceneMouseEvent*)));
-    connect(mScrollArea, SIGNAL(handleMouseMoveEvent(QGraphicsSceneMouseEvent*)),
-            this, SLOT(sendMouseMoveEventToScroll(QGraphicsSceneMouseEvent*)));
-
-    connect(mScrollArea, SIGNAL(handleLongPressGesture(const QPointF &)),
-                this, SLOT(sendLongPressGesture(const QPointF &)));
-
+    NM_FUNCTION;
+    
     // Connect options menu about to show to create options menu function
     // Menu needs to be create "just-in-time"
     connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createOptionsMenu()));
     NmAction *dummy = new NmAction(0);
     menu()->addAction(dummy);
 
+    mVkbHost = new HbShrinkingVkbHost(this);
+    
     initializeVKB();
-    connect(mContentWidget->header(), SIGNAL(recipientFieldsHaveContent(bool)),
+    
+    //start to listen VKB open and close signals for hiding the chrome.
+    connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
+    connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
+    
+    connect(mContent->header(), SIGNAL(recipientFieldsHaveContent(bool)),
             this, SLOT(setButtonsDimming(bool)) );
 
-    // call the createToolBar on load view layout
-    createToolBar();
-
-    // Set dimensions
-    adjustViewDimensions();
-	
     // Connect to observe orientation change events
     connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
             this, SLOT(orientationChanged(Qt::Orientation)));
     // Signal for handling the attachment list selection
+    connect(mHeaderWidget, SIGNAL(attachmentShortPressed(NmId)),
+            this, SLOT(openAttachmentTriggered(NmId)));
     connect(mHeaderWidget, SIGNAL(attachmentLongPressed(NmId, QPointF)),
             this, SLOT(attachmentLongPressed(NmId, QPointF)));
     
-    // Set message data
-    setMessageData();
+    if (mStartParam) {
+        fetchMessageIfNeeded(*mStartParam);
+    }
+    else { // execution cannot proceed without start param 
+        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
+    }
 }
 
 /*!
-    Find message data based on start parameters.  Method is called
-    when editor is started. If message data is found it means that
-    operation is forward or reply message.
+    If entering editor for forwarding or replying, use attachment manager
+    to check that we have all message parts fetched. Also show dialog for
+    fetching progress.
 */
-void NmEditorView::setMessageData()
+void NmEditorView::fetchMessageIfNeeded(NmUiStartParam &startParam)
 {
-    // Check the outbox.
-    if (mCheckOutboxOperation && mCheckOutboxOperation->isRunning()) {
-        mCheckOutboxOperation->cancelOperation();
-        NMLOG("NmEditorView::setMessageData old mCheckOutboxOperation running");
-    }
-	
-    mCheckOutboxOperation = mUiEngine.checkOutbox(mStartParam->mailboxId());
+    NM_FUNCTION;
     
-    if (mCheckOutboxOperation) {
-        connect(mCheckOutboxOperation, SIGNAL(operationCompleted(int)),
-                this, SLOT(outboxChecked(int)));
+    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( mStartParam->editorStartMode() );
+        startMessageCreation(startParam);
     }
 }
 
 /*!
+    Slot. Called when attachments fetch progress changes.
 */
-void NmEditorView::startMessageCreation(NmUiEditorStartMode startMode)
+void NmEditorView::progressChanged(int value)
+{
+    NM_FUNCTION;
+    
+    Q_UNUSED(value);
+}
+
+/*!
+    Slot. Called when attachments fetch is completed. We can start
+    message creation. 
+*/
+void NmEditorView::fetchCompleted(int result)
 {
-    NMLOG("NmEditorView::startMessageCreation ");
-    NmId mailboxId = mStartParam->mailboxId();
-    NmId folderId = mStartParam->folderId();
-    NmId msgId = mStartParam->messageId();
+    NM_FUNCTION;
+    
+    if (result == NmNoError && mStartParam) {
+        startMessageCreation(*mStartParam);
+    }
+    else {
+        // Show the fetching failed note only when
+        // the error is not Device/System errors, 
+        if (result != NmNoError && 
+            result != NmNotFoundError &&
+            result != NmGeneralError &&
+            result != NmCancelError &&
+            result != NmAuthenticationError &&
+            result != NmServerConnectionError &&
+            result != NmConnectionError) {
+            
+            HbNotificationDialog *note = new HbNotificationDialog(); 
+            
+            bool enalbeAttribute(true);
+            note->setAttribute(Qt::WA_DeleteOnClose, enalbeAttribute);
+            
+            note->setIcon(HbIcon(QLatin1String("note_warning")));
+            
+            note->setTitle(hbTrId("txt_mail_dpopinfo_loading_failed"));
+            note->setTitleTextWrapping(Hb::TextWordWrap);
+            
+            note->setDismissPolicy(HbNotificationDialog::TapAnywhere);
+            note->setTimeout(HbNotificationDialog::StandardTimeout);
+            
+            note->setSequentialShow(true);
+            note->show();
+        }
+        
+        mWaitDialog->close();         
+        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
+    }
+}
+
+void NmEditorView::fetchProgressDialogShow()
+{
+    NM_FUNCTION;
+    
+    delete mWaitDialog;
+    mWaitDialog = NULL;
+    // Create new wait dialog and set it to me modal with dimmed background
+    mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
+    mWaitDialog->setModal(true);
+    mWaitDialog->setBackgroundFaded(true);
+    connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(fetchProgressDialogCancelled()));
+    mWaitDialog->setText(hbTrId("txt_mail_dialog_loading_mail_content"));
+    // Display wait dialog
+    mWaitDialog->show();
+}
+
+/*!
+    This is called by mFetchProgressDialog when the note is cancelled
+ */
+void NmEditorView::fetchProgressDialogCancelled()
+{
+    NM_FUNCTION;
+    
+    if (mAttaManager.isFetching()) {
+        mAttaManager.cancelFetch();
+        mAttaManager.clearObserver();
+    }
+    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
+}
+
+void NmEditorView::startMessageCreation(NmUiStartParam &startParam)
+{
+    NM_FUNCTION;
+    
+    NmUiEditorStartMode startMode = startParam.editorStartMode();
+    NmId mailboxId = startParam.mailboxId();
+    NmId folderId = startParam.folderId();
+    NmId msgId = startParam.messageId();
     
     if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) {
         mMessageCreationOperation->cancelOperation();
     }
-	
+	  
     // original message is now fetched so start message creation
     if (startMode == NmUiEditorForward) {
         mMessageCreationOperation = mUiEngine.createForwardMessage(mailboxId, msgId);
@@ -397,6 +515,14 @@
             msgId, 
             startMode == NmUiEditorReplyAll);
     }
+    else if (startMode == NmUiEditorFromDrafts) {
+        // Draft opened, so reload message and fill editor with message data.
+        mMessage = mUiEngine.message(
+            mStartParam->mailboxId(), 
+            mStartParam->folderId(), 
+            mStartParam->messageId());
+        fillEditorWithMessageContents();
+    }
     else {
         mMessageCreationOperation = mUiEngine.createNewMessage(mailboxId);
     }
@@ -415,36 +541,114 @@
 */
 void NmEditorView::startSending()
 {
+    NM_FUNCTION;
+    
     // The message contents should be verified
     updateMessageWithEditorContents();
     
     // verify addresses before sending
     QList<NmAddress> invalidAddresses;
     if (mMessage) {
-        NmUtilities::getRecipientsFromMessage(*mMessage, invalidAddresses, NmUtilities::InvalidAddress);
+        NmUtilities::getRecipientsFromMessage(*mMessage, invalidAddresses, NmUtilities::NmInvalidAddress);
     }
     
-    bool okToSend = true;
     if (invalidAddresses.count() > 0) {
         
         // invalid addresses found, verify send from user
         QString noteText = hbTrId("txt_mail_dialog_invalid_mail_address_send");
         // set the first failing address to the note
         noteText = noteText.arg(invalidAddresses.at(0).address());
-        okToSend = NmUtilities::displayQuestionNote(noteText);
+        
+        if (mQueryDialog) {
+            delete mQueryDialog;
+            mQueryDialog = 0;
+        }
+        // Launch query dialog. Pressing "yes" will finalize the sending.
+        mQueryDialog = NmUtilities::displayQuestionNote(noteText,
+                                                        this,
+                                                        SLOT(invalidAddressQuery(HbAction*)));
     }
+    else {
+        // no need to ask anything, just send
+        finalizeSending();
+    }
+}
+
+/*!
+    Send the message after all checks have been done.
+*/
+void NmEditorView::finalizeSending()
+{
+    NM_FUNCTION;
     
-    if (okToSend) {
-        QList<NmOperation *> preliminaryOperations;
+    QList<NmOperation *> preliminaryOperations;
+    if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
         preliminaryOperations.append(mAddAttachmentOperation);
+    }
+    if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
         preliminaryOperations.append(mRemoveAttachmentOperation);
-        // ownership of mMessage is transferred
-        // NmOperations are automatically deleted after completion
-        mUiEngine.sendMessage(mMessage, preliminaryOperations);
-        mMessage = NULL;
-        preliminaryOperations.clear();
-        mApplication.popView();
     }
+    // ownership of mMessage is transferred
+    // NmOperations are automatically deleted after completion
+    mUiEngine.sendMessage(mMessage, preliminaryOperations);
+    mMessage = NULL;
+    preliminaryOperations.clear();
+
+    bool service = XQServiceUtil::isService();
+
+    // If sending is started as a service, progress dialog needs to be shown
+    // so long that sending is finished otherwise we can close pop current view.
+    if (service && mStartParam && mStartParam->service() && 
+        mUiEngine.isSendingMessage()) {
+        connect(&mUiEngine, SIGNAL(sendOperationCompleted()),
+            this, SLOT(handleSendOperationCompleted()), Qt::UniqueConnection);
+
+        // Construct and setup the wait dialog.
+        mServiceSendingDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
+        mServiceSendingDialog->setAttribute(Qt::WA_DeleteOnClose);
+        mServiceSendingDialog->setText(hbTrId("txt_mail_shareui_sending_please_wait"));
+        connect(mServiceSendingDialog, SIGNAL(cancelled()),
+            this, SLOT(sendProgressDialogCancelled()));
+
+        if (!XQServiceUtil::isEmbedded()) {
+            // Hide the application.
+            XQServiceUtil::toBackground(true);
+        }
+         // Display the wait dialog.
+         mServiceSendingDialog->setModal(true);
+         mServiceSendingDialog->setBackgroundFaded(true);
+         mServiceSendingDialog->show();
+    } else {
+        // Must use delayed editor view destruction so that query dialog
+        // (which has signaled this) gets time to complete.
+        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
+    }
+}
+
+/*!
+    Handle the user selection for invalid address query which was started by startSending.
+*/
+void NmEditorView::invalidAddressQuery(HbAction* action)
+{
+    NM_FUNCTION;
+
+    HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
+    // The first action in dialogs action list is for the "Yes"-button.
+    if (action == dlg->actions().at(0)) {
+        finalizeSending();
+    }
+}
+
+/*!
+    This is called when the view's geometry size has been changed, eg. when VKB is opened/closed.
+*/
+void NmEditorView::resizeEvent(QGraphicsSceneResizeEvent *event)
+{
+    NM_FUNCTION;
+    
+    NmBaseView::resizeEvent(event);
+    
+    emit sizeChanged();
 }
 
 /*!
@@ -452,10 +656,17 @@
 */
 void NmEditorView::messageCreated(int result)
 {
+    NM_FUNCTION;
+    
     delete mMessage;
     mMessage = NULL;
 
-    if (result == NmNoError && mMessageCreationOperation) {
+    // Close wait dialog here
+    if (mWaitDialog) {
+        mWaitDialog->close();
+    }
+    
+    if (result == NmNoError && mStartParam && mMessageCreationOperation) {
         NmUiEditorStartMode startMode = mStartParam->editorStartMode();
         
         // get message "again" from engine to update the message contents 
@@ -473,46 +684,48 @@
 */
 void NmEditorView::updateMessageWithEditorContents()
 {
+    NM_FUNCTION;
+    
     if (mMessage) {
-        if (mContentWidget && mContentWidget->editor()) {
+        if (mContent && mContent->editor()) {
             NmMessagePart* bodyPart = mMessage->htmlBodyPart();
             if (bodyPart) {
-                bodyPart->setTextContent(mContentWidget->editor()->toHtml(), NmContentTypeTextHtml);
+                bodyPart->setTextContent(mContent->editor()->toHtml(), NmContentTypeTextHtml);
             }
             bodyPart = mMessage->plainTextBodyPart();
             if (bodyPart) {
-                bodyPart->setTextContent(mContentWidget->editor()->toPlainText(), NmContentTypeTextPlain);
+                bodyPart->setTextContent(mContent->editor()->toPlainText(), NmContentTypeTextPlain);
             }
         }
-        if (mContentWidget && mContentWidget->header() ) {
-            if (mContentWidget->header()->subjectField()) {
+        if (mContent && mContent->header() ) {
+            if (mContent->header()->subjectEdit()) {
                 mMessage->envelope().setSubject(
-                    mContentWidget->header()->subjectField()->text());
+                    mContent->header()->subjectEdit()->text());
             }
-            if (mContentWidget->header()->toField()) {
+            if (mContent->header()->toEdit()) {
                 QString toFieldText =
-                    mContentWidget->header()->toField()->text();
+                    mContent->header()->toEdit()->text();
 
                 // This verification of zero length string isn't needed
                 // after list of addresses
                 if (toFieldText.length() > 0) {
-                    mMessage->envelope().setToRecipients(mContentWidget->header()->toField()->emailAddressList());  
+                    mMessage->envelope().setToRecipients(mContent->header()->toEdit()->emailAddressList());  
                 }
             }
-            if (mContentWidget->header()->ccField()) {
+            if (mContent->header()->ccEdit()) {
                 QString ccFieldText =
-                    mContentWidget->header()->ccField()->text();
+                    mContent->header()->ccEdit()->text();
 
                 if (ccFieldText.length() > 0) {
-                    mMessage->envelope().setCcRecipients(mContentWidget->header()->ccField()->emailAddressList());      
+                    mMessage->envelope().setCcRecipients(mContent->header()->ccEdit()->emailAddressList());      
                 }
             }
-            if (mContentWidget->header()->bccField()) {
+            if (mContent->header()->bccEdit()) {
                 QString bccFieldText =
-                    mContentWidget->header()->bccField()->text();
+                    mContent->header()->bccEdit()->text();
 
                 if (bccFieldText.length() > 0) {
-                    mMessage->envelope().setBccRecipients(mContentWidget->header()->bccField()->emailAddressList());  
+                    mMessage->envelope().setBccRecipients(mContent->header()->bccEdit()->emailAddressList());  
                 }
             }
         }
@@ -526,21 +739,20 @@
 */
 void NmEditorView::fillEditorWithMessageContents()
 {
-    if (!mMessage || !mContentWidget) {
+    NM_FUNCTION;
+    
+    if (!mStartParam || !mMessage || !mContent) {
         return;
     }
 
     NmMessageEnvelope messageEnvelope(mMessage->envelope());
-    NmUiEditorStartMode editorStartMode = NmUiEditorCreateNew;
     bool useStartParam(false);
 
-    if (mStartParam) {
-        editorStartMode = mStartParam->editorStartMode();
+    NmUiEditorStartMode editorStartMode = mStartParam->editorStartMode();
 
-        if (editorStartMode == NmUiEditorMailto) {
-            // Retrieve the message header data e.g. recipients from mStartParam.
-            useStartParam = true;        
-        }
+    if (editorStartMode == NmUiEditorMailto) {
+        // Retrieve the message header data e.g. recipients from mStartParam.
+        useStartParam = true;        
     }
     
     // Set recipients (to, cc and bcc).
@@ -559,14 +771,14 @@
         bccAddressesString = addressListToString(messageEnvelope.bccRecipients());
     }
 
-    mContentWidget->header()->toField()->setPlainText(toAddressesString);
-    mContentWidget->header()->ccField()->setPlainText(ccAddressesString);
-    mContentWidget->header()->bccField()->setPlainText(bccAddressesString);
+    mContent->header()->toEdit()->setPlainText(toAddressesString);
+    mContent->header()->ccEdit()->setPlainText(ccAddressesString);
+    mContent->header()->bccEdit()->setPlainText(bccAddressesString);
 
     if (ccAddressesString.length() || bccAddressesString.length()) {
         // Since cc or/and bcc recipients exist, expand the group box to display
         // the addresses by expanding the group box.
-        mContentWidget->header()->setGroupBoxCollapsed(false);
+        mContent->header()->setFieldVisibility(true);
     }
 
     // Set subject.
@@ -574,79 +786,57 @@
         QString *subject = mStartParam->subject();
 
         if (subject) {
-            mContentWidget->header()->subjectField()->setPlainText(*subject);
+            mContent->header()->subjectEdit()->setPlainText(*subject);
         }
     }
     else {
-        // If a message is taken from the outbox, no subject formatting is done.
-        NmId notUsed(0);
-
-        if (mCheckOutboxOperation &&
-            mCheckOutboxOperation->getMessageId(notUsed)) {
-            editorStartMode = NmUiEditorCreateNew;
-        }
-
         // Construct the subject field.
-        mContentWidget->header()->subjectField()->setPlainText(
+        mContent->header()->subjectEdit()->setPlainText(
             addSubjectPrefix(editorStartMode, messageEnvelope.subject()));
     }
 
     // Set priority.
+    if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll) {
+        //Clear the importance flag. Replied messages dont keep the importance
+        setPriority(NmActionResponseCommandNone);
+    }
     mHeaderWidget->setPriority(messageEnvelope.priority());
     
     // Set the message body.
-    // Fetch plain text part form message store.
-    NmMessagePart *plainPart = mMessage->plainTextBodyPart();
-
-    if (plainPart) {
-        mUiEngine.contentToMessagePart(mMessage->envelope().mailboxId(),
-                                       mMessage->envelope().folderId(),
-                                       mMessage->envelope().messageId(),
-                                       *plainPart);
-    }
-
-    // Fetch html part form message store.
-    NmMessagePart *htmlPart = mMessage->htmlBodyPart();
-
-    if (htmlPart) {
-        mUiEngine.contentToMessagePart(mMessage->envelope().mailboxId(),
-                                       mMessage->envelope().folderId(),
-                                       mMessage->envelope().messageId(),
-                                       *htmlPart);
-    }
-
-    // Fetch attachment.html part form message store if such exists.
-    QList<NmMessagePart*> parts;
-    mMessage->attachmentList(parts);
-    NmMessagePart *attachmentHtml = NULL;
-
-    foreach(NmMessagePart *part, parts) {
-        if (part->contentDescription().startsWith(NmContentDescrAttachmentHtml)) {
-            attachmentHtml = part;
-        }
-    }
-
-    if (attachmentHtml) {
-        mUiEngine.contentToMessagePart(mMessage->envelope().mailboxId(),
-                                       mMessage->envelope().folderId(),
-                                       mMessage->envelope().messageId(),
-                                       *attachmentHtml);
-    }
-
-    // Set content data
     if (editorStartMode==NmUiEditorReply||
         editorStartMode==NmUiEditorReplyAll||
-        editorStartMode==NmUiEditorForward){
-        // Pass envelope ptr only when needed for reaply header creation
+        editorStartMode==NmUiEditorForward||
+        editorStartMode==NmUiEditorFromDrafts){
+
+        // Use the body from the original message.
         NmMessage *originalMessage = mUiEngine.message(mStartParam->mailboxId(), 
                                                        mStartParam->folderId(), 
                                                        mStartParam->messageId());
-        mContentWidget->setMessageData(*mMessage, &originalMessage->envelope()); 
+
+        if (originalMessage) {
+            NmMessagePart *plainPart = originalMessage->plainTextBodyPart();
+
+            if (plainPart) {
+                mUiEngine.contentToMessagePart(originalMessage->envelope().mailboxId(),
+                                               originalMessage->envelope().folderId(),
+                                               originalMessage->envelope().messageId(),
+                                               *plainPart);
+            }
+
+            NmMessagePart *htmlPart = originalMessage->htmlBodyPart();
+
+            if (htmlPart) {
+                mUiEngine.contentToMessagePart(originalMessage->envelope().mailboxId(),
+                                               originalMessage->envelope().folderId(),
+                                               originalMessage->envelope().messageId(),
+                                               *htmlPart);
+            }
+
+		mContent->setMessageData(*originalMessage, editorStartMode);
+        }
+
         delete originalMessage;
-    }
-    else{
-        // Reply header not needed, do not pass envelope ptr
-        mContentWidget->setMessageData(*mMessage);     
+        originalMessage = NULL;
     }
     
     // Get list of attachments from the message and set those into UI attachment list
@@ -660,18 +850,13 @@
             attachments[i]->partId());
     }
 
-    if (mStartParam) {
-        // Attach passed files to the message.
-        QStringList *fileList = mStartParam->attachmentList();
+    // Attach passed files to the message.
+    QStringList *fileList = mStartParam->attachmentList();
 
-        if (fileList) {
-            addAttachments(*fileList);
-        }
+    if (fileList) {
+        addAttachments(*fileList);
     }
 
-    // TODO Switch the following arbitrary (magic number) timeout to a
-    // meaningful constant, please!
-    QTimer::singleShot(200, mHeaderWidget, SLOT(sendHeaderHeightChanged()));
 }
 
 
@@ -681,6 +866,8 @@
 */
 void NmEditorView::createToolBar()
 {
+    NM_FUNCTION;
+    
     HbToolBar *tb = toolBar();
     NmUiExtensionManager &extMngr = mApplication.extManager();
     if (tb && &extMngr && mStartParam) {
@@ -713,10 +900,21 @@
                     connect(actionMusic, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchAudio()));
                     
                     HbAction* actionVideo = 
-                        extension->addAction(hbTrId("txt_mail_list_video"), extension, SLOT(close()));                
+                        extension->addAction(hbTrId("txt_mail_list_video"), extension, SLOT(close()));
+                    connect(actionVideo, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchVideo()));
+                    
                     HbAction* actionOther = 
                         extension->addAction(hbTrId("txt_mail_list_other"), extension, SLOT(close()));
+                    connect(actionOther, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchOther()));
+                    
+                    HbAction* actionCameraStill = 
+                       extension->addAction(hbTrId("txt_mail_list_new_photo"), extension, SLOT(close()));
+                    connect(actionCameraStill, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchCameraStill()));
             
+                    HbAction* actionCameraVideo = 
+                        extension->addAction(hbTrId("txt_mail_list_new_video"), extension, SLOT(close()));
+                    connect(actionCameraVideo, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchCameraVideo()));
+                                        
                     list[i]->setToolBarExtension(extension);
                 }
             }            
@@ -730,11 +928,23 @@
 */
 void NmEditorView::createOptionsMenu()
 {
-    if (!mPrioritySubMenu) {
+    NM_FUNCTION;
+    
+    menu()->clearActions();
+
+	// Create CC/BCC options menu object
+    if (mCcBccFieldVisible) {
+        menu()->addAction(hbTrId("txt_mail_opt_hide_cc_bcc"), this, SLOT(switchCcBccFieldVisibility()));
+    }
+    else {
+        menu()->addAction(hbTrId("txt_mail_opt_show_cc_bcc"), this, SLOT(switchCcBccFieldVisibility()));
+    }
+
+	// Create Priority options menu object
+	if (!mPrioritySubMenu) {
         mPrioritySubMenu = new HbMenu();
     }
     mPrioritySubMenu->clearActions();
-    menu()->clearActions();
     NmActionRequest request(this, NmActionOptionsMenu, NmActionContextViewEditor,
             NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
             mStartParam->messageId());
@@ -750,11 +960,29 @@
 }
 
 /*!
+    Show or hide Cc field
+*/
+void NmEditorView::switchCcBccFieldVisibility()
+{
+    NM_FUNCTION;
+    
+    if (mCcBccFieldVisible) {
+    	mCcBccFieldVisible = false;
+    }
+    else {
+    	mCcBccFieldVisible = true;
+    }
+    mHeaderWidget->setFieldVisibility( mCcBccFieldVisible );
+}
+
+/*!
     handleActionCommand. From NmActionObserver, extension manager calls this
     call to handle menu command in the UI.
 */
 void NmEditorView::handleActionCommand(NmActionResponse &actionResponse)
 {
+    NM_FUNCTION;
+    
     NmActionResponseCommand responseCommand = actionResponse.responseCommand();
     
     // Handle options menu
@@ -766,8 +994,7 @@
         case NmActionResponseCommandSendMail: {
             // Just in case send mail would be somehow accessible during message creation or
             // outobox checking
-            if ((!mCheckOutboxOperation || !mCheckOutboxOperation->isRunning()) 
-                && (!mMessageCreationOperation || !mMessageCreationOperation->isRunning())) {
+            if (!mMessageCreationOperation || !mMessageCreationOperation->isRunning()) {
                 startSending();
             }
             break;
@@ -776,75 +1003,40 @@
             break;
         }
     }
+    else if (actionResponse.menuType() == NmActionContextMenu) {
+        switch (responseCommand) {
+        case NmActionResponseCommandRemoveAttachment: {
+            removeAttachmentTriggered();
+            break;
+        }
+        case NmActionResponseCommandOpenAttachment: {
+            openAttachmentTriggered(mSelectedAttachment);
+            break;
+        }
+        default:
+            break;
+        }
+    }
 }
 
 /*!
-    This function converts background scroll area coordinate point into
-    body text editor coordinate point.
+    Slot. Cancelled sending progress dialog.
 */
-QPointF NmEditorView::viewCoordinateToEditCoordinate(QPointF orgPoint)
-{
-    QPointF contentWidgetPos = mScrollAreaContents->pos();
-    qreal y = orgPoint.y() - mHeaderWidget->headerHeight();
-    y -= contentWidgetPos.y();
-    qreal x = orgPoint.x() - contentWidgetPos.x();
-    return QPointF(x, y);
-}
-
-/*!
-   Send mouse press event to body edit widget
-*/
-void NmEditorView::sendMousePressEventToScroll(QGraphicsSceneMouseEvent *event)
-{
-    if (event && mEditWidget && mHeaderWidget) {
-        event->setPos(viewCoordinateToEditCoordinate(event->pos()));
-        event->setAccepted(true);
-        mEditWidget->sendMousePressEvent(event);
-    }
-}
-
-/*!
-   Send mouse release event to body edit widget
-*/
-void NmEditorView::sendMouseReleaseEventToScroll(QGraphicsSceneMouseEvent *event)
+void NmEditorView::sendProgressDialogCancelled()
 {
-    if (event&& mEditWidget && mHeaderWidget) {
-        event->setPos(viewCoordinateToEditCoordinate(event->pos()));
-        event->setAccepted(true);
-        mEditWidget->sendMouseReleaseEvent(event);
-    }
+    // Must use delayed editor view destruction so that dialog
+    // gets time to complete, closes also nmail.
+    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
 }
 
 /*!
-   Send mouse move event to body edit widget
-*/
-void NmEditorView::sendMouseMoveEventToScroll(QGraphicsSceneMouseEvent *event)
-{
-    if (event&& mEditWidget && mHeaderWidget) {
-        event->setPos(viewCoordinateToEditCoordinate(event->pos()));
-        event->setAccepted(true);
-        mEditWidget->sendMouseMoveEvent(event);
-    }
-}
-
-void NmEditorView::sendLongPressGesture(const QPointF &point)
-{
-    if (mEditWidget && mHeaderWidget) {
-        QPointF scenePos = mEditWidget->scenePos();
-        QPointF newPoint = QPointF(point.x()-scenePos.x(), point.y()-scenePos.y());
-        if(mEditWidget->contains(newPoint)) {
-            mEditWidget->sendLongPressEvent(point);
-        }
-    }
-}
-
-
-/*!
    Sets all toolbar and VKB buttons dimmed state. All actions that have the
    availability condition NmSendable set, will be enabled/disabled.
 */
 void NmEditorView::setButtonsDimming(bool enabled)
 {
+    NM_FUNCTION;
+    
     // Set the toolbar action states
     HbToolBar *tb = toolBar();
     if (tb) {
@@ -860,7 +1052,7 @@
         // Set the VKB action states
         // All editors of the view share the same action, so it is enough to set
         // this only to one of them.
-        HbEditorInterface editorInterface(mContentWidget->editor());
+        HbEditorInterface editorInterface(mContent->editor());
         QList<HbAction *> vkbList = editorInterface.actions();
         count = vkbList.count();
         for (int i = 0; i < count; i++) {
@@ -878,6 +1070,12 @@
 */
 void NmEditorView::initializeVKB()
 {
+    NM_FUNCTION;
+    
+    if (!mStartParam) {
+        return;
+    }
+    
     NmActionRequest request(this, NmActionVKB, NmActionContextViewEditor,
          NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() );
     NmUiExtensionManager &extMngr = mApplication.extManager();
@@ -896,15 +1094,15 @@
 
             // Link VKB to the action. This must be done to all
             // editors that show the button in VKB.
-            HbEditorInterface editorInterface(mContentWidget->editor());
+            HbEditorInterface editorInterface(mContent->editor());
             editorInterface.addAction(list[i]);
-            HbEditorInterface toEditorInterface(mContentWidget->header()->toField());
+            HbEditorInterface toEditorInterface(mContent->header()->toEdit());
             toEditorInterface.addAction(list[i]);
-            HbEditorInterface ccEditorInterface(mContentWidget->header()->ccField());
+            HbEditorInterface ccEditorInterface(mContent->header()->ccEdit());
             ccEditorInterface.addAction(list[i]);
-            HbEditorInterface bccEditorInterface(mContentWidget->header()->bccField());
+            HbEditorInterface bccEditorInterface(mContent->header()->bccEdit());
             bccEditorInterface.addAction(list[i]);
-            HbEditorInterface subjectEditorInterface(mContentWidget->header()->subjectField());
+            HbEditorInterface subjectEditorInterface(mContent->header()->subjectEdit());
             subjectEditorInterface.addAction(list[i]);
         }
     }
@@ -915,6 +1113,8 @@
 */
 void NmEditorView::setMailboxName()
 {
+    NM_FUNCTION;
+    
     if (mStartParam){
         NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId());
         if (meta){
@@ -929,6 +1129,8 @@
 */
 QString NmEditorView::addSubjectPrefix( NmUiEditorStartMode startMode, const QString &subject )
 {
+    NM_FUNCTION;
+    
     QString newSubject(subject.trimmed());
     
     if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll || 
@@ -974,6 +1176,8 @@
 */
 void NmEditorView::onAttachmentReqCompleted(const QVariant &value)
 {
+    NM_FUNCTION;
+    
     //temporary fix for music picker back button:
     //it shouldn't emit requestOk signal when nothing is selected
 	if (value.canConvert<QStringList>()) {
@@ -984,6 +1188,19 @@
     }
 }
 
+/*!
+    This slot is called when 'attachment picker' request has been unsuccesfull
+    Parameter 'errorCode' is the error code returned by the service
+    Parameter 'errorMessage' is the error message returned by the service
+*/
+void NmEditorView::onAttachmentsFetchError(int errorCode, const QString& errorMessage)
+{
+    NM_FUNCTION;
+    Q_UNUSED(errorCode);
+    Q_UNUSED(errorMessage);
+    NM_COMMENT(QString("Error code: %1").arg(errorCode));
+    NM_COMMENT(QString("Error message: %1").arg(errorMessage));
+}
 
 /*!
     Closes the wait dialog if one exists.
@@ -994,24 +1211,28 @@
 */
 void NmEditorView::handleSendOperationCompleted()
 {
-    if (mWaitDialog) {
-        mWaitDialog->close();
+    NM_FUNCTION;
+
+    if (mServiceSendingDialog) {
+        mServiceSendingDialog->close();
     }
+    // Must use delayed editor view destruction so that dialog
+    // gets time to complete, closes also nmail.
+    QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
 }
 
-
 /*!
     Add list of attachments
 */
 void NmEditorView::addAttachments(const QStringList& fileNames) 
 {
-    NMLOG("NmEditorView::addAttachments");
-
+    NM_FUNCTION;
+    
     // Add attachment name into UI
     foreach (QString fileName, fileNames)  {
         // At this phase attachment size and nmid are not known
         mHeaderWidget->addAttachment(fileName, QString("0"), NmId(0));
-        NMLOG(fileName);
+        NM_COMMENT(fileName);
     }
     //  Cancel previous operation if it's not running.
     if (mAddAttachmentOperation) {
@@ -1045,6 +1266,8 @@
 */
 void NmEditorView::attachmentLongPressed(NmId attachmentPartId, QPointF point)
 {
+    NM_FUNCTION;
+    
     // Store id of the attachment to be removed into member.
     // It is used by removeAttachmentTriggered later if 'remove' selected.
     mSelectedAttachment = attachmentPartId;
@@ -1068,28 +1291,7 @@
     // Add menu position check here, so that it does not go outside of the screen
     QPointF menuPos(point.x(),point.y());
     mAttachmentListContextMenu->setPreferredPos(menuPos);
-    mAttachmentListContextMenu->open(this, SLOT(contextButton(NmActionResponse&)));
-}
-
-/*!
-    Slot. Signaled when menu option is selected
-*/
-void NmEditorView::contextButton(NmActionResponse &result)
-{
-    if (result.menuType() == NmActionContextMenu) {
-        switch (result.responseCommand()) {
-        case NmActionResponseCommandRemoveAttachment: {
-            removeAttachmentTriggered();
-            break;
-        }
-        case NmActionResponseCommandOpenAttachment: {
-            openAttachmentTriggered();
-            break;
-        }
-        default:
-            break;
-        }
-    }
+    mAttachmentListContextMenu->open();
 }
 
 /*!
@@ -1098,18 +1300,23 @@
 */
 void NmEditorView::oneAttachmentAdded(const QString &fileName, const NmId &msgPartId, int result)
 {
+    NM_FUNCTION;
+    
     if (result == NmNoError && mMessage) {
         // Need to get the message again because new attachment part has been added.
         NmId mailboxId = mMessage->envelope().mailboxId();
         NmId folderId = mMessage->envelope().folderId();
         NmId msgId = mMessage->envelope().messageId();
-
+        NmMessagePriority messagePriority = mMessage->envelope().priority();        
+        
         delete mMessage;
         mMessage = NULL;
         
         mMessage = mUiEngine.message(mailboxId, folderId, msgId);
 
         if (mMessage) {
+            mMessage->envelope().setPriority(messagePriority);
+            mMessage->envelope().setHasAttachments(true);
             // Get attachment list from the message
             QList<NmMessagePart*> attachmentList;
             mMessage->attachmentList(attachmentList);
@@ -1128,7 +1335,7 @@
     }
     else {
         // Attachment adding failed. Show an error note and remove from UI attachment list.
-        NMLOG(QString("nmailui: attachment adding into message failed: %1").arg(fileName));
+        NM_ERROR(1,QString("nmailui: attachment adding into message failed: %1").arg(fileName));
         mHeaderWidget->removeAttachment(fileName);
     }
 }
@@ -1139,6 +1346,8 @@
 */
 void NmEditorView::allAttachmentsAdded(int result)
 {
+    NM_FUNCTION;
+    
     enableToolBarAttach(true);
     if (result != NmNoError) {
         NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_unable_to_add_attachment"));
@@ -1146,48 +1355,12 @@
 }
 
 /*!
-    This is signalled by mCheckOutboxOperation when the operation is complete.
-*/
-void NmEditorView::outboxChecked(int result)
-{
-    bool messageInOutbox = false;
-    
-    if (result == NmNoError && mCheckOutboxOperation) {
-
-        NmId messageId;
-        messageInOutbox = mCheckOutboxOperation->getMessageId(messageId);
-        
-        if (messageInOutbox) {
-            delete mMessage;
-            mMessage = NULL;
-
-            mMessage = mUiEngine.message(
-                mStartParam->mailboxId(), 
-                mUiEngine.standardFolderId(
-                    mStartParam->mailboxId(), NmFolderOutbox), 
-                messageId);
-            
-            fillEditorWithMessageContents();
-            
-            if (mMessage) {
-                NmUtilities::displayWarningNote(
-                    hbTrId("txt_mail_dialog_sending failed").arg(
-                        NmUtilities::truncate(
-                            mMessage->envelope().subject(), 20)));
-            }
-        }
-    }
-
-    if (!messageInOutbox) {
-        startMessageCreation(mStartParam->editorStartMode());
-    }
-}
-
-/*!
    Sets priority for the message object that is being edited 
 */
 void NmEditorView::setPriority(NmActionResponseCommand priority)
 {
+    NM_FUNCTION;
+    
     mHeaderWidget->setPriority(priority);
 
     if (mMessage) {
@@ -1213,13 +1386,15 @@
 */
 QString NmEditorView::addressListToString(const QList<NmAddress*> &list) const
 {
+    NM_FUNCTION;
+    
     QString addressesString;
     QList<NmAddress*>::const_iterator i = list.constBegin();
     
     while (i != list.constEnd() && *i) {
         if (i > list.constBegin()) {
             // Add the delimiter.
-            addressesString += Delimiter;
+            addressesString += NmDelimiter;
         }
 
         addressesString += (*i)->address();
@@ -1239,13 +1414,15 @@
 */
 QString NmEditorView::addressListToString(const QList<NmAddress> &list) const
 {
+    NM_FUNCTION;
+    
     QString addressesString;
     QList<NmAddress>::const_iterator i = list.constBegin();
     
     while (i != list.constEnd()) {
         if (i > list.constBegin()) {
             // Add the delimiter.
-            addressesString += Delimiter;
+            addressesString += NmDelimiter;
         }
 
         addressesString += (*i).address();
@@ -1260,6 +1437,8 @@
 */
 void NmEditorView::removeAttachmentTriggered()
 {
+    NM_FUNCTION;
+    
     // Cancel will delete previous operation
     if (mRemoveAttachmentOperation) {
         if (!mRemoveAttachmentOperation->isRunning()) {
@@ -1285,6 +1464,8 @@
  */
 void NmEditorView::attachmentRemoved(int result)
 {
+    NM_FUNCTION;
+    
     // It is not desided yet what to do if operation fails
     Q_UNUSED(result);
     
@@ -1293,20 +1474,44 @@
         NmId mailboxId = mMessage->envelope().mailboxId();
         NmId folderId = mMessage->envelope().folderId();
         NmId msgId = mMessage->envelope().messageId();
+        NmMessagePriority messagePriority = mMessage->envelope().priority();    
 
         delete mMessage;
         mMessage = NULL;
     
         mMessage = mUiEngine.message(mailboxId, folderId, msgId);
+        
+        if(mMessage) {
+            // Set the correct priority
+            mMessage->envelope().setPriority(messagePriority);    
+            
+            // If there is no more attachments in the message, set the correct value
+            QList<NmMessagePart*> attachmentList;
+            mMessage->attachmentList(attachmentList);
+            if(attachmentList.count() == 0) {
+                mMessage->envelope().setHasAttachments(false);
+            }
+        }
     }
 }
 
 /*!
     This slot is called when 'open' is selected from attachment list context menu.
 */
-void NmEditorView::openAttachmentTriggered()
+void NmEditorView::openAttachmentTriggered(NmId attachmentId)
 {
-    mHeaderWidget->launchAttachment(mSelectedAttachment);
+    NM_FUNCTION;
+    NmId mailboxId = mMessage->envelope().mailboxId();
+    NmId folderId = mMessage->envelope().folderId();
+    NmId msgId = mMessage->envelope().messageId();
+
+    XQSharableFile file = mUiEngine.messagePartFile(mailboxId, folderId,
+    		msgId, attachmentId);
+    int error = NmUtilities::openFile(file);
+    file.close();
+    if ( error == NmNotFoundError ) {
+        NmUtilities::displayErrorNote(hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty")); 
+    }
 }
 
 /*!
@@ -1314,6 +1519,8 @@
 */
 void NmEditorView::enableToolBarAttach(bool enable)
 {
+    NM_FUNCTION;
+    
     HbToolBar *tb = toolBar();
     if (tb) {
         QList<QAction *> toolbarList = tb->actions();
@@ -1326,6 +1533,3 @@
         }
     }
 }
-
-
-// End of file.
--- a/emailuis/nmailui/src/nmmailboxlistview.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmmailboxlistview.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -37,7 +37,7 @@
     NmMailboxListModel &mailboxListModel,
     HbDocumentLoader *documentLoader,
     QGraphicsItem *parent)
-: NmBaseView(startParam,parent),
+: NmBaseView(startParam, application, parent),
 mApplication(application),
 mMailboxListWidget(NULL),
 mUiEngine(uiEngine),
@@ -46,6 +46,8 @@
 mDocumentLoader(documentLoader),
 mViewReady(false)
 {
+    NM_FUNCTION;
+    
     // Load view layout
     loadViewLayout();
     
@@ -58,6 +60,8 @@
 */
 NmMailboxListView::~NmMailboxListView()
 {
+    NM_FUNCTION;
+    
     delete mDocumentLoader;
     mWidgetList.clear();
     if (mItemContextMenu){
@@ -71,44 +75,44 @@
 */
 void NmMailboxListView::loadViewLayout()
 {
+    NM_FUNCTION;
+    
+
     // Use document loader to load the view
-    bool ok = false;
-    setObjectName(QString(NMUI_MAILBOX_LIST_VIEW));
-    QObjectList objectList;
-    objectList.append(this);
-    // Pass the view to documentloader. Document loader uses this view
-    // when docml is parsed, instead of creating new view.
-    if (mDocumentLoader) {
-        mDocumentLoader->setObjectTree(objectList);
-        mWidgetList = mDocumentLoader->load(NMUI_MAILBOX_LIST_VIEW_XML, &ok);
-    }
+     bool ok(false);
+     setObjectName(QString(NMUI_MAILBOX_LIST_VIEW));
+     QObjectList objectList;
+     objectList.append(this);
+     // Pass the view to documentloader. Document loader uses this view
+     // when docml is parsed, instead of creating new view.
+     if (mDocumentLoader) {
+         mDocumentLoader->setObjectTree(objectList);
+         mWidgetList = mDocumentLoader->load(NMUI_MAILBOX_LIST_VIEW_XML, &ok);
+     }
 
-    if (ok == true && mWidgetList.count()) {
+    if (ok) {
         // Create item context menu
         mItemContextMenu = new HbMenu();
         // Get mailbox widget pointer and set parameters
         mMailboxListWidget = qobject_cast<HbListView *>
             (mDocumentLoader->findWidget(NMUI_MAILBOX_LIST_WIDGET));
         if (mMailboxListWidget) {
-            NMLOG("nmailui: mailboxlistview: List object loaded");
+            NM_COMMENT("nmailui: mailboxlistview: list object loaded");
             // Set item prototype.
             mMailboxListWidget->setItemPrototype(new NmMailboxListViewItem(this));
             mMailboxListWidget->setItemRecycling(true);
             QObject::connect(mMailboxListWidget,
                     SIGNAL(activated(const QModelIndex &)),
                 this, SLOT(itemActivated(const QModelIndex &)));
-            QObject::connect(mMailboxListWidget,
-                    SIGNAL(longPressed(HbAbstractViewItem*, const QPointF&)),
-                this, SLOT(showItemContextMenu(HbAbstractViewItem*,const QPointF&)));
             mMailboxListWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
             mMailboxListWidget->setFrictionEnabled(true);
         }
         else {
-            NMLOG("nmailui: mailboxlistview: List object loading failed");
+            NM_ERROR(1,"nmailui: mailboxlistview: list object loading failed");
         }
     }
     else {
-         NMLOG("nmailui: mailboxlistview: Reasource loading failed");
+         NM_ERROR(1,"nmailui: mailboxlistview: resource loading failed");
     }
 }
 
@@ -117,6 +121,8 @@
 */
 void NmMailboxListView::viewReady()
 {
+    NM_FUNCTION;
+    
     if (!mViewReady){
         // Set title
         setTitle(hbTrId("txt_mail_title_mail"));
@@ -133,6 +139,8 @@
 */
 void NmMailboxListView::reloadViewContents(NmUiStartParam* startParam)
 {
+    NM_FUNCTION;
+    
     // Check start parameter validity.
     if (startParam&&startParam->viewId()==NmUiViewMailboxList) {
         // Delete existing start parameter data
@@ -144,7 +152,7 @@
         refreshList();
     }
     else {
-        NMLOG("nmailui: mailboxlistview: Invalid start parameter");
+        NM_ERROR(1,"nmailui: mailboxlistview: invalid start parameter");
         // Unused start parameter needs to be deleted
         delete startParam;
         startParam = NULL;
@@ -156,6 +164,8 @@
 */
 NmUiViewId NmMailboxListView::nmailViewId() const
 {
+    NM_FUNCTION;
+    
     return NmUiViewMailboxList;
 }
 
@@ -164,6 +174,8 @@
 */
 void NmMailboxListView::refreshList()
 {
+    NM_FUNCTION;
+    
 	if (mMailboxListWidget) {
         mMailboxListWidget->setModel(&mListModel);
 	}
@@ -174,6 +186,8 @@
 */
 void NmMailboxListView::itemActivated(const QModelIndex &index)
 {
+    NM_FUNCTION;
+    
     mActivatedIndex = index;
     QMetaObject::invokeMethod(this, "openSelectedMailBox", Qt::QueuedConnection);
 }
@@ -184,6 +198,8 @@
 */
 void NmMailboxListView::openSelectedMailBox()
 {
+    NM_FUNCTION;
+    
     // Get mailbox meta data
     NmMailboxMetaData *mailbox =
         mListModel.data(mActivatedIndex, Qt::DisplayRole).value<NmMailboxMetaData*>();
@@ -196,80 +212,4 @@
     }
 }
 
-/*!
-    showItemContextMenu. Functions starts fetching item context menu objects
-    from extension. Menu is displayed in view callback funtion.
-*/
-void NmMailboxListView::showItemContextMenu(HbAbstractViewItem *item, const QPointF &coords)
-{
-    if (mItemContextMenu&&item){
-        // Clear previous items from context menu
-        mItemContextMenu->clearActions();
-        // Get mailbox meta data
-        NmMailboxMetaData *mailbox =
-            mListModel.data(item->modelIndex(), Qt::DisplayRole).value<NmMailboxMetaData*>();
-        NmId mailboxId(0);
-        if (mailbox) {
-            mailboxId = mailbox->id();
-        }
-        // Fetch items from extension based on item
-        NmActionRequest request(this, NmActionContextMenu, NmActionContextViewNone,
-        		NmActionContextDataMailbox, mailboxId);
-        NmUiExtensionManager &extMngr = mApplication.extManager();
-        QList<NmAction*> list;
-        extMngr.getActions(request, list);
-        for (int i=0;i<list.count();i++) {
-            mItemContextMenu->addAction(list[i]);
-        }
-        // Display menu
-        if (mMailboxListWidget){
-            mMailboxListWidget->setCurrentIndex(item->modelIndex());
-            mItemContextMenu->setObjectName("MailboxItemContextMenu");
-            mItemContextMenu->setPreferredPos(coords);
-            mItemContextMenu->open(this, SLOT(contextButton(NmActionResponse&)));
-        }
-    }
-}
 
-/*!
-    Slot. Signaled when menu option is selected
-*/
-void NmMailboxListView::contextButton(NmActionResponse &result)
-{
-    // Handle context menu commands here
-    if (result.menuType()==NmActionContextMenu){
-        switch (result.responseCommand()){
-            case NmActionResponseCommandOpen:{
-                // Check that given start response has mailbox and folder id's
-                if (result.mailboxId()!=0){
-                    // Use standard folder id inbox if folder has not been specified
-                    NmId folderId = result.folderId();
-                    if (folderId==0){
-                        folderId=mUiEngine.standardFolderId(result.mailboxId(),
-                                                            NmFolderInbox);
-                    }
-                    NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageList,
-                                                                    result.mailboxId(),
-                                                                    folderId);
-                    mApplication.enterNmUiView(startParam);
-                    }
-                }
-                break;
-            default:
-                break;
-        }
-    }
-}
-
-/*!
-    handleActionCommand. From NmMenuObserver, extension manager calls this
-    call to handle menu command in the UI.
-*/
-
-void NmMailboxListView::handleActionCommand(NmActionResponse &actionResponse)
-{
-    // Handle context menu commands here
-    Q_UNUSED(actionResponse);
-}
-
-
--- a/emailuis/nmailui/src/nmmailboxlistviewitem.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmmailboxlistviewitem.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -17,6 +17,9 @@
 
 #include "nmuiheaders.h"
 
+const QString NmMailboxListViewItemIcon = "MailboxListViewMailboxIcon";
+const QString NmMailboxListViewItemName = "MailboxListViewMailboxName";
+
 /*!
     \class NmMailboxListViewItem
     \brief Mailbox list view item inherited from HbListViewItem
@@ -29,6 +32,7 @@
 : HbListViewItem(parent),
 mLayout(NULL)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -36,6 +40,7 @@
 */
 NmMailboxListViewItem::~NmMailboxListViewItem()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -43,6 +48,8 @@
 */
 HbListViewItem* NmMailboxListViewItem::createItem()
 {
+    NM_FUNCTION;
+    
     return new NmMailboxListViewItem(*this);
 }
 
@@ -51,22 +58,35 @@
 */
 void NmMailboxListViewItem::updateChildItems()
 {
+    NM_FUNCTION;
+    
     // To create primitives
     HbListViewItem::updateChildItems();
 
+    EmailMailboxInfo mailboxInfo;
+    
     NmMailboxMetaData *mailbox =
             modelIndex().data(Qt::DisplayRole).value<NmMailboxMetaData*>();
-    if (mailbox){
+    
+    HbLabel *textLabel = findChild<HbLabel *>(NmMailboxListViewItemName);
+    HbLabel *icon = findChild<HbLabel *>(NmMailboxListViewItemIcon);
+    
+    if (mailbox && !textLabel && !icon){
         mLayout = new QGraphicsLinearLayout(Qt::Horizontal, 0);
         mLayout->setContentsMargins(0,0,0,0);
 
         HbLabel *mbIcon = new HbLabel();
-        mbIcon->setObjectName("MailboxListViewMailboxIcon");
-        mbIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconDefaultMailbox));
+        mbIcon->setParent(this);
+        mbIcon->setObjectName(NmMailboxListViewItemIcon);
+        
+        QString domainName = mailbox->address();
+        QString iconName = mailboxInfo.mailboxIcon(domainName);
+        mbIcon->setIcon(HbIcon(iconName));
         mbIcon->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
 
         HbLabel *mbName = new HbLabel();
-        mbName->setObjectName("MailboxListViewMailboxName");
+        mbName->setParent(this);
+        mbName->setObjectName(NmMailboxListViewItemName);
         mbName->setPlainText(mailbox->name());
         mbName->setAlignment(Qt::AlignVCenter);
         mbName->setFontSpec(HbFontSpec(HbFontSpec::Primary));
@@ -77,6 +97,17 @@
         mLayout->setItemSpacing(0,0);
 
         setLayout(mLayout); // Ownership is transferred
+    } else if (mailbox) {
+        
+        if (textLabel) {
+            textLabel->setPlainText(mailbox->name());
+        }
+        
+        QString iconName = mailboxInfo.mailboxIcon(mailbox->address());
+        if (icon && !iconName.isEmpty()) {
+            icon->setIcon(HbIcon(iconName));
+        }
+        
     }
 }
 
@@ -85,6 +116,8 @@
 */
 bool NmMailboxListViewItem::canSetModelIndex(const QModelIndex &index)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(index);
     return true;
 }
@@ -94,18 +127,8 @@
 */
 void NmMailboxListViewItem::polishEvent()
 {
+    NM_FUNCTION;
+    
     QGraphicsWidget::polishEvent();
 }
 
-/*!
-    paint. Paint function for line painting.
-*/
-void NmMailboxListViewItem::paint(
-    QPainter *painter,
-    const QStyleOptionGraphicsItem *option,
-    QWidget *widget)
-{
-    Q_UNUSED(option);
-    Q_UNUSED(widget);
-    Q_UNUSED(painter);
-}
--- a/emailuis/nmailui/src/nmmailboxselectiondialog.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmmailboxselectiondialog.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -42,7 +42,7 @@
       mParent(parent),
       mMailboxId(0)
 {
-    // No implementation required.
+    NM_FUNCTION;
 }
 
 
@@ -51,6 +51,8 @@
 */
 NmMailboxSelectionDialog::~NmMailboxSelectionDialog()
 {
+    NM_FUNCTION;
+    
     delete mContentItemModel;
     delete mMailboxListView;
     delete mMailboxSelectionDialog;
@@ -63,7 +65,8 @@
 */
 void NmMailboxSelectionDialog::open()
 {
-    NMLOG("NmMailboxSelectionDialog::exec()");
+    NM_FUNCTION;
+    
     mMailboxId = 0;
 
     // Initialize the UI and fetch the mailbox items into the list.
@@ -79,12 +82,14 @@
  */
 void NmMailboxSelectionDialog::dialogClosed(HbAction *action)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(action);
-    
+
     // Store the ID of the selected mailbox into the given argument.
-    NMLOG(QString("NmMailboxSelectionDialog::dialogClosed() return %1").
+    NM_COMMENT(QString("NmMailboxSelectionDialog::dialogClosed() return %1").
         arg(mMailboxId.id()));
-    
+
     emit selectionDialogClosed(mMailboxId);
 }
 
@@ -96,11 +101,11 @@
 */
 bool NmMailboxSelectionDialog::initializeUi()
 {
-    NMLOG("NmMailboxSelectionDialog::initializeUi()");
-
+    NM_FUNCTION;
+    
     // Use the document loader to load the widgets.
     HbDocumentLoader documentLoader;
-    bool documentLoaded = false;
+    bool documentLoaded(false);
 
     QObjectList objectList;
     objectList.append(this);
@@ -118,7 +123,7 @@
     }
 
     if (!mMailboxSelectionDialog || !mMailboxListView) {
-        NMLOG("NmMailboxSelectionDialog::initializeUi(): Failed to load widgets!");
+        NM_ERROR(1,"NmMailboxSelectionDialog::initializeUi(): Failed to load widgets!");
         return false;
     }
 
@@ -153,7 +158,8 @@
 */
 bool NmMailboxSelectionDialog::populateListItems()
 {
-    NMLOG("NmMailboxSelectionDialog::populateListItems()");
+    NM_FUNCTION;
+    
     const int count = mMailboxListModel.rowCount();
 
     if (!mContentItemModel || count == 0) {
@@ -164,13 +170,14 @@
     NmMailboxMetaData *metaData = NULL;
     QStandardItem *item = NULL;
 
+    EmailMailboxInfo mailboxInfo;
     for (int i = 0; i < count; ++i) {
         metaData = mailboxMetaData(i);
 
         if (metaData) {
-            // Implement the branded icons when possible.
-            const HbIcon &mailboxIcon =
-                NmIcons::getIcon(NmIcons::NmIconDefaultMailbox);
+            QString domainName = metaData->address();
+            QString iconName = mailboxInfo.mailboxIcon(domainName);
+			HbIcon mailboxIcon( iconName );
 
             // Construct the item and append it into the list.
             item = new QStandardItem(mailboxIcon.qicon(), metaData->name());
@@ -190,6 +197,8 @@
 */
 NmMailboxMetaData *NmMailboxSelectionDialog::mailboxMetaData(int index) const
 {
+    NM_FUNCTION;
+    
     QVariant mailbox = mMailboxListModel.data(mMailboxListModel.index(index, 0));
     NmMailboxMetaData *mailboxMetaData = mailbox.value<NmMailboxMetaData*>();
     return mailboxMetaData;
@@ -203,6 +212,8 @@
 */
 void NmMailboxSelectionDialog::itemActivated(QModelIndex index)
 {
+    NM_FUNCTION;
+    
     const int rowIndex = index.row();
     NmMailboxMetaData *metaData = mailboxMetaData(rowIndex);
 
--- a/emailuis/nmailui/src/nmmailboxserviceinterface.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmmailboxserviceinterface.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -33,18 +33,12 @@
 NmMailboxServiceInterface::NmMailboxServiceInterface(QObject *parent,
         NmUiEngine &uiEngine,
         NmApplication *application)
-#ifndef NM_WINS_ENV
     : XQServiceProvider(emailFullServiceNameMailbox, parent),
-#else
-    : QObject(parent),
-#endif
       mUiEngine(uiEngine),
       mApplication(application),
       mAsyncReqId(0)
 {
-#ifndef NM_WINS_ENV
     publishAll();
-#endif
 }
 
 
@@ -53,6 +47,7 @@
 */
 NmMailboxServiceInterface::~NmMailboxServiceInterface()
 {
+    NM_FUNCTION;
 }
 
 
@@ -63,15 +58,17 @@
 */
 void NmMailboxServiceInterface::displayInboxByMailboxId(QVariant data)
 {
-    NMLOG("NmMailboxServiceInterface::displayInboxByMailboxId()");
+    NM_FUNCTION;
 
-#ifndef NM_WINS_ENV
 
     // Get the given ID and convert it into NmId type.
     NmId mailboxNmId(data.toULongLong());
 
     mAsyncReqId = setCurrentRequestAsync();
 
+    // Make sure that app stays background if user presses back in message list view
+    bool visible = mApplication->updateVisibilityState();
+
     // Verify that the ID matches one of the existing mailboxes.
     if (mailboxExistsById(mailboxNmId)) {
 
@@ -80,26 +77,30 @@
 
         // Bring the application to the foreground.
         XQServiceUtil::toBackground(false);
+        if (mApplication) {
+            HbMainWindow *mainWindow = mApplication->mainWindow();
+            mainWindow->show();
 
-        // Launch the message list view.
-        NmUiStartParam *startParam =
-            new NmUiStartParam(NmUiViewMessageList,
-                               mailboxNmId,
-                               inboxId, // folder id
-                               0, // message id
-                               NmUiEditorCreateNew, // editor start mode
-                               NULL, // address list
-                               NULL, // attachment list
-                               true); // start as service
-        mApplication->enterNmUiView(startParam);
-
+            // Launch the message list view.
+            NmUiStartParam *startParam =
+                new NmUiStartParam(NmUiViewMessageList,
+                                   mailboxNmId,
+                                   inboxId, // folder id
+                                   0, // message id
+                                   NmUiEditorCreateNew, // editor start mode
+                                   NULL, // address list
+                                   NULL, // attachment list
+                                   true); // start as service
+            mApplication->enterNmUiView(startParam);
+        }
+       
         completeRequest(mAsyncReqId, 0);
     }
     else {
         // No mailbox found with the given ID.
 
         // if started as embedded, do not hide the app
-		if (!XQServiceUtil::isEmbedded()) {
+		if (!XQServiceUtil::isEmbedded() && !visible) {
 			XQServiceUtil::toBackground(true);
 		}
 
@@ -111,7 +112,6 @@
                     mApplication, SLOT(delayedExitApplication()));
         }
     }
-#endif
 }
 
 
@@ -122,7 +122,7 @@
 */
 bool NmMailboxServiceInterface::mailboxExistsById(const NmId &mailboxId) const
 {
-    NMLOG("NmMailboxServiceInterface::mailboxExistsById()");
+    NM_FUNCTION;
 
     const NmMailboxListModel& mailboxListModel = mUiEngine.mailboxListModel();
     int mailboxCount = mailboxListModel.rowCount();
@@ -137,7 +137,9 @@
         modelIndex = mailboxListModel.index(i, 0);
         mailbox = mailboxListModel.data(modelIndex);
         mailboxMetaData = mailbox.value<NmMailboxMetaData*>();
-        currentId = mailboxMetaData->id();
+        if (mailboxMetaData) {
+            currentId = mailboxMetaData->id();        
+        }
 
         if (currentId.id() == mailboxId.id()) {
             // Found a mailbox with the matching ID.
--- a/emailuis/nmailui/src/nmmessagelistview.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmmessagelistview.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -19,12 +19,13 @@
 static const char *NMUI_MESSAGE_LIST_VIEW = "NmMessageListView";
 static const char *NMUI_MESSAGE_LIST_TREE_LIST = "MessageTreeList";
 static const char *NMUI_MESSAGE_LIST_NO_MESSAGES = "MessageListNoMessages";
-static const char *NMUI_MESSAGE_LIST_FOLDER_LABEL = "folderLabel";
-static const char *NMUI_MESSAGE_LIST_SYNC_ICON = "syncIcon";
+static const char *NMUI_MESSAGE_LIST_FOLDER_LABEL = "labelGroupBox";
 
 #include "nmuiheaders.h"
 
-/*!
+const QString syncIndicatorName = "com.nokia.nmail.indicatorplugin.sync/1.0";
+
+/*! 
 	\class NmMessageListView
 	\brief Message list view
 */
@@ -37,10 +38,10 @@
     NmUiStartParam* startParam,
     NmUiEngine &uiEngine,
     NmMailboxListModel &mailboxListModel,
-    NmMessageListModel &messageListModel,
+    NmMessageListModel *messageListModel,
     HbDocumentLoader *documentLoader,
     QGraphicsItem *parent)
-: NmBaseView(startParam, parent),
+: NmBaseView(startParam, application, parent),
 mApplication(application),
 mMessageListWidget(NULL),
 mUiEngine(uiEngine),
@@ -51,15 +52,18 @@
 mLongPressedItem(NULL),
 mNoMessagesLabel(NULL),
 mFolderLabel(NULL),
-mSyncIcon(NULL),
 mViewReady(false),
-mCurrentFolderType(NmFolderInbox)
+mCurrentFolderType(NmFolderInbox),
+mSettingsLaunched(false),
+mPreviousModelCount(0),
+mIsFirstSyncInMessageList(true)
 {
-    // Load view layout
+    NM_FUNCTION;
+
     loadViewLayout();
-    // Init tree view
+    createToolBar();
     initTreeView();
-    // Set folder name
+    setMailboxName();
     setFolderName();
 }
 
@@ -68,6 +72,8 @@
 */
 NmMessageListView::~NmMessageListView()
 {
+    NM_FUNCTION;
+
     delete mDocumentLoader;
     mWidgetList.clear();
     if (mItemContextMenu){
@@ -81,8 +87,10 @@
 */
 void NmMessageListView::loadViewLayout()
 {
+    NM_FUNCTION;
+
     // Use document loader to load the view
-    bool ok = false;
+    bool ok(false);
     setObjectName(QString(NMUI_MESSAGE_LIST_VIEW));
     QObjectList objectList;
     objectList.append(this);
@@ -93,54 +101,56 @@
         mWidgetList = mDocumentLoader->load(NMUI_MESSAGE_LIST_VIEW_XML, &ok);
     }
 
-    if (ok == true && mWidgetList.count()) {
+    if (ok) {
         // Get message list widget
         mMessageListWidget = qobject_cast<HbTreeView *>
             (mDocumentLoader->findWidget(NMUI_MESSAGE_LIST_TREE_LIST));
+
         if (mMessageListWidget) {
-            NMLOG("nmailui: List object loaded");
+            NM_COMMENT("nmailui: list object loaded");
+
             // Set item prototype.
             mMessageListWidget->setItemPrototype(new NmMessageListViewItem());
+
+            // Set the list widget properties.
             mMessageListWidget->setItemRecycling(true);
             mMessageListWidget->contentWidget()->setProperty("indentation", 0);
             mMessageListWidget->setScrollDirections(Qt::Vertical);
             mMessageListWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
             mMessageListWidget->setFrictionEnabled(true);
+
+            // Enable animations to display an email as soon as it is added to
+            // the list.
+            mMessageListWidget->setEnabledAnimations(HbAbstractItemView::Appear &
+                                                     HbAbstractItemView::Expand);
         }
         else {
-            NMLOG("nmailui: List object loading failed");
+            NM_ERROR(1,"nmailui: list object loading failed");
         }
+
         mNoMessagesLabel = qobject_cast<HbLabel *>
             (mDocumentLoader->findWidget(NMUI_MESSAGE_LIST_NO_MESSAGES));
         if (mNoMessagesLabel) {
             mNoMessagesLabel->hide();
         }
         else{
-            NMLOG("nmailui: (no messages) object loading failed");
+            NM_ERROR(1,"nmailui: (no messages) object loading failed");
         }
 
-        // Create folder label and set inbox text for it
-        mFolderLabel = qobject_cast<HbLabel *>(mDocumentLoader->findWidget(NMUI_MESSAGE_LIST_FOLDER_LABEL));
-
-        mSyncIcon = qobject_cast<HbLabel *>(mDocumentLoader->findWidget(NMUI_MESSAGE_LIST_SYNC_ICON));
-        if (mSyncIcon) {
-            mSyncIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconOffline));
-        }
+        mFolderLabel = qobject_cast<HbGroupBox *>(mDocumentLoader->findWidget(NMUI_MESSAGE_LIST_FOLDER_LABEL));
 
         // Connect options menu about to show to create options menu function
         QObject::connect(menu(), SIGNAL(aboutToShow()),
                          this, SLOT(createOptionsMenu()));
         QObject::connect(&mUiEngine, SIGNAL(syncStateEvent(NmSyncState, const NmId &)),
                          this, SLOT(handleSyncStateEvent(NmSyncState, const NmId &)));
-        QObject::connect(&mUiEngine, SIGNAL(connectionEvent(NmConnectState, const NmId &)),
-                                        this, SLOT(handleConnectionEvent(NmConnectState, const NmId &)));
 
         // Menu needs one dummy item so that aboutToShow signal is emitted.
         NmAction *dummy = new NmAction(0);
         menu()->addAction(dummy);
     }
     else {
-        NMLOG("nmailui: Resource loading failed");
+        NM_ERROR(1,"nmailui: resource loading failed");
     }
 }
 
@@ -149,15 +159,44 @@
 */
 void NmMessageListView::viewReady()
 {
+    NM_FUNCTION;
+
     if (!mViewReady){
-        // Set mailbox name to title pane
-        setMailboxName();
-        //create toolbar
-        createToolBar();
         // Refresh list
         QMetaObject::invokeMethod(this, "refreshList", Qt::QueuedConnection);
         mViewReady=true;
     }
+    mSettingsLaunched = false;
+}
+
+/*!
+    Getter for currently displayed folder type
+*/
+NmFolderType NmMessageListView::folderType()
+{
+    NM_FUNCTION;
+
+    return mCurrentFolderType;
+}
+
+/*!
+    okToExitView. Message list view determines whether it is
+    ok to exit view and calls mapplication popview.
+*/
+void NmMessageListView::okToExitView()
+{
+    NM_FUNCTION;
+
+    // Close view if current folder is inbox
+    if (mCurrentFolderType==NmFolderInbox){
+        mApplication.popView();
+    }
+    // Switch to inbox
+    else{
+        mSelectedMailboxId=mStartParam->mailboxId();
+        mSelectedFolderId=mUiEngine.standardFolderId(mSelectedMailboxId,NmFolderInbox);
+        QMetaObject::invokeMethod(this, "folderSelected", Qt::QueuedConnection);
+    }
 }
 
 /*!
@@ -165,6 +204,8 @@
 */
 void NmMessageListView::initTreeView()
 {
+    NM_FUNCTION; 
+
     // Get mailbox widget pointer and set parameters
     if (mMessageListWidget){
         QObject::connect(mMessageListWidget,
@@ -174,7 +215,6 @@
                 SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), this,
                 SLOT(showItemContextMenu(HbAbstractViewItem*, QPointF)));
         mMessageListWidget->setFocus();
-        mItemContextMenu = new HbMenu();
     }
 }
 
@@ -182,10 +222,12 @@
 /*!
     Reload view contents with new start parameters
     Typically when view is already open and external view activation occurs
-    for this same view
+    for this same view. Startparam ownership is transferred to this view
 */
 void NmMessageListView::reloadViewContents(NmUiStartParam* startParam)
 {
+    NM_FUNCTION;
+
     // Check start parameter validity, message view cannot
     // be updated if given parameter is zero.
     if (startParam&&startParam->viewId()==NmUiViewMessageList&&
@@ -196,26 +238,26 @@
         // Store new start parameter data
         mStartParam=startParam;
         // Update the model with new parameters
-        mUiEngine.messageListModel(startParam->mailboxId(), startParam->folderId());
+        mMessageListModel = &mUiEngine.messageListModel(startParam->mailboxId(), startParam->folderId());
         refreshList();
         // Refresh the mailboxname
         setMailboxName();
-        // Show message list if it is hidden
-        mMessageListWidget->show();
     }
     else {
-        NMLOG("nmailui: Invalid message list start parameter");
+        NM_ERROR(1,"nmailui: invalid message list start parameter");
         // Unused start parameter needs to be deleted
         delete startParam;
     }
 }
 
-
+ 
 /*!
     Return view id
 */
 NmUiViewId NmMessageListView::nmailViewId() const
 {
+    NM_FUNCTION;
+
     return NmUiViewMessageList;
 }
 
@@ -224,157 +266,134 @@
 */
 void NmMessageListView::refreshList()
 {
-    NmId mailboxId = mMessageListModel.currentMailboxId();
-    if (mSyncIcon && mailboxId == mMessageListModel.currentMailboxId()) {
-        if (mUiEngine.syncState(mailboxId) == Synchronizing) {
-            mSyncIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconSynching));
-        }
-        else {
-            if (mUiEngine.connectionState(mailboxId) == Connected) {
-                mSyncIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconOnline));
-            }
-            else {
-                mSyncIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconOffline));
+    NM_FUNCTION;
+
+    if (mMessageListModel) {
+        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; 
             }
         }
-    }
 
-    if (mMessageListWidget) {
-        mMessageListWidget->setModel(static_cast<QStandardItemModel*>(&mMessageListModel));
-        QObject::connect(&mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
-                this, SLOT(itemsAdded(const QModelIndex&,int,int)));
-        QObject::connect(&mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
-                this, SLOT(itemsRemoved()));
-        QObject::connect(&mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)),
-                this, SLOT(reloadViewContents(NmUiStartParam*)));
+        // Set item model to message list widget
+        if (mMessageListWidget) {
+            mMessageListWidget->setModel(static_cast<QStandardItemModel*>(mMessageListModel));
+            QObject::connect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
+                    this, SLOT(itemsAdded(const QModelIndex&,int,int)));
+            QObject::connect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
+                    this, SLOT(itemsRemoved()));
+            QObject::connect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)),
+                    this, SLOT(reloadViewContents(NmUiStartParam*)));
 
-        if (mMessageListModel.rowCount()==0){
-            showNoMessagesText();
-        }
+            mPreviousModelCount=mMessageListModel->rowCount();
+            if (mPreviousModelCount==0){
+                showNoMessagesText();
+            }
+            else{
+                hideNoMessagesText();
+            }
+        }    
     }
 }
 
+/*!
+    Sync state event handling
+*/
 void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId & mailboxId)
 {
-    if (mSyncIcon && mailboxId == mMessageListModel.currentMailboxId()) {
+    NM_FUNCTION;
+    if (mMessageListModel && mailboxId == mMessageListModel->currentMailboxId()) {
         if (syncState == Synchronizing) {
-            mSyncIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconSynching));
-        }
-        else {
-            if (mUiEngine.connectionState(mailboxId) == Connected) {
-                mSyncIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconOnline));
+             // before first sync inbox id might be zero
+            if (mStartParam->folderId() == 0) {
+                // after sync inbox id should be updated to correct value
+                NmId folderId = mUiEngine.standardFolderId(
+                    mStartParam->mailboxId(),
+                    NmFolderInbox);
+                mStartParam->setFolderId(folderId);
             }
-            else {
-                mSyncIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconOffline));
+            // 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());
+                mIsFirstSyncInMessageList = false;
             }
         }
     }
 }
 
-/*!
-    Connection event handling
-*/
-void NmMessageListView::handleConnectionEvent(NmConnectState connectState, const NmId &mailboxId)
-{
-    if (mSyncIcon && mailboxId == mMessageListModel.currentMailboxId() && mUiEngine.syncState(mailboxId) != Synchronizing) {
-        if (connectState == Connected) {
-            mSyncIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconOnline));
-        }
-        else {
-            mSyncIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconOffline));
-        }
-    }
-}
-
-/*!
+/*! 
     folder selection handling within current mailbox
 */
-void NmMessageListView::folderSelected(NmId mailbox, NmId folder)
+void NmMessageListView::folderSelected()
 {
-    // Reloas view contents with new startparams
-    if (mStartParam){
-        NmUiStartParam* startParam = new NmUiStartParam(NmUiViewMessageList,mailbox,folder);
-        // Hide message lis for redraw
-        mMessageListWidget->hide();
+    NM_FUNCTION;
+
+    // Reload view contents with new startparams if mailbox or folder
+    // id is different than current values.
+    if (mStartParam && (mStartParam->mailboxId()!=mSelectedMailboxId||
+                        mStartParam->folderId()!=mSelectedFolderId)){
+        // Create start params
+        NmUiStartParam* startParam = new NmUiStartParam(NmUiViewMessageList,
+                                                        mSelectedMailboxId,
+                                                        mSelectedFolderId);
+        // Store active folder type
+        mCurrentFolderType = mUiEngine.folderTypeById(startParam->mailboxId(),startParam->folderId());
         // Reload view, ownership of the startparams is passed and old startparams
         // are deleted within reloadViewContents function
         reloadViewContents(startParam);
         //Set folder text to status bar
         setFolderName();
-        // Store active folder type
-        mCurrentFolderType = NmFolderInbox;
     }
 }
 
 
 /*!
-    Long keypress handling
+    Long keypress handling 
 */
 void NmMessageListView::showItemContextMenu(HbAbstractViewItem *listViewItem, const QPointF &coords)
 {
-    // Store long press item for later use with response
-    mLongPressedItem = mMessageListModel.data(
-            listViewItem->modelIndex(), Qt::DisplayRole).value<NmMessageListModelItem*>();
-    if (mItemContextMenu && mLongPressedItem && mLongPressedItem->itemType() ==
-        NmMessageListModelItem::NmMessageItemMessage) {
-
-        // Clear previous items from context menu
-        mItemContextMenu->clearActions();
-        NmUiExtensionManager &extMngr = mApplication.extManager();
-        QList<NmAction*> list;
-        // Fetch items from extension based on item
-        NmMessageEnvelope *envelope = mLongPressedItem->envelopePtr();
-        if (envelope){
-            NmActionRequest request(this, NmActionContextMenu, NmActionContextViewMessageList,
-                    NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
-                    envelope->messageId(),QVariant::fromValue(envelope));
-            extMngr.getActions(request, list);
+    NM_FUNCTION;
+   
+    if (listViewItem) {
+        // Recreate item context menu each time it is called
+        if (mItemContextMenu){
+            mItemContextMenu->clearActions();
+            delete mItemContextMenu;    
+            mItemContextMenu=NULL;
         }
-        else{
-            NmActionRequest request(this, NmActionContextMenu, NmActionContextViewMessageList,
-                    NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
-                    envelope->messageId());
-            extMngr.getActions(request, list);
-        }
-        for (int i=0;i<list.count();i++) {
-            mItemContextMenu->addAction(list[i]);
-        }
-        mItemContextMenu->setPreferredPos(coords);
-        mItemContextMenu->open(this, SLOT(contextButton(NmActionResponse&)));
-    }
-}
+        mItemContextMenu = new HbMenu();
+        // Store long press item for later use with response
+        mLongPressedItem = mMessageListModel->data(
+                listViewItem->modelIndex(), Qt::DisplayRole).value<NmMessageListModelItem*>();
+        if (mItemContextMenu && mLongPressedItem && mLongPressedItem->itemType() ==
+            NmMessageListModelItem::NmMessageItemMessage) {
 
-/*!
-    Slot. Signaled when menu option is selected
-*/
-void NmMessageListView::contextButton(NmActionResponse &result)
-{
-    // Handle context menu commands here
-    if (result.menuType()==NmActionContextMenu){
-        switch (result.responseCommand()){
-           case NmActionResponseCommandOpen:{
-               if (mLongPressedItem){
-                   NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer,
-                       mStartParam->mailboxId(), mStartParam->folderId(),
-                       mLongPressedItem->envelope().messageId());
-                   mApplication.enterNmUiView(startParam);
-                   mLongPressedItem=NULL;
-                   }
-               }
-               break;
-           //temporary solution..
-           case NmActionResponseCommandForward:{
-                if (mLongPressedItem){
-                   NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor,
-                       mStartParam->mailboxId(), mStartParam->folderId(),
-                       mLongPressedItem->envelope().messageId());
-                   mApplication.enterNmUiView(startParam);
-                   mLongPressedItem=NULL;
-                   }
-               }
-               break;
-           default:
-               break;
+            // Clear previous items from context menu
+            mItemContextMenu->clearActions();
+            NmUiExtensionManager &extMngr = mApplication.extManager();
+            QList<NmAction*> list;
+            // Fetch items from extension based on item
+            NmMessageEnvelope *envelope = mLongPressedItem->envelopePtr();
+            if (envelope){
+                NmActionRequest request(this, NmActionContextMenu, NmActionContextViewMessageList,
+                        NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
+                        envelope->messageId(),QVariant::fromValue(envelope));
+                extMngr.getActions(request, list);
+                for (int i=0;i<list.count();i++) {
+                    mItemContextMenu->addAction(list[i]);
+                }
+			    mItemContextMenu->setPreferredPos(coords);
+                mItemContextMenu->open();
+            }
         }
     }
 }
@@ -385,6 +404,8 @@
 */
 void NmMessageListView::itemActivated(const QModelIndex &index)
 {
+    NM_FUNCTION;
+
     mActivatedIndex = index;
     QMetaObject::invokeMethod(this, "handleSelection", Qt::QueuedConnection);
 }
@@ -395,8 +416,10 @@
 */
 void NmMessageListView::handleSelection()
 {
+    NM_FUNCTION;
+
     // Do expand/collapse for title divider items
-    NmMessageListModelItem* modelItem = mMessageListModel.data(
+    NmMessageListModelItem* modelItem = mMessageListModel->data(
             mActivatedIndex, Qt::DisplayRole).value<NmMessageListModelItem*>();
     if (modelItem && modelItem->itemType()==
         NmMessageListModelItem::NmMessageItemTitleDivider) {
@@ -408,8 +431,9 @@
             mMessageListWidget->setExpanded(mActivatedIndex, false);
             modelItem->setExpanded(false);
         }
-    } 
-    if (modelItem && modelItem->itemType() == NmMessageListModelItem::NmMessageItemMessage)
+    }
+    if (modelItem && modelItem->itemType() == NmMessageListModelItem::NmMessageItemMessage
+        && !mSettingsLaunched)
     {
         NmFolderType folderType = mUiEngine.folderTypeById(mStartParam->mailboxId(),
                                   mStartParam->folderId());
@@ -417,15 +441,15 @@
             NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor,
                 mStartParam->mailboxId(), mStartParam->folderId(),
                 modelItem->envelope().messageId(),NmUiEditorFromDrafts);
-            mApplication.enterNmUiView(startParam);            
+            mApplication.enterNmUiView(startParam);
         }
         else if (folderType!=NmFolderOutbox){
             NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer,
                 mStartParam->mailboxId(), mStartParam->folderId(),
                 modelItem->envelope().messageId());
-            mApplication.enterNmUiView(startParam);        
+            mApplication.enterNmUiView(startParam);
         }
-    }    
+    }
 }
 
 
@@ -436,6 +460,8 @@
 */
 void NmMessageListView::createOptionsMenu()
 {
+    NM_FUNCTION;
+
     menu()->clearActions();
     NmActionRequest request(this, NmActionOptionsMenu, NmActionContextViewMessageList,
     		NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() );
@@ -453,6 +479,8 @@
 */
 void NmMessageListView::handleActionCommand(NmActionResponse &actionResponse)
 {
+    NM_FUNCTION;
+
     // Handle context menu commands here
     if (actionResponse.menuType() == NmActionOptionsMenu) {
         switch (actionResponse.responseCommand()) {
@@ -471,11 +499,17 @@
                 break;
             }
             case NmActionResponseCommandMailboxDeleted: {
-                mApplication.popView();
+                mApplication.prepareForPopView();
 				break;
             }
             case NmActionResponseCommandSwitchFolder: {
-                folderSelected(actionResponse.mailboxId(), actionResponse.folderId());
+                mSelectedFolderId=actionResponse.folderId();
+                mSelectedMailboxId=actionResponse.mailboxId();
+                QMetaObject::invokeMethod(this, "folderSelected", Qt::QueuedConnection);
+                break;
+            }
+            case NmActionResponseCommandSettings: {
+                mSettingsLaunched = true;
                 break;
             }
             default: {
@@ -483,56 +517,46 @@
             }
         }
     }
+
+    // Handle context menu commands here
+    else if (actionResponse.menuType()==NmActionContextMenu){
+        switch (actionResponse.responseCommand()){
+           case NmActionResponseCommandOpen:{
+               if (mLongPressedItem){
+                   NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer,
+                       mStartParam->mailboxId(), mStartParam->folderId(),
+                       mLongPressedItem->envelope().messageId());
+                   mApplication.enterNmUiView(startParam);
+                   mLongPressedItem=NULL;
+                   }
+               }
+               break;
+           default:
+               break;
+        }
+    }
+
     // Handle toolbar commands here
     else if ( actionResponse.menuType() == NmActionToolbar ) {
         if ( actionResponse.responseCommand() == NmActionResponseCommandNewMail ) {
             // Check that given start response has mailbox and folder id's
             if (actionResponse.mailboxId()!=0){
-                if (mUiEngine.isSendingMessage()) {
-                    // sending is ongoing so just show a note
-                    QString noteText = hbTrId("txt_mail_dialog_still_sending");
-                    
-                    // get message subject from the message being sent
-                    const NmMessage *message = mUiEngine.messageBeingSent();
-                    if (message) {
-                        noteText = noteText.arg(NmUtilities::truncate(message->envelope().subject(), 20));
-                    }
-                    HbMessageBox::warning(noteText);
-                }
-                else {
-                    NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor,
-                            actionResponse.mailboxId(), mStartParam->folderId());
-                    // startParam ownerhips transfers
-                    mApplication.enterNmUiView(startParam);
-                }
+                NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor,
+                        actionResponse.mailboxId(), mStartParam->folderId());
+                // startParam ownerhips transfers
+                mApplication.enterNmUiView(startParam);
             }
         }
         if (actionResponse.responseCommand() == NmActionResponseCommandSearch) {
             // Check that the given start response has mailbox and folder IDs.
             if (actionResponse.mailboxId() != 0) {
-                if (mUiEngine.isSendingMessage()) {
-                    // Sending is ongoing so just show a note.
-                    QString noteText = hbTrId("txt_mail_dialog_still_sending");
-
-                    // Get the message subject from the message being sent.
-                    const NmMessage *message = mUiEngine.messageBeingSent();
-
-                    if (message) {
-                        noteText = noteText.arg(
-                            NmUtilities::truncate(message->envelope().subject(), 20));
-                    }
+                NmUiStartParam *startParam =
+                    new NmUiStartParam(NmUiViewMessageSearchList,
+                                       actionResponse.mailboxId(),
+                                       mStartParam->folderId());
 
-                    HbMessageBox::warning(noteText);
-                }
-                else {
-                    NmUiStartParam *startParam =
-                        new NmUiStartParam(NmUiViewMessageSearchList,
-                                           actionResponse.mailboxId(),
-                                           mStartParam->folderId());
-
-                    // startParam ownership transfers.
-                    mApplication.enterNmUiView(startParam);
-                }
+                // startParam ownership transfers.
+                mApplication.enterNmUiView(startParam);
             }
         }
     }
@@ -544,6 +568,8 @@
 */
 void NmMessageListView::setMailboxName()
 {
+    NM_FUNCTION;
+
     if (mStartParam){
         NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId());
         if (meta){
@@ -559,6 +585,8 @@
 */
 void NmMessageListView::createToolBar()
 {
+    NM_FUNCTION;
+
     HbToolBar *tb = toolBar();
     if (!tb) {
         return;
@@ -582,71 +610,100 @@
 */
 void NmMessageListView::setFolderName()
 {
-    if (mStartParam && mFolderLabel) {
-        switch (mUiEngine.folderTypeById(mStartParam->mailboxId(),
-                mStartParam->folderId())) {
+    NM_FUNCTION;
+
+    if (mStartParam&&mFolderLabel){
+        switch (mCurrentFolderType) {
         case NmFolderOutbox:
             {
-            mFolderLabel->setPlainText(hbTrId("txt_mail_subhead_outbox"));
+            mFolderLabel->setHeading(hbTrId("txt_mail_subhead_outbox"));
             }
             break;
         case NmFolderDrafts:
             {
-            mFolderLabel->setPlainText(hbTrId("txt_mail_subhead_drafts"));
+            mFolderLabel->setHeading(hbTrId("txt_mail_subhead_drafts"));
             }
             break;
         case NmFolderSent:
             {
-            mFolderLabel->setPlainText(hbTrId("txt_mail_subhead_sent_items"));
+            mFolderLabel->setHeading(hbTrId("txt_mail_subhead_sent_items"));
             }
             break;
         case NmFolderDeleted:
             {
-            mFolderLabel->setPlainText(hbTrId("txt_mail_subhead_deleted_items"));
+            mFolderLabel->setHeading(hbTrId("txt_mail_subhead_deleted_items"));
             }
             break;
         case NmFolderInbox:
         default:
             {
-            mFolderLabel->setPlainText(hbTrId("txt_mail_subhead_inbox"));
+            mFolderLabel->setHeading(hbTrId("txt_mail_subhead_inbox"));
             }
             break;
         }
     }
 }
 
+
 /*!
-    Observe items added
+    Handles the addition of a new item. Makes sure the message list widget is
+    visible and keeps the scroll position on the top of the list.
+
+    \param parent Not used.
+    \param start 
+    \param end Not used.
 */
 void NmMessageListView::itemsAdded(const QModelIndex &parent, int start, int end)
 {
-    NMLOG("nmailui: NmMessageListView::itemsAdded");
+    NM_FUNCTION;
+
     Q_UNUSED(parent);
     Q_UNUSED(end);
-    if (mNoMessagesLabel && mNoMessagesLabel->isVisible()) {
-        mNoMessagesLabel->hide();
-        mMessageListWidget->show();
+
+    // Hide no messages if previous model count has been zero
+    // and new items have been added to the list
+    if (mPreviousModelCount==0) {
+        hideNoMessagesText();
     }
-    if (0 == start && mMessageListWidget) {
+
+    // Make sure the top of the list is kept visible by scrolling back to the
+    // top if necessary.
+    if (start == 0 && mMessageListWidget) {
         QList<HbAbstractViewItem*> items = mMessageListWidget->visibleItems();
+
         if (items.count()) {
             QModelIndex index = items.at(0)->modelIndex();
-            if (1 == index.row()) {
-                QModelIndex previous = mMessageListWidget->modelIterator()->previousIndex(index);
+
+            while (index.row() > 0) {
+                QModelIndex previous =
+                    mMessageListWidget->modelIterator()->previousIndex(index);
+
                 if (previous.isValid()) {
                     mMessageListWidget->scrollTo(previous);
                 }
+
+                index = previous;
             }
         }
     }
+    // Store model count
+    if (mMessageListModel){
+        mPreviousModelCount=mMessageListModel->rowCount();    
+    }
 }
 
+
 /*!
     Observe items removed
 */
 void NmMessageListView::itemsRemoved()
 {
-    if (mNoMessagesLabel && mMessageListModel.rowCount() == 0){
+    NM_FUNCTION;
+    // Store model count
+    if (mMessageListModel){
+        mPreviousModelCount=mMessageListModel->rowCount();    
+    }
+    if (mPreviousModelCount == 0){
         showNoMessagesText();
     }
 }
@@ -656,8 +713,24 @@
 */
 void NmMessageListView::showNoMessagesText()
 {
-    if (mNoMessagesLabel) {
+    NM_FUNCTION;
+
+    if (mNoMessagesLabel&&mMessageListWidget) {
         mMessageListWidget->hide();
         mNoMessagesLabel->show();
     }
 }
+
+/*!
+    Hide "(no messages)" text at the middle of the screen.
+*/
+void NmMessageListView::hideNoMessagesText()
+{
+    NM_FUNCTION;
+
+    if (mNoMessagesLabel&&mMessageListWidget) {
+        mNoMessagesLabel->hide();
+        mMessageListWidget->show();
+    }
+}
+
--- a/emailuis/nmailui/src/nmmessagelistviewitem.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmmessagelistviewitem.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -21,7 +21,7 @@
     \brief list view item for message list view
 */
 
-static const qreal NmItemLineOpacity = 0.4;
+static const int NmFolderTypeRole = Qt::UserRole+1; 
 
 /*!
     Constructor
@@ -39,6 +39,7 @@
     mSecondarySize(0),
     mTinySize(0)    
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -46,13 +47,15 @@
 */
 NmMessageListViewItem::~NmMessageListViewItem()
 {
-
+    NM_FUNCTION;
 }
 
 /*!
 */
 HbTreeViewItem *NmMessageListViewItem::createItem()
 {
+    NM_FUNCTION;
+    
     return new NmMessageListViewItem(*this);
 }
 
@@ -62,6 +65,8 @@
 */
 bool NmMessageListViewItem::canSetModelIndex(const QModelIndex &index) const
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(index);
     // This item class can handle all items in message list
     return true;
@@ -73,6 +78,8 @@
 */
 void NmMessageListViewItem::updateChildItems()
 {
+    NM_FUNCTION;
+    
     // Get model pointer
     NmMessageListModelItem *msgModelItem = modelIndex().data(
             Qt::DisplayRole).value<NmMessageListModelItem*>();
@@ -97,6 +104,8 @@
 */
 void NmMessageListViewItem::createMessageItemLayout()
 { 
+    NM_FUNCTION;
+    
     getFontSizes();
     // Create sender label and set name from widgetml
     if (!mSender){
@@ -146,21 +155,19 @@
 void NmMessageListViewItem::setContentsToMessageItem(const NmMessageEnvelope &envelope, 
                                                      bool dividersActive)
 {
+    NM_FUNCTION;
+    
     // member variables are created in previous function
     // sender
-    QString displayName = envelope.sender().displayName();
-    if (displayName.length()) {
-        mSender->setText(NmUtilities::cleanupDisplayName(displayName));
-    } else {
-        mSender->setText(envelope.sender().address());            
-    }
+    mSender->setText(senderFieldText(envelope));
     // time
     HbExtendedLocale locale = HbExtendedLocale::system();
-    QDate sentLocalDate = envelope.sentTime().toLocalTime().date();
+    QDateTime localTime = envelope.sentTime().addSecs(locale.universalTimeOffset());
+    QDate sentLocalDate = localTime.date();
     QDate currentdate = QDate::currentDate();
     if (dividersActive || sentLocalDate == currentdate) {
         QString shortTimeSpec = r_qtn_time_usual;
-        QTime time = envelope.sentTime().toLocalTime().time();
+        QTime time = localTime.time();
         mTime->setText(locale.format(time, shortTimeSpec));
     } else {
         QString shortDateSpec = r_qtn_date_without_year;
@@ -229,74 +236,138 @@
 }
 
 /*!
-    paint. Paint function for line painting.
+    setFontsUnread
 */
-void NmMessageListViewItem::paint(
-    QPainter *painter,
-    const QStyleOptionGraphicsItem *option,
-    QWidget *widget)
-{
-    Q_UNUSED(option);
-    Q_UNUSED(widget);
-    Q_UNUSED(painter);
-}
-
 void  NmMessageListViewItem::setFontsUnread()
 {    
+    NM_FUNCTION;
+    
     static QColor colorRole = HbColorScheme::color("qtc_list_item_title_normal");
-    HbFontSpec spekki(HbFontSpec::Primary);
-    setFonts(colorRole, spekki);
+    HbFontSpec fontSpec(HbFontSpec::Primary);
+    setFonts(colorRole, fontSpec);
 }
 
+/*!
+    setFontsRead
+*/
 void  NmMessageListViewItem::setFontsRead()
 {
+    NM_FUNCTION;
+    
     static QColor colorRole = HbColorScheme::color("qtc_list_item_content_normal");
-    HbFontSpec spekki(HbFontSpec::Secondary);
-    setFonts(colorRole, spekki);
+    HbFontSpec fontSpec(HbFontSpec::Secondary);
+    setFonts(colorRole, fontSpec);
 }
 
+/*!
+    getFontSizes.
+*/
 void  NmMessageListViewItem::getFontSizes()
 {
+    NM_FUNCTION;
+    
     // Get font sizes from style  
     qreal currentSize;
-    HbStyle mystyle;
-    bool found = mystyle.parameter(QString("hb-param-text-height-primary"), currentSize );
+    bool found = style()->parameter(QString("hb-param-text-height-primary"), currentSize );
     if (found) {
         mPrimarySize = currentSize;
     }      
-    found = mystyle.parameter(QString("hb-param-text-height-secondary"), currentSize );
+    found = style()->parameter(QString("hb-param-text-height-secondary"), currentSize );
     if (found) {
         mSecondarySize = currentSize;
     }        
-    found = mystyle.parameter(QString("hb-param-text-height-tiny"), currentSize );
+    found = style()->parameter(QString("hb-param-text-height-tiny"), currentSize );
     if (found) {
         mTinySize = currentSize;
     } 
 }
 
+/*!
+    setFonts.
+*/
 void  NmMessageListViewItem::setFonts(const QColor &colorRole, 
-        HbFontSpec &spekki)
+        HbFontSpec &fontSpec)
 {
+    NM_FUNCTION;
+    
     // Change sizes explicitly since css is overwritten in polish now.    
     if (mSender && mSubject && mTime) {
         
         if (mPrimarySize) {
-            spekki.setTextHeight(mPrimarySize);
+            fontSpec.setTextHeight(mPrimarySize);
         }      
-        mSender->setFontSpec(spekki);
+        mSender->setFontSpec(fontSpec);
         mSender->setTextColor(colorRole);
         
         if (mSecondarySize) {
-            spekki.setTextHeight(mSecondarySize);
+            fontSpec.setTextHeight(mSecondarySize);
         }        
-        mSubject->setFontSpec(spekki);
+        mSubject->setFontSpec(fontSpec);
         mSubject->setTextColor(colorRole);
 
         if (mTinySize) {
-            spekki.setTextHeight(mTinySize);
+            fontSpec.setTextHeight(mTinySize);
         } 
-        mTime->setFontSpec(spekki);        
+        mTime->setFontSpec(fontSpec);        
         mTime->setTextColor(colorRole);
     }
 }
 
+/*!
+    senderFieldText. 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
+        case NmFolderOutbox:
+        case NmFolderDrafts:
+        case NmFolderSent:
+        {
+            QList<NmAddress>& toRecipients = envelope.toRecipients();
+            QList<NmAddress>& ccRecipients = envelope.ccRecipients();
+            NmAddress addressToUse;
+            bool foundAddress(false);
+            if (toRecipients.count()){
+                addressToUse=toRecipients[0];
+                foundAddress=true;
+            }
+            else if (ccRecipients.count()) {
+                addressToUse=ccRecipients[0]; 
+                foundAddress=true;         
+            }
+            if (foundAddress){
+                QString displayName = addressToUse.displayName();
+                if (displayName.length()) {
+                    ret += NmUtilities::cleanupDisplayName(displayName);
+                } 
+                else {
+                    ret += addressToUse.address();                    
+                }               
+            }
+            
+        }
+        break;    
+        // All other folders will show sender display name
+        default: 
+        {
+            QString displayName = envelope.sender().displayName();
+            if (displayName.length()) {
+                ret += NmUtilities::cleanupDisplayName(displayName);
+            } 
+            else {
+                ret += envelope.sender().address();                    
+            }
+        }
+        break;
+    }
+    return ret;
+}
+
--- a/emailuis/nmailui/src/nmmessagesearchlistview.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmmessagesearchlistview.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -16,10 +16,10 @@
 */
 
 static const char *NMUI_MESSAGE_SEARCH_LIST_VIEW_XML = ":/docml/nmmessagesearchlistview.docml";
-static const char *NMUI_MESSAGE_SEARCH_LIST_VIEW = "NmMessageListView";
+static const char *NMUI_MESSAGE_SEARCH_LIST_VIEW = "NmMessageSearchListView";
 static const char *NMUI_MESSAGE_SEARCH_LIST_TREE_LIST = "MessageTreeList";
 static const char *NMUI_MESSAGE_SEARCH_LIST_NO_MESSAGES = "MessageListNoMessages";
-static const char *NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL = "InfoLabel";
+static const char *NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL = "LabelGroupBox";
 static const char *NMUI_MESSAGE_SEARCH_LIST_LINE_EDIT = "LineEdit";
 static const char *NMUI_MESSAGE_SEARCH_LIST_PUSH_BUTTON = "PushButton";
 
@@ -40,24 +40,26 @@
     NmApplication &application,
     NmUiStartParam* startParam,
     NmUiEngine &uiEngine,
-    NmMessageSearchListModel &searchListModel,
+    NmMessageListModel &msgListModel,
     HbDocumentLoader *documentLoader,
     QGraphicsItem *parent)
-: NmBaseView(startParam, parent),
+: NmBaseView(startParam, application, parent),
   mApplication(application),
   mUiEngine(uiEngine),
-  mSearchListModel(searchListModel),
+  mMsgListModel(msgListModel),
   mDocumentLoader(documentLoader),
   mItemContextMenu(NULL),
   mMessageListWidget(NULL),
+  mInfoLabel(NULL),
   mNoMessagesLabel(NULL),
-  mInfoLabel(NULL),
   mLineEdit(NULL),
   mPushButton(NULL),
   mLongPressedItem(NULL),
   mViewReady(false),
   mSearchInProgress(false)
 {
+    NM_FUNCTION;
+    
     loadViewLayout();
     initTreeView();
 }
@@ -68,6 +70,8 @@
 */
 NmMessageSearchListView::~NmMessageSearchListView()
 {
+    NM_FUNCTION;
+    
     delete mDocumentLoader;
 
     mWidgetList.clear();
@@ -89,6 +93,8 @@
 */
 NmUiViewId NmMessageSearchListView::nmailViewId() const
 {
+    NM_FUNCTION;
+    
     return NmUiViewMessageSearchList;
 }
 
@@ -100,6 +106,8 @@
 */
 void NmMessageSearchListView::viewReady()
 {
+    NM_FUNCTION;
+    
     if (!mViewReady){
         // Set the mailbox name to the title pane.
         setViewTitle();
@@ -125,6 +133,8 @@
 */
 void NmMessageSearchListView::handleActionCommand(NmActionResponse &actionResponse)
 {
+    NM_FUNCTION;
+    
     // Handle options menu commands here.
     if (actionResponse.menuType() == NmActionOptionsMenu) {
         switch (actionResponse.responseCommand()) {
@@ -133,7 +143,7 @@
                 break;
             }
             case NmActionResponseCommandMailboxDeleted: {
-                mApplication.popView();
+                mApplication.prepareForPopView();
                 break;
             }
             default: {
@@ -141,6 +151,17 @@
             }
         }
     }
+    // Handle context menu commands here.
+    if (actionResponse.menuType() == NmActionContextMenu) {
+        if (mLongPressedItem){
+            NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer,
+                mStartParam->mailboxId(), mLongPressedItem->envelope().folderId(),
+                mLongPressedItem->envelope().messageId());
+
+            mApplication.enterNmUiView(startParam);
+            mLongPressedItem = NULL;
+       }
+    }
 }
 
 
@@ -151,6 +172,8 @@
 */
 void NmMessageSearchListView::loadViewLayout()
 {
+    NM_FUNCTION;
+    
     // Use the document loader to load the view layout.
     bool ok(false);
     setObjectName(QString(NMUI_MESSAGE_SEARCH_LIST_VIEW));
@@ -164,62 +187,74 @@
         mWidgetList = mDocumentLoader->load(NMUI_MESSAGE_SEARCH_LIST_VIEW_XML, &ok);
     }
 
-    if (ok && mWidgetList.count()) {
+    if (ok) {
+        // Load the search panel (contains the line edit and the push button
+        // widgets.
+        mLineEdit = qobject_cast<HbLineEdit *>(
+            mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_LINE_EDIT));
+
+        if (mLineEdit) {
+            connect(mLineEdit, SIGNAL(textChanged(QString)), 
+                    this, SLOT(criteriaChanged(QString)));
+        }
+    
+        mPushButton = qobject_cast<HbPushButton *>(
+        mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_PUSH_BUTTON));
+
+        if (mPushButton) {
+            // button is disabled when line edit is empty
+            mPushButton->setEnabled(false);
+
+            // The push button both starts and stops the search.
+            connect(mPushButton, SIGNAL(clicked()), this, SLOT(toggleSearch()));
+            mPushButton->setIcon(HbIcon("qtg_mono_search"));
+        }
+
+        // Load the info label.
+        mInfoLabel = qobject_cast<HbGroupBox *>(
+            mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL));
+
+        if (mInfoLabel) {
+            NM_COMMENT("NmMessageSearchListView: info label loaded");
+
+            // If the heading is empty, the widget will not be shown which in
+            // turn would ruin the layout.
+            mInfoLabel->setHeading(" ");
+        }
+
         // Get the message list widget.
         mMessageListWidget = qobject_cast<HbTreeView *>(
             mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_TREE_LIST));
 
         if (mMessageListWidget) {
-            NMLOG("NmMessageSearchListView: Message list widget loaded.");
+            NM_COMMENT("NmMessageSearchListView: message list widget loaded");
 
             // Set the item prototype.
             mMessageListWidget->setItemPrototype(new NmMessageListViewItem());
+
+            // Set the list widget properties.
             mMessageListWidget->setItemRecycling(true);
             mMessageListWidget->contentWidget()->setProperty("indentation", 0);
             mMessageListWidget->setScrollDirections(Qt::Vertical);
             mMessageListWidget->setClampingStyle(HbScrollArea::BounceBackClamping);
             mMessageListWidget->setFrictionEnabled(true);
+
+            // We want the search results to appear one by one.
+            mMessageListWidget->setEnabledAnimations(HbAbstractItemView::Appear &
+                                                     HbAbstractItemView::Expand);
         }
 
-        // Load the "no messages" label.
+        // Load the no messages label.
         mNoMessagesLabel = qobject_cast<HbLabel *>(
             mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_NO_MESSAGES));
 
         if (mNoMessagesLabel) {
-            NMLOG("NmMessageSearchListView: \"No messages\" label loaded.");
+            NMLOG("NmMessageSearchListView: No messages label loaded.");
             mNoMessagesLabel->hide();
         }
-
-        // Load the info label.
-        mInfoLabel = qobject_cast<HbLabel *>(
-            mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_INFO_LABEL));
-
-        if (mInfoLabel) {
-            NMLOG("NmMessageSearchListView: Info label loaded.");
-            mInfoLabel->setPlainText(hbTrId("txt_mail_subhead_inbox"));
-            mInfoLabel->hide();
-        }
-
-        // Load the search panel.
-        mLineEdit = qobject_cast<HbLineEdit *>(
-            mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_LINE_EDIT));
-        if (mLineEdit) {
-            connect(mLineEdit, SIGNAL(textChanged(QString)), 
-                this, SLOT(criteriaChanged(QString)));
-        }
-        
-        mPushButton = qobject_cast<HbPushButton *>(
-            mDocumentLoader->findWidget(NMUI_MESSAGE_SEARCH_LIST_PUSH_BUTTON));
-        if (mPushButton) {
-			// button is disabled when line edit is empty
-			mPushButton->setEnabled(false);
-            // The push button both starts and stops the search.
-            connect(mPushButton, SIGNAL(clicked()), this, SLOT(toggleSearch()));
-            mPushButton->setIcon(HbIcon("qtg_mono_search"));
-        }
     }
     else {
-        NMLOG("NmMessageSearchListView: Failed to load widgets from XML!");
+        NM_ERROR(1, "NmMessageSearchListView: failed to load widgets from XML");
     }
 }
 
@@ -229,6 +264,8 @@
 */
 void NmMessageSearchListView::initTreeView()
 {
+    NM_FUNCTION;
+    
     // Get the mailbox widget pointer and set the parameters.
     if (mMessageListWidget) {
         connect(mMessageListWidget, SIGNAL(activated(const QModelIndex &)),
@@ -242,7 +279,7 @@
     }
 
     // Clear the previous content if any.
-    mSearchListModel.clearSearchResults();
+    mMsgListModel.clear();
 }
 
 
@@ -251,6 +288,8 @@
 */
 void NmMessageSearchListView::setViewTitle()
 {
+    NM_FUNCTION;
+    
     if (mStartParam){
         NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId());
 
@@ -270,6 +309,8 @@
 */
 void NmMessageSearchListView::noMessagesLabelVisibility(bool visible)
 {
+    NM_FUNCTION;
+    
     if (visible) {
         // Hide the message list widget and display the "no messages" label.
         if (mMessageListWidget) {
@@ -294,12 +335,50 @@
 
 
 /*!
+    Updates the search result count information. If the message list does not
+    contain any items, a "no messages" label is displayed. Otherwise the result
+    count in the information label is updated according to the number of
+    messages in the list.
+*/
+void NmMessageSearchListView::updateSearchResultCountInfo()
+{
+    NM_FUNCTION;
+
+    const int resultCount = mMsgListModel.rowCount();
+
+    if (resultCount) {
+        if (mInfoLabel) {
+            // Display the result count on the info label.
+            QString resultsString(hbTrId("txt_mail_list_search_results").arg(resultCount));
+            mInfoLabel->setHeading(resultsString);
+
+            if (!mInfoLabel->isVisible()) {
+                mInfoLabel->show();
+            }
+        }
+    }
+    else {
+        // No search results!
+        if (mInfoLabel && mInfoLabel->isVisible()) {
+            mInfoLabel->hide();
+        }
+
+        // Display the "no messages" label and highlight the search term.
+        noMessagesLabelVisibility(true);
+    }
+    
+}
+
+
+/*!
     Sets the mode for the search input.
 
     \param mode The mode to set.
 */
 void NmMessageSearchListView::setSearchInputMode(NmSearchInputMode mode)
 {
+    NM_FUNCTION;
+    
     if (!mLineEdit) {
         // No line edit widget!
         return;
@@ -332,10 +411,9 @@
 */
 void NmMessageSearchListView::reloadViewContents(NmUiStartParam *startParam)
 {
-    // Check the start parameter's validity; message view cannot be updated if
-    // the given parameter is zero.
-    if (startParam&&startParam->viewId() == NmUiViewMessageSearchList &&
-        startParam->folderId() != 0) {
+    NM_FUNCTION;
+    
+    if (startParam && startParam->viewId() == NmUiViewMessageSearchList) {
         // Delete the existing start parameter data.
         delete mStartParam;
         mStartParam = NULL;
@@ -344,10 +422,7 @@
         mStartParam = startParam;
 
         // Update the model with new parameters.
-        NmMessageListModel &messageListModel =
-            mUiEngine.messageListModel(startParam->mailboxId(),
-                                       startParam->folderId());
-        mSearchListModel.setSourceModel(&messageListModel);
+        mUiEngine.messageListModelForSearch(startParam->mailboxId());
         refreshList();
 
         // Refresh the mailbox name.
@@ -356,26 +431,52 @@
     else {
         // Invalid start parameter data! Unused start parameter needs to be
         // deleted.
-        NMLOG("NmMessageSearchListView: Invalid message list start parameter!");
+        NM_ERROR(1, "NmMessageSearchListView: invalid message list start parameter");
         delete startParam;
     }
 }
 
 
 /*!
+    Called when text is changed in the edit field. If there is no search term
+    in the edit field, the search button is dimmed and disabled. If the field
+    contains text, the button can be clicked.
+    
+    \param text The text in the field after the modification.
+*/
+void NmMessageSearchListView::criteriaChanged(QString text) 
+{
+    NM_FUNCTION;
+    NM_COMMENT(QString("NmMessageSearchListView::criteriaChanged %1").arg(text));
+    
+    // Check if the button should be disabled/enabled.
+    bool enabled = mPushButton->isEnabled();
+
+    if (!enabled && !text.isEmpty()) {
+        mPushButton->setEnabled(true);
+    }
+    else if (enabled && text.isEmpty()) {
+        mPushButton->setEnabled(false);
+    }
+}
+
+
+/*!
     Displays the item context menu. This method gets called if an item on the
     list is long pressed.
 */
 void NmMessageSearchListView::showItemContextMenu(
     HbAbstractViewItem *listViewItem, const QPointF &coords)
 {
+    NM_FUNCTION;
+    
     // Store long press item for later use with response.
     mLongPressedItem = 
-        mSearchListModel.data(listViewItem->modelIndex(),
-                              Qt::DisplayRole).value<NmMessageListModelItem*>();
+        mMsgListModel.data(listViewItem->modelIndex(),
+                           Qt::DisplayRole).value<NmMessageListModelItem*>();
 
-    if (mItemContextMenu && mLongPressedItem && mLongPressedItem->itemType() ==
-        NmMessageListModelItem::NmMessageItemMessage) {
+    if (mItemContextMenu && mLongPressedItem &&
+        mLongPressedItem->itemType() == NmMessageListModelItem::NmMessageItemMessage) {
         // Clear the previous menu actions.
         mItemContextMenu->clearActions();
         NmUiExtensionManager &extMngr = mApplication.extManager();
@@ -385,16 +486,10 @@
         NmMessageEnvelope *envelope = mLongPressedItem->envelopePtr();
 
         if (envelope){
-            NmActionRequest request(this, NmActionContextMenu, NmActionContextViewMessageList,
-                NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
-                envelope->messageId(),QVariant::fromValue(envelope));
-
-            extMngr.getActions(request, list);
-        }
-        else{
-            NmActionRequest request(this, NmActionContextMenu, NmActionContextViewMessageList,
-                NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(),
-                envelope->messageId());
+            NmActionRequest request(this, NmActionContextMenu,
+                NmActionContextViewMessageSearchList, NmActionContextDataMessage,
+                mStartParam->mailboxId(), envelope->folderId(),
+                envelope->messageId(), QVariant::fromValue(envelope));
 
             extMngr.getActions(request, list);
         }
@@ -402,37 +497,12 @@
         for (int i(0); i < list.count(); ++i) {
             mItemContextMenu->addAction(list[i]);
         }
+
         mItemContextMenu->setPreferredPos(coords);
-        mItemContextMenu->open(this, SLOT(contextButton(NmActionResponse&)));
+        mItemContextMenu->open();
     }
 }
 
-/*!
-    Slot. Signaled when menu option is selected
-*/
-void NmMessageSearchListView::contextButton(NmActionResponse &result)
-{
-// Handle context menu commands here.
-    if (result.menuType() == NmActionContextMenu){
-        switch (result.responseCommand()) {
-           case NmActionResponseCommandOpen: {
-               if (mLongPressedItem){
-                   NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer,
-                       mStartParam->mailboxId(), mStartParam->folderId(),
-                       mLongPressedItem->envelope().messageId());
-
-                   mApplication.enterNmUiView(startParam);
-                   mLongPressedItem = NULL;
-               }
-
-               break;
-           }
-           default: {
-               break;
-           }
-        }
-    }
-}
 
 /*!
     Stores the given index and forwards the call to handleSelection(). This
@@ -442,36 +512,22 @@
 */
 void NmMessageSearchListView::itemActivated(const QModelIndex &index)
 {
+    NM_FUNCTION;
+    
     mActivatedIndex = index;
     QMetaObject::invokeMethod(this, "handleSelection", Qt::QueuedConnection);
 }
 
-/*!
-    Called when text is changed in the edit field
-    
-    \param text new text entered in the field
- */
-void NmMessageSearchListView::criteriaChanged(QString text) 
-{
-    NMLOG(QString("NmMessageSearchListView::criteriaChanged %1").arg(text));
-    
-    // Check when button should be disabled/enabled
-    bool enabled = mPushButton->isEnabled();
-    if (!enabled && !text.isEmpty()) {
-		mPushButton->setEnabled(true);
-    }
-    else if (enabled && text.isEmpty()) {
-		mPushButton->setEnabled(false);
-    }
-}
 
 /*!
     If the selected item is a message, will open the message.
 */
 void NmMessageSearchListView::handleSelection()
 {
+    NM_FUNCTION;
+    
     // Do expand/collapse for title divider items
-    NmMessageListModelItem* modelItem = mSearchListModel.data(
+    NmMessageListModelItem* modelItem = mMsgListModel.data(
         mActivatedIndex, Qt::DisplayRole).value<NmMessageListModelItem*>();
 
     if (modelItem &&
@@ -484,7 +540,7 @@
 
         // Open the message.
         NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageViewer,
-            mStartParam->mailboxId(), mStartParam->folderId(),
+            mStartParam->mailboxId(), modelItem->envelope().folderId(),
             modelItem->envelope().messageId());
 
         mApplication.enterNmUiView(startParam);
@@ -498,13 +554,19 @@
 */
 void NmMessageSearchListView::itemsAdded(const QModelIndex &parent, int start, int end)
 {
-    NMLOG("nmailui: NmMessageSearchListView::itemsAdded()");
-
+    NM_FUNCTION;
+    
     Q_UNUSED(parent);
     Q_UNUSED(end);
 
-    // Display the message list widget if not visible.
-    noMessagesLabelVisibility(false);
+    // The search is an asynchronous operation. If a user stops the search, it
+    // might take a short while before the search is actually stopped and during
+    // this time it is possible that messages matching the search are added.
+    // Therefore, update the result count info if items are added after the
+    // search has been stopped by the user.
+    if (!mSearchInProgress) {
+        updateSearchResultCountInfo();
+    }
 
     if (!start && mMessageListWidget) {
         QList<HbAbstractViewItem*> items = mMessageListWidget->visibleItems();
@@ -512,12 +574,15 @@
         if (items.count()) {
             QModelIndex index = items.at(0)->modelIndex();
 
-            if (1 == index.row()) {
-                QModelIndex previous = mMessageListWidget->modelIterator()->previousIndex(index);
+            while (index.row() > 0) {
+                QModelIndex previous =
+                    mMessageListWidget->modelIterator()->previousIndex(index);
 
                 if (previous.isValid()) {
                     mMessageListWidget->scrollTo(previous);
                 }
+
+                index = previous;
             }
         }
     }
@@ -525,13 +590,16 @@
 
 
 /*!
-    This method gets called when an item is removed from the list. If the list
-    contains no items, "no messages" label is displayed.
+    This method gets called when an item is removed from the list. If the
+    search has completed (or stopped), the search result count information is
+    updated according to the number of messages in the list.
 */
 void NmMessageSearchListView::itemsRemoved()
 {
-    if (mSearchListModel.searchResultCount() == 0) {
-        noMessagesLabelVisibility(true);
+    NM_FUNCTION;
+    
+    if (!mSearchInProgress) {
+        updateSearchResultCountInfo();
     }
 }
 
@@ -541,25 +609,29 @@
 */
 void NmMessageSearchListView::refreshList()
 {
+    NM_FUNCTION;
+    
     if (mMessageListWidget) {
         // Set the model.
-        NmMessageListModel &messageListModel =
-            mUiEngine.messageListModel(mStartParam->mailboxId(),
-                                       mStartParam->folderId());
-        mSearchListModel.setSourceModel(&messageListModel);
         mMessageListWidget->setModel(
-            static_cast<QSortFilterProxyModel*>(&mSearchListModel));
+            static_cast<QStandardItemModel*>(&mMsgListModel));
 
         // Connect the signals.
-        connect(&mSearchListModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
+        connect(&mMsgListModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
                 this, SLOT(itemsAdded(const QModelIndex&, int, int)), Qt::UniqueConnection);
 
-        connect(&mSearchListModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
+        connect(&mMsgListModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
                 this, SLOT(itemsRemoved()), Qt::UniqueConnection);
 
-        connect(&messageListModel, SIGNAL(setNewParam(NmUiStartParam*)),
+        connect(&mMsgListModel, SIGNAL(setNewParam(NmUiStartParam*)),
                 this, SLOT(reloadViewContents(NmUiStartParam*)), Qt::UniqueConnection);
+    }
 
+    // The info label cannot be hidden when constructed because doing so would
+    // ruin the layout (for example the line edit widget's width would be too
+    // short in lanscape).
+    if (mInfoLabel) {
+        mInfoLabel->hide();
     }
 }
 
@@ -575,6 +647,8 @@
 */
 void NmMessageSearchListView::toggleSearch()
 {
+    NM_FUNCTION;
+    
     if (mSearchInProgress) {
         // Search is in progress - do cancel.
         mUiEngine.cancelSearch(mStartParam->mailboxId());
@@ -585,7 +659,7 @@
         mSearchInProgress = true;
     
         // Clear previous results if any.
-        mSearchListModel.clearSearchResults();
+        mMsgListModel.clear();
 
         connect(&mUiEngine, SIGNAL(searchComplete()),
                 this, SLOT(handleSearchComplete()), Qt::UniqueConnection);
@@ -605,7 +679,7 @@
 
         // Display the info label.
         if (mInfoLabel) {
-            mInfoLabel->setPlainText(hbTrId("txt_mail_list_searching"));
+            mInfoLabel->setHeading(hbTrId("txt_mail_list_searching"));
             mInfoLabel->show();
         }
 
@@ -624,7 +698,8 @@
 */
 void NmMessageSearchListView::handleSearchComplete()
 {
-    NMLOG("NmMessageSearchListView::handleSearchComplete()");
+    NM_FUNCTION;
+    
     mSearchInProgress = false;
     
     // Change the push button text.
@@ -632,38 +707,17 @@
         mPushButton->setIcon(HbIcon("qtg_mono_search"));
     }
 
-    const int resultCount = mSearchListModel.searchResultCount();
+    // Display the search result count.
+    updateSearchResultCountInfo();
 
-    if (resultCount == 1) {
-        // For some reason when the result count is only 1, the search list
-        // will not display the found message. Until the underlying reason for
-        // this bug is found, let us use the following solution to fix this
-        // issue.
-        refreshList();
-    }
+    const int resultCount = mMsgListModel.rowCount();
 
     if (resultCount) {
-        if (mInfoLabel) {
-            // Display the result count on the info label.
-            QString resultsString(hbTrId("txt_mail_list_search_results"));
-            resultsString.arg(resultCount);
-            mInfoLabel->setPlainText(resultsString);
-
-            if (!mInfoLabel->isVisible()) {
-                mInfoLabel->show();
-            }
-        }
-
         // Undim the search input.
         setSearchInputMode(NmNormalMode);
     }
     else {
-        // No search results!
-        if (mInfoLabel && mInfoLabel->isVisible()) {
-            mInfoLabel->hide();
-        }
-
-        // Display the "no messags" label and highlight the search term.
+        // Highlight the search field.
         noMessagesLabelVisibility(true);
         setSearchInputMode(NmHighlightedMode);
     }
--- a/emailuis/nmailui/src/nmrecipientfield.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmrecipientfield.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -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"
@@ -17,87 +17,55 @@
 
 #include "nmuiheaders.h"
 
-static const double Un = 6.66;
-static const double Margin = 2 * Un;
-static const int MaxRows = 10000;
-static const double LabelFieldWidth = 10 * Un + Un;
-static const double ButtonWidth = 9.5 * Un;
-static const double FieldHeight = 5 * Un;
-static const char *ContactsServiceName = "com.nokia.services.phonebookservices";
-static const char *ContactsInterfaceName = "Fetch";
-static const char *ContactsOperationName = "fetch(QString,QString,QString)";
+static const QString NmContactsServiceName = "com.nokia.services.phonebookservices";
+static const QString NmContactsInterfaceName = "Fetch";
+static const QString NmContactsOperationName = "fetch(QString,QString,QString)";
+
+static const int NmMaxRows = 10000;
 
 /*!
-   Constructor
+   widget is created using AD/docml
 */
 NmRecipientField::NmRecipientField(
-    HbLabel *label,
-    NmRecipientLineEdit *edit,
-    HbPushButton *button,
-    QGraphicsItem *parent):
-    HbWidget(parent),
-    mLabel(label),
-    mRecipientsEditor(edit),
-    mLaunchContactsPickerButton(button),
-    mOwned(false)
-{
-    mLaunchContactsPickerButton->setIcon(NmIcons::getIcon(NmIcons::NmIconContacts));
-    createConnections();
-}
-
-
-/*!
-   Constructor for 'Cc:' and 'Bcc:' fields. This can be removed when groupBox content
-   widget is created using AD/docml
-*/
-NmRecipientField::NmRecipientField(const QString &labelString, QGraphicsItem *parent):
-    HbWidget(parent),
+        QObject *parent, HbDocumentLoader &docLoader, const QString &objPrefix):
+    QObject(parent),
+    mDocumentLoader(docLoader),
+    mObjectPrefix(objPrefix),
     mLabel(NULL),
     mRecipientsEditor(NULL),
-    mLaunchContactsPickerButton(NULL),
-    mOwned(true)
+    mLaunchContactsPickerButton(NULL)
 {
-    mLayoutHorizontal = new QGraphicsLinearLayout(Qt::Horizontal, this);
+    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"));
 
-    mLabel = new HbLabel(labelString);
-    if (mLabel) {
-        mLayoutHorizontal->addItem(mLabel);
-        mLabel->setPreferredWidth(LabelFieldWidth);
-        mLabel->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
-        mLabel->setAlignment(Qt::AlignTop);
+    mLabel = qobject_cast<HbLabel *>
+        (mDocumentLoader.findWidget(mObjectPrefix + "Label"));
+
+    mRecipientsEditor = qobject_cast<NmRecipientLineEdit *>
+        (mDocumentLoader.findWidget(mObjectPrefix + "Edit"));
+    if (mRecipientsEditor) {
+        mRecipientsEditor->setMaxRows(NmMaxRows);    
     }
 
-    mRecipientsEditor = new NmRecipientLineEdit();
-    if (mRecipientsEditor) {
-    	mLayoutHorizontal->addItem(mRecipientsEditor);
-        mRecipientsEditor->setMaxRows(MaxRows);
-        mRecipientsEditor->setPreferredHeight(FieldHeight);
-        mRecipientsEditor->setMinimumHeight(FieldHeight);
-        mRecipientsEditor->setFontSpec(HbFontSpec(HbFontSpec::Secondary));
-    }
-
-    mLaunchContactsPickerButton = new HbPushButton();
+    mLaunchContactsPickerButton = qobject_cast<HbPushButton *>
+        (mDocumentLoader.findWidget(mObjectPrefix + "Button"));
     if (mLaunchContactsPickerButton) {
-    	mLayoutHorizontal->addItem(mLaunchContactsPickerButton);
-    	mLayoutHorizontal->setAlignment(mLaunchContactsPickerButton, Qt::AlignTop);
-        mLaunchContactsPickerButton->setPreferredHeight(FieldHeight);
-        mLaunchContactsPickerButton->setPreferredWidth(ButtonWidth);
-        mLaunchContactsPickerButton->setMaximumHeight(FieldHeight);
-
-        mLaunchContactsPickerButton->setIcon(NmIcons::getIcon(NmIcons::NmIconContacts));
+        mLaunchContactsPickerButton->setIcon(NmIcons::getIcon(NmIcons::NmIconContacts));    
     }
 
-    mLayoutHorizontal->setContentsMargins(0, 0, 0, 0);
-    // Set the spacing between the line edit  and the Add button to
-    mLayoutHorizontal->setItemSpacing(1, Un);
-    // Set the spacing between the label and the line edit to 0.0
-    mLayoutHorizontal->setItemSpacing(0, 0.0);
-
     createConnections();
 }
 
+/*!
+   Creates connections for this class items
+*/
 void NmRecipientField::createConnections()
 {
+    NM_FUNCTION;
+    
     connect(mRecipientsEditor, SIGNAL(textChanged(const QString &)),
         this, SIGNAL(textChanged(const QString &)));
     connect(mRecipientsEditor, SIGNAL(cursorPositionChanged(int, int)),
@@ -108,10 +76,8 @@
         this, SIGNAL(selectionChanged()));
     connect(mLaunchContactsPickerButton, SIGNAL(pressed()),
             this, SIGNAL(launchContactsPickerButtonClicked()));
-
-#ifdef Q_OS_SYMBIAN
-    connect(mLaunchContactsPickerButton, SIGNAL(pressed()), this, SLOT(launchContactsPicker()));
-#endif
+    connect(mLaunchContactsPickerButton, SIGNAL(pressed()), 
+            this, SLOT(launchContactsPicker()));
 }
 
 
@@ -120,21 +86,7 @@
 */
 NmRecipientField::~NmRecipientField()
 {
-    if (mOwned)
-    {
-        if (mLaunchContactsPickerButton) {
-            delete mLaunchContactsPickerButton;
-            mLaunchContactsPickerButton = 0;
-        }
-        if (mRecipientsEditor) {
-            delete mRecipientsEditor;
-            mRecipientsEditor = 0;
-        }
-        if (mLabel) {
-            delete mLabel;
-            mLabel = 0;
-        }
-    }
+    NM_FUNCTION;
 }
 
 /*!
@@ -142,7 +94,9 @@
 */
 qreal NmRecipientField::height()
 {
-    return mRecipientsEditor->geometry().height() + Margin;
+    NM_FUNCTION;
+    
+    return mWidget->geometry().height();
 }
 
 /*!
@@ -150,6 +104,8 @@
 */
 NmRecipientLineEdit *NmRecipientField::editor() const
 {
+    NM_FUNCTION;
+    
     return mRecipientsEditor;
 }
 
@@ -159,6 +115,8 @@
 */
 const QString NmRecipientField::text() const
 {
+    NM_FUNCTION;
+    
     return mRecipientsEditor->text();
 }
 
@@ -168,6 +126,8 @@
 */
 void NmRecipientField::setText(const QString &newText)
 {
+    NM_FUNCTION;
+    
     if (newText != mRecipientsEditor->text()) {
         mRecipientsEditor->setText(newText);
         emit textChanged(newText);
@@ -175,36 +135,42 @@
 }
 
 
-#ifdef Q_OS_SYMBIAN
 /*!
    This Slot launches the contacts-picker
 */
 void NmRecipientField::launchContactsPicker()
 {
+    NM_FUNCTION;
+    
     XQApplicationManager mAppmgr;
     XQAiwRequest *launchContactsPickerRequest;
     
     bool isEmbeded = true;
-    launchContactsPickerRequest = mAppmgr.create(ContactsServiceName, ContactsInterfaceName, 
-                                                 ContactsOperationName, isEmbeded);
+    launchContactsPickerRequest = mAppmgr.create(NmContactsServiceName, NmContactsInterfaceName, 
+                                                 NmContactsOperationName, isEmbeded);
     
     if (launchContactsPickerRequest) {
         connect(launchContactsPickerRequest, SIGNAL(requestOk(QVariant)),
-                mRecipientsEditor, SLOT(insertSelectedContacts(QVariant)));
+                mRecipientsEditor, SLOT(addSelectedContacts(QVariant)));
     }
     else {
         // Failed creating request 
-        NMLOG("XQApplicationManager: failed creating fecth contactspicker request.");
+        NM_ERROR(1,"XQApplicationManager: failed creating fecth contactspicker request");
 	    return;
     }
 
+    QVariantList args; 
+    args << hbTrId("txt_mail_select_contacts");
+    args << KCntActionEmail; 
+    args << KCntFilterDisplayAll; 
+    launchContactsPickerRequest->setArguments(args); 
+    
     // Send request
     if (!launchContactsPickerRequest->send()) {
        //Failed sending request 
-       NMLOG("XQApplicationManager: failed sending request.");
+       NM_ERROR(1,"XQApplicationManager: failed sending request");
     }
         
     delete launchContactsPickerRequest;
-    launchContactsPickerRequest = 0;
+    launchContactsPickerRequest = NULL;
 }
-#endif
--- a/emailuis/nmailui/src/nmsendserviceinterface.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmsendserviceinterface.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -38,6 +38,7 @@
       mAttachmentList(0),
       mEditorStartMode(NmUiEditorCreateNew)
     {
+        NM_FUNCTION;
     }
 
     /*!
@@ -45,6 +46,7 @@
     */
     inline ~NmStartParamDataHelper()
     {
+        NM_FUNCTION;
     }
 
     /*!
@@ -54,36 +56,24 @@
     */
     inline bool extractData(const QVariant &data)
     {
-        QVariant::Type dataType = data.type();
-        bool success = false;
+        NM_FUNCTION;
+        
+        bool success(false);
 
-        switch (dataType) {
-            case QVariant::String: {
-                // The given data contains a single attachment.
-                QString attachment = data.toString();
-                mAttachmentList = new QStringList(attachment);
-                success = true;
-                break;
-            }
-            case QVariant::StringList: {
-                // The given data contains a list of attachments.
-                QStringList attachmentList = data.toStringList();
-                mAttachmentList = new QStringList(attachmentList);
-                success = true;
-                break;
-            }
-            case QVariant::Map: {
-                // The given data may contain a mail subject and recipient lists.
-                QMap<QString, QVariant> map = data.toMap();
-                success = processMap(map);
-                break;
-            }
-            default: {
-                // Data type not supported!
-                NMLOG("NmStartParamDataHelper::extractData(): Data type not supported!");
-                break;
-            }
-        } // switch ()
+        if (data.canConvert(QVariant::Map)) {
+            // The given data may contain a mail subject and recipient lists.
+            QMap<QString, QVariant> map = data.toMap();
+            success = processMap(map);
+        }
+        else if (data.canConvert(QVariant::StringList)) {
+            QStringList attachmentList = data.toStringList();
+            mAttachmentList = new QStringList(attachmentList);
+            success = true;
+        }
+        else {
+            // Data type not supported!
+            NM_ERROR(1,"NmStartParamDataHelper::extractData(): data type not supported");
+        }
 
         // Determine the editor start mode.
         if (mToAddresses || mCcAddresses || mBccAddresses) {
@@ -102,6 +92,8 @@
     */
     inline void deleteData()
     {
+        NM_FUNCTION;
+        
         delete mSubject;
         mSubject = 0;
 
@@ -137,6 +129,8 @@
     */
     inline bool processMap(const QMap<QString, QVariant> &map)
     {
+        NM_FUNCTION;
+        
         QMap<QString, QVariant>::const_iterator i = map.constBegin();
         QString key;
         QVariant value;
@@ -186,7 +180,8 @@
     inline void addAddressesToList(const QVariant &addresses,
                                    QList<NmAddress*> **list)
     {
-
+        NM_FUNCTION;
+        
         if (!list) {
             // Invalid argument!
             return;
@@ -254,11 +249,7 @@
                                                QObject *parent,
                                                NmUiEngine &uiEngine,
                                                NmApplication *application)
-#ifndef NM_WINS_ENV
     : XQServiceProvider(interfaceName, parent),
-#else
-    : QObject(parent),
-#endif
       mApplication(application),
       mUiEngine(uiEngine),
       mAsyncReqId(0),
@@ -266,9 +257,7 @@
       mSelectionDialog(NULL),
       mCurrentView(NULL)
 {
-#ifndef NM_WINS_ENV
     publishAll();
-#endif
 }
 
 
@@ -277,6 +266,8 @@
 */
 NmSendServiceInterface::~NmSendServiceInterface()
 {
+    NM_FUNCTION;
+    
     delete mStartParam;
     delete mSelectionDialog;
 }
@@ -289,7 +280,8 @@
 */
 void NmSendServiceInterface::selectionDialogClosed(NmId &mailboxId)
 {
-    NMLOG("NmSendServiceInterface::selectionDialogClosed");
+    NM_FUNCTION;
+    
     if (mailboxId.id()) { // mailbox selected
         launchEditorView(mailboxId);
     }
@@ -311,15 +303,21 @@
 */
 void NmSendServiceInterface::send(QVariant data)
 {
-    NMLOG("NmSendServiceInterface::send()");
-
-#ifndef NM_WINS_ENV
-    HbMainWindow *mainWindow = mApplication->mainWindow();
-    mCurrentView = mainWindow->currentView();
-
-    // Hide the current view.
-    if (mCurrentView) {
-        mCurrentView->hide();
+    NM_FUNCTION;
+    
+    HbMainWindow *mainWindow(NULL);
+    
+    // Make sure that qmail stays background if user presses back in editorview
+    if (mApplication) {
+        mApplication->updateVisibilityState();
+        
+        mainWindow = mApplication->mainWindow();
+        mCurrentView = mainWindow->currentView();
+    
+        // Hide the current view.
+        if (mCurrentView) {
+            mCurrentView->hide();
+        }    
     }
 
     // Check the given data.
@@ -331,35 +329,23 @@
     NmId mailboxId(0);
 
     mAsyncReqId = setCurrentRequestAsync();
-    
+
     if (!validData) {
         // Failed to extract the data!
-        NMLOG("NmSendServiceInterface::send(): Failed to process the given data!");
+        NM_ERROR(1,"NmSendServiceInterface::send(): failed to process the given data");
         cancelService();
     }
     else if (count == 0) {
-        // No mailboxes.
-        if (mainWindow) {
-            mainWindow->hide();
-        }
-
-        // Hide the app if it not embedded
-        if (!XQServiceUtil::isEmbedded()) {
-            XQServiceUtil::toBackground(true);
-        }
-
         HbDeviceMessageBox note(hbTrId("txt_mail_dialog_no_mailboxes_defined"),
                           HbMessageBox::MessageTypeInformation);
         note.setTimeout(HbMessageBox::NoTimeout);
-        note.exec();
-        if (mainWindow) {
-            mainWindow->show();
-        }
+        note.show();
         cancelService();
     }
     else { // count > 0
-        // Make sure the NMail application is in the foreground.
-        XQServiceUtil::toBackground(false);
+        if (mainWindow) {
+            mainWindow->show();        
+        }
 
     	mStartParam = new NmUiStartParam(
         	NmUiViewMessageEditor,
@@ -388,8 +374,9 @@
                 mSelectionDialog =
                     new NmMailboxSelectionDialog(mUiEngine.mailboxListModel());
             }
-            connect(mSelectionDialog,SIGNAL(selectionDialogClosed(NmId&)),
-                this,SLOT(selectionDialogClosed(NmId&)));
+
+            connect(mSelectionDialog, SIGNAL(selectionDialogClosed(NmId&)),
+                    this, SLOT(selectionDialogClosed(NmId&)));
             mSelectionDialog->open();
 
             // launch the editor when the dialog is closed
@@ -401,26 +388,30 @@
     Called when mailbox id is know and editor can be opened
     \param mailboxId mailbox using in editor
  */
-void NmSendServiceInterface::launchEditorView(NmId mailboxId) 
+void NmSendServiceInterface::launchEditorView(NmId mailboxId)
 {
-    NMLOG(QString("NmSendServiceInterface::launchEditorView %1").arg(mailboxId.id()));
+    NM_FUNCTION;
+    NM_COMMENT(QString("NmSendServiceInterface::launchEditorView(): mailboxId=%1").arg(mailboxId.id()));
+    
     // Make the previous view visible again.
     if (mCurrentView) {
         mCurrentView->show();
-        mCurrentView = NULL;        
+        mCurrentView = NULL;
     }
-    
+
     if (mStartParam) {
         mStartParam->setMailboxId(mailboxId);
         mApplication->enterNmUiView(mStartParam);
         mStartParam = NULL; // ownership passed
     }
     completeRequest(mAsyncReqId, 1);
+    mAsyncReqId = 0;
 }
 
-void NmSendServiceInterface::cancelService() 
+void NmSendServiceInterface::cancelService()
 {
-    NMLOG("NmSendServiceInterface::cancelService");
+    NM_FUNCTION;
+    
     delete mStartParam;
     mStartParam = NULL;
 
@@ -430,6 +421,7 @@
     }
 
     completeRequest(mAsyncReqId, 0);
+    mAsyncReqId = 0;
 
     // If started as service, the application must be closed now.
     if (XQServiceUtil::isService()) {
@@ -445,8 +437,4 @@
     }
 }
 
-#endif /* NM_WINS_ENV */
-
-
-
 // End of file.
--- a/emailuis/nmailui/src/nmuidocumentloader.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmuidocumentloader.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -22,6 +22,7 @@
 */
 NmUiDocumentLoader::NmUiDocumentLoader(const HbMainWindow *window) : HbDocumentLoader(window)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -29,6 +30,7 @@
 */
 NmUiDocumentLoader::~NmUiDocumentLoader()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -36,7 +38,9 @@
 */
 QObject *NmUiDocumentLoader::createObject(const QString& type, const QString &name)
 {
-    QObject *res = NULL;
+    NM_FUNCTION;
+    
+    QObject *res(NULL);
     if( type == NmMailViewerWK::staticMetaObject.className() ) {
         res = new NmMailViewerWK();
         res->setObjectName(name);
@@ -53,7 +57,7 @@
         res = new NmAttachmentListWidget();
         res->setObjectName(name);
     }    
-    if (res == NULL) {
+    if (!res) {
         res = HbDocumentLoader::createObject(type, name);
     }
     return res;
--- a/emailuis/nmailui/src/nmuieffects.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmuieffects.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -17,7 +17,7 @@
 
 #include "nmuiheaders.h"
 
-static const char *SendAnimation = ":/effects/mail_send.fxml";
+static const char *NmSendAnimation = ":/effects/mail_send.fxml";
 
 /*!
     \class NmEffects
@@ -32,6 +32,7 @@
     mSendAnimationScreenShot(NULL),
     mDoSendAnimation(false)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -39,6 +40,8 @@
 */
 NmUiEffects::~NmUiEffects()
 {
+    NM_FUNCTION;
+    
     // Clean send animation if sendAnimationComplete slot is not called for some reason.
     // E.g. red key pressed.
     resetSendAnimation();
@@ -49,30 +52,38 @@
 */
 void NmUiEffects::prepareEffect(NmUiEffectType effect)
 {
+    NM_FUNCTION;
+    
     switch (effect) {
-    case NmEditorSendMessageAnimation:
-        // delete any existing stuff
-        resetSendAnimation();
-        
-        // This effect is for editor send message. Get the screen capture of
-        // editor view for animation which will be lauched soon.
-        mDoSendAnimation = true;
-
-        // take screen shot
-        mSendAnimationScreenShot = screenShot();
+        case NmEditorSendMessageAnimation: {
+            // delete any existing stuff
+            resetSendAnimation();
+            
+            // This effect is for editor send message. Get the screen capture of
+            // editor view for animation which will be lauched soon.
+            mDoSendAnimation = true;
+    
+            // take screen shot
+            mSendAnimationScreenShot = screenShot();
+            
+            if (mSendAnimationScreenShot){
+                // Create graphics item based pixmap image but don't show it yet.
+                mSendAnimationScreenShot->hide();
+                mSendAnimationScreenShot->setPos(0,0);
+                mSendAnimationScreenShot->setZValue(0);
         
-        // Create graphics item based pixmap image but don't show it yet.
-        mSendAnimationScreenShot->hide();
-        mSendAnimationScreenShot->setPos(0,0);
-        mSendAnimationScreenShot->setZValue(0);
-        mMainWindow.scene()->addItem(mSendAnimationScreenShot);
-
-        // Set editor screen capture visible before old view is popped.
-        // New view is drawn under this image.
-        mSendAnimationScreenShot->show();
-
-        HbEffect::add(mSendAnimationScreenShot, SendAnimation, "mail_send");
-        break;
+                // Adds or moves the item and all its childen to this scene.
+                // This scene takes ownership of the item.
+                mMainWindow.scene()->addItem(mSendAnimationScreenShot);
+        
+                // Set editor screen capture visible before old view is popped.
+                // New view is drawn under this image.
+                mSendAnimationScreenShot->show();
+        
+                HbEffect::add(mSendAnimationScreenShot, NmSendAnimation, "mail_send");        
+            }
+            break;
+        }
     }
 }
 
@@ -81,15 +92,18 @@
 */
 void NmUiEffects::startEffect(NmUiEffectType effect)
 {
+    NM_FUNCTION;
+    
     switch (effect) {
-    case NmEditorSendMessageAnimation:
-        // Send message animation for editor view.
-        if (mDoSendAnimation && mSendAnimationScreenShot) {
-            mDoSendAnimation = false;
-            // Start animation and connect completion signal to sendAnimationComplete slot.
-            HbEffect::start(mSendAnimationScreenShot, "mail_send", this, "sendAnimationComplete");
+        case NmEditorSendMessageAnimation: {
+            // Send message animation for editor view.
+            if (mDoSendAnimation && mSendAnimationScreenShot) {
+                mDoSendAnimation = false;
+                // Start animation and connect completion signal to sendAnimationComplete slot.
+                HbEffect::start(mSendAnimationScreenShot, "mail_send", this, "sendAnimationComplete");
+            }
+            break;
         }
-        break;
     }
 }
 
@@ -99,10 +113,11 @@
  */
 QGraphicsPixmapItem *NmUiEffects::screenShot()
 {
+    NM_FUNCTION;
+    
     // Grab whole view into pixmap image (also chrome is included)
     QPixmap screenCapture = QPixmap::grabWindow(mMainWindow.internalWinId());
-
-    QGraphicsPixmapItem *ret = NULL;
+    QGraphicsPixmapItem *ret(NULL);
     
     // for landscape, the screenshot must be rotated
     if(mMainWindow.orientation() == Qt::Horizontal) {
@@ -122,9 +137,16 @@
  */
 void NmUiEffects::resetSendAnimation()
 {
+    NM_FUNCTION;
+    
     if (mSendAnimationScreenShot) {
         // Clean send animation
-        HbEffect::remove(mSendAnimationScreenShot, SendAnimation, "mail_send");
+        HbEffect::remove(mSendAnimationScreenShot, NmSendAnimation, "mail_send");
+        // Ownership of QGraphicsPixmapItem is tranferred to GraphicsScene when it has been added
+        // to it GraphicsScene.
+        // GraphicsPixmapItem needs to be removed from the GraphicsScene before deleting
+        // it to prevent double deletion.
+        mMainWindow.scene()->removeItem(mSendAnimationScreenShot);
         delete mSendAnimationScreenShot;
         mSendAnimationScreenShot = NULL;
         mDoSendAnimation = false;
@@ -136,6 +158,8 @@
 */
 void NmUiEffects::sendAnimationComplete(HbEffect::EffectStatus status)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(status);
     resetSendAnimation();
 }
--- a/emailuis/nmailui/src/nmuiextensionmanager.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmuiextensionmanager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -17,23 +17,21 @@
 
 #include "nmuiheaders.h"
 
-const QString NmsPluginExtensionName = "nmsclientplugin.qtplugin"; 
+static const QString NmSettingsPluginFolderPath("/resource/qt/plugins/nmail/uiext");
+
 /*!
     \class NmUiExtensionManager
     \brief Handles ui extension plugins
  */
 
-// ======== HELPER FUNCTIONS ========
-
 /*!
   Creates list of folder paths where plug-ins can be loaded from.
   \return folder path list.
 */
 QStringList NmUiExtensionManager::pluginFolders()
 {
-    NMLOG(QString("NmUiExtensionManager - HELPER FUNCTIONS - pluginFolders"));
-
-    const QString NmSettingsPluginFolderPath("/resource/qt/plugins/nmail/uiext");
+    NM_FUNCTION;
+    
     QStringList pluginDirectories;
     QFileInfoList driveList = QDir::drives();
 
@@ -45,13 +43,14 @@
             pluginDirectories.append(pluginDirectory);
         }
     }
-
-    NMLOG(QString("NmUiExtensionManager - HELPER FUNCTIONS - pluginFolders - OK"));
+    
     return pluginDirectories;
 }
 
 NmUiExtensionManager::NmUiExtensionManager()
 {
+    NM_FUNCTION;
+    
     // load the protocol extension plugins
     loadExtensionPlugins();
 }
@@ -61,6 +60,8 @@
  */
 NmUiExtensionManager::~NmUiExtensionManager()
 {
+    NM_FUNCTION;
+    
     // delete plugins from array
     qDeleteAll(mExtensions.begin(), mExtensions.end());
     mExtensions.clear();
@@ -76,8 +77,10 @@
     const NmActionRequest &menuRequest,
     QList<NmAction*> &actionList)
 {
+    NM_FUNCTION;
+    
     for (int i = 0; i < mExtensions.count(); i++) {
-    	NmUiExtensionInterface* interface = mExtensions[i];
+    	NmUiExtensionInterface *interface = mExtensions[i];
         interface->getActions(menuRequest, actionList);
     }
 }
@@ -87,7 +90,7 @@
  */
 void NmUiExtensionManager::loadExtensionPlugins()
 {
-    NMLOG(QString("NmUiExtensionManager::loadExtensionPlugins -->"));
+    NM_FUNCTION;
     
     QStringList directories(pluginFolders());
     foreach (const QString &directoryPath, directories) {
@@ -95,7 +98,7 @@
         QFileInfoList fileList(directory.entryInfoList());
 
         foreach (const QFileInfo &fileInfo, fileList) {
-            NMLOG(QString("Plugin absolute FilePath : %1").arg(fileInfo.absoluteFilePath()));  
+            NM_COMMENT(QString("Plugin absolute FilePath : %1").arg(fileInfo.absoluteFilePath()));  
             QScopedPointer<QPluginLoader> loader(
                 new QPluginLoader(fileInfo.absoluteFilePath()));
             mPluginLoaders.append(loader.data());
@@ -103,19 +106,16 @@
         }
     }
     
-    NmUiExtensionInterface *interface = NULL;    
+    NmUiExtensionInterface *interface(NULL);    
     foreach (QPluginLoader *loader, mPluginLoaders) {      
-        NMLOG(QString("Plugin fileName() : %1").arg(loader->fileName()));
-        QString fileName = loader->fileName();
-        if (fileName.contains(NmsPluginExtensionName, Qt::CaseInsensitive) == false) {
-            QObject *pluginInstance = loader->instance();
-            interface = qobject_cast<NmUiExtensionInterface*>(pluginInstance);
-            if (interface) {
-                mExtensions.append(interface);
-            }
+        NM_COMMENT(QString("Plugin fileName() : %1").arg(loader->fileName()));
+        QString fileName = loader->fileName();        
+        QObject *pluginInstance = loader->instance();
+        interface = qobject_cast<NmUiExtensionInterface*>(pluginInstance);
+        if (interface) {
+            mExtensions.append(interface);
         }
-    }            
-    NMLOG(QString("<-- NmUiExtensionManager::loadExtensionPlugins"));
+    }
 }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmailui/src/nmuriserviceinterface.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,354 @@
+/*
+* 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: NMail Application Launcher interface used for interfacing between
+*              QT highway and other applications
+*
+*/
+
+//  INCLUDES
+#include "nmuiheaders.h"
+
+/*!
+    \class NmStartParamDataHelper
+    \brief A helper class for processing the data given to the actual service.
+*/
+class NmStartParamDataHelper
+{
+public:
+
+    /*!
+        Class constructor.
+    */
+    inline NmStartParamDataHelper()
+    : mSubject(NULL),
+      mToAddresses(NULL),
+      mCcAddresses(NULL),
+      mBccAddresses(NULL)
+    {
+        NM_FUNCTION;
+    }
+
+    /*!
+        Class destructor.
+    */
+    inline ~NmStartParamDataHelper()
+    {
+        NM_FUNCTION;
+    }
+
+    /*!
+        Extracts the data from the given QString into the class members.
+        \param data QString containing the data.
+        \return True if success, false otherwise.
+    */
+    inline bool extractData(const QString &data)
+    {
+        NM_FUNCTION;
+        
+        bool success(false);
+        
+        QUrl uri(data);
+        
+        if (uri.isValid()) {
+            
+            mSubject = new QString(uri.queryItemValue(emailSendSubjectKey));
+            QString to = uri.path();
+            QString cc = uri.queryItemValue(emailSendCcKey);
+            QString bcc = uri.queryItemValue(emailSendBccKey);
+            
+            addAddressesToList(to, &mToAddresses);
+            addAddressesToList(cc, &mCcAddresses);
+            addAddressesToList(bcc, &mBccAddresses);
+            
+            success = true;
+        }
+        
+        return success;
+    }
+
+    /*!
+        Appends the given addresses into the given list.
+        \param address The addresses to append.
+        \param list The list where the addresses are appended to.
+    */
+    inline void addAddressesToList(QString &addresses,
+                                   QList<NmAddress*> **list)
+    {
+        NM_FUNCTION;
+        
+        if (!addresses.isEmpty()) {
+
+            QList<NmAddress*> foundAddresses;
+                    
+            // Process multiple addresses.
+            if (addresses.contains(",")) {
+                QString str;               
+                while (addresses.contains(",")) {
+                    str = addresses.section(",", 0, 0); // Get the occurance.
+                    addresses.remove(0, (addresses.indexOf(",")+1)); // Remove the occurance.
+                    if (!str.isEmpty()) { // In case str would be empty on some error data. 
+                        NmAddress *address = new NmAddress(str);
+                        foundAddresses.append(address);    
+                    }
+                }
+            }
+            if (!addresses.isEmpty()) { // In case addresses would be empty on some error data. 
+                // Last one or single address.
+                NmAddress *address = new NmAddress(addresses);
+                foundAddresses.append(address);
+            }
+            // Append the found addresses into the given list.
+            *list = new QList<NmAddress*>();
+            (*list)->append(foundAddresses);
+        }
+    }
+        
+    /*!
+        Deletes the class members. Must be used if NmUiStartParam does not
+        take ownership of the members.
+    */
+    inline void deleteData()
+    {
+        NM_FUNCTION;
+        
+        delete mSubject;
+        mSubject = 0;
+
+        if (mToAddresses) {
+            qDeleteAll(*mToAddresses);
+            delete mToAddresses;
+            mToAddresses = 0;
+        }
+
+        if (mCcAddresses) {
+            qDeleteAll(*mCcAddresses);
+            delete mCcAddresses;
+            mCcAddresses = 0;
+        }
+
+        if (mBccAddresses) {
+            qDeleteAll(*mBccAddresses);
+            delete mBccAddresses;
+            mBccAddresses = 0;
+        }
+    }
+
+public: // Data
+
+    QString *mSubject; // Not owned.
+    QList<NmAddress*> *mToAddresses; // Not owned.
+    QList<NmAddress*> *mCcAddresses; // Not owned.
+    QList<NmAddress*> *mBccAddresses; // Not owned.
+};
+
+/*!
+    \class NmUriServiceInterface
+    \brief NMail application service interface which provides an email sending
+           interface for other application using the Qt Highway.
+*/
+
+/*!
+    Class constructor.
+*/
+NmUriServiceInterface::NmUriServiceInterface(QObject *parent,
+                                               NmUiEngine &uiEngine,
+                                               NmApplication *application)
+    : XQServiceProvider(emailServiceName+"."+XQI_URI_VIEW, parent),
+      mApplication(application),
+      mUiEngine(uiEngine),
+      mAsyncReqId(0),
+      mStartParam(NULL),
+      mSelectionDialog(NULL),
+      mCurrentView(NULL)
+{
+    publishAll();
+}
+
+
+/*!
+    Class desctructor.
+*/
+NmUriServiceInterface::~NmUriServiceInterface()
+{
+    NM_FUNCTION;
+    
+    delete mStartParam;
+    delete mSelectionDialog;
+}
+
+
+/*!
+    Queries the user for a mailbox to use.
+    \param mailboxId Where the ID of the selected mailbox is set.
+    \return True if a mailbox was selected, false otherwise.
+*/
+void NmUriServiceInterface::selectionDialogClosed(NmId &mailboxId)
+{
+    NM_FUNCTION;
+    
+    if (mailboxId.id()) { // mailbox selected
+        launchEditorView(mailboxId);
+    }
+    else {
+        cancelService();
+    }
+}
+
+
+/*!
+    Used from external applications to handle mailto: uri's.
+
+    \param data <mailto:> uri
+*/
+bool NmUriServiceInterface::view(const QString& uri)
+{
+    NM_FUNCTION;
+      
+    HbMainWindow *mainWindow(NULL);
+    if (mApplication) {
+        // Make sure that nmail stays background if user presses back in editorview
+        mApplication->updateVisibilityState();
+        
+        mainWindow = mApplication->mainWindow();
+        if (mainWindow) {
+            mCurrentView = mainWindow->currentView();  
+        } 
+    }
+
+    // Hide the current view.
+    if (mCurrentView) {
+        mCurrentView->hide();
+    }
+    
+    // Check the given data.
+    NmStartParamDataHelper dataHelper;
+    bool validData = dataHelper.extractData(uri);
+     
+    NmMailboxListModel &mailboxListModel = mUiEngine.mailboxListModel();
+    const int count = mailboxListModel.rowCount();
+    NmId mailboxId(0);
+
+    mAsyncReqId = setCurrentRequestAsync();
+
+    if (!validData) {
+        // Failed to extract the data!
+        NM_ERROR(1,"NmUriServiceInterface::view(): failed to process the given data");
+        cancelService();
+    }
+    else if (count == 0) {
+        HbDeviceMessageBox note(hbTrId("txt_mail_dialog_no_mailboxes_defined"),
+                          HbMessageBox::MessageTypeInformation);
+        note.setTimeout(HbMessageBox::NoTimeout);
+        note.show();
+        cancelService();
+    }
+    else { // count > 0
+        // Make sure the NMail application is in the foreground.
+        XQServiceUtil::toBackground(false);
+        if (mainWindow) {
+            mainWindow->show();        
+        }
+
+    	mStartParam = new NmUiStartParam(
+        	NmUiViewMessageEditor,
+	        0, // account id
+	        0, // folder id
+    	    0, // message id
+    	    NmUiEditorMailto, // editor start mode
+	        dataHelper.mToAddresses, // address list
+    	    0, // attachment list
+        	true, // start as service
+	        dataHelper.mSubject, // message subject
+	        dataHelper.mCcAddresses, // list containing cc recipient addresses
+    	    dataHelper.mBccAddresses // list containing bcc recipient addresses
+	    );
+
+        if (count == 1) {
+            // A single mailbox exists.
+            QModelIndex modelIndex = mailboxListModel.index(0, 0);
+            QVariant mailbox(mailboxListModel.data(modelIndex));
+            NmMailboxMetaData *mailboxMetaData = mailbox.value<NmMailboxMetaData*>();
+            mailboxId = mailboxMetaData->id();
+        	launchEditorView(mailboxId);
+        }
+        else { // count > 1
+            if (!mSelectionDialog) {
+                mSelectionDialog =
+                    new NmMailboxSelectionDialog(mUiEngine.mailboxListModel());
+            }
+            connect(mSelectionDialog,SIGNAL(selectionDialogClosed(NmId&)),
+                this,SLOT(selectionDialogClosed(NmId&)));
+            mSelectionDialog->open();
+
+            // launch the editor when the dialog is closed
+        }
+    }
+    
+    return true;
+}
+
+/*!
+    Called when mailbox id is known and editor can be opened
+    \param mailboxId mailbox using in editor
+ */
+void NmUriServiceInterface::launchEditorView(NmId mailboxId)
+{
+    NM_FUNCTION;
+    NM_COMMENT(QString("NmUriServiceInterface::launchEditorView(): mailboxId=%1").arg(mailboxId.id()));
+    
+    // Make the previous view visible again.
+    if (mCurrentView) {
+        mCurrentView->show();
+        mCurrentView = NULL;
+    }
+
+    if (mStartParam) {
+        mStartParam->setMailboxId(mailboxId);
+        mApplication->enterNmUiView(mStartParam);
+        mStartParam = NULL; // ownership passed
+    }
+    completeRequest(mAsyncReqId, 1);
+    mAsyncReqId = 0;
+}
+
+void NmUriServiceInterface::cancelService()
+{
+    NM_FUNCTION;
+    
+    delete mStartParam;
+    mStartParam = NULL;
+
+    // If the service was started as embedded, do not hide the app.
+    if (!XQServiceUtil::isEmbedded()) {
+        XQServiceUtil::toBackground(true);
+    }
+
+    completeRequest(mAsyncReqId, 0);
+    mAsyncReqId = 0;
+
+    // If started as service, the application must be closed now.
+    if (XQServiceUtil::isService()) {
+        connect(this, SIGNAL(returnValueDelivered()),
+            mApplication, SLOT(delayedExitApplication()));
+    }
+    else {
+        // Make the previous view visible again
+        if (mCurrentView) {
+            mCurrentView->show();
+            mCurrentView = NULL;
+        }
+    }
+}
+
+// End of file.
--- a/emailuis/nmailui/src/nmutilities.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmutilities.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -18,10 +18,9 @@
 #include "nmuiheaders.h"
 
 static const int NmMegabyte = 1048576;
-static const int NmShortInterval = 1000; // 1 sec
-
+static const qreal NmMinAttachmentSize = 0.1;
 // taken from http://www.regular-expressions.info/email.html
-static const QRegExp EmailAddressPattern("[A-Za-z\\d!#$%&'*+/=?^_`{|}~-]+"
+static const QRegExp NmEmailAddressPattern("[A-Za-z\\d!#$%&'*+/=?^_`{|}~-]+"
                                          "(?:"
                                          "\\."
                                          "[A-Za-z\\d!#$%&'*+/=?^_`{|}~-]+"
@@ -47,44 +46,49 @@
     QList<NmAddress> &recipients,
     NmAddressValidationType type )
 {
+    NM_FUNCTION;
+
+    // Get envelope from message
+    const NmMessageEnvelope &env = message.envelope();
+    
     // validate TO addresses
-    QList<NmAddress> toRecipients = message.envelope().toRecipients();
+    QList<NmAddress> toRecipients = env.toRecipients();
     int recipientCount = toRecipients.count();
 
     for (int i = 0; i < recipientCount; ++i) {
         bool validAddress = isValidEmailAddress(toRecipients.at(i).address());
 
-        if (type == Default ||
-            type == ValidAddress && validAddress ||
-            type == InvalidAddress && !validAddress) {
+        if (type == NmDefault ||
+            type == NmValidAddress && validAddress ||
+            type == NmInvalidAddress && !validAddress) {
             recipients.append(toRecipients.at(i));
         }
     }
 
     // validate CC addresses
-    QList<NmAddress> ccRecipients = message.envelope().ccRecipients();
+    QList<NmAddress> ccRecipients = env.ccRecipients();
     recipientCount = ccRecipients.count();
 
     for (int i = 0; i < recipientCount; ++i) {
         bool validAddress = isValidEmailAddress(ccRecipients.at(i).address());
 
-        if (type == Default ||
-            type == ValidAddress && validAddress ||
-            type == InvalidAddress && !validAddress) {
+        if (type == NmDefault ||
+            type == NmValidAddress && validAddress ||
+            type == NmInvalidAddress && !validAddress) {
             recipients.append(ccRecipients.at(i));
         }
     }
 
     // validate BCC addresses
-    QList<NmAddress> bccRecipients = message.envelope().bccRecipients();
+    QList<NmAddress> bccRecipients = env.bccRecipients();
     recipientCount = bccRecipients.count();
 
     for (int i = 0; i < recipientCount; ++i) {
         bool validAddress = isValidEmailAddress(bccRecipients.at(i).address());
 
-        if (type == Default ||
-            type == ValidAddress && validAddress ||
-            type == InvalidAddress && !validAddress) {
+        if (type == NmDefault ||
+            type == NmValidAddress && validAddress ||
+            type == NmInvalidAddress && !validAddress) {
             recipients.append(bccRecipients.at(i));
         }
     }
@@ -95,7 +99,9 @@
 */
 bool NmUtilities::isValidEmailAddress( const QString &emailAddress )
 {
-    return EmailAddressPattern.exactMatch(emailAddress);
+    NM_FUNCTION;
+
+    return NmEmailAddressPattern.exactMatch(emailAddress);
 }
 
 /*!
@@ -103,6 +109,8 @@
 */
 QString NmUtilities::addressToDisplayName( const NmAddress &address )
 {
+    NM_FUNCTION;
+
     QString emailAddress = address.address();
     QString displayName = address.displayName();
 
@@ -121,9 +129,11 @@
 */
 bool NmUtilities::parseEmailAddress( const QString &emailAddress, NmAddress &address )
 {
-    bool foundAddress = false;
+    NM_FUNCTION;
 
-    QRegExp rx(EmailAddressPattern);
+    bool foundAddress(false);
+
+    QRegExp rx(NmEmailAddressPattern);
     // locate the email address in the string
     int pos = rx.indexIn(emailAddress);
     if (pos != -1) {
@@ -147,6 +157,8 @@
 */
 QString NmUtilities::cleanupDisplayName( const QString &displayName )
 {
+    NM_FUNCTION;
+
     // find the first and last position that is NOT one of the characters below
     QRegExp rx("[^\\s\"<>]");
     int firstPos = std::max(rx.indexIn(displayName), 0);
@@ -160,49 +172,23 @@
 }
 
 /*!
-  Opens file specified by QFile handle. Usually used by editor
-  for opening added attachments
+  Opens file specified by XQSharableFile handle. Usually used by viewer
+  for opening attachments from message store as RFiles
 */
-int NmUtilities::openFile(QFile &file)
+int NmUtilities::openFile(XQSharableFile &file)
 {
+    NM_FUNCTION;
+
     int ret(NmNotFoundError);
     XQApplicationManager aiwMgr;
     XQAiwRequest *request(NULL);
     request = aiwMgr.create(file);
-    // If request is created then there is a handler for that file
-    if (request) {
-         // Set request arguments
-         QList<QVariant> args;
-         args << file.fileName();
-         request->setArguments(args);
-         // Send the request, ownership of request is transferred
-         bool res = request->send();
-         if (res) {
-             // Request ok, set error status.
-             ret = NmNoError;
-         }
-    }
-    delete request;
-    return ret;
-}
-
-
-/*!
-  Opens file specified by RFile handle. Usually used by viewer
-  for opening attachments from message store as RFiles
-*/
-int NmUtilities::openFile(XQSharableFile &file)
-{
-    int ret(NmNotFoundError);
-    XQApplicationManager aiwMgr;
-    XQAiwRequest *request(NULL);
-    request = aiwMgr.create(file);  
     // Create request for the sharable file
     if (request)
     {
         // Set request arguments
         QList<QVariant> args;
-        args << qVariantFromValue(file);  
+        args << qVariantFromValue(file);
         request->setArguments(args);
         // Send the request, ownership of request is transferred
         bool res = request->send();
@@ -220,6 +206,8 @@
  */
 QString NmUtilities::truncate( const QString &string, int length )
 {
+    NM_FUNCTION;
+
     if (string.length() <= length) {
         return string;
     }
@@ -231,12 +219,14 @@
 
 /*!
  * Shows an error note. Used by at least editor and viewer classes.
- * 
+ *
  */
 void NmUtilities::displayErrorNote(QString noteText)
 {
+    NM_FUNCTION;
+
 	HbNotificationDialog *note = new HbNotificationDialog();
-	
+
 	note->setIcon(HbIcon(QLatin1String("note_warning")));
 	note->setTitle(noteText);
 	note->setTitleTextWrapping(Hb::TextWordWrap);
@@ -253,75 +243,45 @@
  */
 QString NmUtilities::attachmentSizeString(const int sizeInBytes)
 {
-    qreal sizeMb = (qreal)sizeInBytes / (qreal)NmMegabyte;
-    if (sizeMb < 0.1) {
-        // 0.1 Mb is the minimum size shown for attachment
-        sizeMb = 0.1;
-    }
-    return QString().sprintf("(%.1f Mb)", sizeMb); // Use loc string when available    
-}
+    NM_FUNCTION;
 
-/*!
-    takes care of necessary error/information note displaying based on the given operation completion event
-    returns boolean whether settings should be opened or not
-*/
-bool NmUtilities::displayOperationCompletionNote(const NmOperationCompletionEvent &event)
-{
-    bool openSettings(false);
-    // nothing to do in successfull or cancelled case
-    if(event.mCompletionCode != NmNoError && event.mCompletionCode != NmCancelError) {
-        if(event.mOperationType == Synch && event.mCompletionCode == NmAuthenticationError) {
-            openSettings = displayQuestionNote(hbTrId("txt_mail_dialog_address_or_password_incorrect"));
-        }
-        if(event.mOperationType == Synch && event.mCompletionCode == NmServerConnectionError) {
-            openSettings = displayQuestionNote(hbTrId("txt_mail_dialog_server_settings_incorrect"));
-        }
-        // following applies to all operation/event types
-        if(event.mCompletionCode == NmConnectionError) {
-            displayWarningNote(hbTrId("txt_mail_dialog_mail_connection_error"));
-        }
-    }
-    return openSettings;
+    qreal sizeMb = (qreal)sizeInBytes / (qreal)NmMegabyte;
+    if (sizeMb < NmMinAttachmentSize) {
+        // NmMinAttachmentSize (0.1Mb) is the minimum size shown for attachment
+        sizeMb = NmMinAttachmentSize;
+    }   
+    return QString().sprintf("(%.1f Mb)", sizeMb); // Use loc string when available
 }
 
 /*!
-    displays a note with Yes/No buttons. Note has no timeout, i.e. it has to be dismissed manually
-    returns boolean whether primaryaction was taken (Left button ("Yes") pressed)
+    Displays a note with Yes/No buttons. Note has no timeout, i.e. it has to be dismissed manually.
+    Returns pointer to dialog so that caller can take ownership and handle deletion.
+    Parameter 'receiver' is the object and 'member' is the slot where user selection is passed.
 */
-bool NmUtilities::displayQuestionNote(QString noteText)
+HbMessageBox* NmUtilities::displayQuestionNote(
+    QString noteText, QObject* receiver, const char* member)
 {
-	HbMessageBox::warning(noteText);
-	return true;
-	/*
-	 * Commented out because of exec() deprecation. Will be fixed later...
-	 * 
-    bool ret(false);
+    NM_FUNCTION;
+
     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
     messageBox->setText(noteText);
-    messageBox->setTimeout(HbMessageBox::NoTimeout); // note has to be dismissed manually
-    HbAction *action = messageBox->exec();
-    if(action == messageBox->primaryAction()) {
-        ret=true; // primary/left button was pressed
-    }
-    delete messageBox;
-    return ret;
-    */
+    messageBox->setTimeout(HbMessageBox::NoTimeout); // Note has to be dismissed manually
+    messageBox->open(receiver, member);
+    return messageBox;
 }
 
 /*!
- * displays an error note with no buttons. Note dismisses itself after NmShortInterval.
+ * displays an warning note.
  */
-void NmUtilities::displayWarningNote(QString noteText)
+HbMessageBox* NmUtilities::displayWarningNote(QString noteText, QObject* receiver, const char* member)
 {
+    NM_FUNCTION;
+
     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
     messageBox->setText(noteText);
-    messageBox->setTimeout(NmShortInterval);
-    messageBox->clearActions(); // gets rid of buttons from the note
-    messageBox->setModal(false);
-    messageBox->setBackgroundFaded(false);
-    messageBox->show();
-
-    delete messageBox;
+    messageBox->setTimeout(HbMessageBox::NoTimeout); // Note has to be dismissed manually
+    messageBox->open(receiver, member);
+    return messageBox;
 }
 
 /*!
@@ -330,32 +290,35 @@
 */
 QString NmUtilities::createReplyHeader(const NmMessageEnvelope &env)
 {
+    NM_FUNCTION;
+
     QString ret = "<html><body><br><br>";
     // Append "----- Original message ----" text
-    ret+=hbTrId("txt_mail_editor_reply_original_msg");                  
+    ret+=hbTrId("txt_mail_editor_reply_original_msg");
     // Append sender
     ret+="<br>";
-    ret+=hbTrId("txt_mail_editor_reply_from");               
-    ret+=" ";        
+    ret+=hbTrId("txt_mail_editor_reply_from");
+    ret+=" ";
     if (env.sender().displayName().length()){
         ret+=env.sender().displayName();
     }
     else{
         ret+=env.sender().address();
-    }   
+    }
     // Append sent time
     ret+="<br>";
-    ret+=hbTrId("txt_mail_editor_reply_sent");   
-    ret+=" ";  
+    ret+=hbTrId("txt_mail_editor_reply_sent");
+    ret+=" ";
     HbExtendedLocale locale = HbExtendedLocale::system();
-    QDate sentLocalDate = env.sentTime().toLocalTime().date();
-    ret+=locale.format(sentLocalDate, r_qtn_date_usual);   
+    QDateTime localTime = env.sentTime().addSecs(locale.universalTimeOffset());
+    QDate sentLocalDate = localTime.date();
+    ret+=locale.format(sentLocalDate, r_qtn_date_usual);
     // Append to recipients
     const QList<NmAddress> &toList = env.toRecipients();
     if (toList.count()){
         ret+="<br>";
-        ret+=hbTrId("txt_mail_editor_reply_to"); 
-        ret+=" ";    
+        ret+=hbTrId("txt_mail_editor_reply_to");
+        ret+=" ";
         for (int i=0;i<toList.count();i++){
             if (toList[i].displayName().length()){
                 ret+=toList[i].displayName();
@@ -364,16 +327,16 @@
                 ret+=toList[i].address();
             }
             if (i!=toList.count()-1){
-                ret+=";";          
+                ret+=";";
             }
-        }    
+        }
     }
     // Append cc recipients
     const QList<NmAddress> &ccList = env.ccRecipients();
     if (ccList.count()){
         ret+="<br>";
-        ret+=hbTrId("txt_mail_editor_reply_cc"); 
-        ret+=" ";         
+        ret+=hbTrId("txt_mail_editor_reply_cc");
+        ret+=" ";
         for (int i=0;i<ccList.count();i++){
             if (ccList[i].displayName().length()){
                 ret+=ccList[i].displayName();
@@ -382,29 +345,29 @@
                 ret+=ccList[i].address();
             }
             if (i!=toList.count()-1){
-                ret+=";";          
+                ret+=";";
             }
-        }    
+        }
     }
     // Append subject if there is subject to display
     if (env.subject().length()){
         ret+="<br>";
-        ret+=hbTrId("txt_mail_editor_reply_subject"); 
-        ret+=" ";    
-        ret+=env.subject();    
+        ret+=hbTrId("txt_mail_editor_reply_subject");
+        ret+=" ";
+        ret+=env.subject();
     }
-    // Append priority if it is other than normal  
-    if (env.priority()!=NmMessagePriorityNormal){   
+    // Append priority if it is other than normal
+    if (env.priority()!=NmMessagePriorityNormal){
         ret+="<br>";
-        ret+=hbTrId("txt_mail_editor_reply_importance"); 
-        ret+=" ";    
+        ret+=hbTrId("txt_mail_editor_reply_importance");
+        ret+=" ";
         if (env.priority()==NmMessagePriorityLow){
-            ret+=hbTrId("txt_mail_editor_reply_importance_low");         
+            ret+=hbTrId("txt_mail_editor_reply_importance_low");
         }
         else {
-            ret+=hbTrId("txt_mail_editor_reply_importance_high"); 
+            ret+=hbTrId("txt_mail_editor_reply_importance_high");
         }
-    }    
+    }
     ret+="<br></body></html>";
     return ret;
 }
--- a/emailuis/nmailui/src/nmviewerheader.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmviewerheader.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -11,14 +11,14 @@
 *
 * Contributors:
 *
-* Description:
+* Description: NMail viewer view header widget implementation
 *
 */
 
 
 #include "nmuiheaders.h"
 
-static const qreal nmHeaderLineOpacity = 0.4;
+static const qreal NmHeaderLineOpacity = 0.4;
 
 /*!
     \class NmViewerHeader
@@ -38,7 +38,10 @@
     mRecipientsBox(NULL),
     mViewerView(NULL)
 {
+    NM_FUNCTION;
+    
     loadWidgets();
+    setFlag(QGraphicsItem::ItemHasNoContents, false);
 }
 
 /*!
@@ -46,6 +49,7 @@
 */
 NmViewerHeader::~NmViewerHeader()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -53,6 +57,8 @@
 */
 void NmViewerHeader::setView(NmViewerView* view)
 {
+    NM_FUNCTION;
+    
     mViewerView = view;
 }
 
@@ -61,6 +67,8 @@
 */
 void NmViewerHeader::loadWidgets()
 {
+    NM_FUNCTION;
+    
     // Scale header widget to screen width
     setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); 
 
@@ -105,10 +113,13 @@
     const QStyleOptionGraphicsItem *option,
     QWidget *widget)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(option);
     Q_UNUSED(widget);
     if (painter) {
-        painter->setOpacity(nmHeaderLineOpacity);
+        painter->save();
+        painter->setOpacity(NmHeaderLineOpacity);
         QLineF line1( rect().topLeft().x(), rect().bottomRight().y(),
                      rect().bottomRight().x(), rect().bottomRight().y());
         painter->drawLine(line1);
@@ -117,7 +128,8 @@
             QLineF line2( headerBoxGeometry.topLeft().x(), headerBoxGeometry.bottomRight().y(),
                           headerBoxGeometry.bottomRight().x(), headerBoxGeometry.bottomRight().y());
             painter->drawLine(line2);        
-        }       
+        } 
+        painter->restore();      
     }
 }
 
@@ -126,6 +138,8 @@
 */
 void NmViewerHeader::setMessage(NmMessage* message)
 {
+    NM_FUNCTION;
+    
     mMessage=message;
     setHeaderData();
 }
@@ -139,12 +153,14 @@
 */
 void NmViewerHeader::updateMessageData(NmMessage* message)
 {
+    NM_FUNCTION;
+    
     if (message){
         mMessage=message;
         // Set recipients to text edit field as html 
         NmAddress sender = mMessage->envelope().sender();      
         if (mRecipientsBox){  
-            mRecipientsBox->setHtml(formatRecipientList(addressToDisplayInHtml(sender),
+            mRecipientsBox->setHtml(formatRecipientList(addressToDisplay(sender),
                                     mMessage->envelope().toRecipients(), 
                                     mMessage->envelope().ccRecipients()));
         }       
@@ -156,6 +172,8 @@
 */
 void NmViewerHeader::setHeaderData()
 {
+    NM_FUNCTION;
+    
     if (mMessage) {
         // Background is all white always, so force text color to black
         QColor textColor(Qt::black);
@@ -183,8 +201,9 @@
         }
         if (mSent){
             HbExtendedLocale locale = HbExtendedLocale::system();
-            QTime time = envelope.sentTime().toLocalTime().time();
-            QDate sentLocalDate = envelope.sentTime().toLocalTime().date();
+            QDateTime localTime = envelope.sentTime().addSecs(locale.universalTimeOffset());
+            QTime time = localTime.time();
+            QDate sentLocalDate = localTime.date();
             QString shortDateSpec = r_qtn_date_without_year;
             QString shortTimeSpec = r_qtn_time_usual;
             QString text = locale.format(sentLocalDate, shortDateSpec);
@@ -222,6 +241,8 @@
 */ 
 void NmViewerHeader::rescaleHeader(const QSizeF layoutReso)
 {  
+    NM_FUNCTION;
+    
     setMinimumWidth(layoutReso.width());
     setMaximumWidth(layoutReso.width());
 }
@@ -231,6 +252,8 @@
 */
 void NmViewerHeader::createExpandableHeader()
 {
+    NM_FUNCTION;
+    
     if (mHeaderBox) {        // Initialize recipient box
         if (!mRecipientsBox){
             mRecipientsBox = new HbTextEdit();
@@ -249,7 +272,7 @@
         // Set recipients to text edit field as html 
         NmAddress sender = mMessage->envelope().sender();               
         if (mMessage) {
-            mRecipientsBox->setHtml(formatRecipientList(addressToDisplayInHtml(sender),
+            mRecipientsBox->setHtml(formatRecipientList(addressToDisplay(sender),
                                     mMessage->envelope().toRecipients(), 
                                     mMessage->envelope().ccRecipients()));
         }
@@ -267,10 +290,12 @@
                                             const QList<NmAddress> &to,
                                             const QList<NmAddress> &cc)
 {
+    NM_FUNCTION;
+    
     QString result;
     result.append("<html><body link=\"blue\" topmargin=\"0\" leftmargin=\"0\" marginheight=\"0\"");
-    result.append("marginwidth=\"0\" bgcolor=\"white\" text=\"black\">");    
-    result.append("<font color=\"black\" face=\"");
+    result.append("marginwidth=\"0\">");    
+    result.append("<font face=\"");
     result.append("Nokia Sans");
     result.append("\"size=\"3\">"); 
     // Set text in HTML format based on layout direction
@@ -284,7 +309,7 @@
         result.append(" </b>");
         int reciCount = to.count();
         for (int i=0; i < reciCount; i++) { 
-            result.append(addressToDisplayInHtml(to[i]));
+            result.append(addressToDisplay(to[i]));
             result.append(" ");
         } 
         reciCount = cc.count();
@@ -293,7 +318,7 @@
             result.append(hbTrId("txt_mail_list_cc"));
             result.append(" </b>");
             for (int i=0; i < reciCount; i++) {
-                result.append(addressToDisplayInHtml(cc[i]));
+                result.append(addressToDisplay(cc[i]));
                 result.append(" "); 
             }
         }   
@@ -308,7 +333,7 @@
         result.append(" </b>");
         int reciCount = to.count();
         for (int i=0; i < reciCount; i++) { 
-            result.append(addressToDisplayInHtml(to[i]));
+            result.append(addressToDisplay(to[i]));
             result.append("; ");
         }
         reciCount = cc.count();
@@ -317,7 +342,7 @@
             result.append(hbTrId("txt_mail_list_cc"));
             result.append(" </b>");
             for (int i=0; i < reciCount; i++) {
-                result.append(addressToDisplayInHtml(cc[i]));
+                result.append(addressToDisplay(cc[i]));
                 result.append("; ");
             }
         }   
@@ -330,8 +355,10 @@
     Function retursn address string from NmAddress to
     be displayed in HTML format
 */
-QString NmViewerHeader::addressToDisplayInHtml(const NmAddress &addr)
+QString NmViewerHeader::addressToDisplay(const NmAddress &addr)
 {
+    NM_FUNCTION;
+    
     QString dispName;
     if (addr.displayName().length()!=0){
         dispName.append(NmUtilities::cleanupDisplayName(addr.displayName()));
@@ -353,6 +380,8 @@
 */
 void NmViewerHeader::cursorPositionChanged(int oldPos, int newPos)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(oldPos);
     QString string = mRecipientsBox->anchorAt(newPos); 
     if (mViewerView&&string.contains("mailto:",Qt::CaseSensitive)){
--- a/emailuis/nmailui/src/nmviewerserviceinterface.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmviewerserviceinterface.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -31,18 +31,12 @@
 NmViewerServiceInterface::NmViewerServiceInterface(QObject *parent,
         NmApplication *application,
         NmUiEngine &uiEngine)
-#ifndef NM_WINS_ENV
     : XQServiceProvider(emailFullServiceNameMessage, parent),
-#else
-    : QObject(parent),
-#endif
       mApplication(application),
       mUiEngine(uiEngine),
       mAsyncReqId(0)
 {
-#ifndef NM_WINS_ENV
     publishAll();
-#endif
 }
 
 
@@ -51,6 +45,7 @@
 */
 NmViewerServiceInterface::~NmViewerServiceInterface()
 {
+    NM_FUNCTION;
 }
 
 
@@ -59,20 +54,37 @@
  */
 void NmViewerServiceInterface::viewMessage(QVariant mailboxId, QVariant folderId, QVariant messageId)
 {
-    NMLOG("NmViewerServiceInterface::viewMessage()");
-#ifndef NM_WINS_ENV
+    NM_FUNCTION;
+
     mAsyncReqId = setCurrentRequestAsync();
 
     NmId mailboxNmId(mailboxId.toULongLong());
     NmId messageNmId(messageId.toULongLong());
     NmId folderNmId(folderId.toULongLong());
 
+	// Make sure the app stays background if user presses back in viewer view
+	bool visible = mApplication->updateVisibilityState();
+
     NmMessage *message = mUiEngine.message( mailboxNmId, folderNmId, messageNmId );
     if (message) {
         // bring application to foreground
         XQServiceUtil::toBackground(false);
+        HbMainWindow *mainWindow = mApplication->mainWindow();
+        mainWindow->show();
 
         // Launch the message list view.
+        NmUiStartParam *startParam1 = 
+            new NmUiStartParam(NmUiViewMessageList,
+                               mailboxNmId,
+                               folderNmId, // folder id
+                               messageNmId, // message id
+                               NmUiEditorCreateNew, // editor start mode
+                               NULL, // address list
+                               NULL, // attachment list
+                               true); // start as service
+        mApplication->enterNmUiView(startParam1);
+        
+        // Launch the message view.
         NmUiStartParam *startParam =
             new NmUiStartParam(NmUiViewMessageViewer,
                                mailboxNmId,
@@ -81,7 +93,7 @@
                                NmUiEditorCreateNew, // editor start mode
                                NULL, // address list
                                NULL, // attachment list
-                               true); // start as service
+                               false); // not started as service
         mApplication->enterNmUiView(startParam);
 
         completeRequest(mAsyncReqId,0);
@@ -90,7 +102,7 @@
         // Message was not found
 
         // if started as embedded, do not hide the app
-		if (!XQServiceUtil::isEmbedded()) {
+		if (!XQServiceUtil::isEmbedded() && !visible) {
 			XQServiceUtil::toBackground(true);
 		}
 
@@ -103,7 +115,6 @@
                     mApplication, SLOT(delayedExitApplication()));
         }
     }
-#endif
 }
 
 // End of file.
--- a/emailuis/nmailui/src/nmviewerview.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmviewerview.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -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: Mail viewer implementation.
+ *
+ */
 
 #include "nmuiheaders.h"
 
@@ -25,11 +25,14 @@
 static const char *NMUI_MESSAGE_VIEWER_HEADER = "viewerHeader";
 static const char *NMUI_MESSAGE_VIEWER_ATTALIST = "viewerAttaList";
 static const char *NMUI_MESSAGE_VIEWER_SCROLL_WEB_VIEW = "viewerWebView";
-
 static const int NmOrientationTimer = 100;
 static const int NmHeaderMargin = 3;
-
+static const int NmWhitePixmapSize = 10;
+static const int NmProgressValueComplete = 100;
 static const QString NmParamTextHeightSecondary = "hb-param-text-height-secondary";
+static const QString NmHttpLinkScheme = "http";
+static const QString NmHttpsLinkScheme = "https";
+static const QString NmMailtoLinkScheme = "mailto";
 
 /*!
 	\class NmViewerView
@@ -47,7 +50,7 @@
     NmAttachmentManager &attaManager,
     bool toolbarEnabled,
     QGraphicsItem *parent)
-:NmBaseView(startParam, parent),
+:NmBaseView(startParam, application, parent),
 mApplication(application),
 mUiEngine(uiEngine),
 mMainWindow(mainWindow),
@@ -58,12 +61,10 @@
 mViewerContent(NULL),
 mWebView(NULL),
 mHeaderWidget(NULL),
-mViewerContentLayout(NULL),
 mMessageFetchingOperation(NULL),
 mDisplayingPlainText(false),
 mDocumentLoader(NULL),
 mScrollAreaContents(NULL),
-mViewerHeaderContainer(NULL),
 mScreenSize(QSize(0,0)),
 mWaitDialog(NULL),
 webFrameloadingCompleted(false),
@@ -72,9 +73,8 @@
 mAttaWidget(NULL),
 mViewReady(false),
 mWaitNoteCancelled(false),
-mOkAction(NULL),
-mCancelAction(NULL)
-    {
+mErrorNote(NULL)
+{
     // Create documentloader
     mDocumentLoader = new NmUiDocumentLoader(mMainWindow);
     // Get screensize
@@ -95,6 +95,8 @@
 */
 NmViewerView::~NmViewerView()
 {
+    delete mErrorNote;
+    mErrorNote=NULL;
     delete mWebView;
     mWebView = NULL;
     delete mMessage;
@@ -107,10 +109,6 @@
     // remove view from osbserving atta manager events
     mAttaManager.clearObserver();
     mAttaManager.cancelFetch();
-    delete mOkAction;
-    mOkAction = NULL;
-    delete mCancelAction;
-    mCancelAction = NULL;
 }
 
 /*!
@@ -121,6 +119,7 @@
     // View is about to exit, for safety, stop 
     // loading of content before closing the view
     if (mWebView){
+        mAttaManager.cancelFetch();
         mWebView->stop();
         if (mWebView->page()){
             mWebView->page()->deleteLater();
@@ -133,50 +132,49 @@
 */
 void NmViewerView::loadViewLayout()
 {
+    NM_FUNCTION;
+    
     // Use document loader to load the view
-    bool ok = false;
+    bool ok(false);
     setObjectName(QString(NMUI_MESSAGE_VIEWER_VIEW));
-    QObjectList objectList;
-    objectList.append(this);
-    // Pass the view to documentloader. Document loader uses this view
-    // when docml is parsed, instead of creating new view.
-    if (mDocumentLoader) {
-        mDocumentLoader->setObjectTree(objectList);
-        mWidgetList = mDocumentLoader->load(NMUI_MESSAGE_VIEWER_XML, &ok);
-    }
-    int widgetCount = mWidgetList.count();
-    if (ok == true && widgetCount)
-    {
+   QObjectList objectList;
+   objectList.append(this);
+   // Pass the view to documentloader. Document loader uses this view
+   // when docml is parsed, instead of creating new view.
+   // documentloader is created in constructor
+   mDocumentLoader->setObjectTree(objectList);
+   mWidgetList = mDocumentLoader->load(NMUI_MESSAGE_VIEWER_XML, &ok);
+
+   if (ok)
+   {
         // Create content and content layout
         // qobject_cast not work in this case, using reinterpret_cast
         mViewerContent = reinterpret_cast<HbWidget *>(
                 mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_CONTENT));
         // Find scroll area
-        mScrollArea = reinterpret_cast<NmBaseViewScrollArea *>(
+        mScrollArea = reinterpret_cast<HbScrollArea *>(
                 mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_SCROLL_AREA));
         if (mScrollArea) {
             mScrollArea->setParentItem(this);
             mScrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal);
             connect(mScrollArea, SIGNAL(scrollPositionChanged(QPointF)),
                 this, SLOT(contentScrollPositionChanged(QPointF)));
-            connect(mScrollArea, SIGNAL(handleMousePressEvent(QGraphicsSceneMouseEvent*)),
-                this, SLOT(handleMousePressEvent(QGraphicsSceneMouseEvent*)));
-            connect(mScrollArea, SIGNAL(handleMouseReleaseEvent(QGraphicsSceneMouseEvent*)),
-                this, SLOT(handleMouseReleaseEvent(QGraphicsSceneMouseEvent*)));
 
             // Get scroll area contents and set layout margins
             mScrollAreaContents = qobject_cast<HbWidget *>(
                     mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_SCROLL_AREA_CONTENTS));
-            if (mScrollAreaContents->layout()){
-                mScrollAreaContents->layout()->setContentsMargins(0,0,0,0);
+            if (mScrollAreaContents) {
+                QGraphicsLayout *layout = mScrollAreaContents->layout();
+                if (layout){
+                    layout->setContentsMargins(0,0,0,0);
+                }
+                // Set white pixmap to backgrounditem 
+                QPixmap whitePixmap(NmWhitePixmapSize,NmWhitePixmapSize);
+                whitePixmap.fill(Qt::white);
+                QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(whitePixmap);
+                mScrollAreaContents->setBackgroundItem(pixmapItem);
             }
 
-            // Set white pixmap to backgrounditem 
-            QPixmap whitePixmap(10,10);
-            whitePixmap.fill(Qt::white);
-            QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(whitePixmap);
-            mScrollAreaContents->setBackgroundItem(pixmapItem);
-
             // Load headerwidget
             mHeaderWidget = qobject_cast<NmViewerHeader *>(
                     mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_HEADER));
@@ -191,23 +189,24 @@
             mWebView = reinterpret_cast<NmMailViewerWK *>(
                     mDocumentLoader->findObject(QString(NMUI_MESSAGE_VIEWER_SCROLL_WEB_VIEW)));
             if (mWebView) {
-                mWebView->setParentView(this);
                 // Set auto load images and private browsing(no history) attributes
-                mWebView->settings()->setAttribute(QWebSettings::AutoLoadImages, true);
-                mWebView->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);                                
-                HbEditorInterface editorInterface(mWebView);
-                editorInterface.setInputConstraints(HbEditorConstraintIgnoreFocus);
-                mWebView->setAcceptedMouseButtons(Qt::NoButton);
-                if (mWebView->page()){
-                    mWebView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical,
-                                                                      Qt::ScrollBarAlwaysOff);
-                    mWebView->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal,
-                                                                      Qt::ScrollBarAlwaysOff);
-                    connect(mWebView->page()->mainFrame(),
-                            SIGNAL(contentsSizeChanged(const QSize&)),
-                        this, SLOT(scaleWebViewWhenLoading(const QSize&)));
+                QWebSettings *settings = mWebView->settings();
+                if (settings) {
+                    settings->setAttribute(QWebSettings::AutoLoadImages, true);
+                    settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);   
                 }
-             }
+                QWebPage *page = mWebView->page();
+                if (page) {
+                    QWebFrame *frame = page->mainFrame();
+                    if (frame) {
+                        frame->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff);
+                        frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
+                        connect(mWebView->page()->mainFrame(),
+                                SIGNAL(contentsSizeChanged(const QSize&)),
+                            this, SLOT(scaleWebViewWhenLoading(const QSize&)));  
+                    }
+                }
+            }
         }
     }
 }
@@ -223,8 +222,7 @@
         // Create toolbar if needed
         if (mToolbarEnabled) {
             createToolBar();
-        }
-        else {
+        } else {
             // Connect options menu about to show to create options menu function
             QObject::connect(menu(), SIGNAL(aboutToShow()),
                     this, SLOT(createOptionsMenu())); 
@@ -232,12 +230,11 @@
             NmAction *dummy = new NmAction(0);
             menu()->addAction(dummy);
         }
-        
-        
-        if (mHeaderWidget){
+                
+        if (mHeaderWidget) {
             QPointF contentWidgetPos = mScrollArea->pos();
             qreal headerHeight = mHeaderWidget->geometry().height();
-            if(mMainWindow->orientation()==Qt::Horizontal) {
+            if (mMainWindow->orientation() == Qt::Horizontal) {
                 const QPointF pointToWebView(contentWidgetPos.x(), headerHeight+NmHeaderMargin);
                 mScrollArea->scrollContentsTo(pointToWebView,0);
             }
@@ -246,7 +243,7 @@
         // Run fetchmessage in queue
         QMetaObject::invokeMethod(this, "fetchMessage", Qt::QueuedConnection);
         // Set view ready
-        mViewReady=true;
+        mViewReady = true;
     }
 }
 
@@ -255,18 +252,17 @@
 */
 void NmViewerView::loadMessage()
 {
+    NM_FUNCTION;
+    
     if (mMessage) {
         delete mMessage;
         mMessage = NULL;
     }
-    NmId mailboxId;
-    NmId folderId;
-    NmId msgId;
     // Read start params and message object
     if (mStartParam){
-        mailboxId = mStartParam->mailboxId();
-        folderId = mStartParam->folderId();
-        msgId = mStartParam->messageId();
+        NmId mailboxId = mStartParam->mailboxId();
+        NmId folderId = mStartParam->folderId();
+        NmId msgId = mStartParam->messageId();
         mMessage = mUiEngine.message(mailboxId, folderId, msgId);
     }
 }
@@ -277,7 +273,8 @@
 */
 void NmViewerView::fetchMessage()
 {
-#ifdef Q_OS_SYMBIAN
+    NM_FUNCTION;
+    
     if (mMessage) {
         NmId mailboxId = mStartParam->mailboxId();
         NmId folderId = mStartParam->folderId();
@@ -301,28 +298,13 @@
                         SIGNAL(operationCompleted(int)),
                         this,
                         SLOT(messageFetched(int)));
-
-                delete mWaitDialog;
-                mWaitDialog = NULL;
-                // Create new wait dialog and set it to me modal with dimmed background
-                mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
-                mWaitDialog->setModal(true);
-                mWaitDialog->setBackgroundFaded(true);
-                connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(waitNoteCancelled()));
-                mWaitDialog->setText(hbTrId("txt_mail_dialog_loading_mail_content"));
-                // Display wait dialog
-                mWaitDialog->show();
+                createAndShowWaitDialog();
             }
-        }
-        else {
+        } else {
             // message is fetched
             setMessageData();
         }
-
     }
-#else
-    setMessageData();
-#endif
 }
 
 /*!
@@ -330,22 +312,20 @@
  */
 void NmViewerView::messageFetched(int result)
 {
-    delete mWaitDialog;
-    mWaitDialog = NULL;
-
+    mWaitDialog->close();
+    disconnect(mWaitDialog->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
+                this, SLOT(orientationChanged(Qt::Orientation)));
+    
     if (result == NmNoError && mMessageFetchingOperation) {
         if (mMessage) {
             delete mMessage;
             mMessage = NULL;
         }
-        NmId mailboxId;
-        NmId folderId;
-        NmId msgId;
         // Read start params and message object
         if (mStartParam) {
-            mailboxId = mStartParam->mailboxId();
-            folderId = mStartParam->folderId();
-            msgId = mStartParam->messageId();
+            NmId mailboxId = mStartParam->mailboxId();
+            NmId folderId = mStartParam->folderId();
+            NmId msgId = mStartParam->messageId();
             mMessage = mUiEngine.message(mailboxId, folderId, msgId);
         }
         setMessageData();
@@ -367,7 +347,7 @@
 	        mMessageFetchingOperation->cancelOperation();
         }
         mWaitNoteCancelled = true;
-        QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
+        QMetaObject::invokeMethod(&mApplication, "prepareForPopView", Qt::QueuedConnection);
     }
 }
 
@@ -377,6 +357,8 @@
 */
 void NmViewerView::setMessageData()
 {
+    NM_FUNCTION;
+    
     // Connect to observe orientation change events
     connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
                 this, SLOT(orientationChanged(Qt::Orientation)));
@@ -391,6 +373,10 @@
         NmViewerViewNetManager &netMngr = mApplication.networkAccessManager();
         netMngr.setView(this);
         page->setNetworkAccessManager(&netMngr);
+        QWebSettings *webSettings = page->settings();
+        if (webSettings) {
+            webSettings->setObjectCacheCapacities(0,0,0);
+        }
 
         connect(page, SIGNAL(loadFinished(bool)),
                     this, SLOT(webFrameLoaded(bool)));
@@ -401,8 +387,9 @@
   	// if everything is ok, set message to html viewer
     if (mMessage && mWebView && page) {
         // Set initial size of component and content before loading data
-        mWebView->setMaximumWidth(mScreenSize.width());
-        page->setPreferredContentsSize(mScreenSize);
+        mWebView->setPreferredWidth(mScreenSize.width());
+        QRectF myGeometry = geometry();
+        page->setViewportSize(myGeometry.size().toSize());
         //Set message data to html viewer.
         mWebView->setHtml(formatMessage());
         // Connect to link clicked
@@ -418,6 +405,8 @@
 */
 void NmViewerView::setAttachmentList()
 {
+    NM_FUNCTION;
+    
     // Load headerwidget
     mAttaWidget = qobject_cast<NmAttachmentListWidget *>(
             mDocumentLoader->findObject(NMUI_MESSAGE_VIEWER_ATTALIST));
@@ -430,7 +419,7 @@
         // Set attawidget minimum & maximum size
         mAttaWidget->setMinimumWidth(mScreenSize.width());
         mAttaWidget->setMaximumWidth(mScreenSize.width());
-        bool inserted = false;
+        bool inserted(false);
         QList<NmMessagePart*> messageParts;
         mMessage->attachmentList(messageParts);
         for (int i = 0; i < messageParts.count();i++) {
@@ -471,36 +460,45 @@
 */
 void NmViewerView::openAttachment(int index)
 {
-    NmId attaId = mAttaIdList.at(index);
-    // reload message to get updates part sizes
-    loadMessage();
-    QList<NmMessagePart*> messageParts;
-    mMessage->attachmentList(messageParts);
-    for (int i = 0; i < messageParts.count(); i++) {
-        // message part found have to found
-        // and its fetched size is smaller than size, then start part fetch
-        if (messageParts[i]->partId() == attaId &&
-            messageParts[i]->size() > messageParts[i]->fetchedSize()) {
-            // do not start if there's already ongoing fetch
-            if (mAttaIndexUnderFetch == NmNotFoundError) {
-                mAttaIndexUnderFetch = index;
-                mAttaManager.fetchAttachment(
-                        mMessage->envelope().mailboxId(),
-                        mMessage->envelope().folderId(),
-                        mMessage->envelope().messageId(),
-                        attaId);
-            }
-        }
-        // attachment is fetched, open file
-        else if (messageParts[i]->partId() == attaId) {
-            XQSharableFile file = mUiEngine.messagePartFile(
-                    mMessage->envelope().mailboxId(),
-                    mMessage->envelope().folderId(),
-                    mMessage->envelope().messageId(),
-                    attaId);
-            NmUtilities::openFile(file);
-            file.close();
-        }
+    NM_FUNCTION;
+    if (index >= 0) {
+        NmId attaId = mAttaIdList.at(index);
+        // reload message to get updates part sizes
+        loadMessage();
+        QList<NmMessagePart*> messageParts;
+        if (mMessage) {
+            mMessage->attachmentList(messageParts);
+             NmId mailboxId = mMessage->envelope().mailboxId();
+             NmId folderId = mMessage->envelope().folderId();
+             NmId messageId = mMessage->envelope().messageId();
+             for (int i = 0; i < messageParts.count(); i++) {
+                 // message part found have to found
+                 // and its fetched size is smaller than size, then start part fetch
+                 if (messageParts[i]->partId() == attaId &&
+                     messageParts[i]->size() > messageParts[i]->fetchedSize()) {
+                     // do not start if there's already ongoing fetch
+                     if (mAttaIndexUnderFetch == NmNotFoundError) {
+                         mAttaIndexUnderFetch = index;
+                         mAttaManager.fetchAttachment(mailboxId, folderId,
+                                                      messageId, attaId);
+                     }
+                 }
+                 // attachment is fetched, open file
+                 else if (messageParts[i]->partId() == attaId) {
+                     mAttaManager.cancelFetch();
+                     XQSharableFile file = mUiEngine.messagePartFile(mailboxId, folderId,
+                                                                     messageId, attaId);
+                     int error = NmUtilities::openFile(file);
+                     file.close();
+                     if (error==NmNotFoundError){
+                         delete mErrorNote;
+                         mErrorNote=NULL;
+                         mErrorNote = NmUtilities::displayWarningNote(
+                                 hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty"));
+                     }
+                 }
+             }            
+         }
     }
 }
 
@@ -509,83 +507,115 @@
 */
 QString NmViewerView::formatMessage()
 {
+    NM_FUNCTION;
+    
     QString msg = "";
-    // null pointer check for mMessage is done before calling this function
-    NmMessagePart *html = mMessage->htmlBodyPart();
-    if (html) {
+    if (mMessage) {
+        NmMessagePart *html = mMessage->htmlBodyPart();
+        if (html) {
+            msg += formatHtmlMessage(html);
+        }
+        else {
+            NmMessagePart *plain = mMessage->plainTextBodyPart();
+            if (plain) {
+                msg += formatPlainTextMessage(plain);
+            }
+        }    
+    }
+    return msg;
+}
+
+/*!
+    Function formats html message
+*/
+QString NmViewerView::formatHtmlMessage(NmMessagePart *html)
+{    
+    NM_FUNCTION;
+
+    QString msg = "";
+    if (html && mMessage) {
+        NmId mailboxId = mMessage->envelope().mailboxId();
+        NmId folderId = mMessage->envelope().folderId();
+        NmId messageId = mMessage->envelope().messageId();
         QList<NmMessagePart*> parts;
         mMessage->attachmentList(parts);
         for (int i=0; i < parts.count(); i++) {
             NmMessagePart *child = parts[i];
             // Browse through embedded image parts and add those
             // the web view.
-            quint32 fetchedSize = child->fetchedSize();
-            quint32 size = child->size();
-            if (fetchedSize >= size &&
-                    child->contentType().startsWith("image", Qt::CaseInsensitive)) {
+            bool isFetched = child->fetchedSize() >= child->size();
+            if (child->contentType().startsWith("image", Qt::CaseInsensitive)) {
                 QString contentId = child->contentId();
-                int ret = mUiEngine.contentToMessagePart(
-                        mMessage->envelope().mailboxId(),
-                        mMessage->envelope().folderId(),
-                        mMessage->envelope().messageId(),
-                        *child);
-                if (ret == NmNoError) {
-                  mWebView->addContent(contentId, QVariant::fromValue(child->binaryContent()));
+                if (isFetched) {
+                    int ret = mUiEngine.contentToMessagePart(
+                            mailboxId, folderId, messageId, *child);
+                    if (ret == NmNoError) {
+                      mWebView->addContent(contentId, QVariant::fromValue(child->binaryContent()), 
+                              child->partId(), isFetched);
+                    }
+                }
+                else {
+                    mWebView->addContent(contentId, QVariant::fromValue(QByteArray()), 
+                            child->partId(), isFetched);
                 }
             }
         }
-        int ret = mUiEngine.contentToMessagePart(
-                mMessage->envelope().mailboxId(),
-                mMessage->envelope().folderId(),
-                mMessage->envelope().messageId(),
-                *html);
+        int ret = mUiEngine.contentToMessagePart(mailboxId, folderId, messageId, *html);
         if (ret == NmNoError) {
-            msg = html->textContent();
-        }
+         msg = html->textContent();
+        }    
     }
-    else {
-        NmMessagePart *plain = mMessage->plainTextBodyPart();
-        if (plain) {
-            int ret = mUiEngine.contentToMessagePart(
-                    mMessage->envelope().mailboxId(),
-                    mMessage->envelope().folderId(),
-                    mMessage->envelope().messageId(),
-                    *plain);
-            if (ret == NmNoError) {
-                QTextDocument doku;
-                // set font
-                QFont currentFont = doku.defaultFont();
-                currentFont.setWeight(QFont::Normal);
-                qreal secondarySize;
-                HbStyle myStyle;
-                bool found = myStyle.parameter(NmParamTextHeightSecondary, secondarySize);
-                if (found) {
-                    HbFontSpec fontSpec(HbFontSpec::Secondary);
-                    fontSpec.setTextHeight(secondarySize);
-                    currentFont.setPixelSize(fontSpec.font().pixelSize());
-                }
-                doku.setDefaultFont(currentFont);
-                // convert to html
-                doku.setPlainText(plain->textContent());
-                msg = doku.toHtml();
+    return msg;
+}
 
-                if (qApp->layoutDirection()==Qt::RightToLeft){
-                    // add right alignment to document css section
-                    QRegExp rx("(<style type=\"text/css\">)(.+)(</style>)", Qt::CaseInsensitive);
-                    rx.setMinimal(true);
-                    int pos = rx.indexIn(msg);
-                    if (pos > -1) {
-                        QString newStr = rx.cap(1);
-                        newStr.append(rx.cap(2));
-                        newStr.append("p { text-align: right } ");
-                        newStr.append(rx.cap(3));
-                        msg.replace(rx, newStr);
-                    }
+/*!
+    Function formats plain text message message
+*/
+QString NmViewerView::formatPlainTextMessage(NmMessagePart *plain)
+{
+    NM_FUNCTION;
+      
+    QString msg = "";
+    if (plain && mMessage) {
+        NmId mailboxId = mMessage->envelope().mailboxId();
+        NmId folderId = mMessage->envelope().folderId();
+        NmId messageId = mMessage->envelope().messageId();
+        int ret = mUiEngine.contentToMessagePart(mailboxId, folderId,
+                                                 messageId, *plain);
+        if (ret == NmNoError) {
+            QTextDocument document;
+            // set font
+            QFont currentFont = document.defaultFont();
+            currentFont.setWeight(QFont::Normal);
+            qreal secondarySize;
+            HbStyle myStyle;
+            bool found = myStyle.parameter(NmParamTextHeightSecondary, secondarySize);
+            if (found) {
+                HbFontSpec fontSpec(HbFontSpec::Secondary);
+                fontSpec.setTextHeight(secondarySize);
+                currentFont.setPixelSize(fontSpec.font().pixelSize());
+            }
+            document.setDefaultFont(currentFont);
+            // convert to html
+            document.setPlainText(plain->textContent());
+            msg = document.toHtml();
+    
+            if (qApp->layoutDirection()==Qt::RightToLeft){
+                // add right alignment to document css section
+                QRegExp rx("(<style type=\"text/css\">)(.+)(</style>)", Qt::CaseInsensitive);
+                rx.setMinimal(true);
+                int pos = rx.indexIn(msg);
+                if (pos > -1) {
+                    QString newStr = rx.cap(1);
+                    newStr.append(rx.cap(2));
+                    newStr.append("p { text-align: right } ");
+                    newStr.append(rx.cap(3));
+                    msg.replace(rx, newStr);
                 }
             }
-            mDisplayingPlainText=true;
-        }
+        }    
     }
+    mDisplayingPlainText=true;  
     return msg;
 }
 
@@ -645,27 +675,22 @@
     // So that screen is scrollable even before images are fully loaded
     // First check that new size is different than previous, no need to react if
     // same size value is received more than once.
-    if (size!=mLatestLoadingSize){
-        if (!webFrameloadingCompleted&&mWebView&&mWebView->page()&&
-            (size.width()>mScreenSize.width()||size.height()>mScreenSize.height())) {
+    if (size != mLatestLoadingSize) {
+        if (!webFrameloadingCompleted && mWebView && mWebView->page() &&
+            (size.width() > mScreenSize.width() || size.height() > geometry().height())) {
             int width = (int)size.width();
             int height = (int)size.height();
             // Set content (webview) width
             if (mDisplayingPlainText){
-                mWebView->setMaximumWidth(mScreenSize.width());
-                mWebView->setMinimumWidth(mScreenSize.width());
-                mWebView->setPreferredWidth(mScreenSize.width());
+                mWebView->setPreferredWidth(geometry().width());           
             }
             else {
-                 mWebView->setMaximumWidth(width);
-                 mWebView->setMinimumWidth(width);
-                 mWebView->setPreferredWidth(width);
+                mWebView->setPreferredWidth(width);
             }
-            mWebView->setMinimumHeight(height);
-            mWebView->setPreferredHeight(height);
+            mWebView->setPreferredHeight(height);        
         }
     }
-    mLatestLoadingSize=size;
+    mLatestLoadingSize = size;
 }
 
 /*!
@@ -673,43 +698,18 @@
 */
 void NmViewerView::scaleWebViewWhenLoaded()
 {
-    if (mWebView&&mWebView->page()) {
-        QSizeF contentSize = mWebView->page()->mainFrame()->contentsSize();
+    QRectF myGeometry = geometry();
+    QWebPage *page = mWebView->page();
+    if (mWebView && page) {
+        page->setViewportSize(myGeometry.size().toSize());
+        QSizeF contentSize = page->mainFrame()->contentsSize();
         int width = (int)contentSize.width();
-        int height = (int)contentSize.height();
-        // Set content (webview) width
-        if (mDisplayingPlainText){
-            mWebView->page()->setPreferredContentsSize(mScreenSize);
-            mWebView->setMinimumWidth(mScreenSize.width());
-            mWebView->setMaximumWidth(mScreenSize.width());
-            mWebView->setPreferredWidth(mScreenSize.width());
-        }
-        else {
-            mWebView->setMinimumWidth(width);
-            mWebView->setMaximumWidth(width);
-            mWebView->setPreferredWidth(width);
-        }
-        // Set content (webview) height
-        if (mScrollAreaContents){
-            QRectF contentRect = mScrollAreaContents->geometry();
-            if (contentRect.height()<geometry().height()){
-                contentRect.setHeight(geometry().height());
-                mViewerContent->setPreferredHeight(contentRect.height());
-                qreal webViewHeight = geometry().height()-mHeaderWidget->geometry().height();
-                mWebView->setMinimumHeight(webViewHeight);
-                mWebView->setMaximumHeight(webViewHeight);
-                mWebView->setPreferredHeight(webViewHeight);
-            }
-            else{
-                mWebView->setMinimumHeight(height);
-                mWebView->setMaximumHeight(height);
-                mWebView->setPreferredHeight(height);
-            }
-        }
+        int height = (int)contentSize.height();  
+        mWebView->setPreferredWidth(width);
+        mWebView->setPreferredHeight(height);
     }
 }
 
-
 /*!
     Set new dimensions after orientation change.
 */
@@ -725,31 +725,8 @@
         // Set attawidget minimum & maximum size
         mAttaWidget->setMinimumWidth(mScreenSize.width());
         mAttaWidget->setMaximumWidth(mScreenSize.width());
-    }
-
-    // Scale web view and its contens
-    if (mWebView){
-        if (mDisplayingPlainText){
-            mWebView->setMaximumWidth((int)mScreenSize.width());
-            mWebView->page()->setPreferredContentsSize(QSize((int)mScreenSize.width(),
-                                           (int)mScreenSize.height()));
-        }
-        else{
-            // Check whether contentsize fits to screen
-            // and if not, set preferred size again to allow panning
-            QSizeF contentSize = mWebView->page()->mainFrame()->contentsSize();
-            if (contentSize.width()>mScreenSize.width()){
-                mWebView->setMaximumWidth((int)contentSize.width());
-                mWebView->page()->setPreferredContentsSize(QSize((int)contentSize.width(),
-                                                           (int)contentSize.height()));
-            }
-            else{
-                mWebView->setMaximumWidth((int)mScreenSize.width());
-                mWebView->page()->setPreferredContentsSize(QSize((int)mScreenSize.width(),
-                                               (int)mScreenSize.height()));
-            }
-        }
-    }
+    }    
+    scaleWebViewWhenLoaded();
 
     if (mToolbarEnabled) {
 		// Re-create toolbar in orientation switch
@@ -757,7 +734,6 @@
     }
 }
 
-
 /*!
    Screen orientation changed. Web view needs to be scaled when
    landscape <-> portrait switch occurs because text needs to
@@ -774,66 +750,30 @@
 */
 void NmViewerView::linkClicked(const QUrl& link)
 {
-    NMLOG("link clicked");
-      if (link.scheme() == "http" ||
-          link.scheme() == "https" ) {
-          QDesktopServices::openUrl(link);
-      }
-      else if (link.scheme() == "mailto"){
-          QList<NmAddress*> *addrList = new QList<NmAddress*>();
-          NmAddress *mailtoAddr = new NmAddress();
-          QString address = link.toString(QUrl::RemoveScheme);
-          mailtoAddr->setAddress(address);
-          mailtoAddr->setDisplayName(address);
-          addrList->append(mailtoAddr);
-          // Create start parameters. Address list ownership
-          // is transferred to startparam object
-          NmUiStartParam* param = new NmUiStartParam(NmUiViewMessageEditor,
-                                                     mStartParam->mailboxId(),
-                                                      mStartParam->folderId(),
-                                                     0, NmUiEditorMailto, addrList );
-          mApplication.enterNmUiView(param);
-      }
-}
-
-/*!
-   Send mouse release event to web view
-*/
-void NmViewerView::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
-    NmMailViewerWK* view = webView();
-    if (event&& view && mHeaderWidget && mScrollAreaContents) {
-        QPointF lastReleasePoint = event->pos();
-        QPointF contentWidgetPos = mScrollAreaContents->pos();
-        qreal headerHeight = mHeaderWidget->geometry().height();
-        qreal y = lastReleasePoint.y()-headerHeight;
-        y -= contentWidgetPos.y();
-        qreal x = lastReleasePoint.x()-contentWidgetPos.x();
-        const QPointF pointToWebView(x, y);
-        event->setPos(pointToWebView);
-        event->setAccepted(true);
-        view->sendMouseReleaseEvent(event);
-    }
-}
-
-/*!
-   Send mouse press event
-*/
-void NmViewerView::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
-{
-    NmMailViewerWK* view = webView();
-    if (event&& view && mHeaderWidget && mScrollAreaContents) {
-        QPointF lastPressPoint = event->pos();
-        QPointF contentWidgetPos = mScrollAreaContents->pos();
-        qreal headerHeight = mHeaderWidget->geometry().height();
-        qreal y = lastPressPoint.y()-headerHeight;
-        y -= contentWidgetPos.y();
-        qreal x = lastPressPoint.x()-contentWidgetPos.x();
-        const QPointF pointToWebView(x, y);
-        event->setPos(pointToWebView);
-        event->setAccepted(true);
-        view->sendMousePressEvent(event);
-    }
+    NM_FUNCTION;
+    
+    if (link.scheme() == NmHttpLinkScheme ||
+        link.scheme() == NmHttpsLinkScheme) {
+        mAttaManager.cancelFetch();
+        QDesktopServices::openUrl(link);
+    } else if (link.scheme() == NmMailtoLinkScheme){
+        mAttaManager.cancelFetch();
+        QList<NmAddress*> *addrList = new QList<NmAddress*>();
+        NmAddress *mailtoAddr = new NmAddress();
+        QString address = link.toString(QUrl::RemoveScheme);
+        mailtoAddr->setAddress(address);
+        mailtoAddr->setDisplayName(address);
+        addrList->append(mailtoAddr);
+        // Create start parameters. Address list ownership
+        // is transferred to startparam object
+        NmUiStartParam* param = new NmUiStartParam(NmUiViewMessageEditor,
+                                                   mStartParam->mailboxId(),
+                                                   mStartParam->folderId(),
+                                                   0,
+                                                   NmUiEditorMailto,
+                                                   addrList);
+        mApplication.enterNmUiView(param);
+    }    
 }
 
 /*!
@@ -843,11 +783,11 @@
 bool NmViewerView::eventOnTopOfHeaderArea(QGraphicsSceneMouseEvent *event)
 {
     bool ret(false);
-    if (event && mHeaderWidget){
+    if (event && mHeaderWidget) {
         QPointF lastReleasePoint = event->lastPos();
         QPointF contentWidgetPos = mScrollAreaContents->pos();
         int headerHeight = (int)mHeaderWidget->geometry().height();
-        if (lastReleasePoint.y()<headerHeight+contentWidgetPos.y()){
+        if (lastReleasePoint.y()<headerHeight+contentWidgetPos.y()) {
             ret=true;
         }
     }
@@ -855,7 +795,7 @@
 }
 
 /*!
-   get function for content widget web view.
+    Get function for content widget web view.
 */
 NmMailViewerWK* NmViewerView::webView()
 {
@@ -863,14 +803,24 @@
 }
 
 /*!
+    Get function for message being viewed
+*/
+NmMessage* NmViewerView::message()
+{
+    return mMessage;
+}
+
+/*!
    Function to set message read status
 */
 void NmViewerView::changeMessageReadStatus(bool read)
 {
+    NM_FUNCTION;
+    
     QList<const NmMessageEnvelope*> envelopeList;
     NmMessageEnvelope *envelope = &mMessage->envelope();
     QPointer<NmStoreEnvelopesOperation> op(NULL);
-    if (envelope){
+    if (envelope) {
         if ( read != envelope->isRead() ){
             if (read){
                 envelope->setRead(true);
@@ -901,7 +851,7 @@
 {
     if (mStartParam){
         NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId());
-        if (meta){
+        if (meta) {
             setTitle(meta->name());
         }
     }
@@ -918,17 +868,17 @@
         QRectF webViewRect = mWebView->geometry();
         QTransform tr;
         qreal leftMovementThreshold(webViewRect.width()-mHeaderWidget->geometry().width());
-        if (newPosition.x()<0){
+        if (newPosition.x()<0) {
             tr.translate(webViewRect.topLeft().x() ,0);
         }
-        else if (newPosition.x()>=0 && newPosition.x()<leftMovementThreshold){
+        else if (newPosition.x()>=0 && newPosition.x()<leftMovementThreshold) {
             tr.translate(mHeaderStartScenePos.x()+newPosition.x() ,0);
         }
         else {
             tr.translate(webViewRect.topLeft().x()+leftMovementThreshold ,0);
         }
         mHeaderWidget->setTransform(tr);
-        if (mAttaWidget){
+        if (mAttaWidget) {
             mAttaWidget->setTransform(tr);
         }
     }
@@ -982,17 +932,12 @@
 */
 void NmViewerView::handleActionCommand(NmActionResponse &actionResponse)
 {
-    bool showSendInProgressNote = false;
-
     // Handle options menu or toolbar
     if (actionResponse.menuType() == NmActionOptionsMenu ||
     	actionResponse.menuType() == NmActionToolbar) {
         switch (actionResponse.responseCommand()) {
             case NmActionResponseCommandReply: {
-                if (mUiEngine.isSendingMessage()) {
-                    showSendInProgressNote = true;
-                    break;
-                }
+                mAttaManager.cancelFetch();
                 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor,
                     mStartParam->mailboxId(), mStartParam->folderId(),
                     mStartParam->messageId(), NmUiEditorReply);
@@ -1000,10 +945,7 @@
             }
             break;
             case NmActionResponseCommandReplyAll: {
-                if (mUiEngine.isSendingMessage()) {
-                    showSendInProgressNote = true;
-                    break;
-                }
+                mAttaManager.cancelFetch();
                 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor,
                     mStartParam->mailboxId(), mStartParam->folderId(),
                     mStartParam->messageId(), NmUiEditorReplyAll);
@@ -1011,10 +953,7 @@
             }
             break;
             case NmActionResponseCommandForward: {
-                if (mUiEngine.isSendingMessage()) {
-                    showSendInProgressNote = true;
-                    break;
-                }
+                mAttaManager.cancelFetch();
                 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageEditor,
                     mStartParam->mailboxId(), mStartParam->folderId(),
                     mStartParam->messageId(), NmUiEditorForward);
@@ -1022,63 +961,34 @@
             }
             break;
             case NmActionResponseCommandDeleteMail: {
-                HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
-                messageBox->setText(hbTrId("txt_mail_dialog_delete_mail"));
-                messageBox->setTimeout(HbMessageBox::NoTimeout);
-
-                mOkAction = new HbAction(tr("Ok"),messageBox);
-                mCancelAction = new HbAction(tr("Cancel"),messageBox);
-                messageBox->addAction(mOkAction);
-                messageBox->addAction(mCancelAction);
-                
-                // Read user selection
-                messageBox->open(this, SLOT(deleteButton(HbAction*)));
-              }
+                mAttaManager.cancelFetch();
+                deleteMessage();
+                }
             break;
             default:
                 break;
         }
     }
-
-    if (showSendInProgressNote) {
-        QString noteText = hbTrId("txt_mail_dialog_still_sending");
-
-        // get message subject from the message being sent
-        const NmMessage *message = mUiEngine.messageBeingSent();
-        if (message) {
-            noteText = noteText.arg(NmUtilities::truncate(message->envelope().subject(), 20));
-        }
-        HbMessageBox::warning(noteText);
-    }
 }
 
 /*!
-    Slot. Signaled when delete button is pressed
+    Deletes the currently open message
 */
-void NmViewerView::deleteButton(HbAction* result)
+void NmViewerView::deleteMessage()
 {
-     if (result == mOkAction ) {
-        QList<NmId> messageList;
-        messageList.append(mStartParam->messageId());
-
-        int err = mUiEngine.deleteMessages(mStartParam->mailboxId(),
-                                           mStartParam->folderId(),
-                                           messageList);
-
-        messageList.clear();
-        if (NmNoError != err) {
-            // Failed to delete the messages!
-            NMLOG(QString("NmViewerView::handleActionCommand(): failed err=%1").arg(err));
-        }
-    }
-
-    mCancelAction = NULL;
-    mOkAction = NULL;
+    NM_FUNCTION;
+    
+    QList<NmId> messageList;
+    messageList.append(mStartParam->messageId());  
+    int err = mUiEngine.deleteMessages(mStartParam->mailboxId(),
+                                       mStartParam->folderId(),
+                                       messageList);
+    messageList.clear();
 }
 
 
 /*!
-    Slot. Signaled when attachment fetch progress changes
+    This is called when attachment fetch progress changes
 */
 void NmViewerView::progressChanged(int value)
 {
@@ -1091,15 +1001,15 @@
 }
 
 /*!
-    Slot. Signaled when attachment fetch is completed
+    This is called when attachment fetch is completed
 */
 void NmViewerView::fetchCompleted(int result)
 {
     if (mAttaWidget && mAttaIndexUnderFetch != NmNotFoundError) {
         if (result == NmNoError) {
-            progressValueChanged(mAttaIndexUnderFetch, 100);
-        }
-        else {
+            progressValueChanged(mAttaIndexUnderFetch, NmProgressValueComplete);
+            openAttachment(mAttaIndexUnderFetch);
+        } else {
             mAttaWidget->hideProgressBar(mAttaIndexUnderFetch);
         }
     }
@@ -1107,16 +1017,34 @@
 }
 
 /*!
-    externalDelete. From NmMessageListModel, handles viewer shutdown when current message is deleted.
+    externalDelete. From NmUiEngine, handles viewer shutdown when current message is deleted.
 */
 void NmViewerView::messageDeleted(const NmId &mailboxId, const NmId &folderId, const NmId &messageId)
 {
-    NMLOG("NmViewerView::messageDeleted");
     if ((mStartParam->viewId() == NmUiViewMessageViewer)
         && (mStartParam->mailboxId()== mailboxId)
         && (mStartParam->folderId()== folderId)
-        && (mStartParam->messageId()== messageId)){
-        mApplication.popView();
+        && (mStartParam->messageId()== messageId)) {
+        mApplication.prepareForPopView();
     }
 }
 
+/*!
+    Helper function for wait dialog creation.
+*/
+void NmViewerView::createAndShowWaitDialog()
+{
+    delete mWaitDialog;
+    mWaitDialog = NULL;
+    // Create new wait dialog and set it to me modal with dimmed background
+    mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
+    // Connect to observe orientation change events
+    connect(mWaitDialog->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
+                this, SLOT(orientationChanged(Qt::Orientation)));
+    mWaitDialog->setModal(true);
+    mWaitDialog->setBackgroundFaded(true);
+    connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(waitNoteCancelled()));
+    mWaitDialog->setText(hbTrId("txt_mail_dialog_loading_mail_content"));
+    // Display wait dialog
+    mWaitDialog->show(); 
+}
--- a/emailuis/nmailui/src/nmviewerviewnetmanager.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmviewerviewnetmanager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -11,8 +11,9 @@
 *
 * Contributors:
 *
-* Description:
-*
+* Description: NMail viewer net manager implementation.
+*              This class is needed to separate cid
+*              images from url-based images
 */
 
 #include "nmuiheaders.h"
@@ -28,10 +29,12 @@
 /*!
     Constructor
 */
-NmViewerViewNetManager::NmViewerViewNetManager()
+NmViewerViewNetManager::NmViewerViewNetManager(NmUiEngine &uiEngine)
     : QNetworkAccessManager(),
+      mUiEngine(uiEngine),
       mMessageView(NULL)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -39,6 +42,7 @@
 */
 NmViewerViewNetManager::~NmViewerViewNetManager()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -46,6 +50,8 @@
 */
 void NmViewerViewNetManager::setView(NmViewerView *viewerView)
 {
+    NM_FUNCTION;
+    
     mMessageView=viewerView;
 }
 
@@ -55,6 +61,8 @@
 QNetworkReply *NmViewerViewNetManager::createRequest(
     Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
 {
+    NM_FUNCTION;
+    
     QNetworkRequest myRequest(request);
     // Set request attribute to prefer cachevar  
     const QVariant cacheControl((int)QNetworkRequest::PreferCache);
@@ -64,11 +72,27 @@
     // Check whether request is for embedded image
     if (mMessageView&&mMessageView->webView()&&op==QNetworkAccessManager::GetOperation
         && requestUrl.scheme()==NmViewerViewNetManagerScheme) {
-        NmViewerViewNetReply* reply = new NmViewerViewNetReply(
-            mMessageView->webView()->loadResource(QTextDocument::ImageResource, requestUrl));
-        reply->setOriginalRequest(myRequest);
-        return reply;
+        QString id = requestUrl.path();
+        NmId partId;
+        bool isFetched(false);
+        NmMessage *message = mMessageView->message();
+        if (message) {
+            QVariant data = mMessageView->webView()->loadResource(
+                    QTextDocument::ImageResource, requestUrl, partId, isFetched);
+            NmViewerViewNetReply* reply(NULL);
+            if (isFetched) {
+                reply = new NmViewerViewNetReply(data, mUiEngine);
+            }
+            else {
+                const NmMessageEnvelope &env = message->envelope();
+                reply = new NmViewerViewNetReply(data, mUiEngine,
+                        env.mailboxId(), env.folderId(),
+                        env.messageId(), partId);
+            }
+            reply->setOriginalRequest(myRequest);
+            return reply;
         }
+    }
     // If request is not for embedded image, forward to base class
     return QNetworkAccessManager::createRequest(op, myRequest, outgoingData);
 }
--- a/emailuis/nmailui/src/nmviewerviewnetreply.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmviewerviewnetreply.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -28,18 +28,52 @@
 /*!
     Constructor
 */
-NmViewerViewNetReply::NmViewerViewNetReply(QVariant data)
+NmViewerViewNetReply::NmViewerViewNetReply(QVariant data, NmUiEngine &uiEngine)
     : QNetworkReply(),
       mDataArray(data.toByteArray()),
+      mUiEngine(uiEngine),
+      mOperation(NULL),
       mReadIndex(0)
 {
+    NM_FUNCTION;
+    
     open(ReadWrite);
     setReadBufferSize(mDataArray.length());
     // QNetworkAccessManager starts listening the signals only
     // after the construction, so we cannot signal reply to be
     // ready instantly. We need to emit the signals after the
     // construction.
-    QTimer::singleShot(100, this, SLOT(signalReady()));
+    QMetaObject::invokeMethod(this, "signalReady", Qt::QueuedConnection);
+}
+
+/*!
+
+*/
+NmViewerViewNetReply::NmViewerViewNetReply(QVariant data, NmUiEngine &uiEngine, 
+        const NmId &mailboxId, const NmId &folderId, const NmId &messageId, 
+        const NmId &messagePartId)
+    : QNetworkReply(),
+      mDataArray(data.toByteArray()),
+      mUiEngine(uiEngine),
+      mMailboxId(mailboxId),
+      mFolderId(folderId),
+      mMessageId(messageId),
+      mMessagePartId(messagePartId),
+      mOperation(NULL),
+      mReadIndex(0)
+{
+    mOperation = uiEngine.fetchMessagePart(mMailboxId, mFolderId, mMessageId, mMessagePartId);
+    if (mOperation) {
+        connect(mOperation, SIGNAL(operationCompleted(int)),
+            this, SLOT(fetchCompleted(int)));
+        connect(mOperation, SIGNAL(operationCancelled()),
+            this, SLOT(fetchCancelled()));
+    }
+    else {
+        open(ReadWrite);
+        setReadBufferSize(mDataArray.length());
+        QMetaObject::invokeMethod(this, "signalReady", Qt::QueuedConnection);
+    }
 }
 
 /*!
@@ -47,6 +81,7 @@
 */
 NmViewerViewNetReply::~NmViewerViewNetReply()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -54,9 +89,14 @@
 */
 void NmViewerViewNetReply::signalReady()
 {
+    NM_FUNCTION;
+    
     // Insert embedded images into cache manually
     if(manager()) {
         if(manager()->cache() && request().url().scheme() == NMUI_NET_REPLY_CONTENT_ID) {
+            // Store url to use for reply in access manager finished emitting. 
+            setUrl(request().url());
+            
             // Metadata required for inserted data
             QNetworkCacheMetaData metaData;
             metaData.setUrl(request().url());
@@ -76,11 +116,58 @@
 }
 
 /*!
+    Slot. Called when fetch operation completes
+*/
+void NmViewerViewNetReply::fetchCompleted(int result)
+{
+    NM_FUNCTION;
+    
+    Q_UNUSED(result);
+    NmMessage *message = mUiEngine.message(
+                        mMailboxId, mFolderId, mMessageId);
+    if (message) {
+        QList<NmMessagePart*> partList;
+        message->attachmentList(partList);
+        NmMessagePart *part(NULL);
+        for (int i = 0; !part && i < partList.count(); i++) {
+            if (partList[i]->partId() == mMessagePartId) {
+                part = partList[i];
+                break;
+            }
+        }
+        if (part) {
+            int error = mUiEngine.contentToMessagePart(mMailboxId, mFolderId, mMessageId, *part);
+            if (error == NmNoError) {
+                mDataArray = part->binaryContent();
+            }
+        }
+    }
+    delete message;
+    message = NULL;
+    open(ReadWrite);
+    setReadBufferSize(mDataArray.length());
+    QMetaObject::invokeMethod(this, "signalReady", Qt::QueuedConnection);
+}
+
+/*!
+    Slot. Called if fetch operation is cancelled
+*/
+void NmViewerViewNetReply::fetchCancelled()
+{
+    NM_FUNCTION;
+    
+    // just call fetch completed
+    fetchCompleted(NmCancelError);
+}
+
+/*!
     setOriginalRequest. This function is created to provide access to call
     base class' protected function setRequest
 */
 void NmViewerViewNetReply::setOriginalRequest(const QNetworkRequest &request)
 {
+    NM_FUNCTION;
+    
     setRequest(request);
 }
 
@@ -89,6 +176,8 @@
 */
 qint64 NmViewerViewNetReply::readData(char *data, qint64 maxlen)
 {
+    NM_FUNCTION;
+    
     qint64 i = 0;
     const qint64 dataLength(mDataArray.length());
 
@@ -107,6 +196,8 @@
 */
 qint64 NmViewerViewNetReply::readBufferSize() const
 {
+    NM_FUNCTION;
+    
     return mDataArray.length();
 }
 
@@ -118,6 +209,8 @@
 */
 qint64 NmViewerViewNetReply::bytesAvailable() const
 {
+    NM_FUNCTION;
+    
     return mDataArray.length() + QIODevice::bytesAvailable();
 }
 
@@ -126,6 +219,8 @@
 */
 bool NmViewerViewNetReply::isSequential () const
 {
+    NM_FUNCTION;
+    
     return false;
 }
 
@@ -135,5 +230,6 @@
 */
 void NmViewerViewNetReply::abort()
 {
+    NM_FUNCTION;
 }
 
--- a/emailuis/nmailui/src/nmviewerwebview.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/src/nmviewerwebview.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -1,90 +1,177 @@
 /*
-* 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: NMailUI web viewer. Inherits from
+ *              QGrapohicsWebView and handles gestures, etc.
+ */
 
 #include "nmuiheaders.h"
 
 /*!
-    Constructor
+    Constructor.
 */
 NmMailViewerWK::NmMailViewerWK()
-	:QGraphicsWebView()
+: QGraphicsWebView(),
+  mContent(),
+  mSuppressRelease(false)
 {
+    // Subscribe this widget to tap and pinch gestures.
+    grabGesture(Qt::TapGesture);
+    grabGesture(Qt::PinchGesture);
+    // Prevent this widget from accepting focus.
+    setFocusPolicy(Qt::NoFocus);
 }
 
 /*!
-    Destructor
-*/
+    Destructor.
+ */
 NmMailViewerWK::~NmMailViewerWK()
 {
     mContent.clear();
 }
 
 /*!
-
-*/
-void NmMailViewerWK::setParentView(NmViewerView *parentView)
+    Adds content into web view.
+ */
+void NmMailViewerWK::addContent(QString key, QVariant val, NmId partId, bool isFetched) 
 {
-    mParentView = parentView;
+    mContent[key] = NmMailViewerWkContentItem(val, partId, isFetched);
 }
 
 /*!
-    addContent. Function adds content into web view.
-*/
-void NmMailViewerWK::addContent(QString key, QVariant val) {
-    mContent[key] = val;
-}
-
-/*!
-    loadResource. Function returns resource from added content (added with addContent)
-*/
-QVariant NmMailViewerWK::loadResource(int type, const QUrl &name)
+    Returns resource from added content.
+ */
+QVariant NmMailViewerWK::loadResource(int type, const QUrl &name, NmId &partId, bool &isFetched)
 {
+    NM_FUNCTION;
+    
     if (type == QTextDocument::ImageResource) {
         QString key = '<' + name.path() + '>';
         if (!mContent.contains(key)) {
             key = name.path();
         }
         if (mContent.contains(key)) {
-            return mContent[key];
+            partId = mContent[key].mPartId;
+            isFetched = mContent[key].mIsFetched;
+            return mContent[key].mData;
         }
-        return 0;
     }
     return 0;
 }
 
 /*!
-    sendMousePressEvent. Function is used to relay mouse event to base class
-*/
-void NmMailViewerWK::sendMousePressEvent(QGraphicsSceneMouseEvent *event)
+    This is the main event handler that processes all incoming events in an
+    appropriate manner.
+ */
+bool NmMailViewerWK::event(QEvent* event)
 {
-    if (event){
-        QGraphicsWebView::mousePressEvent(event);
+    bool consumed = false;
+    if (event) {
+        switch (event->type()) {
+        case QEvent::Gesture:
+            // Handle gesture events.
+            gestureEvent(static_cast<QGestureEvent*>(event));
+            consumed = event->isAccepted();
+            break;
+        case QEvent::GraphicsSceneContextMenu:
+            // Handle context-menu events.
+            // contextMenuEvent() is invoked directly in order to override
+            // text selection in QWebPage.
+            contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent*>(event));
+            consumed = event->isAccepted();
+            break;
+        default:
+            // Invoke base class' event handler.
+            consumed = QGraphicsWebView::event(event);
+            break;
+        }
+    }
+    return consumed;
+}
+
+/*!
+    Handles context-menu events.
+ */
+void NmMailViewerWK::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
+{
+    if (event) {
+        // Suppress context-menu invocations.
+        event->accept();
     }
 }
 
 /*!
-    sendMouseReleaseEvent. Function is used to relay mouse event to base class
-*/
-void NmMailViewerWK::sendMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+    Handles gesture events.
+ */
+void NmMailViewerWK::gestureEvent(QGestureEvent* event)
 {
     if (event) {
-        QGraphicsWebView::mouseReleaseEvent(event);
+        if (QTapGesture* tap = static_cast<QTapGesture*>(event->gesture(Qt::TapGesture))) {
+            switch (tap->state()) {
+            case Qt::GestureCanceled:
+                // Tap cancellation suppresses the following mouse release.
+                mSuppressRelease = true;
+                break;
+            default:
+                // Other states disclose the following mouse release.
+                mSuppressRelease = false;
+                break;
+            }
+            event->accept();
+        }
+        if (QPinchGesture* pinch = static_cast<QPinchGesture*>(event->gesture(Qt::PinchGesture))) {
+            // Handle pinch (zoom).
+            // At the moment we simply consume the event.
+            event->accept();
+        }
     }
 }
 
+/*!
+    Handles double-click events.
+ */
+void NmMailViewerWK::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
+{
+    if (event) {
+        // Handle double clicks (instant zoom).
+        // At the moment we simply consume the event.
+        event->accept();
+    }
+}
 
+/*!
+    Handles mouse-move events.
+ */
+void NmMailViewerWK::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
+{
+    if (event) {
+        // Suppress drag selection.
+        event->accept();
+    }
+}
 
+/*!
+    Handles mouse-release events.
+ */
+void NmMailViewerWK::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
+{
+    if (event) {
+        // Suppress mouse release if the previous tap was cancelled.
+        // Otherwise, invoke the base class' event handler.
+        if (mSuppressRelease) {
+            event->accept();
+        } else {
+            QGraphicsWebView::mouseReleaseEvent(event);
+        }
+    }
+}
Binary file emailuis/nmailui/translations/mail.qm has changed
--- a/emailuis/nmailui/translations/mail.ts	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailui/translations/mail.ts	Thu Jul 22 16:30:28 2010 +0100
@@ -7,7 +7,7 @@
     <source>(No Subject)</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
     <extra-loc-positionid>dblist_3_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -17,7 +17,7 @@
     <source>Delete</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
     <extra-loc-positionid>opt</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -32,12 +32,22 @@
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_subhead_outbox">
+    <comment>Text for indicating the current folder in mail list view. Component is simple label</comment>        
+    <source>Outbox</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>txt_mail_subhead_inbox</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001</extra-loc-viewid>
+    <extra-loc-positionid>subhead</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_menu_remove_all">
     <comment>Item specific menu item for removing all attachments from the highlighted mail in mail editor</comment>        
     <source>Remove all</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>menu</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -46,8 +56,8 @@
     <comment>Original message header data in the editor. Followed by the name/mail address of the recipient of the message.</comment>        
     <source>To:</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_editor_reply_sent</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004_c</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -62,12 +72,22 @@
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_dialog_save_message_to_drafts">
+    <comment>Dialog that is shown if the editor if the user tries to go back without sending the message. Drafts refers to the name of the folder where unsent messages are saved.</comment>        
+    <source>Do you want to save this message to drafts?</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
+    <extra-loc-positionid>dialog</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_opt_add_priority_sub_normal">
     <comment>Suboption for option &quot;Add priority&quot; to set mail as normal priority</comment>        
     <source>Normal</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_sec_add</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>opt_1_sub</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -77,27 +97,37 @@
     <source>Attach</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_toolbar_tiny_2</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>button</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_list_photo">
-    <comment>Attach toolbar extension item in the viewer, opens images fetch for selecting image. Allows the user to attach an image to the message.</comment>        
+    <comment>Attach toolbar extension item in the editor, opens images fetch for selecting image. Allows the user to attach an image to the message. Note! The text is Image in the visio file but it is not consistent with other apps so it has been decided to change.</comment>        
     <source>Photo</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_004_b</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_dialog_no_mailboxes_defined">
+    <comment>When mail is selected and there are no mailboxes defined</comment>        
+    <source>No mailboxes defined</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
+    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-positionid>dialog</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_list_cc">
     <comment>Cc label in mail viewer</comment>        
     <source>Cc:</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_list_from</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_03</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_003</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -107,7 +137,7 @@
     <source>Mark as read</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_01_c</extra-loc-viewid>
+    <extra-loc-viewid>mail_001_c</extra-loc-viewid>
     <extra-loc-positionid>menu</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -117,7 +147,7 @@
     <source>Hide cc / bcc</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_a</extra-loc-viewid>
+    <extra-loc-viewid>mail_004_a</extra-loc-viewid>
     <extra-loc-positionid>opt</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -127,7 +157,7 @@
     <source>Send</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_toolbar_tiny_2</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>button</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -147,7 +177,7 @@
     <source>Reply all</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
     <extra-loc-positionid>opt</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -157,17 +187,27 @@
     <source>Reply</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
     <extra-loc-positionid>opt</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_shareui_send_as_mail">
+    <comment>text for share ui component. By selecting this the selected content will be sent as mail. For selecting content from another application to be sent as mail.</comment>        
+    <source>Send as new mail</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_pri_graphic</extra-loc-layout_id>    
+    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_opt_add_priority_sub_high">
     <comment>Suboption for option &quot;Add priority&quot; to set mail as high priority.</comment>        
     <source>High</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_sec_add</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>opt_1_sub</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -176,18 +216,18 @@
     <comment>Empty list text for Mail list view. Displayed in the Mail list view if there are no mails.</comment>        
     <source>(No messages)</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_view_empty_title_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_01</extra-loc-viewid>
+    <extra-loc-layout_id>txt_mail_dblist_val_no_subject</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001</extra-loc-viewid>
     <extra-loc-positionid>dblist_2</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_editor_reply_importance_high">
-    <comment>Custom layout ID parent. Original message header data in the editor. Level of importance for the message: High.</comment>        
+    <comment>Original message header data in the editor. Level of importance for the message: High.</comment>        
     <source>High</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_editor_reply_importance_high</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004_c</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -197,7 +237,7 @@
     <source>Settings</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_01_a</extra-loc-viewid>
+    <extra-loc-viewid>mail_001_a</extra-loc-viewid>
     <extra-loc-positionid>opt</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -207,7 +247,7 @@
     <source>New</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_toolbar_tiny_2</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_01</extra-loc-viewid>
+    <extra-loc-viewid>mail_001</extra-loc-viewid>
     <extra-loc-positionid>button</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -217,7 +257,17 @@
     <source>Sending mail %[]1 failed. Try to send it again or press back to cancel</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
+    <extra-loc-positionid>dialog</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_dialog_downloading_canceled">
+    <comment>A notification shown to a user when download cannot be completed because of there is not enough disk space.</comment>        
+    <source>Not enough memory - downloading canceled</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_002_a</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -227,7 +277,7 @@
     <source>%[]1 deleted.</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-viewid>mail_dialog_11</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -237,14 +287,14 @@
     <source>Still sending mail %[]1. Please wait operation to complete</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail </extra-loc-viewid>
+    <extra-loc-viewid>mail_dialog_13</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
-    <extra-loc-feature>mail </extra-loc-feature>
+    <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_dialog_you_can_not_send_more_than_l1_att">
-    <comment>Information note. %L1 is the maximum amount of attachments the server allows to be sent at once.  If the adds  attachments, which overall count exceeds the limit and presses send this note is shown and the mail is not sent. Maximum number of digits replacing the parameter is 3.</comment>        
-    <source>You can not send more than %L1 attachments at a time </source>
+<message numerus="yes" id="txt_mail_dialog_you_can_not_send_more_than_l1_att">
+    <comment>Information note. %Ln is the maximum amount of attachments the server allows to be sent at once.  If the adds  attachments, which overall count exceeds the limit and presses send this note is shown and the mail is not sent. Maximum number of digits replacing the parameter is 3.</comment>        
+    <source>You can not send more than %Ln attachments at a time </source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
     <extra-loc-viewid>mail</extra-loc-viewid>
@@ -267,7 +317,7 @@
     <source>Delete</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_01_c</extra-loc-viewid>
+    <extra-loc-viewid>mail_001_c</extra-loc-viewid>
     <extra-loc-positionid>menu</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -276,28 +326,18 @@
     <comment>Original message header data in the editor. Followed by the subject of the message.</comment>        
     <source>Subject:</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_editor_reply_sent</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004_c</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_menu_search_from_server">
-    <comment>Item specific command for searching number &amp;address from the service. IS THIS NEEDED?</comment>        
-    <source>search from server</source>
+<message numerus="no" id="txt_mail_status_menu_sending">
+    <comment>Secondary text for status menu item: indicates the sending progress is ongoing.</comment>        
+    <source>Sending in progress</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_menu_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
-    <extra-loc-positionid>menu</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mail_list_re">
-    <comment>Prefix in subject field in the editor. This indicates that the mail is replyed</comment>        
-    <source>Re:</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_list_fw</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
+    <extra-loc-layout_id>qtl_notifdialog_sec_medium_graphic</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001_d</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -307,87 +347,87 @@
     <source>(%L1 Mb)</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_menu_send_mail">
-    <comment>Item specific command for sending mail to a contact</comment>        
-    <source>send mail</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_menu_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
-    <extra-loc-positionid>menu</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mail_shareui_sending_please_wait">
     <comment>Text for shared UI component wait note. Shown when the user has sent an email from shared UI.</comment>        
     <source>Sending, please wait</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_notifdialog_pri2</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_list_fw">
-    <comment>Custom layout ID parent. Prefix in subject field in the editor. This indicates that the mail is forwarded</comment>        
-    <source>Fw:</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_list_fw</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
-    <extra-loc-positionid>list</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mail_dialog_invalid_mail_address_send">
     <comment>Note in editor when the user has typed incorrect mail address (e.g. without @-character). %[]1 is replaced with the name of the invalid mail address. Pressing yes sends the mail anyway</comment>        
     <source>Invalid mail address: %[]1. Send anyway?</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_menu_open_contact_card">
-    <comment>Item specific command for opening contact card from mail viewer</comment>        
-    <source>open contact card</source>
+<message numerus="no" id="txt_mail_opt_change_folder">
+    <comment>options menu item for changing the folder </comment>        
+    <source>Folders</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_menu_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
-    <extra-loc-positionid>menu</extra-loc-positionid>
+    <extra-loc-layout_id>qtl_menu_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001_a</extra-loc-viewid>
+    <extra-loc-positionid>opt_2</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_list_searching">
+    <comment>Text for indicating that the search is ongoing in mail list view. Component is simple label</comment>        
+    <source>Searching</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>txt_mail_subhead_inbox</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_008</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_editor_subject">
-    <comment>Subject label in mail editor</comment>        
+    <comment>Subject label in mail editor. Label for a field in message editor in which the user enters the subject of the message.</comment>        
     <source>Subject:</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>txt_mail_editor_to</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_list_from">
-    <comment>Custom layout ID parent. From label in mail viewer </comment>        
+    <comment>From label in mail viewer </comment>        
     <source>From:</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_list_from</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_03</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_003</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_opt_folder_sub_deleted">
+    <comment>Submenu item for Options menus item Folder (txt_mail_opt_change_folder)</comment>        
+    <source>Deleted items</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_menu_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001_a</extra-loc-viewid>
+    <extra-loc-positionid>opt_2_sub</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_editor_reply_importance_low">
     <comment>Original message header data in the editor. Level of importance for the message: Low.</comment>        
     <source>Low</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_editor_reply_importance_high</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004_c</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -396,8 +436,8 @@
     <comment>Original message header data in the editor. Followed by the name(s)/mail address(es) of the receipients to whom a copy of the message is sent.</comment>        
     <source>Cc:</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_editor_reply_sent</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004_c</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -407,27 +447,37 @@
     <source>Add priority</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>opt_1</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <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>
+    <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>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_dialog_server_settings_incorrect">
     <comment>Notification shown when the connection fails (e.g. when syncing) due to server settings. </comment>        
     <source>Server settings are incorrect. Do you want to check the settings?</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-viewid>mail_dialog_14 </extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_dialog_loading_mail_content">
-    <comment>Wait note shown until the mail content is loaded </comment>        
+    <comment>Wait note shown until the mail content is loaded. Dublicate. I need to check which one is used in implementation.</comment>        
     <source>Loading mail content</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri3</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -442,12 +492,22 @@
     <extra-loc-feature>mail</extra-loc-feature>
     <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>        
+    <source>%[]1: Unsent</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_notifdialog_pri_medium_graphic</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001_d</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_viewer_opt_forward">
     <comment>Options menu item in mail viewer: opens editor for forwarding</comment>        
     <source>Forward</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
     <extra-loc-positionid>opt</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -467,7 +527,7 @@
     <source>Delete message?</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -483,21 +543,41 @@
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_list_new_video">
-    <comment>Attach toolbar extension item in the viewer, opens camera for taking a new video</comment>        
+    <comment>Attach toolbar extension item in the editor, opens camera for taking a new video</comment>        
     <source>New video</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_004_b</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_reply_subject_prefix">
+    <comment>Text for subject field if the message is replyed.</comment>        
+    <source>Re:</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
+    <extra-loc-positionid>dblist_3_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_dialog_select_file">
+    <comment>Title text in file picker view. File picker view is opened when the user selects &quot;Other&quot; option from attachment list. For attaching files to mail messages. Underneath a list of selectable files is displayed.</comment>        
+    <source>Select file</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_007</extra-loc-viewid>
+    <extra-loc-positionid>dpophead</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_common_menu_open">
     <comment>Item specific option for opening the highlighted mail. </comment>        
     <source>Open</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_01_c</extra-loc-viewid>
+    <extra-loc-viewid>mail_001_c</extra-loc-viewid>
     <extra-loc-positionid>menu</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -507,9 +587,39 @@
     <source>Mail</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_list_pri_graphic</extra-loc-layout_id>    
-    <extra-loc-viewid>Mail</extra-loc-viewid>
+    <extra-loc-viewid>mail</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
-    <extra-loc-feature>Mail</extra-loc-feature>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_dblist_no_messages_matched_your_search">
+    <comment>A text shown in mail list view, if there are no matches to a search.</comment>        
+    <source>No messages matched your search. Try another search term. </source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>txt_mail_dblist_val_no_subject</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_008</extra-loc-viewid>
+    <extra-loc-positionid>dblist_4</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_list_sound">
+    <comment>Attach toolbar extension item in the editor, opens music fetch for selecting sound file. Allows the user to attach a sound file to the message. Note! The text is Music in the visio file but it is not consistent with other apps so it has been decided to change.</comment>        
+    <source>Sound</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_editor_to">
+    <comment>Custom layout ID parent. To label in mail editor. Label for a field in message editor in which the user enters the mail addresses of the main recipients  of the message.</comment>        
+    <source>To:</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>txt_mail_editor_to</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_dialog_deleting_mailbox">
@@ -517,27 +627,17 @@
     <source>Deleting mailbox</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri3</extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-viewid>mail_dialog_11</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_editor_to">
-    <comment>Custom layout ID parent. To label in mail editor</comment>        
-    <source>To:</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_editor_to</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
-    <extra-loc-positionid>list</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mail_editor_reply_importance">
     <comment>Original message header data in the editor. The user can select the level of importance for the message (High txt_mail_editor_reply_importance_high or Low txt_mail_editor_reply_importance_low).</comment>        
     <source>Importance:</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_editor_reply_sent</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004_c</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -546,48 +646,28 @@
     <comment>To label in mail viewer</comment>        
     <source>To:</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_list_from</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_03</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_003</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_dialog_data_has_been_deleted_to_protect_a">
-    <comment></comment>        
-    <source>Data has been deleted to protect against theft or loss. Contact you system administrator</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id></extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
-    <extra-loc-positionid>dialog</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mail_dialog_cannot_open_the_attachment_deleted">
-    <comment></comment>        
-    <source>Cannot open the attachment deleted on the server</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id></extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
-    <extra-loc-positionid>dialog</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mail_editor_reply_sent">
     <comment>Original message header data in the editor. Followed by the date when the message was sent.</comment>        
     <source>Sent:</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_editor_reply_sent</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004_c</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_dialog_account_disabled_due_to_security_i">
-    <comment></comment>        
+    <comment>Shown when the user tries to open the mailbox. </comment>        
     <source>Account disabled due to security issues. Contact your system administrator.</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id></extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_dialog_7</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -605,7 +685,7 @@
 <message numerus="no" id="txt_mail_dialog_send_via">
     <comment>Title for send via dialog. This dialog lists all mailboxes the user has. Underneath the title, a list of mailboxes is displayed. </comment>        
     <source>Send via</source>
-    <translation variants="yes" type="unfinished"></translation>
+    <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
     <extra-loc-viewid>mail</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
@@ -617,17 +697,27 @@
     <source>Refresh</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_01_a</extra-loc-viewid>
+    <extra-loc-viewid>mail_001_a</extra-loc-viewid>
     <extra-loc-positionid>opt</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_subhead_sent_items">
+    <comment>Text for indicating the current folder in mail list view. Component is simple label</comment>        
+    <source>Sent items</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>txt_mail_subhead_inbox</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001</extra-loc-viewid>
+    <extra-loc-positionid>subhead</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_opt_add_priority_sub_low">
     <comment>Suboption for option &quot;Add priority&quot; to set mail as low priority</comment>        
     <source>Low</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_sec_add</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>opt_1_sub</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -637,7 +727,7 @@
     <source>Mailbox deleted. </source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_notifdialog_pri2</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06</extra-loc-viewid>
+    <extra-loc-viewid>mail_006</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -646,8 +736,8 @@
     <comment>Original message header data in the editor. Separates the original mail message from the edit area of the new message the user is typing.</comment>        
     <source>---- Original message ----</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_editor_reply_sent</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004_c</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -657,7 +747,7 @@
     <source>Remove</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>menu</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -667,17 +757,27 @@
     <source>Delete mail?</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_select_contacts">
+    <comment>Title text shown in status pane when contacts are fetched from Phonebook.</comment>        
+    <source>Select contacts</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-positionid>dpophead</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_dialog_no">
     <comment>Button for notes txt_mail_dialog_server_settings_incorrect and txt_mail_dialog_address_or_password_incorrect.</comment>        
     <source>No</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_softkey_2</extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-viewid>mail_dialog_14_15</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -687,7 +787,7 @@
     <source>No mailboxes have been defined. Would you like to create a new mailbox?</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-viewid>mail_dialog_8</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -697,47 +797,47 @@
     <source>Do you want to delete the mailbox and all mail messages?</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-viewid>mail_dialog_9</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_dblist_val_no_subject">
-    <comment>No subject text for mail iten in Mail list view. Displayed in the Mail list view under the name of the sender if there is no subject in the received mail.</comment>        
+    <comment>No subject text for mail iten in Mail list view. Displayed in the Mail list view under the name of the sender if there is no subject in the received mail. Custom layout ID parent.</comment>        
     <source>(No Subject)</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_view_empty_title_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_01</extra-loc-viewid>
+    <extra-loc-layout_id>txt_mail_dblist_val_no_subject</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001</extra-loc-viewid>
     <extra-loc-positionid>dblist_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_dialog_conversion_error_unable_to_show_t">
-    <comment></comment>        
-    <source>Conversion error. Unable to show the content properly</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id></extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
-    <extra-loc-positionid>dialog</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mail_editor_bcc">
-    <comment>Bcc: label in mail editor</comment>        
+    <comment>Bcc: label in mail editor. Bcc = blind carbon copy. Label for a field in message editor in which the user enters the mail addresses of those recipients whose names s/he does not want to show to the rest of the recipients.</comment>        
     <source>Bcc:</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>txt_mail_editor_to</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_opt_folder_sub_drafts">
+    <comment>Submenu item for Options menus item Folder (txt_mail_opt_change_folder)</comment>        
+    <source>Drafts</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_menu_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001_a</extra-loc-viewid>
+    <extra-loc-positionid>opt_2_sub</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_editor_cc">
-    <comment>Cc: label in mail editor</comment>        
+    <comment>Cc: label in mail editor. Cc = carbon copy. Label for a field in message editor in which the user enters the mail addresses of additional recipients  who are not the main recipients of the message.</comment>        
     <source>Cc:</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>txt_mail_editor_to</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04</extra-loc-viewid>
+    <extra-loc-viewid>mail_004</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -747,11 +847,31 @@
     <source>Loading mail content</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_notifdialog_pri2_medium_graphic</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
     <extra-loc-positionid>dpophead</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_opt_folder_sub_inbox">
+    <comment>Submenu item for Options menus item Folder (txt_mail_opt_change_folder)</comment>        
+    <source>Inbox </source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_menu_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001_a</extra-loc-viewid>
+    <extra-loc-positionid>opt_2_sub</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_opt_folder_sub_sent">
+    <comment>Submenu item for Options menus item Folder (txt_mail_opt_change_folder)</comment>        
+    <source>Sent</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_menu_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001_a</extra-loc-viewid>
+    <extra-loc-positionid>opt_2_sub</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_dialog_unable_to_add_attachment">
     <comment>Error note for the case where the selected file cannot be attached (it&apos;s deleted, moved etc. at the same time)</comment>        
     <source>Unable to add attachment </source>
@@ -767,17 +887,37 @@
     <source>Yes</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_softkey_2</extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-viewid>mail_dialog_14_15</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_button_download_rest">
+    <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-viewid>mail_002_b</extra-loc-viewid>
+    <extra-loc-positionid>button</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_opt_folder_sub_outbox">
+    <comment>Submenu item for Options menus item Folder (txt_mail_opt_change_folder)</comment>        
+    <source>Outbox</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_menu_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001_a</extra-loc-viewid>
+    <extra-loc-positionid>opt_2_sub</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_editor_reply_from">
     <comment>Original message header data in the editor. Followed by the name/mail address of the sender of the message.</comment>        
     <source>From:</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>txt_mail_editor_reply_sent</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_c</extra-loc-viewid>
+    <extra-loc-layout_id>none</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_004_c</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -792,12 +932,42 @@
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_dialog_mail_address_incorrect">
+    <comment>The information dialog that is shown if the user&apos;s own mail address is incorrect and the user tries to sync or send mail.</comment>        
+    <source>Your mail address is incorrect. Check the mail address settings?</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
+    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-positionid>dpopinfo</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_text_attachment">
+    <comment>Text that is shown in POP mailboxes when there are attachments that are not downloaded yet. This text is preceded by an icon, therefore the lower-case initial letter.</comment>        
+    <source>attachment</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_002_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_status_menu_waiting_to_send">
+    <comment>Text for status menu item: indicates that there are unsent messages in outbox. %L1 is the number of unsent mails in that mailbox. L1% is usually less than 10 but can be also more.</comment>        
+    <source>Waiting to send (%L1)</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>
+    <extra-loc-positionid>dblist_5_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_dialog_do_you_want_to_delete_mfe">
     <comment>Confirmation note for mailbox deleting. This will delete also contacts, calendar and tasks data, which has been synchronized via this account. This MfE protocol only</comment>        
     <source>Do you want to delete all mail, calendar, contacts and tasks data related to this account?</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-viewid>mail_dialog_10</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -807,7 +977,7 @@
     <source>Mail</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_titlebar</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_05</extra-loc-viewid>
+    <extra-loc-viewid>mail_005</extra-loc-viewid>
     <extra-loc-positionid>title</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -817,7 +987,7 @@
     <source>Show cc / bcc</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_a</extra-loc-viewid>
+    <extra-loc-viewid>mail_004_a</extra-loc-viewid>
     <extra-loc-positionid>opt</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -832,13 +1002,13 @@
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_menu_search_from_service">
-    <comment>Item specific command for searching number &amp;address from the service</comment>        
-    <source>search from service</source>
+<message numerus="yes" id="txt_mail_list_search_results">
+    <comment>Text for indicating the search results in mail list view. Component is simple label. %Ln stands for the number of search results found in the search. The parameter can be even up to 9999.</comment>        
+    <source>%Ln results</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_menu_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_02</extra-loc-viewid>
-    <extra-loc-positionid>menu</extra-loc-positionid>
+    <extra-loc-layout_id>txt_mail_subhead_inbox</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_008</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -847,48 +1017,68 @@
     <source>Mark as unread</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_menu_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_01_c</extra-loc-viewid>
+    <extra-loc-viewid>mail_001_c</extra-loc-viewid>
     <extra-loc-positionid>menu</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_list_other">
-    <comment>Attach toolbar extension item in the viewer, opens file fetch for selecting any type of file</comment>        
+    <comment>Attach toolbar extension item in the editor, opens file fetch for selecting any type of file</comment>        
     <source>Other</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_004_b</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mail_forward_subject_prefix">
+    <comment>Text for subject field if the message is forwarded.</comment>        
+    <source>Fw:</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_002</extra-loc-viewid>
+    <extra-loc-positionid>dblist_3_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mail_subhead_drafts">
+    <comment>Text for indicating the current folder in mail list view. Component is simple label</comment>        
+    <source>Drafts</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>txt_mail_subhead_inbox</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001</extra-loc-viewid>
+    <extra-loc-positionid>subhead</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_dialog_address_or_password_incorrect">
-    <comment>Notification shown when the connection fails (e.g. when syncing) due to mail address or password. </comment>        
-    <source>Mail address or password is incorrect. Do you want to check the settings?</source>
+    <comment>Notification shown when the connection fails (e.g. when syncing) due to username or password. </comment>        
+    <source>Username or password is incorrect. Do you want to check the settings?</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-viewid>mail_dialog_15</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_list_music">
-    <comment>Attach toolbar extension item in the viewer, opens music fetch for selecting music file. Allows the user to attach a music file to the message.</comment>        
-    <source>Music</source>
+<message numerus="no" id="txt_mail_list_new_photo">
+    <comment>Attach toolbar extension item in the editor, opens camera for taking a new photo</comment>        
+    <source>New photo</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_004_b</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_list_new_photo">
-    <comment>Attach toolbar extension item in the viewer, opens camera for taking a new photo</comment>        
-    <source>New photo</source>
-    <translation variants="yes" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_b</extra-loc-viewid>
-    <extra-loc-positionid>list</extra-loc-positionid>
+<message numerus="no" id="txt_mail_subhead_deleted_items">
+    <comment>Text for indicating the current folder in mail list view. Component is simple label</comment>        
+    <source>Deleted items</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>txt_mail_subhead_inbox</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_001</extra-loc-viewid>
+    <extra-loc-positionid>subhead</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -903,11 +1093,11 @@
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_list_video">
-    <comment>Attach toolbar extension item in the viewer, opens video fetch for selecting video file. Allows the user to attach a video file to the message.</comment>        
+    <comment>Attach toolbar extension item in the editor, opens video fetch for selecting video file. Allows the user to attach a video file to the message.</comment>        
     <source>Video</source>
     <translation variants="yes" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_list_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_04_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_004_b</extra-loc-viewid>
     <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -917,27 +1107,17 @@
     <source>Inbox </source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>txt_mail_subhead_inbox</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_01</extra-loc-viewid>
+    <extra-loc-viewid>mail_001</extra-loc-viewid>
     <extra-loc-positionid>subhead</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mail_dialog_1_is_disabled_enable">
-    <comment></comment>        
-    <source>%1 is disabled, enable?</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id></extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
-    <extra-loc-positionid>dialog</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mail_dialog_password_expired_new_security_cre">
-    <comment></comment>        
+    <comment>Shown when the user tries to open the mailbox if her password has expired.</comment>        
     <source>Password expired. New security credentials must be created on your computer.</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id></extra-loc-layout_id>    
-    <extra-loc-viewid>mail</extra-loc-viewid>
+    <extra-loc-layout_id>qtl_dialog_pri5</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_dialog_6</extra-loc-viewid>
     <extra-loc-positionid>dialog</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
--- a/emailuis/nmailuiengine/bwins/nmailuiengineu.def	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/bwins/nmailuiengineu.def	Thu Jul 22 16:30:28 2010 +0100
@@ -4,12 +4,12 @@
 	?insertDividerIntoModel@NmMessageListModel@@AAEXPAVNmMessageEnvelope@@H@Z @ 3 NONAME ; void NmMessageListModel::insertDividerIntoModel(class NmMessageEnvelope *, int)
 	?goOnline@NmUiEngine@@QAEHABVNmId@@@Z @ 4 NONAME ; int NmUiEngine::goOnline(class NmId const &)
 	??0NmStoreEnvelopesOperation@@QAE@XZ @ 5 NONAME ; NmStoreEnvelopesOperation::NmStoreEnvelopesOperation(void)
-	?currentMailboxId@NmMessageListModel@@QAE?AVNmId@@XZ @ 6 NONAME ; class NmId NmMessageListModel::currentMailboxId(void)
-	?folderById@NmDataManager@@QAEPAVNmFolderMetaData@@ABVNmId@@0@Z @ 7 NONAME ; class NmFolderMetaData * NmDataManager::folderById(class NmId const &, class NmId const &)
-	?removeAttachment@NmBaseClientPlugin@@QAEXXZ @ 8 NONAME ; void NmBaseClientPlugin::removeAttachment(void)
-	?completeOperationPart@NmAddAttachmentsOperation@@QAEXABVQString@@ABVNmId@@H@Z @ 9 NONAME ; void NmAddAttachmentsOperation::completeOperationPart(class QString const &, class NmId const &, int)
-	?data@NmMessageSearchListModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 10 NONAME ; class QVariant NmMessageSearchListModel::data(class QModelIndex const &, int) const
-	?qt_metacast@NmMessageSearchListModel@@UAEPAXPBD@Z @ 11 NONAME ; void * NmMessageSearchListModel::qt_metacast(char const *)
+	?applicationStateInterfaceInstance@NmDataPluginFactory@@QAEPAVNmApplicationStateInterface@@VNmId@@@Z @ 6 NONAME ; class NmApplicationStateInterface * NmDataPluginFactory::applicationStateInterfaceInstance(class NmId)
+	?currentMailboxId@NmMessageListModel@@QAE?AVNmId@@XZ @ 7 NONAME ; class NmId NmMessageListModel::currentMailboxId(void)
+	?folderById@NmDataManager@@QAEPAVNmFolderMetaData@@ABVNmId@@0@Z @ 8 NONAME ; class NmFolderMetaData * NmDataManager::folderById(class NmId const &, class NmId const &)
+	?removeAttachment@NmBaseClientPlugin@@QAEXXZ @ 9 NONAME ; void NmBaseClientPlugin::removeAttachment(void)
+	?handleCompletedSaveDraftOperation@NmUiEngine@@QAEXXZ @ 10 NONAME ; void NmUiEngine::handleCompletedSaveDraftOperation(void)
+	?completeOperationPart@NmAddAttachmentsOperation@@QAEXABVQString@@ABVNmId@@H@Z @ 11 NONAME ; void NmAddAttachmentsOperation::completeOperationPart(class QString const &, class NmId const &, int)
 	?releaseInstance@NmUiEngine@@SAXAAPAV1@@Z @ 12 NONAME ; void NmUiEngine::releaseInstance(class NmUiEngine * &)
 	?id@NmMailboxMetaData@@QBE?AVNmId@@XZ @ 13 NONAME ; class NmId NmMailboxMetaData::id(void) const
 	??1NmMessageCreationOperation@@MAE@XZ @ 14 NONAME ; NmMessageCreationOperation::~NmMessageCreationOperation(void)
@@ -17,15 +17,15 @@
 	?setName@NmMailboxMetaData@@QAEXABVQString@@@Z @ 16 NONAME ; void NmMailboxMetaData::setName(class QString const &)
 	?staticMetaObject@NmStoreEnvelopesOperation@@2UQMetaObject@@B @ 17 NONAME ; struct QMetaObject const NmStoreEnvelopesOperation::staticMetaObject
 	?handleMessageEvent@NmUiEngine@@AAEXW4NmMessageEvent@@ABVNmId@@ABV?$QList@VNmId@@@@1@Z @ 18 NONAME ; void NmUiEngine::handleMessageEvent(enum NmMessageEvent, class NmId const &, class QList<class NmId> const &, class NmId const &)
-	?tr@NmMessageSearchListModel@@SA?AVQString@@PBD0@Z @ 19 NONAME ; class QString NmMessageSearchListModel::tr(char const *, char const *)
-	?isRunning@NmOperation@@QBE_NXZ @ 20 NONAME ; bool NmOperation::isRunning(void) const
-	?setPriorityLow@NmBaseClientPlugin@@QAEXXZ @ 21 NONAME ; void NmBaseClientPlugin::setPriorityLow(void)
-	?tr@NmMessageCreationOperation@@SA?AVQString@@PBD0H@Z @ 22 NONAME ; class QString NmMessageCreationOperation::tr(char const *, char const *, int)
-	?openMessage@NmBaseClientPlugin@@QAEXXZ @ 23 NONAME ; void NmBaseClientPlugin::openMessage(void)
-	?getStaticMetaObject@NmMailboxListModel@@SAABUQMetaObject@@XZ @ 24 NONAME ; struct QMetaObject const & NmMailboxListModel::getStaticMetaObject(void)
-	?envelope@NmMessageListModelItem@@QBEABVNmMessageEnvelope@@XZ @ 25 NONAME ; class NmMessageEnvelope const & NmMessageListModelItem::envelope(void) const
-	?qt_metacall@NmMailboxListModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 26 NONAME ; int NmMailboxListModel::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?listMailboxIds@NmDataManager@@QAEXAAV?$QList@VNmId@@@@@Z @ 27 NONAME ; void NmDataManager::listMailboxIds(class QList<class NmId> &)
+	?isRunning@NmOperation@@QBE_NXZ @ 19 NONAME ; bool NmOperation::isRunning(void) const
+	?setPriorityLow@NmBaseClientPlugin@@QAEXXZ @ 20 NONAME ; void NmBaseClientPlugin::setPriorityLow(void)
+	?tr@NmMessageCreationOperation@@SA?AVQString@@PBD0H@Z @ 21 NONAME ; class QString NmMessageCreationOperation::tr(char const *, char const *, int)
+	?openMessage@NmBaseClientPlugin@@QAEXXZ @ 22 NONAME ; void NmBaseClientPlugin::openMessage(void)
+	?getStaticMetaObject@NmMailboxListModel@@SAABUQMetaObject@@XZ @ 23 NONAME ; struct QMetaObject const & NmMailboxListModel::getStaticMetaObject(void)
+	?envelope@NmMessageListModelItem@@QBEABVNmMessageEnvelope@@XZ @ 24 NONAME ; class NmMessageEnvelope const & NmMessageListModelItem::envelope(void) const
+	?qt_metacall@NmMailboxListModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 25 NONAME ; int NmMailboxListModel::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?listMailboxIds@NmDataManager@@QAEXAAV?$QList@VNmId@@@@@Z @ 26 NONAME ; void NmDataManager::listMailboxIds(class QList<class NmId> &)
+	?removeDraftMessage@NmUiEngine@@QAEXPAVNmMessage@@@Z @ 27 NONAME ; void NmUiEngine::removeDraftMessage(class NmMessage *)
 	??0NmDataManager@@QAE@XZ @ 28 NONAME ; NmDataManager::NmDataManager(void)
 	?trUtf8@NmAddAttachmentsOperation@@SA?AVQString@@PBD0H@Z @ 29 NONAME ; class QString NmAddAttachmentsOperation::trUtf8(char const *, char const *, int)
 	?refresh@NmMailboxListModel@@QAEXAAV?$QList@PAVNmMailbox@@@@@Z @ 30 NONAME ; void NmMailboxListModel::refresh(class QList<class NmMailbox *> &)
@@ -35,24 +35,24 @@
 	??_ENmFolderListModel@@UAE@I@Z @ 34 NONAME ; NmFolderListModel::~NmFolderListModel(unsigned int)
 	?contentToMessagePart@NmDataManager@@QAEHABVNmId@@00AAVNmMessagePart@@@Z @ 35 NONAME ; int NmDataManager::contentToMessagePart(class NmId const &, class NmId const &, class NmId const &, class NmMessagePart &)
 	?setExpanded@NmMessageListModelItem@@QAEX_N@Z @ 36 NONAME ; void NmMessageListModelItem::setExpanded(bool)
-	?qt_metacall@NmMessageSearchListModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 37 NONAME ; int NmMessageSearchListModel::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?staticMetaObject@NmCheckOutboxOperation@@2UQMetaObject@@B @ 38 NONAME ; struct QMetaObject const NmCheckOutboxOperation::staticMetaObject
-	?getStaticMetaObject@NmStoreEnvelopesOperation@@SAABUQMetaObject@@XZ @ 39 NONAME ; struct QMetaObject const & NmStoreEnvelopesOperation::getStaticMetaObject(void)
-	?setPriorityHigh@NmBaseClientPlugin@@QAEXXZ @ 40 NONAME ; void NmBaseClientPlugin::setPriorityHigh(void)
-	??0NmAddAttachmentsOperation@@QAE@XZ @ 41 NONAME ; NmAddAttachmentsOperation::NmAddAttachmentsOperation(void)
-	?deleteMessage@NmBaseClientPlugin@@QAEXXZ @ 42 NONAME ; void NmBaseClientPlugin::deleteMessage(void)
-	?getStaticMetaObject@NmAddAttachmentsOperation@@SAABUQMetaObject@@XZ @ 43 NONAME ; struct QMetaObject const & NmAddAttachmentsOperation::getStaticMetaObject(void)
-	?standardFolderId@NmUiEngine@@QAE?AVNmId@@ABV2@W4NmFolderType@@@Z @ 44 NONAME ; class NmId NmUiEngine::standardFolderId(class NmId const &, enum NmFolderType)
-	?settings@NmBaseClientPlugin@@QAEXXZ @ 45 NONAME ; void NmBaseClientPlugin::settings(void)
-	?staticMetaObject@NmUiEngine@@2UQMetaObject@@B @ 46 NONAME ; struct QMetaObject const NmUiEngine::staticMetaObject
-	?mailboxDeleted@NmUiEngine@@IAEXABVNmId@@@Z @ 47 NONAME ; void NmUiEngine::mailboxDeleted(class NmId const &)
-	?getIcon@NmIcons@@SAAAVHbIcon@@W4Icon@1@@Z @ 48 NONAME ; class HbIcon & NmIcons::getIcon(enum NmIcons::Icon)
-	?itemType@NmMessageListModelItem@@QBE?AW4NmMessageItemType@1@XZ @ 49 NONAME ; enum NmMessageListModelItem::NmMessageItemType NmMessageListModelItem::itemType(void) const
-	?mInstance@NmDataPluginFactory@@0PAV1@A @ 50 NONAME ; class NmDataPluginFactory * NmDataPluginFactory::mInstance
-	?data@NmFolderListModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 51 NONAME ; class QVariant NmFolderListModel::data(class QModelIndex const &, int) const
-	?setName@NmFolderMetaData@@QAEXABVQString@@@Z @ 52 NONAME ; void NmFolderMetaData::setName(class QString const &)
-	?mReferenceCount@NmUiEngine@@0HA @ 53 NONAME ; int NmUiEngine::mReferenceCount
-	?listFolders@NmDataManager@@QAEXVNmId@@AAV?$QList@PAVNmFolder@@@@@Z @ 54 NONAME ; void NmDataManager::listFolders(class NmId, class QList<class NmFolder *> &)
+	?saveDraftMessage@NmUiEngine@@QAEXPAVNmMessage@@ABV?$QList@PAVNmOperation@@@@@Z @ 37 NONAME ; void NmUiEngine::saveDraftMessage(class NmMessage *, class QList<class NmOperation *> const &)
+	?getStaticMetaObject@NmStoreEnvelopesOperation@@SAABUQMetaObject@@XZ @ 38 NONAME ; struct QMetaObject const & NmStoreEnvelopesOperation::getStaticMetaObject(void)
+	?setPriorityHigh@NmBaseClientPlugin@@QAEXXZ @ 39 NONAME ; void NmBaseClientPlugin::setPriorityHigh(void)
+	??0NmAddAttachmentsOperation@@QAE@XZ @ 40 NONAME ; NmAddAttachmentsOperation::NmAddAttachmentsOperation(void)
+	?deleteMessage@NmBaseClientPlugin@@QAEXXZ @ 41 NONAME ; void NmBaseClientPlugin::deleteMessage(void)
+	?getStaticMetaObject@NmAddAttachmentsOperation@@SAABUQMetaObject@@XZ @ 42 NONAME ; struct QMetaObject const & NmAddAttachmentsOperation::getStaticMetaObject(void)
+	?standardFolderId@NmUiEngine@@QAE?AVNmId@@ABV2@W4NmFolderType@@@Z @ 43 NONAME ; class NmId NmUiEngine::standardFolderId(class NmId const &, enum NmFolderType)
+	?settings@NmBaseClientPlugin@@QAEXXZ @ 44 NONAME ; void NmBaseClientPlugin::settings(void)
+	?staticMetaObject@NmUiEngine@@2UQMetaObject@@B @ 45 NONAME ; struct QMetaObject const NmUiEngine::staticMetaObject
+	?mailboxDeleted@NmUiEngine@@IAEXABVNmId@@@Z @ 46 NONAME ; void NmUiEngine::mailboxDeleted(class NmId const &)
+	?getIcon@NmIcons@@SAAAVHbIcon@@W4Icon@1@@Z @ 47 NONAME ; class HbIcon & NmIcons::getIcon(enum NmIcons::Icon)
+	?itemType@NmMessageListModelItem@@QBE?AW4NmMessageItemType@1@XZ @ 48 NONAME ; enum NmMessageListModelItem::NmMessageItemType NmMessageListModelItem::itemType(void) const
+	?mInstance@NmDataPluginFactory@@0PAV1@A @ 49 NONAME ; class NmDataPluginFactory * NmDataPluginFactory::mInstance
+	?data@NmFolderListModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 50 NONAME ; class QVariant NmFolderListModel::data(class QModelIndex const &, int) const
+	?setName@NmFolderMetaData@@QAEXABVQString@@@Z @ 51 NONAME ; void NmFolderMetaData::setName(class QString const &)
+	?mReferenceCount@NmUiEngine@@0HA @ 52 NONAME ; int NmUiEngine::mReferenceCount
+	?listFolders@NmDataManager@@QAEXVNmId@@AAV?$QList@PAVNmFolder@@@@@Z @ 53 NONAME ; void NmDataManager::listFolders(class NmId, class QList<class NmFolder *> &)
+	?fetchMessageParts@NmUiEngine@@QAE?AV?$QPointer@VNmOperation@@@@ABVNmId@@00ABV?$QList@VNmId@@@@@Z @ 54 NONAME ; class QPointer<class NmOperation> NmUiEngine::fetchMessageParts(class NmId const &, class NmId const &, class NmId const &, class QList<class NmId> const &)
 	?cancelSearch@NmUiEngine@@QAEHABVNmId@@@Z @ 55 NONAME ; int NmUiEngine::cancelSearch(class NmId const &)
 	?data@NmMailboxListModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 56 NONAME ; class QVariant NmMailboxListModel::data(class QModelIndex const &, int) const
 	?metaObject@NmMessageCreationOperation@@UBEPBUQMetaObject@@XZ @ 57 NONAME ; struct QMetaObject const * NmMessageCreationOperation::metaObject(void) const
@@ -64,22 +64,22 @@
 	?refresh@NmBaseClientPlugin@@QAEXXZ @ 63 NONAME ; void NmBaseClientPlugin::refresh(void)
 	??1NmFolderMetaData@@UAE@XZ @ 64 NONAME ; NmFolderMetaData::~NmFolderMetaData(void)
 	??1NmMessageSendingOperation@@MAE@XZ @ 65 NONAME ; NmMessageSendingOperation::~NmMessageSendingOperation(void)
-	?staticMetaObject@NmMessageSearchListModel@@2UQMetaObject@@B @ 66 NONAME ; struct QMetaObject const NmMessageSearchListModel::staticMetaObject
-	?name@NmFolderMetaData@@QBE?AVQString@@XZ @ 67 NONAME ; class QString NmFolderMetaData::name(void) const
-	??_ENmMessageCreationOperation@@UAE@I@Z @ 68 NONAME ; NmMessageCreationOperation::~NmMessageCreationOperation(unsigned int)
-	?sendMail@NmBaseClientPlugin@@QAEXXZ @ 69 NONAME ; void NmBaseClientPlugin::sendMail(void)
-	?insertNewMessageIntoModel@NmMessageListModel@@AAEXABVNmId@@00@Z @ 70 NONAME ; void NmMessageListModel::insertNewMessageIntoModel(class NmId const &, class NmId const &, class NmId const &)
-	?getStaticMetaObject@NmUiEngine@@SAABUQMetaObject@@XZ @ 71 NONAME ; struct QMetaObject const & NmUiEngine::getStaticMetaObject(void)
-	?metaObject@NmMessageListModel@@UBEPBUQMetaObject@@XZ @ 72 NONAME ; struct QMetaObject const * NmMessageListModel::metaObject(void) const
-	?messageBeingSent@NmUiEngine@@QBEPBVNmMessage@@XZ @ 73 NONAME ; class NmMessage const * NmUiEngine::messageBeingSent(void) const
-	?handleMailboxEvent@NmUiEngine@@AAEXW4NmMailboxEvent@@ABV?$QList@VNmId@@@@@Z @ 74 NONAME ; void NmUiEngine::handleMailboxEvent(enum NmMailboxEvent, class QList<class NmId> const &)
-	?interfaceInstance@NmDataPluginFactory@@QAEPAVNmDataPluginInterface@@VNmId@@@Z @ 75 NONAME ; class NmDataPluginInterface * NmDataPluginFactory::interfaceInstance(class NmId)
-	?trUtf8@NmMessageSearchListModel@@SA?AVQString@@PBD0@Z @ 76 NONAME ; class QString NmMessageSearchListModel::trUtf8(char const *, char const *)
+	?name@NmFolderMetaData@@QBE?AVQString@@XZ @ 66 NONAME ; class QString NmFolderMetaData::name(void) const
+	??_ENmMessageCreationOperation@@UAE@I@Z @ 67 NONAME ; NmMessageCreationOperation::~NmMessageCreationOperation(unsigned int)
+	?sendMail@NmBaseClientPlugin@@QAEXXZ @ 68 NONAME ; void NmBaseClientPlugin::sendMail(void)
+	?insertNewMessageIntoModel@NmMessageListModel@@AAEXABVNmId@@00@Z @ 69 NONAME ; void NmMessageListModel::insertNewMessageIntoModel(class NmId const &, class NmId const &, class NmId const &)
+	?getStaticMetaObject@NmUiEngine@@SAABUQMetaObject@@XZ @ 70 NONAME ; struct QMetaObject const & NmUiEngine::getStaticMetaObject(void)
+	?getPluginIdByMailboxId@NmUiEngine@@QAE?AVNmId@@I@Z @ 71 NONAME ; class NmId NmUiEngine::getPluginIdByMailboxId(unsigned int)
+	?applicationStateInterfaceInstance@NmDataPluginFactory@@AAEPAVNmApplicationStateInterface@@PAVQObject@@@Z @ 72 NONAME ; class NmApplicationStateInterface * NmDataPluginFactory::applicationStateInterfaceInstance(class QObject *)
+	?metaObject@NmMessageListModel@@UBEPBUQMetaObject@@XZ @ 73 NONAME ; struct QMetaObject const * NmMessageListModel::metaObject(void) const
+	?messageBeingSent@NmUiEngine@@QBEPBVNmMessage@@XZ @ 74 NONAME ; class NmMessage const * NmUiEngine::messageBeingSent(void) const
+	?handleMailboxEvent@NmUiEngine@@AAEXW4NmMailboxEvent@@ABV?$QList@VNmId@@@@@Z @ 75 NONAME ; void NmUiEngine::handleMailboxEvent(enum NmMailboxEvent, class QList<class NmId> const &)
+	?interfaceInstance@NmDataPluginFactory@@QAEPAVNmDataPluginInterface@@VNmId@@@Z @ 76 NONAME ; class NmDataPluginInterface * NmDataPluginFactory::interfaceInstance(class NmId)
 	?goOffline@NmBaseClientPlugin@@AAEXABVNmId@@@Z @ 77 NONAME ; void NmBaseClientPlugin::goOffline(class NmId const &)
 	?sendMessage@NmUiEngine@@QAEXPAVNmMessage@@ABV?$QList@PAVNmOperation@@@@@Z @ 78 NONAME ; void NmUiEngine::sendMessage(class NmMessage *, class QList<class NmOperation *> const &)
 	?tr@NmDataManager@@SA?AVQString@@PBD0H@Z @ 79 NONAME ; class QString NmDataManager::tr(char const *, char const *, int)
 	??0NmMailboxListModel@@QAE@AAVNmDataManager@@PAVQObject@@@Z @ 80 NONAME ; NmMailboxListModel::NmMailboxListModel(class NmDataManager &, class QObject *)
-	?trUtf8@NmCheckOutboxOperation@@SA?AVQString@@PBD0@Z @ 81 NONAME ; class QString NmCheckOutboxOperation::trUtf8(char const *, char const *)
+	?handleMessageEvent@NmMessageListModel@@QAEXW4NmMessageEvent@@ABVNmId@@ABV?$QList@VNmId@@@@1@Z @ 81 NONAME ; void NmMessageListModel::handleMessageEvent(enum NmMessageEvent, class NmId const &, class QList<class NmId> const &, class NmId const &)
 	?setPriorityNormal@NmBaseClientPlugin@@QAEXXZ @ 82 NONAME ; void NmBaseClientPlugin::setPriorityNormal(void)
 	??_ENmMessageSendingOperation@@UAE@I@Z @ 83 NONAME ; NmMessageSendingOperation::~NmMessageSendingOperation(unsigned int)
 	?changed@NmMessageListModel@@AAE_NABVNmMessageEnvelope@@0@Z @ 84 NONAME ; bool NmMessageListModel::changed(class NmMessageEnvelope const &, class NmMessageEnvelope const &)
@@ -96,236 +96,220 @@
 	?refresh@NmMessageListModel@@QAEXVNmId@@0ABV?$QList@PAVNmMessageEnvelope@@@@@Z @ 95 NONAME ; void NmMessageListModel::refresh(class NmId, class NmId, class QList<class NmMessageEnvelope *> const &)
 	?mailboxById@NmUiEngine@@QAEPAVNmMailboxMetaData@@ABVNmId@@@Z @ 96 NONAME ; class NmMailboxMetaData * NmUiEngine::mailboxById(class NmId const &)
 	?createNewMessage@NmUiEngine@@QAE?AV?$QPointer@VNmMessageCreationOperation@@@@ABVNmId@@@Z @ 97 NONAME ; class QPointer<class NmMessageCreationOperation> NmUiEngine::createNewMessage(class NmId const &)
-	?tr@NmCheckOutboxOperation@@SA?AVQString@@PBD0@Z @ 98 NONAME ; class QString NmCheckOutboxOperation::tr(char const *, char const *)
-	??_ENmMessageListModelItem@@UAE@I@Z @ 99 NONAME ; NmMessageListModelItem::~NmMessageListModelItem(unsigned int)
-	?replyAllMail@NmBaseClientPlugin@@QAEXXZ @ 100 NONAME ; void NmBaseClientPlugin::replyAllMail(void)
+	??_ENmMessageListModelItem@@UAE@I@Z @ 98 NONAME ; NmMessageListModelItem::~NmMessageListModelItem(unsigned int)
+	?replyAllMail@NmBaseClientPlugin@@QAEXXZ @ 99 NONAME ; void NmBaseClientPlugin::replyAllMail(void)
+	?handleMatchFound@NmUiEngine@@AAEXABVNmId@@0@Z @ 100 NONAME ; void NmUiEngine::handleMatchFound(class NmId const &, class NmId const &)
 	?syncStateEvent@NmUiEngine@@IAEXW4NmSyncState@@ABVNmId@@@Z @ 101 NONAME ; void NmUiEngine::syncStateEvent(enum NmSyncState, class NmId const &)
-	?trUtf8@NmDataManager@@SA?AVQString@@PBD0@Z @ 102 NONAME ; class QString NmDataManager::trUtf8(char const *, char const *)
-	?setEnvelopeProperties@NmMessageListModel@@QAEXW4NmEnvelopeProperties@@ABV?$QList@VNmId@@@@@Z @ 103 NONAME ; void NmMessageListModel::setEnvelopeProperties(enum NmEnvelopeProperties, class QList<class NmId> const &)
-	??1NmStoreEnvelopesOperation@@MAE@XZ @ 104 NONAME ; NmStoreEnvelopesOperation::~NmStoreEnvelopesOperation(void)
-	?tr@NmUiEngine@@SA?AVQString@@PBD0@Z @ 105 NONAME ; class QString NmUiEngine::tr(char const *, char const *)
-	?mPluginLoaderArray@NmDataPluginFactory@@0V?$QList@PAVQPluginLoader@@@@A @ 106 NONAME ; class QList<class QPluginLoader *> NmDataPluginFactory::mPluginLoaderArray
-	?trUtf8@NmBaseClientPlugin@@SA?AVQString@@PBD0@Z @ 107 NONAME ; class QString NmBaseClientPlugin::trUtf8(char const *, char const *)
-	?deleteOperation@NmOperation@@AAEXXZ @ 108 NONAME ; void NmOperation::deleteOperation(void)
-	?trUtf8@NmBaseClientPlugin@@SA?AVQString@@PBD0H@Z @ 109 NONAME ; class QString NmBaseClientPlugin::trUtf8(char const *, char const *, int)
-	?createViewerViewCommands@NmBaseClientPlugin@@AAEXABVNmActionRequest@@AAV?$QList@PAVNmAction@@@@@Z @ 110 NONAME ; void NmBaseClientPlugin::createViewerViewCommands(class NmActionRequest const &, class QList<class NmAction *> &)
-	?fetchMessagePart@NmUiEngine@@QAE?AV?$QPointer@VNmOperation@@@@ABVNmId@@000@Z @ 111 NONAME ; class QPointer<class NmOperation> NmUiEngine::fetchMessagePart(class NmId const &, class NmId const &, class NmId const &, class NmId const &)
-	?tr@NmMailboxListModel@@SA?AVQString@@PBD0H@Z @ 112 NONAME ; class QString NmMailboxListModel::tr(char const *, char const *, int)
-	?trUtf8@NmUiEngine@@SA?AVQString@@PBD0H@Z @ 113 NONAME ; class QString NmUiEngine::trUtf8(char const *, char const *, int)
-	?createMailboxItem@NmMailboxListModel@@AAEPAVNmMailboxListModelItem@@PBVNmMailbox@@@Z @ 114 NONAME ; class NmMailboxListModelItem * NmMailboxListModel::createMailboxItem(class NmMailbox const *)
-	?setTitleDivider@NmMessageListModelItem@@QAEXABVQString@@@Z @ 115 NONAME ; void NmMessageListModelItem::setTitleDivider(class QString const &)
-	?markAsRead@NmBaseClientPlugin@@QAEXXZ @ 116 NONAME ; void NmBaseClientPlugin::markAsRead(void)
-	?getInsertionIndex@NmMessageListModel@@ABEHABVNmMessageEnvelope@@@Z @ 117 NONAME ; int NmMessageListModel::getInsertionIndex(class NmMessageEnvelope const &) const
-	?updateOperationProgress@NmOperation@@QAEXH@Z @ 118 NONAME ; void NmOperation::updateOperationProgress(int)
-	??1NmFolderListModel@@UAE@XZ @ 119 NONAME ; NmFolderListModel::~NmFolderListModel(void)
-	?operationCompleted@NmUiEngine@@IAEXABVNmOperationCompletionEvent@@@Z @ 120 NONAME ; void NmUiEngine::operationCompleted(class NmOperationCompletionEvent const &)
-	??1NmDataManager@@UAE@XZ @ 121 NONAME ; NmDataManager::~NmDataManager(void)
-	?trUtf8@NmStoreEnvelopesOperation@@SA?AVQString@@PBD0@Z @ 122 NONAME ; class QString NmStoreEnvelopesOperation::trUtf8(char const *, char const *)
-	?metaObject@NmMessageSearchListModel@@UBEPBUQMetaObject@@XZ @ 123 NONAME ; struct QMetaObject const * NmMessageSearchListModel::metaObject(void) const
-	??0NmMessageSearchListModel@@QAE@PAVQObject@@@Z @ 124 NONAME ; NmMessageSearchListModel::NmMessageSearchListModel(class QObject *)
-	?getStaticMetaObject@NmMessageCreationOperation@@SAABUQMetaObject@@XZ @ 125 NONAME ; struct QMetaObject const & NmMessageCreationOperation::getStaticMetaObject(void)
-	?trUtf8@NmAddAttachmentsOperation@@SA?AVQString@@PBD0@Z @ 126 NONAME ; class QString NmAddAttachmentsOperation::trUtf8(char const *, char const *)
-	?name@NmMailboxMetaData@@QBE?AVQString@@XZ @ 127 NONAME ; class QString NmMailboxMetaData::name(void) const
-	?qt_metacall@NmDataManager@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 128 NONAME ; int NmDataManager::qt_metacall(enum QMetaObject::Call, int, void * *)
-	??1NmMessageSearchListModel@@UAE@XZ @ 129 NONAME ; NmMessageSearchListModel::~NmMessageSearchListModel(void)
-	?runAsyncOperation@NmOperation@@MAEXXZ @ 130 NONAME ; void NmOperation::runAsyncOperation(void)
-	??0NmFolderListModel@@QAE@AAVNmDataManager@@PAVQObject@@@Z @ 131 NONAME ; NmFolderListModel::NmFolderListModel(class NmDataManager &, class QObject *)
-	?getStaticMetaObject@NmCheckOutboxOperation@@SAABUQMetaObject@@XZ @ 132 NONAME ; struct QMetaObject const & NmCheckOutboxOperation::getStaticMetaObject(void)
-	?metaObject@NmCheckOutboxOperation@@UBEPBUQMetaObject@@XZ @ 133 NONAME ; struct QMetaObject const * NmCheckOutboxOperation::metaObject(void) const
-	?tr@NmBaseClientPlugin@@SA?AVQString@@PBD0H@Z @ 134 NONAME ; class QString NmBaseClientPlugin::tr(char const *, char const *, int)
-	??0NmMailboxMetaData@@QAE@XZ @ 135 NONAME ; NmMailboxMetaData::NmMailboxMetaData(void)
-	?setEnvelope@NmMessageListModelItem@@QAEXPAVNmMessageEnvelope@@@Z @ 136 NONAME ; void NmMessageListModelItem::setEnvelope(class NmMessageEnvelope *)
-	?saveMessage@NmUiEngine@@QAEHABVNmMessage@@@Z @ 137 NONAME ; int NmUiEngine::saveMessage(class NmMessage const &)
-	?setId@NmMailboxMetaData@@QAEXABVNmId@@@Z @ 138 NONAME ; void NmMailboxMetaData::setId(class NmId const &)
-	?mReferenceCount@NmDataPluginFactory@@0HA @ 139 NONAME ; int NmDataPluginFactory::mReferenceCount
-	?tr@NmOperation@@SA?AVQString@@PBD0@Z @ 140 NONAME ; class QString NmOperation::tr(char const *, char const *)
-	?qt_metacast@NmCheckOutboxOperation@@UAEPAXPBD@Z @ 141 NONAME ; void * NmCheckOutboxOperation::qt_metacast(char const *)
-	?clearSearchResults@NmMessageSearchListModel@@QAEXXZ @ 142 NONAME ; void NmMessageSearchListModel::clearSearchResults(void)
+	?refreshModelItem@NmMailboxListModel@@QAEXABVNmId@@@Z @ 102 NONAME ; void NmMailboxListModel::refreshModelItem(class NmId const &)
+	?trUtf8@NmDataManager@@SA?AVQString@@PBD0@Z @ 103 NONAME ; class QString NmDataManager::trUtf8(char const *, char const *)
+	?setEnvelopeProperties@NmMessageListModel@@QAEXW4NmEnvelopeProperties@@ABV?$QList@VNmId@@@@@Z @ 104 NONAME ; void NmMessageListModel::setEnvelopeProperties(enum NmEnvelopeProperties, class QList<class NmId> const &)
+	??1NmStoreEnvelopesOperation@@MAE@XZ @ 105 NONAME ; NmStoreEnvelopesOperation::~NmStoreEnvelopesOperation(void)
+	?tr@NmUiEngine@@SA?AVQString@@PBD0@Z @ 106 NONAME ; class QString NmUiEngine::tr(char const *, char const *)
+	?mPluginLoaderArray@NmDataPluginFactory@@0V?$QList@PAVQPluginLoader@@@@A @ 107 NONAME ; class QList<class QPluginLoader *> NmDataPluginFactory::mPluginLoaderArray
+	?trUtf8@NmBaseClientPlugin@@SA?AVQString@@PBD0@Z @ 108 NONAME ; class QString NmBaseClientPlugin::trUtf8(char const *, char const *)
+	?deleteOperation@NmOperation@@AAEXXZ @ 109 NONAME ; void NmOperation::deleteOperation(void)
+	?trUtf8@NmBaseClientPlugin@@SA?AVQString@@PBD0H@Z @ 110 NONAME ; class QString NmBaseClientPlugin::trUtf8(char const *, char const *, int)
+	?createViewerViewCommands@NmBaseClientPlugin@@AAEXABVNmActionRequest@@AAV?$QList@PAVNmAction@@@@@Z @ 111 NONAME ; void NmBaseClientPlugin::createViewerViewCommands(class NmActionRequest const &, class QList<class NmAction *> &)
+	?fetchMessagePart@NmUiEngine@@QAE?AV?$QPointer@VNmOperation@@@@ABVNmId@@000@Z @ 112 NONAME ; class QPointer<class NmOperation> NmUiEngine::fetchMessagePart(class NmId const &, class NmId const &, class NmId const &, class NmId const &)
+	?tr@NmMailboxListModel@@SA?AVQString@@PBD0H@Z @ 113 NONAME ; class QString NmMailboxListModel::tr(char const *, char const *, int)
+	?handleConnectEvent@NmUiEngine@@QAEXW4NmConnectState@@ABVNmId@@H@Z @ 114 NONAME ; void NmUiEngine::handleConnectEvent(enum NmConnectState, class NmId const &, int)
+	?trUtf8@NmUiEngine@@SA?AVQString@@PBD0H@Z @ 115 NONAME ; class QString NmUiEngine::trUtf8(char const *, char const *, int)
+	?createMailboxItem@NmMailboxListModel@@AAEPAVNmMailboxListModelItem@@PBVNmMailbox@@@Z @ 116 NONAME ; class NmMailboxListModelItem * NmMailboxListModel::createMailboxItem(class NmMailbox const *)
+	?setTitleDivider@NmMessageListModelItem@@QAEXABVQString@@@Z @ 117 NONAME ; void NmMessageListModelItem::setTitleDivider(class QString const &)
+	?markAsRead@NmBaseClientPlugin@@QAEXXZ @ 118 NONAME ; void NmBaseClientPlugin::markAsRead(void)
+	?getInsertionIndex@NmMessageListModel@@ABEHABVNmMessageEnvelope@@@Z @ 119 NONAME ; int NmMessageListModel::getInsertionIndex(class NmMessageEnvelope const &) const
+	?updateOperationProgress@NmOperation@@QAEXH@Z @ 120 NONAME ; void NmOperation::updateOperationProgress(int)
+	?messageEventForListModel@NmUiEngine@@AAEXW4NmMessageEvent@@ABVNmId@@ABV?$QList@VNmId@@@@1@Z @ 121 NONAME ; void NmUiEngine::messageEventForListModel(enum NmMessageEvent, class NmId const &, class QList<class NmId> const &, class NmId const &)
+	??1NmFolderListModel@@UAE@XZ @ 122 NONAME ; NmFolderListModel::~NmFolderListModel(void)
+	?operationCompleted@NmUiEngine@@IAEXABVNmOperationCompletionEvent@@@Z @ 123 NONAME ; void NmUiEngine::operationCompleted(class NmOperationCompletionEvent const &)
+	??1NmDataManager@@UAE@XZ @ 124 NONAME ; NmDataManager::~NmDataManager(void)
+	?trUtf8@NmStoreEnvelopesOperation@@SA?AVQString@@PBD0@Z @ 125 NONAME ; class QString NmStoreEnvelopesOperation::trUtf8(char const *, char const *)
+	?setAddress@NmMailboxMetaData@@QAEXABVQString@@@Z @ 126 NONAME ; void NmMailboxMetaData::setAddress(class QString const &)
+	?getStaticMetaObject@NmMessageCreationOperation@@SAABUQMetaObject@@XZ @ 127 NONAME ; struct QMetaObject const & NmMessageCreationOperation::getStaticMetaObject(void)
+	?updateActiveFolder@NmUiEngine@@QAEXABVNmId@@0@Z @ 128 NONAME ; void NmUiEngine::updateActiveFolder(class NmId const &, class NmId const &)
+	?trUtf8@NmAddAttachmentsOperation@@SA?AVQString@@PBD0@Z @ 129 NONAME ; class QString NmAddAttachmentsOperation::trUtf8(char const *, char const *)
+	?name@NmMailboxMetaData@@QBE?AVQString@@XZ @ 130 NONAME ; class QString NmMailboxMetaData::name(void) const
+	?qt_metacall@NmDataManager@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 131 NONAME ; int NmDataManager::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?runAsyncOperation@NmOperation@@MAEXXZ @ 132 NONAME ; void NmOperation::runAsyncOperation(void)
+	??0NmFolderListModel@@QAE@AAVNmDataManager@@PAVQObject@@@Z @ 133 NONAME ; NmFolderListModel::NmFolderListModel(class NmDataManager &, class QObject *)
+	?folderTypeById@NmDataManager@@QAE?AW4NmFolderType@@VNmId@@0@Z @ 134 NONAME ; enum NmFolderType NmDataManager::folderTypeById(class NmId, class NmId)
+	?tr@NmBaseClientPlugin@@SA?AVQString@@PBD0H@Z @ 135 NONAME ; class QString NmBaseClientPlugin::tr(char const *, char const *, int)
+	??0NmMailboxMetaData@@QAE@XZ @ 136 NONAME ; NmMailboxMetaData::NmMailboxMetaData(void)
+	?setEnvelope@NmMessageListModelItem@@QAEXPAVNmMessageEnvelope@@@Z @ 137 NONAME ; void NmMessageListModelItem::setEnvelope(class NmMessageEnvelope *)
+	?saveMessage@NmUiEngine@@QAEHABVNmMessage@@@Z @ 138 NONAME ; int NmUiEngine::saveMessage(class NmMessage const &)
+	?setId@NmMailboxMetaData@@QAEXABVNmId@@@Z @ 139 NONAME ; void NmMailboxMetaData::setId(class NmId const &)
+	?folderTypeById@NmUiEngine@@QAE?AW4NmFolderType@@VNmId@@0@Z @ 140 NONAME ; enum NmFolderType NmUiEngine::folderTypeById(class NmId, class NmId)
+	?mReferenceCount@NmDataPluginFactory@@0HA @ 141 NONAME ; int NmDataPluginFactory::mReferenceCount
+	?tr@NmOperation@@SA?AVQString@@PBD0@Z @ 142 NONAME ; class QString NmOperation::tr(char const *, char const *)
 	?updateMessageEnvelope@NmMessageListModel@@AAEXABVNmId@@00@Z @ 143 NONAME ; void NmMessageListModel::updateMessageEnvelope(class NmId const &, class NmId const &, class NmId const &)
-	?filterAcceptsRow@NmMessageSearchListModel@@MBE_NHABVQModelIndex@@@Z @ 144 NONAME ; bool NmMessageSearchListModel::filterAcceptsRow(int, class QModelIndex const &) const
-	?messageSearchListModel@NmUiEngine@@QAEAAVNmMessageSearchListModel@@PAVQAbstractItemModel@@@Z @ 145 NONAME ; class NmMessageSearchListModel & NmUiEngine::messageSearchListModel(class QAbstractItemModel *)
-	?tr@NmStoreEnvelopesOperation@@SA?AVQString@@PBD0@Z @ 146 NONAME ; class QString NmStoreEnvelopesOperation::tr(char const *, char const *)
-	?messagesBelongUnderSameDivider@NmMessageListModel@@ABE_NPBVNmMessageEnvelope@@0@Z @ 147 NONAME ; bool NmMessageListModel::messagesBelongUnderSameDivider(class NmMessageEnvelope const *, class NmMessageEnvelope const *) const
-	?checkOutbox@NmUiEngine@@QAE?AV?$QPointer@VNmCheckOutboxOperation@@@@ABVNmId@@@Z @ 148 NONAME ; class QPointer<class NmCheckOutboxOperation> NmUiEngine::checkOutbox(class NmId const &)
-	?metaObject@NmDataManager@@UBEPBUQMetaObject@@XZ @ 149 NONAME ; struct QMetaObject const * NmDataManager::metaObject(void) const
-	?isSendingMessage@NmUiEngine@@QBE_NXZ @ 150 NONAME ; bool NmUiEngine::isSendingMessage(void) const
-	?freeIcons@NmIcons@@SAXXZ @ 151 NONAME ; void NmIcons::freeIcons(void)
-	?tr@NmAddAttachmentsOperation@@SA?AVQString@@PBD0@Z @ 152 NONAME ; class QString NmAddAttachmentsOperation::tr(char const *, char const *)
-	?itemFromModel@NmMessageListModel@@AAEPAVNmMessageListModelItem@@ABVNmId@@@Z @ 153 NONAME ; class NmMessageListModelItem * NmMessageListModel::itemFromModel(class NmId const &)
-	?instance@NmUiEngine@@SAPAV1@XZ @ 154 NONAME ; class NmUiEngine * NmUiEngine::instance(void)
-	?createMessageListCommands@NmBaseClientPlugin@@AAEXABVNmActionRequest@@AAV?$QList@PAVNmAction@@@@@Z @ 155 NONAME ; void NmBaseClientPlugin::createMessageListCommands(class NmActionRequest const &, class QList<class NmAction *> &)
-	?updateEnvelopeProperty@NmBaseClientPlugin@@AAEXW4NmEnvelopeProperties@@@Z @ 156 NONAME ; void NmBaseClientPlugin::updateEnvelopeProperty(enum NmEnvelopeProperties)
-	??1NmAddAttachmentsOperation@@MAE@XZ @ 157 NONAME ; NmAddAttachmentsOperation::~NmAddAttachmentsOperation(void)
-	?goOffline@NmUiEngine@@QAEHABVNmId@@@Z @ 158 NONAME ; int NmUiEngine::goOffline(class NmId const &)
-	?staticMetaObject@NmDataManager@@2UQMetaObject@@B @ 159 NONAME ; struct QMetaObject const NmDataManager::staticMetaObject
-	?mInstance@NmUiEngine@@0PAV1@A @ 160 NONAME ; class NmUiEngine * NmUiEngine::mInstance
-	?attach@NmBaseClientPlugin@@QAEXXZ @ 161 NONAME ; void NmBaseClientPlugin::attach(void)
-	?metaObject@NmAddAttachmentsOperation@@UBEPBUQMetaObject@@XZ @ 162 NONAME ; struct QMetaObject const * NmAddAttachmentsOperation::metaObject(void) const
-	?refresh@NmFolderListModel@@QAEXAAV?$QList@PAVNmFolder@@@@@Z @ 163 NONAME ; void NmFolderListModel::refresh(class QList<class NmFolder *> &)
-	?qt_metacall@NmCheckOutboxOperation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 164 NONAME ; int NmCheckOutboxOperation::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?trUtf8@NmMailboxListModel@@SA?AVQString@@PBD0@Z @ 165 NONAME ; class QString NmMailboxListModel::trUtf8(char const *, char const *)
-	?envelopeById@NmDataManager@@QAEPAVNmMessageEnvelope@@ABVNmId@@00@Z @ 166 NONAME ; class NmMessageEnvelope * NmDataManager::envelopeById(class NmId const &, class NmId const &, class NmId const &)
-	?getStaticMetaObject@NmOperation@@SAABUQMetaObject@@XZ @ 167 NONAME ; struct QMetaObject const & NmOperation::getStaticMetaObject(void)
-	?trUtf8@NmOperation@@SA?AVQString@@PBD0@Z @ 168 NONAME ; class QString NmOperation::trUtf8(char const *, char const *)
-	?addAttachments@NmUiEngine@@QAE?AV?$QPointer@VNmAddAttachmentsOperation@@@@ABVNmMessage@@ABV?$QList@VQString@@@@@Z @ 169 NONAME ; class QPointer<class NmAddAttachmentsOperation> NmUiEngine::addAttachments(class NmMessage const &, class QList<class QString> const &)
-	?doCancelOperation@NmOperation@@MAEXXZ @ 170 NONAME ; void NmOperation::doCancelOperation(void)
-	?tr@NmOperation@@SA?AVQString@@PBD0H@Z @ 171 NONAME ; class QString NmOperation::tr(char const *, char const *, int)
-	??_ENmOperation@@UAE@I@Z @ 172 NONAME ; NmOperation::~NmOperation(unsigned int)
-	?tr@NmMessageCreationOperation@@SA?AVQString@@PBD0@Z @ 173 NONAME ; class QString NmMessageCreationOperation::tr(char const *, char const *)
-	?qt_metacall@NmMessageListModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 174 NONAME ; int NmMessageListModel::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?staticMetaObject@NmOperation@@2UQMetaObject@@B @ 175 NONAME ; struct QMetaObject const NmOperation::staticMetaObject
-	??1NmUiEngine@@EAE@XZ @ 176 NONAME ; NmUiEngine::~NmUiEngine(void)
-	?messagePartFile@NmUiEngine@@QAE?AVXQSharableFile@@ABVNmId@@000@Z @ 177 NONAME ; class XQSharableFile NmUiEngine::messagePartFile(class NmId const &, class NmId const &, class NmId const &, class NmId const &)
-	??_ENmMessageListModel@@UAE@I@Z @ 178 NONAME ; NmMessageListModel::~NmMessageListModel(unsigned int)
-	?addPreliminaryOperation@NmOperation@@QAEXPAV1@@Z @ 179 NONAME ; void NmOperation::addPreliminaryOperation(class NmOperation *)
-	?deleteMessages@NmUiEngine@@QAEHABVNmId@@0ABV?$QList@VNmId@@@@@Z @ 180 NONAME ; int NmUiEngine::deleteMessages(class NmId const &, class NmId const &, class QList<class NmId> const &)
-	??_ENmStoreEnvelopesOperation@@UAE@I@Z @ 181 NONAME ; NmStoreEnvelopesOperation::~NmStoreEnvelopesOperation(unsigned int)
-	?mailboxById@NmDataManager@@QAEPAVNmMailboxMetaData@@ABVNmId@@@Z @ 182 NONAME ; class NmMailboxMetaData * NmDataManager::mailboxById(class NmId const &)
+	?tr@NmStoreEnvelopesOperation@@SA?AVQString@@PBD0@Z @ 144 NONAME ; class QString NmStoreEnvelopesOperation::tr(char const *, char const *)
+	?messagesBelongUnderSameDivider@NmMessageListModel@@ABE_NPBVNmMessageEnvelope@@0@Z @ 145 NONAME ; bool NmMessageListModel::messagesBelongUnderSameDivider(class NmMessageEnvelope const *, class NmMessageEnvelope const *) const
+	?matchFound@NmUiEngine@@IAEXABVNmId@@0@Z @ 146 NONAME ; void NmUiEngine::matchFound(class NmId const &, class NmId const &)
+	?metaObject@NmDataManager@@UBEPBUQMetaObject@@XZ @ 147 NONAME ; struct QMetaObject const * NmDataManager::metaObject(void) const
+	?isSendingMessage@NmUiEngine@@QBE_NXZ @ 148 NONAME ; bool NmUiEngine::isSendingMessage(void) const
+	?freeIcons@NmIcons@@SAXXZ @ 149 NONAME ; void NmIcons::freeIcons(void)
+	?tr@NmAddAttachmentsOperation@@SA?AVQString@@PBD0@Z @ 150 NONAME ; class QString NmAddAttachmentsOperation::tr(char const *, char const *)
+	?itemFromModel@NmMessageListModel@@AAEPAVNmMessageListModelItem@@ABVNmId@@@Z @ 151 NONAME ; class NmMessageListModelItem * NmMessageListModel::itemFromModel(class NmId const &)
+	?instance@NmUiEngine@@SAPAV1@XZ @ 152 NONAME ; class NmUiEngine * NmUiEngine::instance(void)
+	?createMessageListCommands@NmBaseClientPlugin@@AAEXABVNmActionRequest@@AAV?$QList@PAVNmAction@@@@@Z @ 153 NONAME ; void NmBaseClientPlugin::createMessageListCommands(class NmActionRequest const &, class QList<class NmAction *> &)
+	?updateEnvelopeProperty@NmBaseClientPlugin@@AAEXW4NmEnvelopeProperties@@@Z @ 154 NONAME ; void NmBaseClientPlugin::updateEnvelopeProperty(enum NmEnvelopeProperties)
+	??1NmAddAttachmentsOperation@@MAE@XZ @ 155 NONAME ; NmAddAttachmentsOperation::~NmAddAttachmentsOperation(void)
+	?goOffline@NmUiEngine@@QAEHABVNmId@@@Z @ 156 NONAME ; int NmUiEngine::goOffline(class NmId const &)
+	?staticMetaObject@NmDataManager@@2UQMetaObject@@B @ 157 NONAME ; struct QMetaObject const NmDataManager::staticMetaObject
+	?mInstance@NmUiEngine@@0PAV1@A @ 158 NONAME ; class NmUiEngine * NmUiEngine::mInstance
+	?attach@NmBaseClientPlugin@@QAEXXZ @ 159 NONAME ; void NmBaseClientPlugin::attach(void)
+	?setIgnoreFolderIds@NmMessageListModel@@QAEX_N@Z @ 160 NONAME ; void NmMessageListModel::setIgnoreFolderIds(bool)
+	?metaObject@NmAddAttachmentsOperation@@UBEPBUQMetaObject@@XZ @ 161 NONAME ; struct QMetaObject const * NmAddAttachmentsOperation::metaObject(void) const
+	?refresh@NmFolderListModel@@QAEXAAV?$QList@PAVNmFolder@@@@@Z @ 162 NONAME ; void NmFolderListModel::refresh(class QList<class NmFolder *> &)
+	?handleCompletedRemoveDraftOperation@NmUiEngine@@QAEXXZ @ 163 NONAME ; void NmUiEngine::handleCompletedRemoveDraftOperation(void)
+	?trUtf8@NmMailboxListModel@@SA?AVQString@@PBD0@Z @ 164 NONAME ; class QString NmMailboxListModel::trUtf8(char const *, char const *)
+	?envelopeById@NmDataManager@@QAEPAVNmMessageEnvelope@@ABVNmId@@00@Z @ 165 NONAME ; class NmMessageEnvelope * NmDataManager::envelopeById(class NmId const &, class NmId const &, class NmId const &)
+	?getStaticMetaObject@NmOperation@@SAABUQMetaObject@@XZ @ 166 NONAME ; struct QMetaObject const & NmOperation::getStaticMetaObject(void)
+	?trUtf8@NmOperation@@SA?AVQString@@PBD0@Z @ 167 NONAME ; class QString NmOperation::trUtf8(char const *, char const *)
+	?addAttachments@NmUiEngine@@QAE?AV?$QPointer@VNmAddAttachmentsOperation@@@@ABVNmMessage@@ABV?$QList@VQString@@@@@Z @ 168 NONAME ; class QPointer<class NmAddAttachmentsOperation> NmUiEngine::addAttachments(class NmMessage const &, class QList<class QString> const &)
+	?doCancelOperation@NmOperation@@MAEXXZ @ 169 NONAME ; void NmOperation::doCancelOperation(void)
+	?tr@NmOperation@@SA?AVQString@@PBD0H@Z @ 170 NONAME ; class QString NmOperation::tr(char const *, char const *, int)
+	??_ENmOperation@@UAE@I@Z @ 171 NONAME ; NmOperation::~NmOperation(unsigned int)
+	?tr@NmMessageCreationOperation@@SA?AVQString@@PBD0@Z @ 172 NONAME ; class QString NmMessageCreationOperation::tr(char const *, char const *)
+	?qt_metacall@NmMessageListModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 173 NONAME ; int NmMessageListModel::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?staticMetaObject@NmOperation@@2UQMetaObject@@B @ 174 NONAME ; struct QMetaObject const NmOperation::staticMetaObject
+	??1NmUiEngine@@EAE@XZ @ 175 NONAME ; NmUiEngine::~NmUiEngine(void)
+	?messagePartFile@NmUiEngine@@QAE?AVXQSharableFile@@ABVNmId@@000@Z @ 176 NONAME ; class XQSharableFile NmUiEngine::messagePartFile(class NmId const &, class NmId const &, class NmId const &, class NmId const &)
+	??_ENmMessageListModel@@UAE@I@Z @ 177 NONAME ; NmMessageListModel::~NmMessageListModel(unsigned int)
+	?addPreliminaryOperation@NmOperation@@QAEXPAV1@@Z @ 178 NONAME ; void NmOperation::addPreliminaryOperation(class NmOperation *)
+	?deleteMessages@NmUiEngine@@QAEHABVNmId@@0ABV?$QList@VNmId@@@@@Z @ 179 NONAME ; int NmUiEngine::deleteMessages(class NmId const &, class NmId const &, class QList<class NmId> const &)
+	??_ENmStoreEnvelopesOperation@@UAE@I@Z @ 180 NONAME ; NmStoreEnvelopesOperation::~NmStoreEnvelopesOperation(unsigned int)
+	?mailboxById@NmDataManager@@QAEPAVNmMailboxMetaData@@ABVNmId@@@Z @ 181 NONAME ; class NmMailboxMetaData * NmDataManager::mailboxById(class NmId const &)
+	?messageListModelForSearch@NmUiEngine@@QAEAAVNmMessageListModel@@ABVNmId@@@Z @ 182 NONAME ; class NmMessageListModel & NmUiEngine::messageListModelForSearch(class NmId const &)
 	?search@NmBaseClientPlugin@@QAEXXZ @ 183 NONAME ; void NmBaseClientPlugin::search(void)
 	?pluginInstances@NmDataPluginFactory@@QAEPAV?$QList@PAVQObject@@@@XZ @ 184 NONAME ; class QList<class QObject *> * NmDataPluginFactory::pluginInstances(void)
 	?tr@NmBaseClientPlugin@@SA?AVQString@@PBD0@Z @ 185 NONAME ; class QString NmBaseClientPlugin::tr(char const *, char const *)
 	?listMessages@NmDataManager@@QAEXABVNmId@@0AAV?$QList@PAVNmMessageEnvelope@@@@@Z @ 186 NONAME ; void NmDataManager::listMessages(class NmId const &, class NmId const &, class QList<class NmMessageEnvelope *> &)
-	?getStaticMetaObject@NmMessageSearchListModel@@SAABUQMetaObject@@XZ @ 187 NONAME ; struct QMetaObject const & NmMessageSearchListModel::getStaticMetaObject(void)
-	??1NmBaseClientPlugin@@UAE@XZ @ 188 NONAME ; NmBaseClientPlugin::~NmBaseClientPlugin(void)
-	?qt_metacast@NmDataManager@@UAEPAXPBD@Z @ 189 NONAME ; void * NmDataManager::qt_metacast(char const *)
-	??0NmMessageCreationOperation@@QAE@XZ @ 190 NONAME ; NmMessageCreationOperation::NmMessageCreationOperation(void)
-	?qt_metacall@NmBaseClientPlugin@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 191 NONAME ; int NmBaseClientPlugin::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?envelopePtr@NmMessageListModelItem@@QAEPAVNmMessageEnvelope@@XZ @ 192 NONAME ; class NmMessageEnvelope * NmMessageListModelItem::envelopePtr(void)
-	?messageListModel@NmUiEngine@@QAEAAVNmMessageListModel@@ABVNmId@@0@Z @ 193 NONAME ; class NmMessageListModel & NmUiEngine::messageListModel(class NmId const &, class NmId const &)
-	??1NmMailboxMetaData@@UAE@XZ @ 194 NONAME ; NmMailboxMetaData::~NmMailboxMetaData(void)
-	?trUtf8@NmCheckOutboxOperation@@SA?AVQString@@PBD0H@Z @ 195 NONAME ; class QString NmCheckOutboxOperation::trUtf8(char const *, char const *, int)
-	??0NmCheckOutboxOperation@@QAE@XZ @ 196 NONAME ; NmCheckOutboxOperation::NmCheckOutboxOperation(void)
-	?connectionEvent@NmUiEngine@@IAEXW4NmConnectState@@ABVNmId@@@Z @ 197 NONAME ; void NmUiEngine::connectionEvent(enum NmConnectState, class NmId const &)
-	?mailbox@NmDataManager@@QAEPAVNmMailbox@@ABVNmId@@@Z @ 198 NONAME ; class NmMailbox * NmDataManager::mailbox(class NmId const &)
-	?interfaceInstance@NmDataPluginFactory@@QAEPAVNmDataPluginInterface@@PAVQObject@@@Z @ 199 NONAME ; class NmDataPluginInterface * NmDataPluginFactory::interfaceInstance(class QObject *)
-	?refreshModelItem@NmMailboxListModel@@QAEXABVNmId@@_N@Z @ 200 NONAME ; void NmMailboxListModel::refreshModelItem(class NmId const &, bool)
-	?metaObject@NmMailboxListModel@@UBEPBUQMetaObject@@XZ @ 201 NONAME ; struct QMetaObject const * NmMailboxListModel::metaObject(void) const
-	?IconId@NmMailboxMetaData@@QBE?AVNmId@@XZ @ 202 NONAME ; class NmId NmMailboxMetaData::IconId(void) const
-	?sendOperationCompleted@NmUiEngine@@IAEXXZ @ 203 NONAME ; void NmUiEngine::sendOperationCompleted(void)
-	??0NmFolderMetaData@@QAE@XZ @ 204 NONAME ; NmFolderMetaData::NmFolderMetaData(void)
-	?staticMetaObject@NmAddAttachmentsOperation@@2UQMetaObject@@B @ 205 NONAME ; struct QMetaObject const NmAddAttachmentsOperation::staticMetaObject
-	?connectionState@NmUiEngine@@QAE?AW4NmConnectState@@ABVNmId@@@Z @ 206 NONAME ; enum NmConnectState NmUiEngine::connectionState(class NmId const &)
-	?createTitleDividerItem@NmMessageListModel@@AAEPAVNmMessageListModelItem@@PAVNmMessageEnvelope@@@Z @ 207 NONAME ; class NmMessageListModelItem * NmMessageListModel::createTitleDividerItem(class NmMessageEnvelope *)
-	?setId@NmFolderMetaData@@QAEXABVNmId@@@Z @ 208 NONAME ; void NmFolderMetaData::setId(class NmId const &)
-	??0NmOperation@@QAE@XZ @ 209 NONAME ; NmOperation::NmOperation(void)
-	?cancelOperation@NmOperation@@QAEXXZ @ 210 NONAME ; void NmOperation::cancelOperation(void)
-	??_ENmFolderMetaData@@UAE@I@Z @ 211 NONAME ; NmFolderMetaData::~NmFolderMetaData(unsigned int)
-	?qt_metacast@NmMessageListModel@@UAEPAXPBD@Z @ 212 NONAME ; void * NmMessageListModel::qt_metacast(char const *)
-	?operationProgressChanged@NmOperation@@IAEXH@Z @ 213 NONAME ; void NmOperation::operationProgressChanged(int)
-	?trUtf8@NmOperation@@SA?AVQString@@PBD0H@Z @ 214 NONAME ; class QString NmOperation::trUtf8(char const *, char const *, int)
-	??_ENmMailboxListModel@@UAE@I@Z @ 215 NONAME ; NmMailboxListModel::~NmMailboxListModel(unsigned int)
-	?messageDeleted@NmUiEngine@@IAEXABVNmId@@00@Z @ 216 NONAME ; void NmUiEngine::messageDeleted(class NmId const &, class NmId const &, class NmId const &)
-	?trUtf8@NmMessageCreationOperation@@SA?AVQString@@PBD0@Z @ 217 NONAME ; class QString NmMessageCreationOperation::trUtf8(char const *, char const *)
-	?metaObject@NmUiEngine@@UBEPBUQMetaObject@@XZ @ 218 NONAME ; struct QMetaObject const * NmUiEngine::metaObject(void) const
-	??_ENmBaseClientPlugin@@UAE@I@Z @ 219 NONAME ; NmBaseClientPlugin::~NmBaseClientPlugin(unsigned int)
-	?markAsUnread@NmBaseClientPlugin@@QAEXXZ @ 220 NONAME ; void NmBaseClientPlugin::markAsUnread(void)
-	?metaObject@NmBaseClientPlugin@@UBEPBUQMetaObject@@XZ @ 221 NONAME ; struct QMetaObject const * NmBaseClientPlugin::metaObject(void) const
-	?tr@NmDataManager@@SA?AVQString@@PBD0@Z @ 222 NONAME ; class QString NmDataManager::tr(char const *, char const *)
-	?mailboxListModel@NmUiEngine@@QAEAAVNmMailboxListModel@@XZ @ 223 NONAME ; class NmMailboxListModel & NmUiEngine::mailboxListModel(void)
-	?fetchMessage@NmUiEngine@@QAE?AV?$QPointer@VNmOperation@@@@ABVNmId@@00@Z @ 224 NONAME ; class QPointer<class NmOperation> NmUiEngine::fetchMessage(class NmId const &, class NmId const &, class NmId const &)
-	?setIconId@NmMailboxMetaData@@QAEXABVNmId@@@Z @ 225 NONAME ; void NmMailboxMetaData::setIconId(class NmId const &)
-	??1NmDataPluginFactory@@EAE@XZ @ 226 NONAME ; NmDataPluginFactory::~NmDataPluginFactory(void)
-	?refreshMailboxListModel@NmUiEngine@@QAEXXZ @ 227 NONAME ; void NmUiEngine::refreshMailboxListModel(void)
-	?qt_metacall@NmStoreEnvelopesOperation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 228 NONAME ; int NmStoreEnvelopesOperation::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?trUtf8@NmMessageListModel@@SA?AVQString@@PBD0@Z @ 229 NONAME ; class QString NmMessageListModel::trUtf8(char const *, char const *)
-	?rowCount@NmFolderListModel@@UBEHABVQModelIndex@@@Z @ 230 NONAME ; int NmFolderListModel::rowCount(class QModelIndex const &) const
-	?doUpdateOperationProgress@NmOperation@@MAEXXZ @ 231 NONAME ; void NmOperation::doUpdateOperationProgress(void)
-	?tr@NmMailboxListModel@@SA?AVQString@@PBD0@Z @ 232 NONAME ; class QString NmMailboxListModel::tr(char const *, char const *)
-	?removeMessage@NmUiEngine@@QAEHABVNmId@@00@Z @ 233 NONAME ; int NmUiEngine::removeMessage(class NmId const &, class NmId const &, class NmId const &)
-	??_ENmUiEngine@@UAE@I@Z @ 234 NONAME ; NmUiEngine::~NmUiEngine(unsigned int)
-	??_ENmMessageSearchListModel@@UAE@I@Z @ 235 NONAME ; NmMessageSearchListModel::~NmMessageSearchListModel(unsigned int)
-	?operationCompleted@NmOperation@@IAEXH@Z @ 236 NONAME ; void NmOperation::operationCompleted(int)
-	?callEmitDataChanged@NmMessageListModelItem@@QAEXXZ @ 237 NONAME ; void NmMessageListModelItem::callEmitDataChanged(void)
-	?matchFound@NmUiEngine@@IAEXABVNmId@@@Z @ 238 NONAME ; void NmUiEngine::matchFound(class NmId const &)
-	?tr@NmCheckOutboxOperation@@SA?AVQString@@PBD0H@Z @ 239 NONAME ; class QString NmCheckOutboxOperation::tr(char const *, char const *, int)
-	?addSearchResult@NmMessageSearchListModel@@QAE_NABVNmId@@@Z @ 240 NONAME ; bool NmMessageSearchListModel::addSearchResult(class NmId const &)
-	??0NmMessageListModel@@QAE@AAVNmDataManager@@PAVQObject@@@Z @ 241 NONAME ; NmMessageListModel::NmMessageListModel(class NmDataManager &, class QObject *)
-	??_ENmAddAttachmentsOperation@@UAE@I@Z @ 242 NONAME ; NmAddAttachmentsOperation::~NmAddAttachmentsOperation(unsigned int)
-	?syncState@NmUiEngine@@QAE?AW4NmSyncState@@ABVNmId@@@Z @ 243 NONAME ; enum NmSyncState NmUiEngine::syncState(class NmId const &)
-	??1NmOperation@@MAE@XZ @ 244 NONAME ; NmOperation::~NmOperation(void)
-	?tr@NmStoreEnvelopesOperation@@SA?AVQString@@PBD0H@Z @ 245 NONAME ; class QString NmStoreEnvelopesOperation::tr(char const *, char const *, int)
-	?listMailboxes@NmDataManager@@QAEXAAV?$QList@PAVNmMailbox@@@@@Z @ 246 NONAME ; void NmDataManager::listMailboxes(class QList<class NmMailbox *> &)
-	?message@NmUiEngine@@QAEPAVNmMessage@@ABVNmId@@00@Z @ 247 NONAME ; class NmMessage * NmUiEngine::message(class NmId const &, class NmId const &, class NmId const &)
-	?refreshMailbox@NmUiEngine@@QAEHABVNmId@@@Z @ 248 NONAME ; int NmUiEngine::refreshMailbox(class NmId const &)
-	?trUtf8@NmUiEngine@@SA?AVQString@@PBD0@Z @ 249 NONAME ; class QString NmUiEngine::trUtf8(char const *, char const *)
-	?contentToMessagePart@NmUiEngine@@QAEHABVNmId@@00AAVNmMessagePart@@@Z @ 250 NONAME ; int NmUiEngine::contentToMessagePart(class NmId const &, class NmId const &, class NmId const &, class NmMessagePart &)
-	?removeItem@NmMessageListModel@@AAEXHAAVNmMessageListModelItem@@@Z @ 251 NONAME ; void NmMessageListModel::removeItem(int, class NmMessageListModelItem &)
-	??1NmMailboxListModel@@UAE@XZ @ 252 NONAME ; NmMailboxListModel::~NmMailboxListModel(void)
-	??0NmBaseClientPlugin@@QAE@XZ @ 253 NONAME ; NmBaseClientPlugin::NmBaseClientPlugin(void)
-	?forwardMail@NmBaseClientPlugin@@QAEXXZ @ 254 NONAME ; void NmBaseClientPlugin::forwardMail(void)
-	?setItemType@NmMessageListModelItem@@QAEXW4NmMessageItemType@1@@Z @ 255 NONAME ; void NmMessageListModelItem::setItemType(enum NmMessageListModelItem::NmMessageItemType)
-	??_ENmDataPluginFactory@@UAE@I@Z @ 256 NONAME ; NmDataPluginFactory::~NmDataPluginFactory(unsigned int)
-	?mailboxListChanged@NmBaseClientPlugin@@AAEXABVNmId@@W4MailboxEventType@NmSettings@@@Z @ 257 NONAME ; void NmBaseClientPlugin::mailboxListChanged(class NmId const &, enum NmSettings::MailboxEventType)
-	?expanded@NmMessageListModelItem@@QBE_NXZ @ 258 NONAME ; bool NmMessageListModelItem::expanded(void) const
-	?columnCount@NmFolderListModel@@UBEHABVQModelIndex@@@Z @ 259 NONAME ; int NmFolderListModel::columnCount(class QModelIndex const &) const
-	?pluginInstance@NmDataPluginFactory@@QAEPAVQObject@@VNmId@@@Z @ 260 NONAME ; class QObject * NmDataPluginFactory::pluginInstance(class NmId)
-	?setNewParam@NmMessageListModel@@IAEXPAVNmUiStartParam@@@Z @ 261 NONAME ; void NmMessageListModel::setNewParam(class NmUiStartParam *)
-	?data@NmMessageListModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 262 NONAME ; class QVariant NmMessageListModel::data(class QModelIndex const &, int) const
-	?goOnline@NmBaseClientPlugin@@AAEXABVNmId@@@Z @ 263 NONAME ; void NmBaseClientPlugin::goOnline(class NmId const &)
-	?createNewMail@NmBaseClientPlugin@@QAEXXZ @ 264 NONAME ; void NmBaseClientPlugin::createNewMail(void)
-	??_ENmCheckOutboxOperation@@UAE@I@Z @ 265 NONAME ; NmCheckOutboxOperation::~NmCheckOutboxOperation(unsigned int)
-	?qt_metacast@NmBaseClientPlugin@@UAEPAXPBD@Z @ 266 NONAME ; void * NmBaseClientPlugin::qt_metacast(char const *)
-	?staticMetaObject@NmBaseClientPlugin@@2UQMetaObject@@B @ 267 NONAME ; struct QMetaObject const NmBaseClientPlugin::staticMetaObject
-	?searchComplete@NmUiEngine@@IAEXXZ @ 268 NONAME ; void NmUiEngine::searchComplete(void)
-	?setEnvelope@NmMessageListModelItem@@QAEXABVNmMessageEnvelope@@@Z @ 269 NONAME ; void NmMessageListModelItem::setEnvelope(class NmMessageEnvelope const &)
-	?qt_metacast@NmAddAttachmentsOperation@@UAEPAXPBD@Z @ 270 NONAME ; void * NmAddAttachmentsOperation::qt_metacast(char const *)
-	?createNewMailViewerToolBar@NmBaseClientPlugin@@QAEXXZ @ 271 NONAME ; void NmBaseClientPlugin::createNewMailViewerToolBar(void)
-	?staticMetaObject@NmMailboxListModel@@2UQMetaObject@@B @ 272 NONAME ; struct QMetaObject const NmMailboxListModel::staticMetaObject
-	?qt_metacall@NmMessageCreationOperation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 273 NONAME ; int NmMessageCreationOperation::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?trUtf8@NmDataManager@@SA?AVQString@@PBD0H@Z @ 274 NONAME ; class QString NmDataManager::trUtf8(char const *, char const *, int)
-	?trUtf8@NmMessageCreationOperation@@SA?AVQString@@PBD0H@Z @ 275 NONAME ; class QString NmMessageCreationOperation::trUtf8(char const *, char const *, int)
-	?createForwardMessage@NmUiEngine@@QAE?AV?$QPointer@VNmMessageCreationOperation@@@@ABVNmId@@0@Z @ 276 NONAME ; class QPointer<class NmMessageCreationOperation> NmUiEngine::createForwardMessage(class NmId const &, class NmId const &)
-	?handleSyncStateEvent@NmUiEngine@@QAEXW4NmSyncState@@ABVNmOperationCompletionEvent@@@Z @ 277 NONAME ; void NmUiEngine::handleSyncStateEvent(enum NmSyncState, class NmOperationCompletionEvent const &)
-	?completeOperation@NmOperation@@QAEXH@Z @ 278 NONAME ; void NmOperation::completeOperation(int)
-	?parent@NmFolderListModel@@UBE?AVQModelIndex@@ABV2@@Z @ 279 NONAME ; class QModelIndex NmFolderListModel::parent(class QModelIndex const &) const
-	?folder@NmDataManager@@QAEPAVNmFolder@@ABVNmId@@0@Z @ 280 NONAME ; class NmFolder * NmDataManager::folder(class NmId const &, class NmId const &)
-	??0NmMessageSendingOperation@@QAE@XZ @ 281 NONAME ; NmMessageSendingOperation::NmMessageSendingOperation(void)
-	?replyMail@NmBaseClientPlugin@@QAEXXZ @ 282 NONAME ; void NmBaseClientPlugin::replyMail(void)
-	??1NmMessageListModelItem@@UAE@XZ @ 283 NONAME ; NmMessageListModelItem::~NmMessageListModelItem(void)
-	?mailboxPropertyChanged@NmBaseClientPlugin@@AAEXABVNmId@@VQVariant@@1@Z @ 284 NONAME ; void NmBaseClientPlugin::mailboxPropertyChanged(class NmId const &, class QVariant, class QVariant)
-	?qt_metacall@NmOperation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 285 NONAME ; int NmOperation::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?removeMessageFromModel@NmMessageListModel@@AAEXABVNmId@@@Z @ 286 NONAME ; void NmMessageListModel::removeMessageFromModel(class NmId const &)
-	?trUtf8@NmMessageListModel@@SA?AVQString@@PBD0H@Z @ 287 NONAME ; class QString NmMessageListModel::trUtf8(char const *, char const *, int)
-	?handleRequest@NmBaseClientPlugin@@AAEXW4NmActionResponseCommand@@ABVNmActionRequest@@@Z @ 288 NONAME ; void NmBaseClientPlugin::handleRequest(enum NmActionResponseCommand, class NmActionRequest const &)
-	?operationPartCompleted@NmAddAttachmentsOperation@@IAEXABVQString@@ABVNmId@@H@Z @ 289 NONAME ; void NmAddAttachmentsOperation::operationPartCompleted(class QString const &, class NmId const &, int)
-	?trUtf8@NmStoreEnvelopesOperation@@SA?AVQString@@PBD0H@Z @ 290 NONAME ; class QString NmStoreEnvelopesOperation::trUtf8(char const *, char const *, int)
-	?tr@NmMessageListModel@@SA?AVQString@@PBD0@Z @ 291 NONAME ; class QString NmMessageListModel::tr(char const *, char const *)
-	?doCompleteOperation@NmOperation@@MAEXXZ @ 292 NONAME ; void NmOperation::doCompleteOperation(void)
-	?dividerInsertionIndex@NmMessageListModel@@AAEHH@Z @ 293 NONAME ; int NmMessageListModel::dividerInsertionIndex(int)
-	??1NmCheckOutboxOperation@@MAE@XZ @ 294 NONAME ; NmCheckOutboxOperation::~NmCheckOutboxOperation(void)
-	?createMessageItem@NmMessageListModel@@AAEPAVNmMessageListModelItem@@PAVNmMessageEnvelope@@@Z @ 295 NONAME ; class NmMessageListModelItem * NmMessageListModel::createMessageItem(class NmMessageEnvelope *)
-	?id@NmFolderMetaData@@QBE?AVNmId@@XZ @ 296 NONAME ; class NmId NmFolderMetaData::id(void) const
-	?createReplyMessage@NmUiEngine@@QAE?AV?$QPointer@VNmMessageCreationOperation@@@@ABVNmId@@0_N@Z @ 297 NONAME ; class QPointer<class NmMessageCreationOperation> NmUiEngine::createReplyMessage(class NmId const &, class NmId const &, bool)
-	?getStandardFolderId@NmDataManager@@QAE?AVNmId@@ABV2@W4NmFolderType@@@Z @ 298 NONAME ; class NmId NmDataManager::getStandardFolderId(class NmId const &, enum NmFolderType)
-	?dividersActive@NmMessageListModel@@QAE_NXZ @ 299 NONAME ; bool NmMessageListModel::dividersActive(void)
-	?trUtf8@NmMessageSearchListModel@@SA?AVQString@@PBD0H@Z @ 300 NONAME ; class QString NmMessageSearchListModel::trUtf8(char const *, char const *, int)
-	?titleDivider@NmMessageListModelItem@@QBE?AVQString@@XZ @ 301 NONAME ; class QString NmMessageListModelItem::titleDivider(void) const
-	?getStaticMetaObject@NmBaseClientPlugin@@SAABUQMetaObject@@XZ @ 302 NONAME ; struct QMetaObject const & NmBaseClientPlugin::getStaticMetaObject(void)
-	?qt_metacast@NmMessageCreationOperation@@UAEPAXPBD@Z @ 303 NONAME ; void * NmMessageCreationOperation::qt_metacast(char const *)
-	?updateEnvelope@NmMessageListModel@@AAEXW4NmEnvelopeProperties@@ABVNmId@@@Z @ 304 NONAME ; void NmMessageListModel::updateEnvelope(enum NmEnvelopeProperties, class NmId const &)
-	??_ENmDataManager@@UAE@I@Z @ 305 NONAME ; NmDataManager::~NmDataManager(unsigned int)
-	?qt_metacast@NmMailboxListModel@@UAEPAXPBD@Z @ 306 NONAME ; void * NmMailboxListModel::qt_metacast(char const *)
-	?search@NmUiEngine@@QAEHABVNmId@@ABVQStringList@@@Z @ 307 NONAME ; int NmUiEngine::search(class NmId const &, class QStringList const &)
-	?setEnvelopes@NmUiEngine@@QAE?AV?$QPointer@VNmStoreEnvelopesOperation@@@@ABVNmId@@0W4NmEnvelopeProperties@@ABV?$QList@PB$$CBVNmMessageEnvelope@@@@@Z @ 308 NONAME ; class QPointer<class NmStoreEnvelopesOperation> NmUiEngine::setEnvelopes(class NmId const &, class NmId const &, enum NmEnvelopeProperties, class QList<class NmMessageEnvelope const *> const &)
-	?getActions@NmBaseClientPlugin@@UAEXABVNmActionRequest@@AAV?$QList@PAVNmAction@@@@@Z @ 309 NONAME ; void NmBaseClientPlugin::getActions(class NmActionRequest const &, class QList<class NmAction *> &)
-	?qt_metacast@NmStoreEnvelopesOperation@@UAEPAXPBD@Z @ 310 NONAME ; void * NmStoreEnvelopesOperation::qt_metacast(char const *)
-	?handleMessageEvent@NmMessageListModel@@QAEXW4NmMessageEvent@@ABVNmId@@ABV?$QList@VNmId@@@@@Z @ 311 NONAME ; void NmMessageListModel::handleMessageEvent(enum NmMessageEvent, class NmId const &, class QList<class NmId> const &)
-	??_ENmMailboxMetaData@@UAE@I@Z @ 312 NONAME ; NmMailboxMetaData::~NmMailboxMetaData(unsigned int)
-	??0NmMessageListModelItem@@QAE@XZ @ 313 NONAME ; NmMessageListModelItem::NmMessageListModelItem(void)
-	?tr@NmAddAttachmentsOperation@@SA?AVQString@@PBD0H@Z @ 314 NONAME ; class QString NmAddAttachmentsOperation::tr(char const *, char const *, int)
-	?setDividers@NmMessageListModel@@QAEX_N@Z @ 315 NONAME ; void NmMessageListModel::setDividers(bool)
-	?loadPlugin@NmDataPluginFactory@@QAEPAVQObject@@ABVQDir@@ABVQString@@@Z @ 316 NONAME ; class QObject * NmDataPluginFactory::loadPlugin(class QDir const &, class QString const &)
-	?qt_metacast@NmOperation@@UAEPAXPBD@Z @ 317 NONAME ; void * NmOperation::qt_metacast(char const *)
-	?tr@NmMessageListModel@@SA?AVQString@@PBD0H@Z @ 318 NONAME ; class QString NmMessageListModel::tr(char const *, char const *, int)
-	?removeAttachment@NmUiEngine@@QAE?AV?$QPointer@VNmOperation@@@@ABVNmMessage@@ABVNmId@@@Z @ 319 NONAME ; class QPointer<class NmOperation> NmUiEngine::removeAttachment(class NmMessage const &, class NmId const &)
-	?staticMetaObject@NmMessageListModel@@2UQMetaObject@@B @ 320 NONAME ; struct QMetaObject const NmMessageListModel::staticMetaObject
-	?qt_metacall@NmAddAttachmentsOperation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 321 NONAME ; int NmAddAttachmentsOperation::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?qt_metacall@NmUiEngine@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 322 NONAME ; int NmUiEngine::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?tr@NmMessageSearchListModel@@SA?AVQString@@PBD0H@Z @ 323 NONAME ; class QString NmMessageSearchListModel::tr(char const *, char const *, int)
-	?message@NmDataManager@@QAEPAVNmMessage@@ABVNmId@@00@Z @ 324 NONAME ; class NmMessage * NmDataManager::message(class NmId const &, class NmId const &, class NmId const &)
-	?metaObject@NmOperation@@UBEPBUQMetaObject@@XZ @ 325 NONAME ; struct QMetaObject const * NmOperation::metaObject(void) const
-	?folderTypeById@NmUiEngine@@QAE?AW4NmFolderType@@VNmId@@0@Z @ 326 NONAME ; enum NmFolderType NmUiEngine::folderTypeById(class NmId, class NmId)
-	?refreshContent@NmMessageSearchListModel@@QAEXXZ @ 327 NONAME ; void NmMessageSearchListModel::refreshContent(void)
-	?searchResultCount@NmMessageSearchListModel@@QBEHXZ @ 328 NONAME ; int NmMessageSearchListModel::searchResultCount(void) const
-	?handleConnectEvent@NmUiEngine@@QAEXW4NmConnectState@@ABVNmId@@H@Z @ 329 NONAME ; void NmUiEngine::handleConnectEvent(enum NmConnectState, class NmId const &, int)
+	??1NmBaseClientPlugin@@UAE@XZ @ 187 NONAME ; NmBaseClientPlugin::~NmBaseClientPlugin(void)
+	?qt_metacast@NmDataManager@@UAEPAXPBD@Z @ 188 NONAME ; void * NmDataManager::qt_metacast(char const *)
+	??0NmMessageCreationOperation@@QAE@XZ @ 189 NONAME ; NmMessageCreationOperation::NmMessageCreationOperation(void)
+	?qt_metacall@NmBaseClientPlugin@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 190 NONAME ; int NmBaseClientPlugin::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?envelopePtr@NmMessageListModelItem@@QAEPAVNmMessageEnvelope@@XZ @ 191 NONAME ; class NmMessageEnvelope * NmMessageListModelItem::envelopePtr(void)
+	?messageListModel@NmUiEngine@@QAEAAVNmMessageListModel@@ABVNmId@@0@Z @ 192 NONAME ; class NmMessageListModel & NmUiEngine::messageListModel(class NmId const &, class NmId const &)
+	??1NmMailboxMetaData@@UAE@XZ @ 193 NONAME ; NmMailboxMetaData::~NmMailboxMetaData(void)
+	?connectionEvent@NmUiEngine@@IAEXW4NmConnectState@@ABVNmId@@@Z @ 194 NONAME ; void NmUiEngine::connectionEvent(enum NmConnectState, class NmId const &)
+	?mailbox@NmDataManager@@QAEPAVNmMailbox@@ABVNmId@@@Z @ 195 NONAME ; class NmMailbox * NmDataManager::mailbox(class NmId const &)
+	?interfaceInstance@NmDataPluginFactory@@QAEPAVNmDataPluginInterface@@PAVQObject@@@Z @ 196 NONAME ; class NmDataPluginInterface * NmDataPluginFactory::interfaceInstance(class QObject *)
+	?metaObject@NmMailboxListModel@@UBEPBUQMetaObject@@XZ @ 197 NONAME ; struct QMetaObject const * NmMailboxListModel::metaObject(void) const
+	?IconId@NmMailboxMetaData@@QBE?AVNmId@@XZ @ 198 NONAME ; class NmId NmMailboxMetaData::IconId(void) const
+	?sendOperationCompleted@NmUiEngine@@IAEXXZ @ 199 NONAME ; void NmUiEngine::sendOperationCompleted(void)
+	??0NmFolderMetaData@@QAE@XZ @ 200 NONAME ; NmFolderMetaData::NmFolderMetaData(void)
+	?staticMetaObject@NmAddAttachmentsOperation@@2UQMetaObject@@B @ 201 NONAME ; struct QMetaObject const NmAddAttachmentsOperation::staticMetaObject
+	?connectionState@NmUiEngine@@QAE?AW4NmConnectState@@ABVNmId@@@Z @ 202 NONAME ; enum NmConnectState NmUiEngine::connectionState(class NmId const &)
+	?createTitleDividerItem@NmMessageListModel@@AAEPAVNmMessageListModelItem@@PAVNmMessageEnvelope@@@Z @ 203 NONAME ; class NmMessageListModelItem * NmMessageListModel::createTitleDividerItem(class NmMessageEnvelope *)
+	?setId@NmFolderMetaData@@QAEXABVNmId@@@Z @ 204 NONAME ; void NmFolderMetaData::setId(class NmId const &)
+	??0NmOperation@@QAE@XZ @ 205 NONAME ; NmOperation::NmOperation(void)
+	?cancelOperation@NmOperation@@QAEXXZ @ 206 NONAME ; void NmOperation::cancelOperation(void)
+	??_ENmFolderMetaData@@UAE@I@Z @ 207 NONAME ; NmFolderMetaData::~NmFolderMetaData(unsigned int)
+	?qt_metacast@NmMessageListModel@@UAEPAXPBD@Z @ 208 NONAME ; void * NmMessageListModel::qt_metacast(char const *)
+	?operationProgressChanged@NmOperation@@IAEXH@Z @ 209 NONAME ; void NmOperation::operationProgressChanged(int)
+	?trUtf8@NmOperation@@SA?AVQString@@PBD0H@Z @ 210 NONAME ; class QString NmOperation::trUtf8(char const *, char const *, int)
+	??_ENmMailboxListModel@@UAE@I@Z @ 211 NONAME ; NmMailboxListModel::~NmMailboxListModel(unsigned int)
+	?messageDeleted@NmUiEngine@@IAEXABVNmId@@00@Z @ 212 NONAME ; void NmUiEngine::messageDeleted(class NmId const &, class NmId const &, class NmId const &)
+	?trUtf8@NmMessageCreationOperation@@SA?AVQString@@PBD0@Z @ 213 NONAME ; class QString NmMessageCreationOperation::trUtf8(char const *, char const *)
+	?metaObject@NmUiEngine@@UBEPBUQMetaObject@@XZ @ 214 NONAME ; struct QMetaObject const * NmUiEngine::metaObject(void) const
+	??_ENmBaseClientPlugin@@UAE@I@Z @ 215 NONAME ; NmBaseClientPlugin::~NmBaseClientPlugin(unsigned int)
+	?markAsUnread@NmBaseClientPlugin@@QAEXXZ @ 216 NONAME ; void NmBaseClientPlugin::markAsUnread(void)
+	?metaObject@NmBaseClientPlugin@@UBEPBUQMetaObject@@XZ @ 217 NONAME ; struct QMetaObject const * NmBaseClientPlugin::metaObject(void) const
+	?tr@NmDataManager@@SA?AVQString@@PBD0@Z @ 218 NONAME ; class QString NmDataManager::tr(char const *, char const *)
+	?mailboxListModel@NmUiEngine@@QAEAAVNmMailboxListModel@@XZ @ 219 NONAME ; class NmMailboxListModel & NmUiEngine::mailboxListModel(void)
+	?fetchMessage@NmUiEngine@@QAE?AV?$QPointer@VNmOperation@@@@ABVNmId@@00@Z @ 220 NONAME ; class QPointer<class NmOperation> NmUiEngine::fetchMessage(class NmId const &, class NmId const &, class NmId const &)
+	?setIconId@NmMailboxMetaData@@QAEXABVNmId@@@Z @ 221 NONAME ; void NmMailboxMetaData::setIconId(class NmId const &)
+	??1NmDataPluginFactory@@EAE@XZ @ 222 NONAME ; NmDataPluginFactory::~NmDataPluginFactory(void)
+	?refreshMailboxListModel@NmUiEngine@@QAEXXZ @ 223 NONAME ; void NmUiEngine::refreshMailboxListModel(void)
+	?qt_metacall@NmStoreEnvelopesOperation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 224 NONAME ; int NmStoreEnvelopesOperation::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?trUtf8@NmMessageListModel@@SA?AVQString@@PBD0@Z @ 225 NONAME ; class QString NmMessageListModel::trUtf8(char const *, char const *)
+	?rowCount@NmFolderListModel@@UBEHABVQModelIndex@@@Z @ 226 NONAME ; int NmFolderListModel::rowCount(class QModelIndex const &) const
+	?doUpdateOperationProgress@NmOperation@@MAEXXZ @ 227 NONAME ; void NmOperation::doUpdateOperationProgress(void)
+	?tr@NmMailboxListModel@@SA?AVQString@@PBD0@Z @ 228 NONAME ; class QString NmMailboxListModel::tr(char const *, char const *)
+	?removeMessage@NmUiEngine@@QAEHABVNmId@@00@Z @ 229 NONAME ; int NmUiEngine::removeMessage(class NmId const &, class NmId const &, class NmId const &)
+	??_ENmUiEngine@@UAE@I@Z @ 230 NONAME ; NmUiEngine::~NmUiEngine(unsigned int)
+	?operationCompleted@NmOperation@@IAEXH@Z @ 231 NONAME ; void NmOperation::operationCompleted(int)
+	?callEmitDataChanged@NmMessageListModelItem@@QAEXXZ @ 232 NONAME ; void NmMessageListModelItem::callEmitDataChanged(void)
+	?handleRequest@NmBaseClientPlugin@@IAEXW4NmActionResponseCommand@@ABVNmActionRequest@@@Z @ 233 NONAME ; void NmBaseClientPlugin::handleRequest(enum NmActionResponseCommand, class NmActionRequest const &)
+	??0NmMessageListModel@@QAE@AAVNmDataManager@@PAVQObject@@@Z @ 234 NONAME ; NmMessageListModel::NmMessageListModel(class NmDataManager &, class QObject *)
+	??_ENmAddAttachmentsOperation@@UAE@I@Z @ 235 NONAME ; NmAddAttachmentsOperation::~NmAddAttachmentsOperation(unsigned int)
+	?syncState@NmUiEngine@@QAE?AW4NmSyncState@@ABVNmId@@@Z @ 236 NONAME ; enum NmSyncState NmUiEngine::syncState(class NmId const &)
+	??1NmOperation@@MAE@XZ @ 237 NONAME ; NmOperation::~NmOperation(void)
+	?tr@NmStoreEnvelopesOperation@@SA?AVQString@@PBD0H@Z @ 238 NONAME ; class QString NmStoreEnvelopesOperation::tr(char const *, char const *, int)
+	?listMailboxes@NmDataManager@@QAEXAAV?$QList@PAVNmMailbox@@@@@Z @ 239 NONAME ; void NmDataManager::listMailboxes(class QList<class NmMailbox *> &)
+	?message@NmUiEngine@@QAEPAVNmMessage@@ABVNmId@@00@Z @ 240 NONAME ; class NmMessage * NmUiEngine::message(class NmId const &, class NmId const &, class NmId const &)
+	?refreshMailbox@NmUiEngine@@QAEHABVNmId@@@Z @ 241 NONAME ; int NmUiEngine::refreshMailbox(class NmId const &)
+	?trUtf8@NmUiEngine@@SA?AVQString@@PBD0@Z @ 242 NONAME ; class QString NmUiEngine::trUtf8(char const *, char const *)
+	?contentToMessagePart@NmUiEngine@@QAEHABVNmId@@00AAVNmMessagePart@@@Z @ 243 NONAME ; int NmUiEngine::contentToMessagePart(class NmId const &, class NmId const &, class NmId const &, class NmMessagePart &)
+	?removeItem@NmMessageListModel@@AAEXHAAVNmMessageListModelItem@@@Z @ 244 NONAME ; void NmMessageListModel::removeItem(int, class NmMessageListModelItem &)
+	??1NmMailboxListModel@@UAE@XZ @ 245 NONAME ; NmMailboxListModel::~NmMailboxListModel(void)
+	??0NmBaseClientPlugin@@QAE@XZ @ 246 NONAME ; NmBaseClientPlugin::NmBaseClientPlugin(void)
+	?forwardMail@NmBaseClientPlugin@@QAEXXZ @ 247 NONAME ; void NmBaseClientPlugin::forwardMail(void)
+	?setItemType@NmMessageListModelItem@@QAEXW4NmMessageItemType@1@@Z @ 248 NONAME ; void NmMessageListModelItem::setItemType(enum NmMessageListModelItem::NmMessageItemType)
+	??_ENmDataPluginFactory@@UAE@I@Z @ 249 NONAME ; NmDataPluginFactory::~NmDataPluginFactory(unsigned int)
+	?mailboxListChanged@NmBaseClientPlugin@@AAEXABVNmId@@W4MailboxEventType@NmSettings@@@Z @ 250 NONAME ; void NmBaseClientPlugin::mailboxListChanged(class NmId const &, enum NmSettings::MailboxEventType)
+	?expanded@NmMessageListModelItem@@QBE_NXZ @ 251 NONAME ; bool NmMessageListModelItem::expanded(void) const
+	?columnCount@NmFolderListModel@@UBEHABVQModelIndex@@@Z @ 252 NONAME ; int NmFolderListModel::columnCount(class QModelIndex const &) const
+	?pluginInstance@NmDataPluginFactory@@QAEPAVQObject@@VNmId@@@Z @ 253 NONAME ; class QObject * NmDataPluginFactory::pluginInstance(class NmId)
+	?setNewParam@NmMessageListModel@@IAEXPAVNmUiStartParam@@@Z @ 254 NONAME ; void NmMessageListModel::setNewParam(class NmUiStartParam *)
+	?data@NmMessageListModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 255 NONAME ; class QVariant NmMessageListModel::data(class QModelIndex const &, int) const
+	?goOnline@NmBaseClientPlugin@@AAEXABVNmId@@@Z @ 256 NONAME ; void NmBaseClientPlugin::goOnline(class NmId const &)
+	?createNewMail@NmBaseClientPlugin@@QAEXXZ @ 257 NONAME ; void NmBaseClientPlugin::createNewMail(void)
+	?qt_metacast@NmBaseClientPlugin@@UAEPAXPBD@Z @ 258 NONAME ; void * NmBaseClientPlugin::qt_metacast(char const *)
+	?staticMetaObject@NmBaseClientPlugin@@2UQMetaObject@@B @ 259 NONAME ; struct QMetaObject const NmBaseClientPlugin::staticMetaObject
+	?searchComplete@NmUiEngine@@IAEXXZ @ 260 NONAME ; void NmUiEngine::searchComplete(void)
+	?setEnvelope@NmMessageListModelItem@@QAEXABVNmMessageEnvelope@@@Z @ 261 NONAME ; void NmMessageListModelItem::setEnvelope(class NmMessageEnvelope const &)
+	?qt_metacast@NmAddAttachmentsOperation@@UAEPAXPBD@Z @ 262 NONAME ; void * NmAddAttachmentsOperation::qt_metacast(char const *)
+	?createNewMailViewerToolBar@NmBaseClientPlugin@@QAEXXZ @ 263 NONAME ; void NmBaseClientPlugin::createNewMailViewerToolBar(void)
+	?staticMetaObject@NmMailboxListModel@@2UQMetaObject@@B @ 264 NONAME ; struct QMetaObject const NmMailboxListModel::staticMetaObject
+	?qt_metacall@NmMessageCreationOperation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 265 NONAME ; int NmMessageCreationOperation::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?trUtf8@NmDataManager@@SA?AVQString@@PBD0H@Z @ 266 NONAME ; class QString NmDataManager::trUtf8(char const *, char const *, int)
+	?trUtf8@NmMessageCreationOperation@@SA?AVQString@@PBD0H@Z @ 267 NONAME ; class QString NmMessageCreationOperation::trUtf8(char const *, char const *, int)
+	?createForwardMessage@NmUiEngine@@QAE?AV?$QPointer@VNmMessageCreationOperation@@@@ABVNmId@@0@Z @ 268 NONAME ; class QPointer<class NmMessageCreationOperation> NmUiEngine::createForwardMessage(class NmId const &, class NmId const &)
+	?handleSyncStateEvent@NmUiEngine@@QAEXW4NmSyncState@@ABVNmOperationCompletionEvent@@@Z @ 269 NONAME ; void NmUiEngine::handleSyncStateEvent(enum NmSyncState, class NmOperationCompletionEvent const &)
+	?completeOperation@NmOperation@@QAEXH@Z @ 270 NONAME ; void NmOperation::completeOperation(int)
+	?parent@NmFolderListModel@@UBE?AVQModelIndex@@ABV2@@Z @ 271 NONAME ; class QModelIndex NmFolderListModel::parent(class QModelIndex const &) const
+	?folder@NmDataManager@@QAEPAVNmFolder@@ABVNmId@@0@Z @ 272 NONAME ; class NmFolder * NmDataManager::folder(class NmId const &, class NmId const &)
+	??0NmMessageSendingOperation@@QAE@XZ @ 273 NONAME ; NmMessageSendingOperation::NmMessageSendingOperation(void)
+	?replyMail@NmBaseClientPlugin@@QAEXXZ @ 274 NONAME ; void NmBaseClientPlugin::replyMail(void)
+	??1NmMessageListModelItem@@UAE@XZ @ 275 NONAME ; NmMessageListModelItem::~NmMessageListModelItem(void)
+	?mailboxPropertyChanged@NmBaseClientPlugin@@AAEXABVNmId@@VQVariant@@1@Z @ 276 NONAME ; void NmBaseClientPlugin::mailboxPropertyChanged(class NmId const &, class QVariant, class QVariant)
+	?qt_metacall@NmOperation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 277 NONAME ; int NmOperation::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?removeMessageFromModel@NmMessageListModel@@AAEXABVNmId@@@Z @ 278 NONAME ; void NmMessageListModel::removeMessageFromModel(class NmId const &)
+	?trUtf8@NmMessageListModel@@SA?AVQString@@PBD0H@Z @ 279 NONAME ; class QString NmMessageListModel::trUtf8(char const *, char const *, int)
+	?operationPartCompleted@NmAddAttachmentsOperation@@IAEXABVQString@@ABVNmId@@H@Z @ 280 NONAME ; void NmAddAttachmentsOperation::operationPartCompleted(class QString const &, class NmId const &, int)
+	?trUtf8@NmStoreEnvelopesOperation@@SA?AVQString@@PBD0H@Z @ 281 NONAME ; class QString NmStoreEnvelopesOperation::trUtf8(char const *, char const *, int)
+	?tr@NmMessageListModel@@SA?AVQString@@PBD0@Z @ 282 NONAME ; class QString NmMessageListModel::tr(char const *, char const *)
+	?doCompleteOperation@NmOperation@@MAEXXZ @ 283 NONAME ; void NmOperation::doCompleteOperation(void)
+	?dividerInsertionIndex@NmMessageListModel@@AAEHH@Z @ 284 NONAME ; int NmMessageListModel::dividerInsertionIndex(int)
+	?createMessageItem@NmMessageListModel@@AAEPAVNmMessageListModelItem@@PAVNmMessageEnvelope@@@Z @ 285 NONAME ; class NmMessageListModelItem * NmMessageListModel::createMessageItem(class NmMessageEnvelope *)
+	?id@NmFolderMetaData@@QBE?AVNmId@@XZ @ 286 NONAME ; class NmId NmFolderMetaData::id(void) const
+	?createReplyMessage@NmUiEngine@@QAE?AV?$QPointer@VNmMessageCreationOperation@@@@ABVNmId@@0_N@Z @ 287 NONAME ; class QPointer<class NmMessageCreationOperation> NmUiEngine::createReplyMessage(class NmId const &, class NmId const &, bool)
+	?getStandardFolderId@NmDataManager@@QAE?AVNmId@@ABV2@W4NmFolderType@@@Z @ 288 NONAME ; class NmId NmDataManager::getStandardFolderId(class NmId const &, enum NmFolderType)
+	?address@NmMailboxMetaData@@QBE?AVQString@@XZ @ 289 NONAME ; class QString NmMailboxMetaData::address(void) const
+	?dividersActive@NmMessageListModel@@QAE_NXZ @ 290 NONAME ; bool NmMessageListModel::dividersActive(void)
+	?titleDivider@NmMessageListModelItem@@QBE?AVQString@@XZ @ 291 NONAME ; class QString NmMessageListModelItem::titleDivider(void) const
+	?getStaticMetaObject@NmBaseClientPlugin@@SAABUQMetaObject@@XZ @ 292 NONAME ; struct QMetaObject const & NmBaseClientPlugin::getStaticMetaObject(void)
+	?qt_metacast@NmMessageCreationOperation@@UAEPAXPBD@Z @ 293 NONAME ; void * NmMessageCreationOperation::qt_metacast(char const *)
+	?updateEnvelope@NmMessageListModel@@AAEXW4NmEnvelopeProperties@@ABVNmId@@@Z @ 294 NONAME ; void NmMessageListModel::updateEnvelope(enum NmEnvelopeProperties, class NmId const &)
+	??_ENmDataManager@@UAE@I@Z @ 295 NONAME ; NmDataManager::~NmDataManager(unsigned int)
+	?qt_metacast@NmMailboxListModel@@UAEPAXPBD@Z @ 296 NONAME ; void * NmMailboxListModel::qt_metacast(char const *)
+	?search@NmUiEngine@@QAEHABVNmId@@ABVQStringList@@@Z @ 297 NONAME ; int NmUiEngine::search(class NmId const &, class QStringList const &)
+	?setEnvelopes@NmUiEngine@@QAE?AV?$QPointer@VNmStoreEnvelopesOperation@@@@ABVNmId@@0W4NmEnvelopeProperties@@ABV?$QList@PB$$CBVNmMessageEnvelope@@@@@Z @ 298 NONAME ; class QPointer<class NmStoreEnvelopesOperation> NmUiEngine::setEnvelopes(class NmId const &, class NmId const &, enum NmEnvelopeProperties, class QList<class NmMessageEnvelope const *> const &)
+	?getActions@NmBaseClientPlugin@@UAEXABVNmActionRequest@@AAV?$QList@PAVNmAction@@@@@Z @ 299 NONAME ; void NmBaseClientPlugin::getActions(class NmActionRequest const &, class QList<class NmAction *> &)
+	?qt_metacast@NmStoreEnvelopesOperation@@UAEPAXPBD@Z @ 300 NONAME ; void * NmStoreEnvelopesOperation::qt_metacast(char const *)
+	??_ENmMailboxMetaData@@UAE@I@Z @ 301 NONAME ; NmMailboxMetaData::~NmMailboxMetaData(unsigned int)
+	??0NmMessageListModelItem@@QAE@XZ @ 302 NONAME ; NmMessageListModelItem::NmMessageListModelItem(void)
+	?tr@NmAddAttachmentsOperation@@SA?AVQString@@PBD0H@Z @ 303 NONAME ; class QString NmAddAttachmentsOperation::tr(char const *, char const *, int)
+	?setDividers@NmMessageListModel@@QAEX_N@Z @ 304 NONAME ; void NmMessageListModel::setDividers(bool)
+	?loadPlugin@NmDataPluginFactory@@QAEPAVQObject@@ABVQDir@@ABVQString@@@Z @ 305 NONAME ; class QObject * NmDataPluginFactory::loadPlugin(class QDir const &, class QString const &)
+	?qt_metacast@NmOperation@@UAEPAXPBD@Z @ 306 NONAME ; void * NmOperation::qt_metacast(char const *)
+	?tr@NmMessageListModel@@SA?AVQString@@PBD0H@Z @ 307 NONAME ; class QString NmMessageListModel::tr(char const *, char const *, int)
+	?removeAttachment@NmUiEngine@@QAE?AV?$QPointer@VNmOperation@@@@ABVNmMessage@@ABVNmId@@@Z @ 308 NONAME ; class QPointer<class NmOperation> NmUiEngine::removeAttachment(class NmMessage const &, class NmId const &)
+	?staticMetaObject@NmMessageListModel@@2UQMetaObject@@B @ 309 NONAME ; struct QMetaObject const NmMessageListModel::staticMetaObject
+	?qt_metacall@NmAddAttachmentsOperation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 310 NONAME ; int NmAddAttachmentsOperation::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?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
 
--- a/emailuis/nmailuiengine/eabi/nmailuiengineu.def	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/eabi/nmailuiengineu.def	Thu Jul 22 16:30:28 2010 +0100
@@ -1,17 +1,17 @@
 EXPORTS
-	_ZN10NmUiEngine10matchFoundERK4NmId @ 1 NONAME
-	_ZN10NmUiEngine11checkOutboxERK4NmId @ 2 NONAME
-	_ZN10NmUiEngine11mailboxByIdERK4NmId @ 3 NONAME
-	_ZN10NmUiEngine11qt_metacallEN11QMetaObject4CallEiPPv @ 4 NONAME
-	_ZN10NmUiEngine11qt_metacastEPKc @ 5 NONAME
-	_ZN10NmUiEngine11saveMessageERK9NmMessage @ 6 NONAME
-	_ZN10NmUiEngine11sendMessageEP9NmMessageRK5QListIP11NmOperationE @ 7 NONAME
-	_ZN10NmUiEngine12cancelSearchERK4NmId @ 8 NONAME
-	_ZN10NmUiEngine12fetchMessageERK4NmIdS2_S2_ @ 9 NONAME
-	_ZN10NmUiEngine12setEnvelopesERK4NmIdS2_20NmEnvelopePropertiesRK5QListIPK17NmMessageEnvelopeE @ 10 NONAME
-	_ZN10NmUiEngine13removeMessageERK4NmIdS2_S2_ @ 11 NONAME
-	_ZN10NmUiEngine14addAttachmentsERK9NmMessageRK5QListI7QStringE @ 12 NONAME
-	_ZN10NmUiEngine14deleteMessagesERK4NmIdS2_RK5QListIS0_E @ 13 NONAME
+	_ZN10NmUiEngine10matchFoundERK4NmIdS2_ @ 1 NONAME
+	_ZN10NmUiEngine11mailboxByIdERK4NmId @ 2 NONAME
+	_ZN10NmUiEngine11qt_metacallEN11QMetaObject4CallEiPPv @ 3 NONAME
+	_ZN10NmUiEngine11qt_metacastEPKc @ 4 NONAME
+	_ZN10NmUiEngine11saveMessageERK9NmMessage @ 5 NONAME
+	_ZN10NmUiEngine11sendMessageEP9NmMessageRK5QListIP11NmOperationE @ 6 NONAME
+	_ZN10NmUiEngine12cancelSearchERK4NmId @ 7 NONAME
+	_ZN10NmUiEngine12fetchMessageERK4NmIdS2_S2_ @ 8 NONAME
+	_ZN10NmUiEngine12setEnvelopesERK4NmIdS2_20NmEnvelopePropertiesRK5QListIPK17NmMessageEnvelopeE @ 9 NONAME
+	_ZN10NmUiEngine13removeMessageERK4NmIdS2_S2_ @ 10 NONAME
+	_ZN10NmUiEngine14addAttachmentsERK9NmMessageRK5QListI7QStringE @ 11 NONAME
+	_ZN10NmUiEngine14deleteMessagesERK4NmIdS2_RK5QListIS0_E @ 12 NONAME
+	_ZN10NmUiEngine14folderTypeByIdE4NmIdS0_ @ 13 NONAME
 	_ZN10NmUiEngine14mailboxDeletedERK4NmId @ 14 NONAME
 	_ZN10NmUiEngine14messageDeletedERK4NmIdS2_S2_ @ 15 NONAME
 	_ZN10NmUiEngine14refreshMailboxERK4NmId @ 16 NONAME
@@ -24,220 +24,220 @@
 	_ZN10NmUiEngine15releaseInstanceERPS_ @ 23 NONAME
 	_ZN10NmUiEngine16createNewMessageERK4NmId @ 24 NONAME
 	_ZN10NmUiEngine16fetchMessagePartERK4NmIdS2_S2_S2_ @ 25 NONAME
-	_ZN10NmUiEngine16mailboxListModelEv @ 26 NONAME
-	_ZN10NmUiEngine16messageListModelERK4NmIdS2_ @ 27 NONAME
-	_ZN10NmUiEngine16removeAttachmentERK9NmMessageRK4NmId @ 28 NONAME
-	_ZN10NmUiEngine16standardFolderIdERK4NmId12NmFolderType @ 29 NONAME
-	_ZN10NmUiEngine16staticMetaObjectE @ 30 NONAME DATA 16
-	_ZN10NmUiEngine18createReplyMessageERK4NmIdS2_b @ 31 NONAME
-	_ZN10NmUiEngine18handleMailboxEventE14NmMailboxEventRK5QListI4NmIdE @ 32 NONAME
-	_ZN10NmUiEngine18handleMessageEventE14NmMessageEventRK4NmIdRK5QListIS1_ES3_ @ 33 NONAME
-	_ZN10NmUiEngine18operationCompletedERK26NmOperationCompletionEvent @ 34 NONAME
-	_ZN10NmUiEngine19getStaticMetaObjectEv @ 35 NONAME
-	_ZN10NmUiEngine20contentToMessagePartERK4NmIdS2_S2_R13NmMessagePart @ 36 NONAME
-	_ZN10NmUiEngine20createForwardMessageERK4NmIdS2_ @ 37 NONAME
-	_ZN10NmUiEngine20handleSyncStateEventE11NmSyncStateRK26NmOperationCompletionEvent @ 38 NONAME
-	_ZN10NmUiEngine22messageSearchListModelEP18QAbstractItemModel @ 39 NONAME
-	_ZN10NmUiEngine22sendOperationCompletedEv @ 40 NONAME
-	_ZN10NmUiEngine23refreshMailboxListModelEv @ 41 NONAME
-	_ZN10NmUiEngine28handleCompletedSendOperationEv @ 42 NONAME
-	_ZN10NmUiEngine6searchERK4NmIdRK11QStringList @ 43 NONAME
-	_ZN10NmUiEngine7messageERK4NmIdS2_S2_ @ 44 NONAME
-	_ZN10NmUiEngine8goOnlineERK4NmId @ 45 NONAME
-	_ZN10NmUiEngine8instanceEv @ 46 NONAME
-	_ZN10NmUiEngine9goOfflineERK4NmId @ 47 NONAME
-	_ZN10NmUiEngine9mInstanceE @ 48 NONAME DATA 4
-	_ZN10NmUiEngine9syncStateERK4NmId @ 49 NONAME
-	_ZN10NmUiEngineC1Ev @ 50 NONAME
-	_ZN10NmUiEngineC2Ev @ 51 NONAME
-	_ZN10NmUiEngineD0Ev @ 52 NONAME
-	_ZN10NmUiEngineD1Ev @ 53 NONAME
-	_ZN10NmUiEngineD2Ev @ 54 NONAME
-	_ZN11NmOperation11qt_metacallEN11QMetaObject4CallEiPPv @ 55 NONAME
-	_ZN11NmOperation11qt_metacastEPKc @ 56 NONAME
-	_ZN11NmOperation15cancelOperationEv @ 57 NONAME
-	_ZN11NmOperation15deleteOperationEv @ 58 NONAME
-	_ZN11NmOperation16staticMetaObjectE @ 59 NONAME DATA 16
-	_ZN11NmOperation17completeOperationEi @ 60 NONAME
-	_ZN11NmOperation17doCancelOperationEv @ 61 NONAME
-	_ZN11NmOperation17runAsyncOperationEv @ 62 NONAME
-	_ZN11NmOperation18operationCancelledEv @ 63 NONAME
-	_ZN11NmOperation18operationCompletedEi @ 64 NONAME
-	_ZN11NmOperation19doCompleteOperationEv @ 65 NONAME
-	_ZN11NmOperation19getStaticMetaObjectEv @ 66 NONAME
-	_ZN11NmOperation23addPreliminaryOperationEPS_ @ 67 NONAME
-	_ZN11NmOperation23updateOperationProgressEi @ 68 NONAME
-	_ZN11NmOperation24operationProgressChangedEi @ 69 NONAME
-	_ZN11NmOperation25doUpdateOperationProgressEv @ 70 NONAME
-	_ZN11NmOperation34handlePreliminaryOperationFinishedEv @ 71 NONAME
-	_ZN11NmOperationC2Ev @ 72 NONAME
-	_ZN11NmOperationD0Ev @ 73 NONAME
-	_ZN11NmOperationD1Ev @ 74 NONAME
-	_ZN11NmOperationD2Ev @ 75 NONAME
-	_ZN13NmDataManager10folderByIdERK4NmIdS2_ @ 76 NONAME
-	_ZN13NmDataManager11listFoldersE4NmIdR5QListIP8NmFolderE @ 77 NONAME
-	_ZN13NmDataManager11mailboxByIdERK4NmId @ 78 NONAME
-	_ZN13NmDataManager11qt_metacallEN11QMetaObject4CallEiPPv @ 79 NONAME
-	_ZN13NmDataManager11qt_metacastEPKc @ 80 NONAME
-	_ZN13NmDataManager12envelopeByIdERK4NmIdS2_S2_ @ 81 NONAME
-	_ZN13NmDataManager12listMessagesERK4NmIdS2_R5QListIP17NmMessageEnvelopeE @ 82 NONAME
-	_ZN13NmDataManager13listMailboxesER5QListIP9NmMailboxE @ 83 NONAME
-	_ZN13NmDataManager14listMailboxIdsER5QListI4NmIdE @ 84 NONAME
-	_ZN13NmDataManager16staticMetaObjectE @ 85 NONAME DATA 16
-	_ZN13NmDataManager19getStandardFolderIdERK4NmId12NmFolderType @ 86 NONAME
-	_ZN13NmDataManager19getStaticMetaObjectEv @ 87 NONAME
-	_ZN13NmDataManager20contentToMessagePartERK4NmIdS2_S2_R13NmMessagePart @ 88 NONAME
-	_ZN13NmDataManager6folderERK4NmIdS2_ @ 89 NONAME
-	_ZN13NmDataManager7mailboxERK4NmId @ 90 NONAME
-	_ZN13NmDataManager7messageERK4NmIdS2_S2_ @ 91 NONAME
-	_ZN13NmDataManagerC1Ev @ 92 NONAME
-	_ZN13NmDataManagerC2Ev @ 93 NONAME
-	_ZN13NmDataManagerD0Ev @ 94 NONAME
-	_ZN13NmDataManagerD1Ev @ 95 NONAME
-	_ZN13NmDataManagerD2Ev @ 96 NONAME
-	_ZN16NmFolderMetaData5setIdERK4NmId @ 97 NONAME
-	_ZN16NmFolderMetaData7setNameERK7QString @ 98 NONAME
-	_ZN16NmFolderMetaDataC1Ev @ 99 NONAME
-	_ZN16NmFolderMetaDataC2Ev @ 100 NONAME
-	_ZN16NmFolderMetaDataD0Ev @ 101 NONAME
-	_ZN16NmFolderMetaDataD1Ev @ 102 NONAME
-	_ZN16NmFolderMetaDataD2Ev @ 103 NONAME
-	_ZN17NmFolderListModel7refreshER5QListIP8NmFolderE @ 104 NONAME
-	_ZN17NmFolderListModelC1ER13NmDataManagerP7QObject @ 105 NONAME
-	_ZN17NmFolderListModelC2ER13NmDataManagerP7QObject @ 106 NONAME
-	_ZN17NmFolderListModelD0Ev @ 107 NONAME
-	_ZN17NmFolderListModelD1Ev @ 108 NONAME
-	_ZN17NmFolderListModelD2Ev @ 109 NONAME
-	_ZN17NmMailboxMetaData5setIdERK4NmId @ 110 NONAME
-	_ZN17NmMailboxMetaData7setNameERK7QString @ 111 NONAME
-	_ZN17NmMailboxMetaData9setIconIdERK4NmId @ 112 NONAME
-	_ZN17NmMailboxMetaDataC1Ev @ 113 NONAME
-	_ZN17NmMailboxMetaDataC2Ev @ 114 NONAME
-	_ZN17NmMailboxMetaDataD0Ev @ 115 NONAME
-	_ZN17NmMailboxMetaDataD1Ev @ 116 NONAME
-	_ZN17NmMailboxMetaDataD2Ev @ 117 NONAME
-	_ZN18NmBaseClientPlugin10getActionsERK15NmActionRequestR5QListIP8NmActionE @ 118 NONAME
-	_ZN18NmBaseClientPlugin10markAsReadEv @ 119 NONAME
-	_ZN18NmBaseClientPlugin11forwardMailEv @ 120 NONAME
-	_ZN18NmBaseClientPlugin11openMessageEv @ 121 NONAME
-	_ZN18NmBaseClientPlugin11qt_metacallEN11QMetaObject4CallEiPPv @ 122 NONAME
-	_ZN18NmBaseClientPlugin11qt_metacastEPKc @ 123 NONAME
-	_ZN18NmBaseClientPlugin12markAsUnreadEv @ 124 NONAME
-	_ZN18NmBaseClientPlugin12replyAllMailEv @ 125 NONAME
-	_ZN18NmBaseClientPlugin13createNewMailEv @ 126 NONAME
-	_ZN18NmBaseClientPlugin13deleteMessageEv @ 127 NONAME
-	_ZN18NmBaseClientPlugin13handleRequestE23NmActionResponseCommandRK15NmActionRequest @ 128 NONAME
-	_ZN18NmBaseClientPlugin14openAttachmentEv @ 129 NONAME
-	_ZN18NmBaseClientPlugin14setPriorityLowEv @ 130 NONAME
-	_ZN18NmBaseClientPlugin15setPriorityHighEv @ 131 NONAME
-	_ZN18NmBaseClientPlugin16removeAttachmentEv @ 132 NONAME
-	_ZN18NmBaseClientPlugin16staticMetaObjectE @ 133 NONAME DATA 16
-	_ZN18NmBaseClientPlugin17setPriorityNormalEv @ 134 NONAME
-	_ZN18NmBaseClientPlugin18mailboxListChangedERK4NmIdN10NmSettings16MailboxEventTypeE @ 135 NONAME
-	_ZN18NmBaseClientPlugin19getStaticMetaObjectEv @ 136 NONAME
-	_ZN18NmBaseClientPlugin22mailboxPropertyChangedERK4NmId8QVariantS3_ @ 137 NONAME
-	_ZN18NmBaseClientPlugin22updateEnvelopePropertyE20NmEnvelopeProperties @ 138 NONAME
-	_ZN18NmBaseClientPlugin24createEditorViewCommandsERK15NmActionRequestR5QListIP8NmActionE @ 139 NONAME
-	_ZN18NmBaseClientPlugin24createViewerViewCommandsERK15NmActionRequestR5QListIP8NmActionE @ 140 NONAME
-	_ZN18NmBaseClientPlugin25createMessageListCommandsERK15NmActionRequestR5QListIP8NmActionE @ 141 NONAME
-	_ZN18NmBaseClientPlugin26createNewMailViewerToolBarEv @ 142 NONAME
-	_ZN18NmBaseClientPlugin27deleteMessageFromViewerViewEv @ 143 NONAME
-	_ZN18NmBaseClientPlugin6attachEv @ 144 NONAME
-	_ZN18NmBaseClientPlugin6searchEv @ 145 NONAME
-	_ZN18NmBaseClientPlugin7refreshEv @ 146 NONAME
-	_ZN18NmBaseClientPlugin8goOnlineERK4NmId @ 147 NONAME
-	_ZN18NmBaseClientPlugin8sendMailEv @ 148 NONAME
-	_ZN18NmBaseClientPlugin8settingsEv @ 149 NONAME
-	_ZN18NmBaseClientPlugin9goOfflineERK4NmId @ 150 NONAME
-	_ZN18NmBaseClientPlugin9replyMailEv @ 151 NONAME
-	_ZN18NmBaseClientPluginC2Ev @ 152 NONAME
-	_ZN18NmBaseClientPluginD0Ev @ 153 NONAME
-	_ZN18NmBaseClientPluginD1Ev @ 154 NONAME
-	_ZN18NmBaseClientPluginD2Ev @ 155 NONAME
-	_ZN18NmMailboxListModel11qt_metacallEN11QMetaObject4CallEiPPv @ 156 NONAME
-	_ZN18NmMailboxListModel11qt_metacastEPKc @ 157 NONAME
-	_ZN18NmMailboxListModel16refreshModelItemERK4NmIdb @ 158 NONAME
-	_ZN18NmMailboxListModel16staticMetaObjectE @ 159 NONAME DATA 16
-	_ZN18NmMailboxListModel17createMailboxItemEPK9NmMailbox @ 160 NONAME
-	_ZN18NmMailboxListModel18handleMailboxEventE14NmMailboxEventRK5QListI4NmIdE @ 161 NONAME
-	_ZN18NmMailboxListModel19getStaticMetaObjectEv @ 162 NONAME
-	_ZN18NmMailboxListModel7refreshER5QListIP9NmMailboxE @ 163 NONAME
-	_ZN18NmMailboxListModelC1ER13NmDataManagerP7QObject @ 164 NONAME
-	_ZN18NmMailboxListModelC2ER13NmDataManagerP7QObject @ 165 NONAME
-	_ZN18NmMailboxListModelD0Ev @ 166 NONAME
-	_ZN18NmMailboxListModelD1Ev @ 167 NONAME
-	_ZN18NmMailboxListModelD2Ev @ 168 NONAME
-	_ZN18NmMessageListModel10removeItemEiR22NmMessageListModelItem @ 169 NONAME
-	_ZN18NmMessageListModel11qt_metacallEN11QMetaObject4CallEiPPv @ 170 NONAME
-	_ZN18NmMessageListModel11qt_metacastEPKc @ 171 NONAME
-	_ZN18NmMessageListModel11setDividersEb @ 172 NONAME
-	_ZN18NmMessageListModel11setNewParamEP14NmUiStartParam @ 173 NONAME
-	_ZN18NmMessageListModel13itemFromModelERK4NmId @ 174 NONAME
-	_ZN18NmMessageListModel14dividersActiveEv @ 175 NONAME
-	_ZN18NmMessageListModel14updateEnvelopeE20NmEnvelopePropertiesRK4NmId @ 176 NONAME
-	_ZN18NmMessageListModel16currentMailboxIdEv @ 177 NONAME
-	_ZN18NmMessageListModel16staticMetaObjectE @ 178 NONAME DATA 16
-	_ZN18NmMessageListModel17createMessageItemEP17NmMessageEnvelope @ 179 NONAME
-	_ZN18NmMessageListModel18handleMessageEventE14NmMessageEventRK4NmIdRK5QListIS1_E @ 180 NONAME
-	_ZN18NmMessageListModel19getStaticMetaObjectEv @ 181 NONAME
-	_ZN18NmMessageListModel21dividerInsertionIndexEi @ 182 NONAME
-	_ZN18NmMessageListModel21setEnvelopePropertiesE20NmEnvelopePropertiesRK5QListI4NmIdE @ 183 NONAME
-	_ZN18NmMessageListModel21updateMessageEnvelopeERK4NmIdS2_S2_ @ 184 NONAME
-	_ZN18NmMessageListModel22createTitleDividerItemEP17NmMessageEnvelope @ 185 NONAME
-	_ZN18NmMessageListModel22insertDividerIntoModelEP17NmMessageEnvelopei @ 186 NONAME
-	_ZN18NmMessageListModel22insertMessageIntoModelEP17NmMessageEnvelopeib @ 187 NONAME
-	_ZN18NmMessageListModel22removeMessageFromModelERK4NmId @ 188 NONAME
-	_ZN18NmMessageListModel25insertNewMessageIntoModelERK4NmIdS2_S2_ @ 189 NONAME
-	_ZN18NmMessageListModel7changedERK17NmMessageEnvelopeS2_ @ 190 NONAME
-	_ZN18NmMessageListModel7refreshE4NmIdS0_RK5QListIP17NmMessageEnvelopeE @ 191 NONAME
-	_ZN18NmMessageListModelC1ER13NmDataManagerP7QObject @ 192 NONAME
-	_ZN18NmMessageListModelC2ER13NmDataManagerP7QObject @ 193 NONAME
-	_ZN18NmMessageListModelD0Ev @ 194 NONAME
-	_ZN18NmMessageListModelD1Ev @ 195 NONAME
-	_ZN18NmMessageListModelD2Ev @ 196 NONAME
-	_ZN19NmDataPluginFactory10loadPluginERK4QDirRK7QString @ 197 NONAME
-	_ZN19NmDataPluginFactory12mPluginArrayE @ 198 NONAME DATA 4
-	_ZN19NmDataPluginFactory14pluginInstanceE4NmId @ 199 NONAME
-	_ZN19NmDataPluginFactory15mReferenceCountE @ 200 NONAME DATA 4
-	_ZN19NmDataPluginFactory15pluginInstancesEv @ 201 NONAME
-	_ZN19NmDataPluginFactory15releaseInstanceERPS_ @ 202 NONAME
-	_ZN19NmDataPluginFactory17interfaceInstanceE4NmId @ 203 NONAME
-	_ZN19NmDataPluginFactory17interfaceInstanceEP7QObject @ 204 NONAME
-	_ZN19NmDataPluginFactory18mPluginLoaderArrayE @ 205 NONAME DATA 4
-	_ZN19NmDataPluginFactory8instanceEv @ 206 NONAME
-	_ZN19NmDataPluginFactory9mInstanceE @ 207 NONAME DATA 4
-	_ZN19NmDataPluginFactoryC1Ev @ 208 NONAME
-	_ZN19NmDataPluginFactoryC2Ev @ 209 NONAME
-	_ZN19NmDataPluginFactoryD0Ev @ 210 NONAME
-	_ZN19NmDataPluginFactoryD1Ev @ 211 NONAME
-	_ZN19NmDataPluginFactoryD2Ev @ 212 NONAME
-	_ZN22NmCheckOutboxOperation11qt_metacallEN11QMetaObject4CallEiPPv @ 213 NONAME
-	_ZN22NmCheckOutboxOperation11qt_metacastEPKc @ 214 NONAME
-	_ZN22NmCheckOutboxOperation16staticMetaObjectE @ 215 NONAME DATA 16
-	_ZN22NmCheckOutboxOperation19getStaticMetaObjectEv @ 216 NONAME
-	_ZN22NmMessageListModelItem11envelopePtrEv @ 217 NONAME
-	_ZN22NmMessageListModelItem11setEnvelopeEP17NmMessageEnvelope @ 218 NONAME
-	_ZN22NmMessageListModelItem11setEnvelopeERK17NmMessageEnvelope @ 219 NONAME
-	_ZN22NmMessageListModelItem11setExpandedEb @ 220 NONAME
-	_ZN22NmMessageListModelItem11setItemTypeENS_17NmMessageItemTypeE @ 221 NONAME
-	_ZN22NmMessageListModelItem15setTitleDividerERK7QString @ 222 NONAME
-	_ZN22NmMessageListModelItem19callEmitDataChangedEv @ 223 NONAME
-	_ZN22NmMessageListModelItemC1Ev @ 224 NONAME
-	_ZN22NmMessageListModelItemC2Ev @ 225 NONAME
-	_ZN22NmMessageListModelItemD0Ev @ 226 NONAME
-	_ZN22NmMessageListModelItemD1Ev @ 227 NONAME
-	_ZN22NmMessageListModelItemD2Ev @ 228 NONAME
-	_ZN24NmMessageSearchListModel11qt_metacallEN11QMetaObject4CallEiPPv @ 229 NONAME
-	_ZN24NmMessageSearchListModel11qt_metacastEPKc @ 230 NONAME
-	_ZN24NmMessageSearchListModel15addSearchResultERK4NmId @ 231 NONAME
-	_ZN24NmMessageSearchListModel16staticMetaObjectE @ 232 NONAME DATA 16
-	_ZN24NmMessageSearchListModel18clearSearchResultsEv @ 233 NONAME
-	_ZN24NmMessageSearchListModel19getStaticMetaObjectEv @ 234 NONAME
-	_ZN24NmMessageSearchListModelC1EP7QObject @ 235 NONAME
-	_ZN24NmMessageSearchListModelC2EP7QObject @ 236 NONAME
-	_ZN24NmMessageSearchListModelD0Ev @ 237 NONAME
-	_ZN24NmMessageSearchListModelD1Ev @ 238 NONAME
-	_ZN24NmMessageSearchListModelD2Ev @ 239 NONAME
+	_ZN10NmUiEngine16handleMatchFoundERK4NmIdS2_ @ 26 NONAME
+	_ZN10NmUiEngine16mailboxListModelEv @ 27 NONAME
+	_ZN10NmUiEngine16messageListModelERK4NmIdS2_ @ 28 NONAME
+	_ZN10NmUiEngine16removeAttachmentERK9NmMessageRK4NmId @ 29 NONAME
+	_ZN10NmUiEngine16saveDraftMessageEP9NmMessageRK5QListIP11NmOperationE @ 30 NONAME
+	_ZN10NmUiEngine16standardFolderIdERK4NmId12NmFolderType @ 31 NONAME
+	_ZN10NmUiEngine16staticMetaObjectE @ 32 NONAME DATA 16
+	_ZN10NmUiEngine17fetchMessagePartsERK4NmIdS2_S2_RK5QListIS0_E @ 33 NONAME
+	_ZN10NmUiEngine18createReplyMessageERK4NmIdS2_b @ 34 NONAME
+	_ZN10NmUiEngine18handleConnectEventE14NmConnectStateRK4NmIdi @ 35 NONAME
+	_ZN10NmUiEngine18handleMailboxEventE14NmMailboxEventRK5QListI4NmIdE @ 36 NONAME
+	_ZN10NmUiEngine18handleMessageEventE14NmMessageEventRK4NmIdRK5QListIS1_ES3_ @ 37 NONAME
+	_ZN10NmUiEngine18operationCompletedERK26NmOperationCompletionEvent @ 38 NONAME
+	_ZN10NmUiEngine18removeDraftMessageEP9NmMessage @ 39 NONAME
+	_ZN10NmUiEngine18updateActiveFolderERK4NmIdS2_ @ 40 NONAME
+	_ZN10NmUiEngine19getStaticMetaObjectEv @ 41 NONAME
+	_ZN10NmUiEngine20contentToMessagePartERK4NmIdS2_S2_R13NmMessagePart @ 42 NONAME
+	_ZN10NmUiEngine20createForwardMessageERK4NmIdS2_ @ 43 NONAME
+	_ZN10NmUiEngine20handleSyncStateEventE11NmSyncStateRK26NmOperationCompletionEvent @ 44 NONAME
+	_ZN10NmUiEngine22getPluginIdByMailboxIdEj @ 45 NONAME
+	_ZN10NmUiEngine22sendOperationCompletedEv @ 46 NONAME
+	_ZN10NmUiEngine23refreshMailboxListModelEv @ 47 NONAME
+	_ZN10NmUiEngine24messageEventForListModelE14NmMessageEventRK4NmIdRK5QListIS1_ES3_ @ 48 NONAME
+	_ZN10NmUiEngine25messageListModelForSearchERK4NmId @ 49 NONAME
+	_ZN10NmUiEngine28handleCompletedSendOperationEv @ 50 NONAME
+	_ZN10NmUiEngine33handleCompletedSaveDraftOperationEv @ 51 NONAME
+	_ZN10NmUiEngine35handleCompletedRemoveDraftOperationEv @ 52 NONAME
+	_ZN10NmUiEngine6searchERK4NmIdRK11QStringList @ 53 NONAME
+	_ZN10NmUiEngine7messageERK4NmIdS2_S2_ @ 54 NONAME
+	_ZN10NmUiEngine8goOnlineERK4NmId @ 55 NONAME
+	_ZN10NmUiEngine8instanceEv @ 56 NONAME
+	_ZN10NmUiEngine9goOfflineERK4NmId @ 57 NONAME
+	_ZN10NmUiEngine9mInstanceE @ 58 NONAME DATA 4
+	_ZN10NmUiEngine9syncStateERK4NmId @ 59 NONAME
+	_ZN10NmUiEngineC1Ev @ 60 NONAME
+	_ZN10NmUiEngineC2Ev @ 61 NONAME
+	_ZN10NmUiEngineD0Ev @ 62 NONAME
+	_ZN10NmUiEngineD1Ev @ 63 NONAME
+	_ZN10NmUiEngineD2Ev @ 64 NONAME
+	_ZN11NmOperation11qt_metacallEN11QMetaObject4CallEiPPv @ 65 NONAME
+	_ZN11NmOperation11qt_metacastEPKc @ 66 NONAME
+	_ZN11NmOperation15cancelOperationEv @ 67 NONAME
+	_ZN11NmOperation15deleteOperationEv @ 68 NONAME
+	_ZN11NmOperation16staticMetaObjectE @ 69 NONAME DATA 16
+	_ZN11NmOperation17completeOperationEi @ 70 NONAME
+	_ZN11NmOperation17doCancelOperationEv @ 71 NONAME
+	_ZN11NmOperation17runAsyncOperationEv @ 72 NONAME
+	_ZN11NmOperation18operationCancelledEv @ 73 NONAME
+	_ZN11NmOperation18operationCompletedEi @ 74 NONAME
+	_ZN11NmOperation19doCompleteOperationEv @ 75 NONAME
+	_ZN11NmOperation19getStaticMetaObjectEv @ 76 NONAME
+	_ZN11NmOperation23addPreliminaryOperationEPS_ @ 77 NONAME
+	_ZN11NmOperation23updateOperationProgressEi @ 78 NONAME
+	_ZN11NmOperation24operationProgressChangedEi @ 79 NONAME
+	_ZN11NmOperation25doUpdateOperationProgressEv @ 80 NONAME
+	_ZN11NmOperation34handlePreliminaryOperationFinishedEv @ 81 NONAME
+	_ZN11NmOperationC2Ev @ 82 NONAME
+	_ZN11NmOperationD0Ev @ 83 NONAME
+	_ZN11NmOperationD1Ev @ 84 NONAME
+	_ZN11NmOperationD2Ev @ 85 NONAME
+	_ZN13NmDataManager10folderByIdERK4NmIdS2_ @ 86 NONAME
+	_ZN13NmDataManager11listFoldersE4NmIdR5QListIP8NmFolderE @ 87 NONAME
+	_ZN13NmDataManager11mailboxByIdERK4NmId @ 88 NONAME
+	_ZN13NmDataManager11qt_metacallEN11QMetaObject4CallEiPPv @ 89 NONAME
+	_ZN13NmDataManager11qt_metacastEPKc @ 90 NONAME
+	_ZN13NmDataManager12envelopeByIdERK4NmIdS2_S2_ @ 91 NONAME
+	_ZN13NmDataManager12listMessagesERK4NmIdS2_R5QListIP17NmMessageEnvelopeE @ 92 NONAME
+	_ZN13NmDataManager13listMailboxesER5QListIP9NmMailboxE @ 93 NONAME
+	_ZN13NmDataManager14folderTypeByIdE4NmIdS0_ @ 94 NONAME
+	_ZN13NmDataManager14listMailboxIdsER5QListI4NmIdE @ 95 NONAME
+	_ZN13NmDataManager16staticMetaObjectE @ 96 NONAME DATA 16
+	_ZN13NmDataManager19getStandardFolderIdERK4NmId12NmFolderType @ 97 NONAME
+	_ZN13NmDataManager19getStaticMetaObjectEv @ 98 NONAME
+	_ZN13NmDataManager20contentToMessagePartERK4NmIdS2_S2_R13NmMessagePart @ 99 NONAME
+	_ZN13NmDataManager6folderERK4NmIdS2_ @ 100 NONAME
+	_ZN13NmDataManager7mailboxERK4NmId @ 101 NONAME
+	_ZN13NmDataManager7messageERK4NmIdS2_S2_ @ 102 NONAME
+	_ZN13NmDataManagerC1Ev @ 103 NONAME
+	_ZN13NmDataManagerC2Ev @ 104 NONAME
+	_ZN13NmDataManagerD0Ev @ 105 NONAME
+	_ZN13NmDataManagerD1Ev @ 106 NONAME
+	_ZN13NmDataManagerD2Ev @ 107 NONAME
+	_ZN16NmFolderMetaData5setIdERK4NmId @ 108 NONAME
+	_ZN16NmFolderMetaData7setNameERK7QString @ 109 NONAME
+	_ZN16NmFolderMetaDataC1Ev @ 110 NONAME
+	_ZN16NmFolderMetaDataC2Ev @ 111 NONAME
+	_ZN16NmFolderMetaDataD0Ev @ 112 NONAME
+	_ZN16NmFolderMetaDataD1Ev @ 113 NONAME
+	_ZN16NmFolderMetaDataD2Ev @ 114 NONAME
+	_ZN17NmFolderListModel7refreshER5QListIP8NmFolderE @ 115 NONAME
+	_ZN17NmFolderListModelC1ER13NmDataManagerP7QObject @ 116 NONAME
+	_ZN17NmFolderListModelC2ER13NmDataManagerP7QObject @ 117 NONAME
+	_ZN17NmFolderListModelD0Ev @ 118 NONAME
+	_ZN17NmFolderListModelD1Ev @ 119 NONAME
+	_ZN17NmFolderListModelD2Ev @ 120 NONAME
+	_ZN17NmMailboxMetaData10setAddressERK7QString @ 121 NONAME
+	_ZN17NmMailboxMetaData5setIdERK4NmId @ 122 NONAME
+	_ZN17NmMailboxMetaData7setNameERK7QString @ 123 NONAME
+	_ZN17NmMailboxMetaData9setIconIdERK4NmId @ 124 NONAME
+	_ZN17NmMailboxMetaDataC1Ev @ 125 NONAME
+	_ZN17NmMailboxMetaDataC2Ev @ 126 NONAME
+	_ZN17NmMailboxMetaDataD0Ev @ 127 NONAME
+	_ZN17NmMailboxMetaDataD1Ev @ 128 NONAME
+	_ZN17NmMailboxMetaDataD2Ev @ 129 NONAME
+	_ZN18NmBaseClientPlugin10getActionsERK15NmActionRequestR5QListIP8NmActionE @ 130 NONAME
+	_ZN18NmBaseClientPlugin10markAsReadEv @ 131 NONAME
+	_ZN18NmBaseClientPlugin11forwardMailEv @ 132 NONAME
+	_ZN18NmBaseClientPlugin11openMessageEv @ 133 NONAME
+	_ZN18NmBaseClientPlugin11qt_metacallEN11QMetaObject4CallEiPPv @ 134 NONAME
+	_ZN18NmBaseClientPlugin11qt_metacastEPKc @ 135 NONAME
+	_ZN18NmBaseClientPlugin12markAsUnreadEv @ 136 NONAME
+	_ZN18NmBaseClientPlugin12replyAllMailEv @ 137 NONAME
+	_ZN18NmBaseClientPlugin13createNewMailEv @ 138 NONAME
+	_ZN18NmBaseClientPlugin13deleteMessageEv @ 139 NONAME
+	_ZN18NmBaseClientPlugin13handleRequestE23NmActionResponseCommandRK15NmActionRequest @ 140 NONAME
+	_ZN18NmBaseClientPlugin14openAttachmentEv @ 141 NONAME
+	_ZN18NmBaseClientPlugin14setPriorityLowEv @ 142 NONAME
+	_ZN18NmBaseClientPlugin15setPriorityHighEv @ 143 NONAME
+	_ZN18NmBaseClientPlugin16removeAttachmentEv @ 144 NONAME
+	_ZN18NmBaseClientPlugin16staticMetaObjectE @ 145 NONAME DATA 16
+	_ZN18NmBaseClientPlugin17setPriorityNormalEv @ 146 NONAME
+	_ZN18NmBaseClientPlugin18mailboxListChangedERK4NmIdN10NmSettings16MailboxEventTypeE @ 147 NONAME
+	_ZN18NmBaseClientPlugin19getStaticMetaObjectEv @ 148 NONAME
+	_ZN18NmBaseClientPlugin22mailboxPropertyChangedERK4NmId8QVariantS3_ @ 149 NONAME
+	_ZN18NmBaseClientPlugin22updateEnvelopePropertyE20NmEnvelopeProperties @ 150 NONAME
+	_ZN18NmBaseClientPlugin24createEditorViewCommandsERK15NmActionRequestR5QListIP8NmActionE @ 151 NONAME
+	_ZN18NmBaseClientPlugin24createViewerViewCommandsERK15NmActionRequestR5QListIP8NmActionE @ 152 NONAME
+	_ZN18NmBaseClientPlugin25createMessageListCommandsERK15NmActionRequestR5QListIP8NmActionE @ 153 NONAME
+	_ZN18NmBaseClientPlugin26createNewMailViewerToolBarEv @ 154 NONAME
+	_ZN18NmBaseClientPlugin27deleteMessageFromViewerViewEv @ 155 NONAME
+	_ZN18NmBaseClientPlugin6attachEv @ 156 NONAME
+	_ZN18NmBaseClientPlugin6searchEv @ 157 NONAME
+	_ZN18NmBaseClientPlugin7refreshEv @ 158 NONAME
+	_ZN18NmBaseClientPlugin8goOnlineERK4NmId @ 159 NONAME
+	_ZN18NmBaseClientPlugin8sendMailEv @ 160 NONAME
+	_ZN18NmBaseClientPlugin8settingsEv @ 161 NONAME
+	_ZN18NmBaseClientPlugin9goOfflineERK4NmId @ 162 NONAME
+	_ZN18NmBaseClientPlugin9replyMailEv @ 163 NONAME
+	_ZN18NmBaseClientPluginC2Ev @ 164 NONAME
+	_ZN18NmBaseClientPluginD0Ev @ 165 NONAME
+	_ZN18NmBaseClientPluginD1Ev @ 166 NONAME
+	_ZN18NmBaseClientPluginD2Ev @ 167 NONAME
+	_ZN18NmMailboxListModel11qt_metacallEN11QMetaObject4CallEiPPv @ 168 NONAME
+	_ZN18NmMailboxListModel11qt_metacastEPKc @ 169 NONAME
+	_ZN18NmMailboxListModel16refreshModelItemERK4NmId @ 170 NONAME
+	_ZN18NmMailboxListModel16staticMetaObjectE @ 171 NONAME DATA 16
+	_ZN18NmMailboxListModel17createMailboxItemEPK9NmMailbox @ 172 NONAME
+	_ZN18NmMailboxListModel18handleMailboxEventE14NmMailboxEventRK5QListI4NmIdE @ 173 NONAME
+	_ZN18NmMailboxListModel19getStaticMetaObjectEv @ 174 NONAME
+	_ZN18NmMailboxListModel7refreshER5QListIP9NmMailboxE @ 175 NONAME
+	_ZN18NmMailboxListModelC1ER13NmDataManagerP7QObject @ 176 NONAME
+	_ZN18NmMailboxListModelC2ER13NmDataManagerP7QObject @ 177 NONAME
+	_ZN18NmMailboxListModelD0Ev @ 178 NONAME
+	_ZN18NmMailboxListModelD1Ev @ 179 NONAME
+	_ZN18NmMailboxListModelD2Ev @ 180 NONAME
+	_ZN18NmMessageListModel10removeItemEiR22NmMessageListModelItem @ 181 NONAME
+	_ZN18NmMessageListModel11qt_metacallEN11QMetaObject4CallEiPPv @ 182 NONAME
+	_ZN18NmMessageListModel11qt_metacastEPKc @ 183 NONAME
+	_ZN18NmMessageListModel11setDividersEb @ 184 NONAME
+	_ZN18NmMessageListModel11setNewParamEP14NmUiStartParam @ 185 NONAME
+	_ZN18NmMessageListModel13itemFromModelERK4NmId @ 186 NONAME
+	_ZN18NmMessageListModel14dividersActiveEv @ 187 NONAME
+	_ZN18NmMessageListModel14updateEnvelopeE20NmEnvelopePropertiesRK4NmId @ 188 NONAME
+	_ZN18NmMessageListModel16currentMailboxIdEv @ 189 NONAME
+	_ZN18NmMessageListModel16staticMetaObjectE @ 190 NONAME DATA 16
+	_ZN18NmMessageListModel17createMessageItemEP17NmMessageEnvelope @ 191 NONAME
+	_ZN18NmMessageListModel18handleMessageEventE14NmMessageEventRK4NmIdRK5QListIS1_ES3_ @ 192 NONAME
+	_ZN18NmMessageListModel18setIgnoreFolderIdsEb @ 193 NONAME
+	_ZN18NmMessageListModel19getStaticMetaObjectEv @ 194 NONAME
+	_ZN18NmMessageListModel21dividerInsertionIndexEi @ 195 NONAME
+	_ZN18NmMessageListModel21setEnvelopePropertiesE20NmEnvelopePropertiesRK5QListI4NmIdE @ 196 NONAME
+	_ZN18NmMessageListModel21updateMessageEnvelopeERK4NmIdS2_S2_ @ 197 NONAME
+	_ZN18NmMessageListModel22createTitleDividerItemEP17NmMessageEnvelope @ 198 NONAME
+	_ZN18NmMessageListModel22insertDividerIntoModelEP17NmMessageEnvelopei @ 199 NONAME
+	_ZN18NmMessageListModel22insertMessageIntoModelEP17NmMessageEnvelopeib @ 200 NONAME
+	_ZN18NmMessageListModel22removeMessageFromModelERK4NmId @ 201 NONAME
+	_ZN18NmMessageListModel25insertNewMessageIntoModelERK4NmIdS2_S2_ @ 202 NONAME
+	_ZN18NmMessageListModel7changedERK17NmMessageEnvelopeS2_ @ 203 NONAME
+	_ZN18NmMessageListModel7refreshE4NmIdS0_RK5QListIP17NmMessageEnvelopeE @ 204 NONAME
+	_ZN18NmMessageListModelC1ER13NmDataManagerP7QObject @ 205 NONAME
+	_ZN18NmMessageListModelC2ER13NmDataManagerP7QObject @ 206 NONAME
+	_ZN18NmMessageListModelD0Ev @ 207 NONAME
+	_ZN18NmMessageListModelD1Ev @ 208 NONAME
+	_ZN18NmMessageListModelD2Ev @ 209 NONAME
+	_ZN19NmDataPluginFactory10loadPluginERK4QDirRK7QString @ 210 NONAME
+	_ZN19NmDataPluginFactory12mPluginArrayE @ 211 NONAME DATA 4
+	_ZN19NmDataPluginFactory14pluginInstanceE4NmId @ 212 NONAME
+	_ZN19NmDataPluginFactory15mReferenceCountE @ 213 NONAME DATA 4
+	_ZN19NmDataPluginFactory15pluginInstancesEv @ 214 NONAME
+	_ZN19NmDataPluginFactory15releaseInstanceERPS_ @ 215 NONAME
+	_ZN19NmDataPluginFactory17interfaceInstanceE4NmId @ 216 NONAME
+	_ZN19NmDataPluginFactory17interfaceInstanceEP7QObject @ 217 NONAME
+	_ZN19NmDataPluginFactory18mPluginLoaderArrayE @ 218 NONAME DATA 4
+	_ZN19NmDataPluginFactory33applicationStateInterfaceInstanceE4NmId @ 219 NONAME
+	_ZN19NmDataPluginFactory33applicationStateInterfaceInstanceEP7QObject @ 220 NONAME
+	_ZN19NmDataPluginFactory8instanceEv @ 221 NONAME
+	_ZN19NmDataPluginFactory9mInstanceE @ 222 NONAME DATA 4
+	_ZN19NmDataPluginFactoryC1Ev @ 223 NONAME
+	_ZN19NmDataPluginFactoryC2Ev @ 224 NONAME
+	_ZN19NmDataPluginFactoryD0Ev @ 225 NONAME
+	_ZN19NmDataPluginFactoryD1Ev @ 226 NONAME
+	_ZN19NmDataPluginFactoryD2Ev @ 227 NONAME
+	_ZN22NmMessageListModelItem11envelopePtrEv @ 228 NONAME
+	_ZN22NmMessageListModelItem11setEnvelopeEP17NmMessageEnvelope @ 229 NONAME
+	_ZN22NmMessageListModelItem11setEnvelopeERK17NmMessageEnvelope @ 230 NONAME
+	_ZN22NmMessageListModelItem11setExpandedEb @ 231 NONAME
+	_ZN22NmMessageListModelItem11setItemTypeENS_17NmMessageItemTypeE @ 232 NONAME
+	_ZN22NmMessageListModelItem15setTitleDividerERK7QString @ 233 NONAME
+	_ZN22NmMessageListModelItem19callEmitDataChangedEv @ 234 NONAME
+	_ZN22NmMessageListModelItemC1Ev @ 235 NONAME
+	_ZN22NmMessageListModelItemC2Ev @ 236 NONAME
+	_ZN22NmMessageListModelItemD0Ev @ 237 NONAME
+	_ZN22NmMessageListModelItemD1Ev @ 238 NONAME
+	_ZN22NmMessageListModelItemD2Ev @ 239 NONAME
 	_ZN25NmAddAttachmentsOperation11qt_metacallEN11QMetaObject4CallEiPPv @ 240 NONAME
 	_ZN25NmAddAttachmentsOperation11qt_metacastEPKc @ 241 NONAME
 	_ZN25NmAddAttachmentsOperation16staticMetaObjectE @ 242 NONAME DATA 16
@@ -273,61 +273,50 @@
 	_ZNK17NmMailboxMetaData2idEv @ 272 NONAME
 	_ZNK17NmMailboxMetaData4nameEv @ 273 NONAME
 	_ZNK17NmMailboxMetaData6IconIdEv @ 274 NONAME
-	_ZNK18NmBaseClientPlugin10metaObjectEv @ 275 NONAME
-	_ZNK18NmMailboxListModel10metaObjectEv @ 276 NONAME
-	_ZNK18NmMailboxListModel4dataERK11QModelIndexi @ 277 NONAME
-	_ZNK18NmMessageListModel10metaObjectEv @ 278 NONAME
-	_ZNK18NmMessageListModel17getInsertionIndexERK17NmMessageEnvelope @ 279 NONAME
-	_ZNK18NmMessageListModel30messagesBelongUnderSameDividerEPK17NmMessageEnvelopeS2_ @ 280 NONAME
-	_ZNK18NmMessageListModel4dataERK11QModelIndexi @ 281 NONAME
-	_ZNK22NmCheckOutboxOperation10metaObjectEv @ 282 NONAME
+	_ZNK17NmMailboxMetaData7addressEv @ 275 NONAME
+	_ZNK18NmBaseClientPlugin10metaObjectEv @ 276 NONAME
+	_ZNK18NmMailboxListModel10metaObjectEv @ 277 NONAME
+	_ZNK18NmMailboxListModel4dataERK11QModelIndexi @ 278 NONAME
+	_ZNK18NmMessageListModel10metaObjectEv @ 279 NONAME
+	_ZNK18NmMessageListModel17getInsertionIndexERK17NmMessageEnvelope @ 280 NONAME
+	_ZNK18NmMessageListModel30messagesBelongUnderSameDividerEPK17NmMessageEnvelopeS2_ @ 281 NONAME
+	_ZNK18NmMessageListModel4dataERK11QModelIndexi @ 282 NONAME
 	_ZNK22NmMessageListModelItem12titleDividerEv @ 283 NONAME
 	_ZNK22NmMessageListModelItem8envelopeEv @ 284 NONAME
 	_ZNK22NmMessageListModelItem8expandedEv @ 285 NONAME
 	_ZNK22NmMessageListModelItem8itemTypeEv @ 286 NONAME
-	_ZNK24NmMessageSearchListModel10metaObjectEv @ 287 NONAME
-	_ZNK24NmMessageSearchListModel16filterAcceptsRowEiRK11QModelIndex @ 288 NONAME
-	_ZNK24NmMessageSearchListModel4dataERK11QModelIndexi @ 289 NONAME
-	_ZNK25NmAddAttachmentsOperation10metaObjectEv @ 290 NONAME
-	_ZNK25NmStoreEnvelopesOperation10metaObjectEv @ 291 NONAME
-	_ZNK26NmMessageCreationOperation10metaObjectEv @ 292 NONAME
-	_ZTI10NmUiEngine @ 293 NONAME
-	_ZTI11NmOperation @ 294 NONAME
-	_ZTI13NmDataManager @ 295 NONAME
-	_ZTI16NmFolderMetaData @ 296 NONAME
-	_ZTI17NmFolderListModel @ 297 NONAME
-	_ZTI17NmMailboxMetaData @ 298 NONAME
-	_ZTI18NmBaseClientPlugin @ 299 NONAME
-	_ZTI18NmMailboxListModel @ 300 NONAME
-	_ZTI18NmMessageListModel @ 301 NONAME
-	_ZTI19NmDataPluginFactory @ 302 NONAME
-	_ZTI22NmCheckOutboxOperation @ 303 NONAME
-	_ZTI22NmMessageListModelItem @ 304 NONAME
-	_ZTI24NmMessageSearchListModel @ 305 NONAME
-	_ZTI25NmAddAttachmentsOperation @ 306 NONAME
-	_ZTI25NmStoreEnvelopesOperation @ 307 NONAME
-	_ZTI26NmMessageCreationOperation @ 308 NONAME
-	_ZTV10NmUiEngine @ 309 NONAME
-	_ZTV11NmOperation @ 310 NONAME
-	_ZTV13NmDataManager @ 311 NONAME
-	_ZTV16NmFolderMetaData @ 312 NONAME
-	_ZTV17NmFolderListModel @ 313 NONAME
-	_ZTV17NmMailboxMetaData @ 314 NONAME
-	_ZTV18NmBaseClientPlugin @ 315 NONAME
-	_ZTV18NmMailboxListModel @ 316 NONAME
-	_ZTV18NmMessageListModel @ 317 NONAME
-	_ZTV19NmDataPluginFactory @ 318 NONAME
-	_ZTV22NmCheckOutboxOperation @ 319 NONAME
-	_ZTV22NmMessageListModelItem @ 320 NONAME
-	_ZTV24NmMessageSearchListModel @ 321 NONAME
-	_ZTV25NmAddAttachmentsOperation @ 322 NONAME
-	_ZTV25NmStoreEnvelopesOperation @ 323 NONAME
-	_ZTV26NmMessageCreationOperation @ 324 NONAME
-	_ZThn8_N18NmBaseClientPlugin10getActionsERK15NmActionRequestR5QListIP8NmActionE @ 325 NONAME
-	_ZThn8_N18NmBaseClientPluginD0Ev @ 326 NONAME
-	_ZThn8_N18NmBaseClientPluginD1Ev @ 327 NONAME
-	_ZN10NmUiEngine14folderTypeByIdE4NmIdS0_ @ 328 NONAME
-	_ZN24NmMessageSearchListModel14refreshContentEv @ 329 NONAME
-	_ZNK24NmMessageSearchListModel17searchResultCountEv @ 330 NONAME
-	_ZN10NmUiEngine18handleConnectEventE14NmConnectStateRK4NmIdi @ 331 NONAME
+	_ZNK25NmAddAttachmentsOperation10metaObjectEv @ 287 NONAME
+	_ZNK25NmStoreEnvelopesOperation10metaObjectEv @ 288 NONAME
+	_ZNK26NmMessageCreationOperation10metaObjectEv @ 289 NONAME
+	_ZTI10NmUiEngine @ 290 NONAME
+	_ZTI11NmOperation @ 291 NONAME
+	_ZTI13NmDataManager @ 292 NONAME
+	_ZTI16NmFolderMetaData @ 293 NONAME
+	_ZTI17NmFolderListModel @ 294 NONAME
+	_ZTI17NmMailboxMetaData @ 295 NONAME
+	_ZTI18NmBaseClientPlugin @ 296 NONAME
+	_ZTI18NmMailboxListModel @ 297 NONAME
+	_ZTI18NmMessageListModel @ 298 NONAME
+	_ZTI19NmDataPluginFactory @ 299 NONAME
+	_ZTI22NmMessageListModelItem @ 300 NONAME
+	_ZTI25NmAddAttachmentsOperation @ 301 NONAME
+	_ZTI25NmStoreEnvelopesOperation @ 302 NONAME
+	_ZTI26NmMessageCreationOperation @ 303 NONAME
+	_ZTV10NmUiEngine @ 304 NONAME
+	_ZTV11NmOperation @ 305 NONAME
+	_ZTV13NmDataManager @ 306 NONAME
+	_ZTV16NmFolderMetaData @ 307 NONAME
+	_ZTV17NmFolderListModel @ 308 NONAME
+	_ZTV17NmMailboxMetaData @ 309 NONAME
+	_ZTV18NmBaseClientPlugin @ 310 NONAME
+	_ZTV18NmMailboxListModel @ 311 NONAME
+	_ZTV18NmMessageListModel @ 312 NONAME
+	_ZTV19NmDataPluginFactory @ 313 NONAME
+	_ZTV22NmMessageListModelItem @ 314 NONAME
+	_ZTV25NmAddAttachmentsOperation @ 315 NONAME
+	_ZTV25NmStoreEnvelopesOperation @ 316 NONAME
+	_ZTV26NmMessageCreationOperation @ 317 NONAME
+	_ZThn8_N18NmBaseClientPlugin10getActionsERK15NmActionRequestR5QListIP8NmActionE @ 318 NONAME
+	_ZThn8_N18NmBaseClientPluginD0Ev @ 319 NONAME
+	_ZThn8_N18NmBaseClientPluginD1Ev @ 320 NONAME
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmailuiengine/inc/nmapplicationstateinterface.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* 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 NMAPPLICATIONSTATEINTERFACE_H_
+#define NMAPPLICATIONSTATEINTERFACE_H_
+
+
+/*!
+    \class NmApplicationStateInterface
+    \brief provides an interface to indicate application state information to protocol plugins    
+*/
+class NmApplicationStateInterface
+{
+public:
+    virtual void updateActiveFolder(const NmId &mailboxId, const NmId &folderId) = 0;
+};
+
+Q_DECLARE_INTERFACE(NmApplicationStateInterface, "sf.app.commonmail.emailuis.nmailuiengine.NmApplicationStateInterface/1.0")
+
+
+#endif /* NMAPPLICATIONSTATEINTERFACE_H_ */
+
+
--- a/emailuis/nmailuiengine/inc/nmbaseclientplugin.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/inc/nmbaseclientplugin.h	Thu Jul 22 16:30:28 2010 +0100
@@ -72,12 +72,12 @@
 
 protected:
     virtual quint32 pluginId() = 0;
+    void handleRequest(NmActionResponseCommand command, const NmActionRequest &request);
 
 private:
     void createMessageListCommands(const NmActionRequest &request, QList<NmAction*> &actionList);
     void createEditorViewCommands(const NmActionRequest &request, QList<NmAction*> &actionList);
     void createViewerViewCommands(const NmActionRequest &request, QList<NmAction*> &actionList);
-    void handleRequest(NmActionResponseCommand command, const NmActionRequest &request);
     void updateEnvelopeProperty(NmEnvelopeProperties property);
 
 protected:
--- a/emailuis/nmailuiengine/inc/nmdatamanager.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/inc/nmdatamanager.h	Thu Jul 22 16:30:28 2010 +0100
@@ -64,6 +64,8 @@
                              NmMessagePart &messagePart);
     NmId getStandardFolderId(const NmId &mailboxId,
                              NmFolderType folderType);
+    
+    NmFolderType folderTypeById(NmId mailboxId, NmId folderId);
 
 private:
     NmDataPluginFactory   *mFactory;
--- a/emailuis/nmailuiengine/inc/nmdatapluginfactory.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/inc/nmdatapluginfactory.h	Thu Jul 22 16:30:28 2010 +0100
@@ -22,6 +22,7 @@
 #include "nmuienginedef.h"
 
 class NmDataPluginInterface;
+class NmApplicationStateInterface;
 class QDir;
 class QPluginLoader;
 
@@ -37,12 +38,14 @@
     static void releaseInstance(NmDataPluginFactory *&instance);
     NmDataPluginInterface *interfaceInstance(QObject *plugin);
     NmDataPluginInterface *interfaceInstance(NmId mailboxId);
+    NmApplicationStateInterface *applicationStateInterfaceInstance(NmId mailboxId);
     QObject *pluginInstance(NmId mailboxId);
     QList<QObject*> *pluginInstances();
     QObject *loadPlugin(
         const QDir &pluginDir,
         const QString& pluginName);
 private:
+    NmApplicationStateInterface *applicationStateInterfaceInstance(QObject *plugin);
     NmDataPluginFactory();
     virtual ~NmDataPluginFactory();
     static NmDataPluginFactory   *mInstance;         // owned
--- a/emailuis/nmailuiengine/inc/nmdataplugininterface.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/inc/nmdataplugininterface.h	Thu Jul 22 16:30:28 2010 +0100
@@ -33,7 +33,6 @@
 class NmMessageCreationOperation;
 class NmStoreEnvelopesOperation;
 class NmAddAttachmentsOperation;
-class NmCheckOutboxOperation;
 class NmMessageSendingOperation;
 
 /*!
@@ -60,7 +59,7 @@
     
     virtual int getMailboxById(const NmId &id, NmMailbox *&mailbox) = 0;
     
-    virtual int deleteMailboxById(const NmId &id) = 0;
+    virtual QPointer<NmOperation> deleteMailboxById(const NmId &id) = 0;
     
     virtual int getMessageById(
         const NmId &mailboxId,
@@ -104,6 +103,12 @@
         const NmId &folderId,
         const NmId &messageId,
         const NmId &messagePartId) = 0;
+ 
+     virtual  QPointer<NmOperation> fetchMessageParts( 
+        const NmId &mailboxId,
+        const NmId &folderId,
+        const NmId &messageId,
+        const QList<NmId> &messagePartIds) = 0;
     
     virtual XQSharableFile messagePartFile(
         const NmId &mailboxId,
@@ -171,8 +176,6 @@
         const NmMessage &message,
         const NmId &attachmentPartId) = 0;
 
-    virtual QPointer<NmCheckOutboxOperation> checkOutbox(const NmId &mailboxId) = 0;
-    
     virtual NmSyncState syncState(const NmId& mailboxId) const = 0;
     
     virtual NmConnectState connectionState(const NmId& mailboxId) const = 0;
@@ -181,6 +184,14 @@
         const QStringList &searchStrings) = 0;
 
     virtual int cancelSearch(const NmId &mailboxId) = 0;
+
+    virtual QPointer<NmOperation> removeDraftMessage(NmMessage *message) = 0;
+
+    virtual int copyMessages(
+        const NmId &mailboxId,
+        const QList<quint64> &messageIds, 
+        const NmId &sourceFolderId,
+        const NmId &destinationFolderId) = 0;
 };
 
 Q_DECLARE_INTERFACE(NmDataPluginInterface, "sf.app.commonmail.emailuis.nmailuiengine.NmDataPluginInterface/1.0")
--- a/emailuis/nmailuiengine/inc/nmmailboxlistmodel.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/inc/nmmailboxlistmodel.h	Thu Jul 22 16:30:28 2010 +0100
@@ -37,7 +37,7 @@
     virtual ~NmMailboxListModel();
     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
     void refresh(QList<NmMailbox*> &mailboxList);
-    void refreshModelItem(const NmId &mailboxId, bool allowEmitDataChanged = true);
+    void refreshModelItem(const NmId &mailboxId);
 
 public slots:
     void handleMailboxEvent(NmMailboxEvent event, const QList<NmId> &mailboxIds);
--- a/emailuis/nmailuiengine/inc/nmmailboxmetadata.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/inc/nmmailboxmetadata.h	Thu Jul 22 16:30:28 2010 +0100
@@ -36,6 +36,8 @@
     void setId(const NmId &id);
     NmId IconId() const;
     void setIconId(const NmId &id);
+    QString address() const;
+    void setAddress(const QString &address);
 
 private:
 
--- a/emailuis/nmailuiengine/inc/nmmessagelistmodel.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/inc/nmmessagelistmodel.h	Thu Jul 22 16:30:28 2010 +0100
@@ -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"
@@ -20,10 +20,9 @@
 
 #include <QStandardItemModel>
 
+#include "nmcommon.h"
+#include "nmmessagelistmodelitem.h"
 #include "nmuienginedef.h"
-#include "nmcommon.h"
-
-#include "nmmessagelistmodelitem.h"
 #include "nmuiviewids.h"
 
 class NmMessage;
@@ -31,73 +30,105 @@
 class QModelIndex;
 class NmMessageEnvelope;
 
+
 class NMUIENGINE_EXPORT NmMessageListModel : public QStandardItemModel
 {
     Q_OBJECT
+
 public:
-    NmMessageListModel(
-      NmDataManager &dataManager,
-      QObject *parent = 0);
+
+    NmMessageListModel(NmDataManager &dataManager,
+                       QObject *parent = 0);
+
     virtual ~NmMessageListModel();
+
     QVariant data(const QModelIndex &index,
                   int role = Qt::DisplayRole) const;
-    void refresh(
-        const NmId mailboxId,
-        const NmId folderId,
-        const QList<NmMessageEnvelope*> &messageEnvelopeList);
+
+    void refresh(const NmId mailboxId,
+                 const NmId folderId,
+                 const QList<NmMessageEnvelope*> &messageEnvelopeList);
+
     bool dividersActive();
-    // This function is temporary, to be removed when
-    // divider state can be modified with settings
+
+    // This function is temporary, to be removed when divider state can be
+    // modified with settings.
     void setDividers(bool active);
-    void setEnvelopeProperties(
-        NmEnvelopeProperties property,
-        const QList<NmId> &messageIds);
+
+    void setEnvelopeProperties(NmEnvelopeProperties property,
+                               const QList<NmId> &messageIds);
+
     NmId currentMailboxId();
+
+    void setIgnoreFolderIds(bool ignore);
+
+
 public slots:
-    void handleMessageEvent(
-        NmMessageEvent event,
-        const NmId &folderId,
-        const QList<NmId> &messageIds);
+
+    void handleMessageEvent(NmMessageEvent event,
+                            const NmId &folderId,
+                            const QList<NmId> &messageIds,
+                            const NmId &mailboxId);
+
 
 private:
+
     bool messagesBelongUnderSameDivider(
         const NmMessageEnvelope *message1,
         const NmMessageEnvelope *message2) const;
+
     void insertDividerIntoModel(
         NmMessageEnvelope *messageForDivider,
         int parentRow);
+
     void insertMessageIntoModel(
         NmMessageEnvelope *messageEnvelope,
         int childRow,
         bool emitSignal);
+
     void insertNewMessageIntoModel(
         const NmId &mailboxId,
         const NmId &folderId,
         const NmId &msgId);
-    int getInsertionIndex(
-        const NmMessageEnvelope &envelope) const;
+
+    int getInsertionIndex(const NmMessageEnvelope &envelope) const;
+
     int dividerInsertionIndex(int messageIndex);
+
     NmMessageListModelItem *createTitleDividerItem(NmMessageEnvelope *messageForDivider);
+
     NmMessageListModelItem *createMessageItem(NmMessageEnvelope *message);
+
     void removeMessageFromModel(const NmId &msgId);
+
     void removeItem(int row, NmMessageListModelItem &item);
+
     NmMessageListModelItem *itemFromModel(const NmId &messageId);
-    bool changed(const NmMessageEnvelope &first, const NmMessageEnvelope &second);
+
+    bool changed(const NmMessageEnvelope &first,
+                 const NmMessageEnvelope &second);
+
     void updateMessageEnvelope(const NmId &mailboxId,
-            const NmId &folderId,
-            const NmId &msgId);
+                               const NmId &folderId,
+                               const NmId &msgId);
+
     void updateEnvelope(NmEnvelopeProperties property, const NmId &msgId);
 
+
 signals:
+
     void setNewParam(NmUiStartParam *startParam);
-    
-private:
-    NmDataManager &mDataManager;         // not owned
+
+
+private: // Data
+
+    NmDataManager &mDataManager;
     bool mDividersActive;
-    NmMessageListModelItem *mParentPtr;  // not owned
+    NmMessageListModelItem *mParentPtr; // Not owned
     NmId mCurrentMailboxId;
     NmId mCurrentFolderId;
-
+    NmFolderType mCurrentFolderType;
+    bool mIgnoreFolderIds;
 };
 
 #endif /* NMMESSAGELISTMODEL_H_*/
--- a/emailuis/nmailuiengine/inc/nmmessagesearchlistmodel.h	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +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:
-*
-*/
-
-#ifndef NMMESSAGESEARCHLISTMODEL_H_
-#define NMMESSAGESEARCHLISTMODEL_H_
-
-#include <QSortFilterProxyModel>
-#include <QVector>
-
-#include "nmuienginedef.h" // For NMUIENGINE_EXPORT
-#include "nmcommon.h"
-
-
-class NMUIENGINE_EXPORT NmMessageSearchListModel : public QSortFilterProxyModel
-{
-    Q_OBJECT
-
-public: // Construction and destruction
-
-    NmMessageSearchListModel(QObject *parent = 0);
-
-    ~NmMessageSearchListModel();
-
-
-public:
-
-    void clearSearchResults();
-
-    int searchResultCount() const;
-
-
-public: // From QSortFilterProxyModel
-
-    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
-
-
-protected: // From QSortFilterProxyModel
-
-    bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
-
-
-public slots:
-
-    bool addSearchResult(const NmId &messageId);
-
-    void refreshContent();
-
-
-private: // Data
-
-    QVector<NmId> mSearchResults;
-};
-
-#endif /* NMMESSAGESEARCHLISTMODEL_H_ */
-
-// End of file.
--- a/emailuis/nmailuiengine/inc/nmuiengine.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/inc/nmuiengine.h	Thu Jul 22 16:30:28 2010 +0100
@@ -28,7 +28,6 @@
 class QAbstractItemModel;
 class NmMailboxListModel;
 class NmMessageListModel;
-class NmMessageSearchListModel;
 class NmDataManager;
 class NmDataPluginFactory;
 class NmMailboxMetaData;
@@ -39,7 +38,6 @@
 class NmMessageCreationOperation;
 class NmStoreEnvelopesOperation;
 class NmAddAttachmentsOperation;
-class NmCheckOutboxOperation;
 class NmMessageSendingOperation;
 
 
@@ -50,12 +48,19 @@
 public:
 
     static NmUiEngine *instance();
+
     static void releaseInstance(NmUiEngine *&instance);
 
     NmMailboxListModel &mailboxListModel();
+
     void refreshMailboxListModel();
-    NmMessageListModel &messageListModel(const NmId &mailboxId, const NmId &folderId);
-    NmMessageSearchListModel &messageSearchListModel(QAbstractItemModel *sourceModel);
+
+    NmId getPluginIdByMailboxId(quint32 accountId);
+    
+    NmMessageListModel &messageListModel(const NmId &mailboxId,
+                                         const NmId &folderId);
+
+    NmMessageListModel &messageListModelForSearch(const NmId &mailboxId);
 
     NmId standardFolderId(const NmId &mailboxId, NmFolderType folderType);
 
@@ -75,6 +80,12 @@
         const NmId &messageId,
         const NmId &messagePartId);
     
+    QPointer<NmOperation> fetchMessageParts( 
+        const NmId &mailboxId,
+        const NmId &folderId,
+        const NmId &messageId,
+        const QList<NmId> &messagePartIds);
+    
     XQSharableFile messagePartFile(
        const NmId &mailboxId,
        const NmId &folderId,
@@ -123,12 +134,17 @@
     
     int goOffline(const NmId &mailboxId);
     
-    int removeMessage(
-                const NmId &mailboxId,
-                const NmId &folderId,
-                const NmId &messageId);
+    int removeMessage(const NmId &mailboxId,
+                      const NmId &folderId,
+                      const NmId &messageId);
+    
+    void removeDraftMessage(NmMessage *message);
     
-    void sendMessage(NmMessage *message, const QList<NmOperation*> &preliminaryOperations);
+    void saveDraftMessage(NmMessage *message,
+                          const QList<NmOperation*> &preliminaryOperations);
+    
+    void sendMessage(NmMessage *message,
+                     const QList<NmOperation*> &preliminaryOperations);
 
     bool isSendingMessage() const;
 
@@ -142,9 +158,8 @@
         const NmMessage &message, 
         const NmId &attachmentPartId);
 
-    QPointer<NmCheckOutboxOperation> checkOutbox(const NmId &mailboxId);
-    
     NmSyncState syncState(const NmId& mailboxId);
+
     NmConnectState connectionState(const NmId& mailboxId);
 
     int search(const NmId &mailboxId,
@@ -154,46 +169,74 @@
     
     NmFolderType folderTypeById(NmId mailboxId, NmId folderId);
 
+    void updateActiveFolder(const NmId &mailboxId, const NmId &folderId);
+    
 public slots:
+
     void handleCompletedSendOperation();
-    void handleSyncStateEvent(NmSyncState syncState, const NmOperationCompletionEvent &event);
-    void handleConnectEvent(NmConnectState connectState, const NmId &mailboxId, const int errorCode);
+    void handleCompletedRemoveDraftOperation();
+    void handleCompletedSaveDraftOperation();
+
+    void handleSyncStateEvent(NmSyncState syncState,
+                              const NmOperationCompletionEvent &event);
+
+    void handleConnectEvent(NmConnectState connectState,
+                            const NmId &mailboxId,
+                            const int errorCode);
+
 
 private slots:
-    void handleMessageEvent(
-            NmMessageEvent event,
-            const NmId &folderId,
-            const QList<NmId> &messageIds, 
-            const NmId& mailboxId);
+
+    void handleMessageEvent(NmMessageEvent event,
+                            const NmId &folderId,
+                            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 NmId& mailboxId);
+
 
 signals:
+
     void syncStateEvent(NmSyncState, const NmId &);
     void connectionEvent(NmConnectState, const NmId &);
     void operationCompleted(const NmOperationCompletionEvent &event);
     void sendOperationCompleted();
     void messageDeleted(const NmId &mailboxId, const NmId &folderId, const NmId &messageId);
     void mailboxDeleted(const NmId &mailboxId);
-    void matchFound(const NmId &);
+    void matchFound(const NmId &, const NmId &);
     void searchComplete();
-    
+
+
 private:
+
     NmUiEngine();
+
     virtual ~NmUiEngine();
 
-private:
+
+private: // Data
+
     static NmUiEngine *mInstance;
     static int	mReferenceCount;
 
     NmDataPluginFactory *mPluginFactory;
     NmDataManager *mDataManager;                // Owned
     NmMailboxListModel *mMailboxListModel;      // Owned
+    NmMessageListModel *mInboxListModel;      // Owned
     NmMessageListModel *mMessageListModel;      // Owned
-    NmMessageSearchListModel *mMessageSearchListModel; // Owned
+    NmMessageListModel *mMessageSearchListModel; // Owned
     QPointer<NmMessageSendingOperation> mSendOperation;  // Not owned
+    QPointer<NmOperation> mRemoveDraftOperation; // not owned
+    QPointer<NmOperation> mSaveDraftOperation;   // not owned
+    NmMessage *mDraftMessage; // owned
 };
 
 
--- a/emailuis/nmailuiengine/inc/nmuiengineheaders.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/inc/nmuiengineheaders.h	Thu Jul 22 16:30:28 2010 +0100
@@ -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,6 +39,7 @@
 #include <hbicon.h>
 #include <hbiconanimationmanager.h>
 #include <hbmenu.h>
+#include <hbindicator.h>
 
 // nmailuiengine
 #include "nmuienginedef.h"
@@ -47,7 +48,6 @@
 #include "nmmailboxlistmodel.h"
 #include "nmfolderlistmodel.h"
 #include "nmmessagelistmodel.h"
-#include "nmmessagesearchlistmodel.h"
 #include "nmdatapluginfactory.h"
 #include "nmdataplugininterface.h"
 #include "nmmailboxlistmodelitem.h"
@@ -61,8 +61,8 @@
 #include "nmmessagesendingoperation.h"
 #include "nmaddattachmentsoperation.h"
 #include "nmmessagecreationoperation.h"
-#include "nmcheckoutboxoperation.h"
 #include "nmmessagecreationoperation.h"
+#include "nmapplicationstateinterface.h"
 
 // nmailui
 #include "nmactionrequest.h"
--- a/emailuis/nmailuiengine/nmailuiengine.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/nmailuiengine.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -1,4 +1,4 @@
-# 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"
@@ -36,7 +36,6 @@
            inc/nmfoldermetadata.h \
            inc/nmmessagelistmodelitem.h \
            inc/nmmessagelistmodel.h \
-           inc/nmmessagesearchlistmodel.h \
            inc/nmuienginedef.h \
            inc/nmdataplugininterface.h \
            inc/nmicons.h \
@@ -44,8 +43,8 @@
            inc/nmoperation.h \
            inc/nmaddattachmentsoperation.h \
            inc/nmmessagesendingoperation.h \
-           inc/nmcheckoutboxoperation.h \
-           inc/nmstoreenvelopesoperation.h
+           inc/nmstoreenvelopesoperation.h \
+           inc/nmapplicationstateinterface.h 
 
 SOURCES += src/nmuiengine.cpp \
            src/nmdatamanager.cpp \
@@ -56,7 +55,6 @@
            src/nmfoldermetadata.cpp \
            src/nmmessagelistmodelitem.cpp \
            src/nmmessagelistmodel.cpp \
-           src/nmmessagesearchlistmodel.cpp \
            src/nmdatapluginfactory.cpp \
            src/nmicons.cpp \
            src/nmbaseclientplugin.cpp \
--- a/emailuis/nmailuiengine/src/nmaddattachmentoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmaddattachmentoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -22,6 +22,7 @@
   */
 NmAddAttachmentsOperation::NmAddAttachmentsOperation()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -29,6 +30,7 @@
  */
 NmAddAttachmentsOperation::~NmAddAttachmentsOperation()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -39,6 +41,8 @@
  */
 void NmAddAttachmentsOperation::completeOperationPart(const QString &fileName, const NmId &msgPartId, int result)
 {
+    NM_FUNCTION;
+    
     emit operationPartCompleted(fileName, msgPartId, result);
 }
 
--- a/emailuis/nmailuiengine/src/nmbaseclientplugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmbaseclientplugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -104,9 +104,9 @@
 mViewerToolBarRequest(NULL),
 mViewerViewRequest(NULL)
 {
-    NMLOG("NmBaseClientPlugin::NmBaseClientPlugin()-->");
+    NM_FUNCTION;
+    
     mUiEngine = NmUiEngine::instance();
-    NMLOG("<--NmBaseClientPlugin::NmBaseClientPlugin()");
 }
 
 /*!
@@ -114,27 +114,29 @@
 */
 NmBaseClientPlugin::~NmBaseClientPlugin()
 {
-    NMLOG("NmBaseClientPlugin::~NmBaseClientPlugin()-->");
+    NM_FUNCTION;
+    
     NmUiEngine::releaseInstance(mUiEngine);
     mUiEngine = NULL;
-    NMLOG("<--NmBaseClientPlugin::~NmBaseClientPlugin()");
 }
 
+
 /*!
-    Provides list of supported NmActions.
+    Provides a list of supported NmActions.
     Implementation of NmUiExtensionInterface.
+
     Parameter \a request controls list of request services.
     Parameter \a actionList is updated by supported NmActions.
 */
-void NmBaseClientPlugin::getActions(
-      const NmActionRequest &request,
-      QList<NmAction *> &actionList)
+void NmBaseClientPlugin::getActions(const NmActionRequest &request,
+                                    QList<NmAction *> &actionList)
 {
-    NMLOG("NmBaseClientPlugin::getActions()-->");
-
+    NM_FUNCTION;
+    
     if (request.observer()) {
         switch (request.contextView()) {
             case NmActionContextViewMessageList:
+            case NmActionContextViewMessageSearchList:
             {
                 createMessageListCommands(request, actionList);
                 break;
@@ -151,30 +153,28 @@
             }
             default:
             {
-                NMLOG(QString("NmBaseClientPlugin::getActions(): Unknown contextView()=%1").arg(request.contextView()));
+                NM_COMMENT(QString("NmBaseClientPlugin::getActions(): unknown contextView()=%1").arg(request.contextView()));
                 break;
             }
         }
     }
-    NMLOG("<--NmBaseClientPlugin::getActions()");
 }
 
+
 /*!
     Public slot connected to options menu refresh NmAction.
     Refreshes mailbox using the NmUiEngine instance.
 */
 void NmBaseClientPlugin::refresh()
 {
-    NMLOG("NmBaseClientPlugin::refresh()-->");
-
+    NM_FUNCTION;
+    
     int err = mUiEngine->refreshMailbox(mMenuRequest.mailboxId());
 
     if (NmNoError != err) {
         // Failed to refresh the mailbox!
-        NMLOG(QString("NmBaseClientPlugin::refresh(): failed err=%1").arg(err));
+        NM_ERROR(1,QString("NmBaseClientPlugin::refresh(): failed err=%1").arg(err));
     }
-
-    NMLOG("<--NmBaseClientPlugin::refresh()");
 }
 
 /*!
@@ -183,6 +183,8 @@
 */
 void NmBaseClientPlugin::openMessage()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandOpen, mMenuRequest);
 }
 
@@ -191,8 +193,8 @@
 */
 void NmBaseClientPlugin::deleteMessage()
 {
-    NMLOG("NmBaseClientPlugin::deleteMessage()-->");
-
+    NM_FUNCTION;
+    
     QList<NmId> messageList;
     messageList.append(mMenuRequest.messageId());
 
@@ -201,10 +203,9 @@
                                         messageList);
     if (NmNoError != err) {
         // Failed to delete the messages!
-        NMLOG(QString("NmBaseClientPlugin::deleteMessage(): failed err=%1").arg(err));
+        NM_ERROR(1,QString("NmBaseClientPlugin::deleteMessage(): failed err=%1").arg(err));
     }
     messageList.clear();
-    NMLOG("<--NmBaseClientPlugin::deleteMessage()");
 }
 
 /*!
@@ -213,6 +214,8 @@
 */
 void NmBaseClientPlugin::deleteMessageFromViewerView()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandDeleteMail, mViewerViewRequest);
 }
 
@@ -222,6 +225,8 @@
 */
 void NmBaseClientPlugin::createNewMailViewerToolBar()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandNewMail, mViewerToolBarRequest);
 }
 
@@ -231,6 +236,8 @@
 */
 void NmBaseClientPlugin::createNewMail()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandNewMail, mMenuRequest);
 }
 
@@ -240,6 +247,9 @@
 */
 void NmBaseClientPlugin::settings()
 {
+    NM_FUNCTION;
+    
+    handleRequest(NmActionResponseCommandSettings, mMenuRequest);
 }
 
 /*!
@@ -248,6 +258,8 @@
 */
 void NmBaseClientPlugin::sendMail()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandSendMail, mEditorToolBarRequest);
 }
 
@@ -258,6 +270,8 @@
 
 void NmBaseClientPlugin::replyMail()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandReply, mViewerViewRequest);
 }
 
@@ -268,6 +282,8 @@
 
 void NmBaseClientPlugin::replyAllMail()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandReplyAll, mViewerViewRequest);
 }
 
@@ -277,6 +293,8 @@
 */
 void NmBaseClientPlugin::forwardMail()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandForward, mViewerViewRequest);
 }
 
@@ -285,6 +303,8 @@
 */
 void NmBaseClientPlugin::setPriorityHigh()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandPriorityHigh, mMenuRequest);
 }
 
@@ -293,6 +313,8 @@
 */
 void NmBaseClientPlugin::setPriorityNormal()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandNone, mMenuRequest);
 }
 
@@ -301,6 +323,8 @@
 */
 void NmBaseClientPlugin::setPriorityLow()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandPriorityLow, mMenuRequest);
 }
 
@@ -309,6 +333,8 @@
 */
 void NmBaseClientPlugin::attach()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandAttach, mEditorToolBarRequest);
 }
 
@@ -317,6 +343,8 @@
 */
 void NmBaseClientPlugin::removeAttachment()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandRemoveAttachment, mMenuRequest);
 }
 
@@ -325,6 +353,8 @@
 */
 void NmBaseClientPlugin::openAttachment()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandOpenAttachment, mMenuRequest);
 }
 
@@ -334,6 +364,8 @@
 */
 void NmBaseClientPlugin::search()
 {
+    NM_FUNCTION;
+    
     handleRequest(NmActionResponseCommandSearch, mViewerToolBarRequest);
 }
 
@@ -346,6 +378,8 @@
 void NmBaseClientPlugin::mailboxListChanged(const NmId &mailboxId,
     NmSettings::MailboxEventType type)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(mailboxId)
     Q_UNUSED(type)
     handleRequest(NmActionResponseCommandMailboxDeleted, mMenuRequest);
@@ -361,15 +395,15 @@
 void NmBaseClientPlugin::mailboxPropertyChanged(const NmId &mailboxId, QVariant property,
     QVariant value)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(property)
     Q_UNUSED(value)
 
     NmActionObserver *observer = mMenuRequest.observer();
     if (observer) {
         // Force model item to be updated, because framework adapter sends it too slowly.
-        // Data changed signal is not emitted by this change, it is send when ever famework adapter
-        // calls data model's handleMailboxEvent method.
-        mUiEngine->mailboxListModel().refreshModelItem(mailboxId, false);
+        mUiEngine->mailboxListModel().refreshModelItem(mailboxId);
 
         // Notify view of changes.
         NmActionResponse response(NmActionResponseCommandUpdateMailboxName, mMenuRequest);
@@ -383,6 +417,8 @@
 */
 void NmBaseClientPlugin::goOnline(const NmId &mailboxId)
 {
+    NM_FUNCTION;
+    
 		(void) mUiEngine->refreshMailbox(mailboxId);
 }
 /*!
@@ -391,6 +427,8 @@
 */
 void NmBaseClientPlugin::goOffline(const NmId &mailboxId)
 {
+    NM_FUNCTION;
+    
         mUiEngine->goOffline(mailboxId);
 }
 
@@ -404,8 +442,8 @@
     const NmActionRequest &request,
     QList<NmAction *> &actionList)
 {
-    NMLOG("NmBaseClientPlugin::createMessageListCommands()-->");
-
+    NM_FUNCTION;
+    
     switch (request.menuType()) {
         case NmActionOptionsMenu:
         {
@@ -477,7 +515,7 @@
                         request.requestData().value<NmMessageEnvelope*>();    
                     if (envelope){
                         if (envelope->isRead()){
-                            NMLOG("nmailui: envelope is read");
+                            NM_COMMENT("nmailui: envelope is read");
                             NmAction* unreadAction = new NmAction(0);
                             unreadAction->setObjectName("baseclientplugin_unreadaction");
                             unreadAction->setText(hbTrId("txt_mail_menu_mark_as_unread"));
@@ -490,7 +528,7 @@
                             actionList.append(unreadAction);
                         }
                         else {
-                            NMLOG("nmailui: envelope is unread");
+                            NM_COMMENT("nmailui: envelope is unread");
                             NmAction* readAction = new NmAction(0);
                             readAction->setObjectName("baseclientplugin_readaction");
                             readAction->setText(hbTrId("txt_mail_menu_mark_as_read"));
@@ -509,11 +547,10 @@
         }
         default:
         {
-            NMLOG(QString("NmBaseClientPlugin::createMessageListCommands(): Unknown menuType()=%1").arg(request.menuType()));
+            NM_COMMENT(QString("NmBaseClientPlugin::createMessageListCommands(): unknown menuType()=%1").arg(request.menuType()));
             break;
         }
     }
-    NMLOG("<--NmBaseClientPlugin::createMessageListCommands()");
 }
 
 /*!
@@ -526,8 +563,8 @@
     const NmActionRequest &request,
     QList<NmAction *> &actionList)
 {
-    NMLOG("NmBaseClientPlugin::createViewerViewCommands()-->");
-
+    NM_FUNCTION;
+    
     switch (request.menuType()) {
     	case NmActionOptionsMenu:
 		{
@@ -620,7 +657,7 @@
         }
         default:
         {
-            NMLOG(QString("NmBaseClientPlugin::createViewerViewCommands(): Unknown menuType()=%1").arg(request.menuType()));
+            NM_COMMENT(QString("NmBaseClientPlugin::createViewerViewCommands(): unknown menuType()=%1").arg(request.menuType()));
             break;
         }
     }
@@ -637,8 +674,8 @@
     const NmActionRequest &request,
     QList<NmAction *> &actionList)
 {
-    NMLOG("NmBaseClientPlugin::createEditorViewCommands()-->");
-
+    NM_FUNCTION;
+    
     switch (request.menuType()) {
         case NmActionToolbar:
         {
@@ -722,12 +759,10 @@
         }
         default:
         {
-            NMLOG(QString("NmBaseClientPlugin::createEditorViewCommands(): Unknown menuType()=%1").arg(request.menuType()));
+            NM_COMMENT(QString("NmBaseClientPlugin::createEditorViewCommands(): unknown menuType()=%1").arg(request.menuType()));
             break;
         }
     }
-
-    NMLOG("<--NmBaseClientPlugin::createEditorViewCommands()");
 }
 
 /*!
@@ -735,9 +770,9 @@
 */
 void NmBaseClientPlugin::markAsRead()
 {
-    NMLOG("NmBaseClientPlugin::markAsRead()-->");
+    NM_FUNCTION;
+    
     updateEnvelopeProperty(MarkAsRead);
-    NMLOG("<--NmBaseClientPlugin::markAsRead()");
 }
 
 /*!
@@ -745,9 +780,9 @@
 */
 void NmBaseClientPlugin::markAsUnread()
 {
-    NMLOG("NmBaseClientPlugin::markAsUnread()-->");
+    NM_FUNCTION;
+    
     updateEnvelopeProperty(MarkAsUnread);
-    NMLOG("<--NmBaseClientPlugin::markAsUnread()");
 }
 
 /*!
@@ -755,6 +790,8 @@
 */
 void NmBaseClientPlugin::handleRequest(NmActionResponseCommand command, const NmActionRequest &request)
 {
+    NM_FUNCTION;
+    
     NmActionObserver *observer = request.observer();
     if (observer) {
         NmActionResponse response(command, request);
@@ -766,8 +803,8 @@
 */
 void NmBaseClientPlugin::updateEnvelopeProperty(NmEnvelopeProperties property)
 {
-    NMLOG("NmBaseClientPlugin::updateEnvelopeProperty()-->");
-
+    NM_FUNCTION;
+    
     QList<const NmMessageEnvelope*> envelopeList;
     NmMessageEnvelope *envelope =
             mMenuRequest.requestData().value<NmMessageEnvelope*>();
@@ -782,5 +819,4 @@
                                         envelopeList);
     }
     envelopeList.clear();
-    NMLOG("<--NmBaseClientPlugin::updateEnvelopeProperty()");
 }
--- a/emailuis/nmailuiengine/src/nmdatamanager.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmdatamanager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -31,6 +31,8 @@
 NmDataManager::NmDataManager() 
 :mFactory(NULL)
 {
+    NM_FUNCTION;
+    
     mFactory = NmDataPluginFactory::instance();
 }
 
@@ -39,6 +41,8 @@
 */
 NmDataManager::~NmDataManager()
 {
+    NM_FUNCTION;
+    
     NmDataPluginFactory::releaseInstance(mFactory);
 }
 
@@ -47,6 +51,8 @@
 */
 void NmDataManager::listMailboxIds(QList<NmId> &mailboxIdList)
 {
+    NM_FUNCTION;
+    
     int count(mFactory->pluginInstances()->count());
     for (int i(0); i < count; i++) {
         NmDataPluginInterface *instance =
@@ -63,6 +69,8 @@
 */
 void NmDataManager::listMailboxes(QList<NmMailbox*> &mailboxList)
 {
+    NM_FUNCTION;
+    
     int count = mFactory->pluginInstances()->count();
     for (int i(0); i < count; i++) {
         NmDataPluginInterface *instance =
@@ -80,6 +88,8 @@
 */
 void NmDataManager::listFolders(const NmId mailboxId, QList<NmFolder*> &folderList)
 {
+    NM_FUNCTION;
+    
     NmDataPluginInterface *instance = mFactory->interfaceInstance(mailboxId);
     if (instance) {
         instance->listFolders(mailboxId, folderList);
@@ -96,6 +106,8 @@
         const NmId &folderId,
         QList<NmMessageEnvelope*> &messageEnvelopeList)
 {
+    NM_FUNCTION;
+    
     NmDataPluginInterface *instance = mFactory->interfaceInstance(folderId);
     if (instance) {
         instance->listMessages(mailboxId, folderId, messageEnvelopeList);
@@ -111,7 +123,8 @@
     const NmId &mailboxId,
     const NmId &folderId)
 {
-    NMLOG("nmuiengine: getFolderById");
+    NM_FUNCTION;
+    
     NmFolderMetaData *folderMetaData(NULL);
     QList<NmFolder*> folderList;
     listFolders(mailboxId, folderList);
@@ -135,7 +148,8 @@
 */
 NmMailboxMetaData *NmDataManager::mailboxById(const NmId &mailboxId)
 {
-    NMLOG("nmuiengine: getMailboxById");
+    NM_FUNCTION;
+    
     NmMailboxMetaData *mailboxMetaData(NULL);
     NmMailbox* mbox = mailbox(mailboxId);
 
@@ -161,8 +175,8 @@
     const NmId &folderId,
     const NmId &messageId)
 {
-    NMLOG("nmuiengine: getMessageById");
-
+    NM_FUNCTION;
+    
     NmMessageEnvelope *msgEnvelope(NULL);
     NmMessage* msg = message(mailboxId, folderId, messageId);
 
@@ -180,6 +194,8 @@
 */
 NmMailbox *NmDataManager::mailbox(const NmId &mailboxId)
 {
+    NM_FUNCTION;
+    
     NmMailbox *newMailboxObject(NULL);
     NmDataPluginInterface *instance = mFactory->interfaceInstance(mailboxId);
     int retVal(NmNotFoundError);
@@ -204,6 +220,8 @@
     const NmId &mailboxId,
     const NmId &folderId)
 {
+    NM_FUNCTION;
+    
     NmFolder* newFolderObject(NULL);
     QList<NmFolder*> folderList;
     listFolders(mailboxId, folderList);
@@ -227,6 +245,8 @@
     const NmId &folderId,
     const NmId &messageId)
 {
+    NM_FUNCTION;
+    
     NmMessage *newMessageObject(NULL);
     NmDataPluginInterface *instance = mFactory->interfaceInstance(mailboxId);
 
@@ -254,6 +274,8 @@
     const NmId &messageId,
     NmMessagePart &messagePart)
 {
+    NM_FUNCTION;
+    
     int retVal(NmNotFoundError);
     NmDataPluginInterface *instance = mFactory->interfaceInstance(mailboxId);
     if (instance) {
@@ -270,6 +292,8 @@
         const NmId &mailboxId,
         NmFolderType folderType )
 {
+    NM_FUNCTION;
+    
     NmId folderId;
     NmDataPluginInterface *instance = mFactory->interfaceInstance(mailboxId);
     if (instance) {
@@ -280,4 +304,34 @@
 }
 
 
+/*!
+    Returns folder type by id
 
+    \param mailboxId The ID of the mailbox containing the folder
+
+    \param folderId The ID of the folder 
+
+    \return Folder type
+*/
+NmFolderType NmDataManager::folderTypeById(NmId mailboxId, NmId folderId)
+{
+    NM_FUNCTION;
+    
+    NmFolderType folderType(NmFolderOther);
+    if (getStandardFolderId(mailboxId,NmFolderInbox)==folderId){
+        folderType=NmFolderInbox;
+    }
+    else if (getStandardFolderId(mailboxId,NmFolderOutbox)==folderId){
+        folderType=NmFolderOutbox; 
+    }
+    else if (getStandardFolderId(mailboxId,NmFolderDrafts)==folderId){
+        folderType=NmFolderDrafts;
+    }
+    else if (getStandardFolderId(mailboxId,NmFolderSent)==folderId){
+        folderType=NmFolderSent; 
+    }    
+    else if (getStandardFolderId(mailboxId,NmFolderDeleted)==folderId){
+        folderType=NmFolderDeleted;  
+    }    
+    return folderType;
+}
--- a/emailuis/nmailuiengine/src/nmdatapluginfactory.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmdatapluginfactory.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -38,7 +38,7 @@
  */
 NmDataPluginFactory::NmDataPluginFactory()
 {
-
+    NM_FUNCTION;
 }
 
 /*!
@@ -46,6 +46,8 @@
  */
 NmDataPluginFactory::~NmDataPluginFactory()
 {
+    NM_FUNCTION;
+    
     if (mPluginArray) {
         qDeleteAll(mPluginArray->begin(), mPluginArray->end());
         mPluginArray->clear();
@@ -62,6 +64,8 @@
  */
 NmDataPluginFactory *NmDataPluginFactory::instance()
 {
+    NM_FUNCTION;
+    
     if (!mInstance) {
         mInstance = new NmDataPluginFactory();
     }
@@ -74,6 +78,8 @@
  */
 void NmDataPluginFactory::releaseInstance(NmDataPluginFactory *&instance)
     {
+    NM_FUNCTION;
+    
     //can't have passed out instances if we don't have any
     if (mInstance) {
         if (instance == mInstance) {
@@ -92,6 +98,8 @@
  */
 NmDataPluginInterface *NmDataPluginFactory::interfaceInstance(QObject *plugin)
 {
+    NM_FUNCTION;
+    
     NmDataPluginInterface *pluginInterface = NULL;
     if (plugin) {
         pluginInterface= qobject_cast<NmDataPluginInterface*>(plugin);
@@ -104,14 +112,42 @@
  */
 NmDataPluginInterface *NmDataPluginFactory::interfaceInstance(NmId mailboxId)
 {
+    NM_FUNCTION;
+    
     return interfaceInstance(pluginInstance(mailboxId));
 }
 
 /*!
 
  */
+NmApplicationStateInterface *NmDataPluginFactory::applicationStateInterfaceInstance(QObject *plugin)
+{
+    NM_FUNCTION;
+    
+    NmApplicationStateInterface *pluginInterface = NULL;
+    if (plugin) {
+        pluginInterface= qobject_cast<NmApplicationStateInterface*>(plugin);
+        }
+    return pluginInterface;
+}
+
+/*!
+
+ */
+NmApplicationStateInterface *NmDataPluginFactory::applicationStateInterfaceInstance(NmId mailboxId)
+{
+    NM_FUNCTION;
+    
+    return applicationStateInterfaceInstance(pluginInstance(mailboxId));
+}
+
+/*!
+
+ */
 QObject *NmDataPluginFactory::pluginInstance(NmId mailboxId)
 {
+    NM_FUNCTION;
+    
     QObject *value(NULL);
 
     quint64 tmp = mailboxId.id();
@@ -138,6 +174,8 @@
  */
 QList<QObject*> *NmDataPluginFactory::pluginInstances()
 {
+    NM_FUNCTION;
+    
     //if plugins have not been already created, do it now.
     if (!mPluginArray) {
         mPluginArray = new QList<QObject*>();
@@ -174,6 +212,8 @@
     const QDir &pluginDir,
     const QString &pluginName )
 {
+    NM_FUNCTION;
+    
     /*!
         This creates plugin entity.
      */
--- a/emailuis/nmailuiengine/src/nmfolderlistmodel.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmfolderlistmodel.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -37,10 +37,13 @@
 
 NmFolderListModelPrivate::NmFolderListModelPrivate()
 {
+    NM_FUNCTION;
 }
 
 NmFolderListModelPrivate::~NmFolderListModelPrivate()
 {
+    NM_FUNCTION;
+    
     while (!mMetaDataList.isEmpty()) {
         delete mMetaDataList.takeLast();
     }
@@ -53,6 +56,8 @@
 :QAbstractListModel(parent),
 mDataManager(dataManager)
 {
+    NM_FUNCTION;
+    
     d = new NmFolderListModelPrivate;
 }
 
@@ -61,6 +66,8 @@
  */
 NmFolderListModel::~NmFolderListModel()
 {
+    NM_FUNCTION;
+    
     delete d;
 }
 
@@ -69,6 +76,8 @@
  */
 QModelIndex NmFolderListModel::parent(const QModelIndex &child) const
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(child);
     return QModelIndex();
 }
@@ -78,6 +87,8 @@
  */
 int NmFolderListModel::rowCount(const QModelIndex &parent) const
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(parent);
     return d->mMetaDataList.size();
 }
@@ -87,6 +98,8 @@
  */
 int NmFolderListModel::columnCount(const QModelIndex &parent) const
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(parent);
 	return 1;
 }
@@ -97,6 +110,8 @@
  */
 QVariant NmFolderListModel::data(const QModelIndex &index, int role) const
 {
+    NM_FUNCTION;
+    
     if (!index.isValid())
         return QVariant();
 
@@ -120,7 +135,8 @@
 void NmFolderListModel::refresh(
         QList<NmFolder*>& folderList)
 {
-    NMLOG("nmuiengine: folder list model refresh");
+    NM_FUNCTION;
+    
     while (!d->mMetaDataList.isEmpty()) {
         delete d->mMetaDataList.takeLast();
     }
--- a/emailuis/nmailuiengine/src/nmfoldermetadata.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmfoldermetadata.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -42,6 +42,8 @@
 */
 NmFolderMetaData::NmFolderMetaData()
 {
+    NM_FUNCTION;
+    
     d = new NmFolderMetaDataPrivate;
 }
 
@@ -51,6 +53,8 @@
 */
 NmFolderMetaData::~NmFolderMetaData()
 {
+    NM_FUNCTION;
+    
     delete d;
 }
 
@@ -59,6 +63,8 @@
 */
 QString NmFolderMetaData::name() const
 {
+    NM_FUNCTION;
+    
     return d->mName;
 }
 
@@ -67,6 +73,8 @@
 */
 void NmFolderMetaData::setName(const QString &name)
 {
+    NM_FUNCTION;
+    
     d->mName = name;
 }
 
@@ -75,6 +83,8 @@
 */
 NmId NmFolderMetaData::id() const
 {
+    NM_FUNCTION;
+    
     return d->mId;
 }
 
@@ -83,6 +93,8 @@
 */
 void NmFolderMetaData::setId(const NmId &id)
 {
+    NM_FUNCTION;
+    
     d->mId = id;
 }
 
--- a/emailuis/nmailuiengine/src/nmicons.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmicons.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -66,6 +66,8 @@
 */
 HbIcon &NmIcons::getIcon(NmIcons::Icon icon)
 {
+    NM_FUNCTION;
+    
     if (!icons[icon]) {
         for (int i(0); icon_res[i].id != NmIcons::NmLastItem; i++) {
             if (icon_res[i].id == icon) {
@@ -81,7 +83,7 @@
         }
     }
     if (!icons[icon]) {
-        NMLOG(QString("nmailuiengine: Cannot open icon file: ###").arg(__FILE__));
+        NM_ERROR(1,QString("nmailuiengine: cannot open icon file: %1").arg(__FILE__));
     }
     return *icons[icon];
 }
@@ -91,7 +93,8 @@
 */
 void NmIcons::freeIcons()
 {
-    NMLOG("nmailuiengine: Enter freeIcons");
+    NM_FUNCTION;
+    
     for (int i(0); icon_res[i].id != NmIcons::NmLastItem; i++) {
         if (icons[i]) {
             delete icons[i];
--- a/emailuis/nmailuiengine/src/nmmailboxlistmodel.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmmailboxlistmodel.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -30,10 +30,11 @@
 /*!
     Constructor
  */
-NmMailboxListModel::NmMailboxListModel(NmDataManager &dataManager, QObject *parent) 
+NmMailboxListModel::NmMailboxListModel(NmDataManager &dataManager, QObject *parent)
 :QStandardItemModel(parent),
 mDataManager(dataManager)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -41,6 +42,8 @@
  */
 NmMailboxListModel::~NmMailboxListModel()
 {
+    NM_FUNCTION;
+    
     clear();
 }
 
@@ -50,6 +53,8 @@
  */
 QVariant NmMailboxListModel::data(const QModelIndex &index, int role) const
 {
+    NM_FUNCTION;
+    
     QVariant qVariant;
     if (index.isValid() && Qt::DisplayRole == role) {
         NmMailboxListModelItem *item = static_cast<NmMailboxListModelItem*>(itemFromIndex(index));
@@ -65,7 +70,8 @@
 void NmMailboxListModel::refresh(
         QList<NmMailbox*> &mailboxList)
 {
-    NMLOG("nmuiengine: mailbox list model refresh");
+    NM_FUNCTION;
+    
     clear();
     for (int i(0); i < mailboxList.count(); i++) {
         NmMailbox *mailbox = mailboxList[i];
@@ -79,13 +85,11 @@
 /*!
     Updates specific model item.
     \param mailboxId Mailbox id.
-    \param allowEmitDataChanged If <code>true</code> data changed signal
-           is emitted \sa QStandardItem, otherwise signal is not send.
  */
-void NmMailboxListModel::refreshModelItem(const NmId &mailboxId, bool allowEmitDataChanged)
+void NmMailboxListModel::refreshModelItem(const NmId &mailboxId)
 {
-    NMLOG("NmMailboxListModel::refreshModelItem");
-
+    NM_FUNCTION;
+    
     // Get correct mailbox data.
     NmMailbox* mailbox = mDataManager.mailbox(mailboxId);
     NmMailboxListModelItem *entryItem(NULL);
@@ -102,21 +106,13 @@
 
     // Update entry item's data.
     if (mailbox && entryItem) {
-        if (allowEmitDataChanged) {
-            // Changes data and emits datachanged.
-            NmMailboxMetaData *metaData = new NmMailboxMetaData;
-            metaData->setId(mailbox->id());
-            metaData->setName(mailbox->name());
-            entryItem->setItemMetaData(metaData);
-        } else {
-            // Only changes meta data information (mailbox name).
-            // No need for updating mailbox id.
-            // Do not call emitDataChanged, because it seems that if
-            // emitDataChanged is called twice, it leads to KERN-EXEC 3 Panic.
-            entryItem->itemMetaData()->setName(mailbox->name());
-       }
+        // Changes data and emits datachanged.
+        NmMailboxMetaData *metaData = new NmMailboxMetaData;
+        metaData->setId(mailbox->id());
+        metaData->setName(mailbox->name());
+        metaData->setAddress(mailbox->address().address());
+        entryItem->setItemMetaData(metaData);
     }
-    NMLOG("NmMailboxListModel::refreshModelItem - OK");
 }
 
 /*!
@@ -124,7 +120,8 @@
  */
 void NmMailboxListModel::handleMailboxEvent(NmMailboxEvent event, const QList<NmId> &mailboxIds)
 {
-    NMLOG("NmMailboxListModel::handleMailboxEvent");
+    NM_FUNCTION;
+    
     for (int a(0); a < mailboxIds.count(); a++) {
         NmId mailboxId = mailboxIds[a];
         switch (event) {
@@ -174,9 +171,12 @@
  */
 NmMailboxListModelItem *NmMailboxListModel::createMailboxItem(const NmMailbox *mailbox)
 {
+    NM_FUNCTION;
+    
     NmMailboxMetaData *newMeta = new NmMailboxMetaData();
     newMeta->setId(mailbox->id());
     newMeta->setName(mailbox->name());
+    newMeta->setAddress(mailbox->address().address());
 
     NmMailboxListModelItem *item = new NmMailboxListModelItem();
     item->setItemMetaData(newMeta);
--- a/emailuis/nmailuiengine/src/nmmailboxlistmodelitem.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmmailboxlistmodelitem.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -30,6 +30,7 @@
 :QStandardItem(),
 mMailbox(NULL)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -37,6 +38,8 @@
  */
 NmMailboxListModelItem::~NmMailboxListModelItem()
 {
+    NM_FUNCTION;
+    
     delete mMailbox;
 }
 
@@ -45,6 +48,8 @@
  */
 void NmMailboxListModelItem::setItemMetaData(NmMailboxMetaData *mailbox)
 {
+    NM_FUNCTION;
+    
     if (mMailbox) {
         delete mMailbox;
     }
@@ -57,6 +62,8 @@
  */
 NmMailboxMetaData *NmMailboxListModelItem::itemMetaData()
 {
+    NM_FUNCTION;
+    
     return mMailbox;
 }
 
@@ -65,6 +72,8 @@
  */
 void NmMailboxListModelItem::callEmitDataChanged()
 {
+    NM_FUNCTION;
+    
     emitDataChanged();
 }
 
--- a/emailuis/nmailuiengine/src/nmmailboxmetadata.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmmailboxmetadata.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -34,6 +34,7 @@
     QString mName;
     NmId mId;
     NmId mIconId;
+    QString mAddress;
 };
 
 
@@ -42,6 +43,8 @@
 */
 NmMailboxMetaData::NmMailboxMetaData()
 {
+    NM_FUNCTION;
+    
     d = new NmMailboxMetaDataPrivate;
 }
 
@@ -51,6 +54,8 @@
 */
 NmMailboxMetaData::~NmMailboxMetaData()
 {
+    NM_FUNCTION;
+    
     delete d;
 }
 
@@ -59,6 +64,8 @@
 */
 QString NmMailboxMetaData::name() const
 {
+    NM_FUNCTION;
+    
     return d->mName;
 }
 
@@ -67,6 +74,8 @@
 */
 void NmMailboxMetaData::setName(const QString &name)
 {
+    NM_FUNCTION;
+    
     d->mName = name;
 }
 
@@ -75,6 +84,8 @@
 */
 NmId NmMailboxMetaData::id() const
 {
+    NM_FUNCTION;
+    
     return d->mId;
 }
 
@@ -83,6 +94,8 @@
 */
 void NmMailboxMetaData::setId(const NmId& id)
 {
+    NM_FUNCTION;
+    
     d->mId = id;
 }
 
@@ -91,6 +104,8 @@
 */
 NmId NmMailboxMetaData::IconId() const
 {
+    NM_FUNCTION;
+    
     return d->mIconId;
 }
 
@@ -99,10 +114,27 @@
 */
 void NmMailboxMetaData::setIconId(const NmId &id)
 {
+    NM_FUNCTION;
+    
     d->mIconId = id;
 }
 
-
+/*!
+    Get mailbox address
+*/
+QString NmMailboxMetaData::address() const
+{
+    NM_FUNCTION;
+    
+    return d->mAddress;
+}
 
-
-
+/*!
+    Set Mailbox address as \a address
+*/
+void NmMailboxMetaData::setAddress(const QString &address)
+{
+    NM_FUNCTION;
+    
+    d->mAddress = address;
+}
--- a/emailuis/nmailuiengine/src/nmmessagelistmodel.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmmessagelistmodel.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -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"
@@ -17,6 +17,7 @@
 
 #include "nmuiengineheaders.h"
 
+static const int NmFolderTypeRole = Qt::UserRole+1; 
 
 /*!
     \class NmMessageListModel
@@ -29,81 +30,127 @@
 */
 
 /*!
-	Constructor
- */
-NmMessageListModel::NmMessageListModel(NmDataManager &dataManager, QObject *parent)
-:QStandardItemModel(parent),
-mDataManager(dataManager),
-mDividersActive(false),
-mParentPtr(NULL)
+	Class constructor.
+*/
+NmMessageListModel::NmMessageListModel(NmDataManager &dataManager,
+                                       QObject *parent /* = 0 */)
+: QStandardItemModel(parent),
+  mDataManager(dataManager),
+  mDividersActive(false),
+  mParentPtr(NULL),
+  mCurrentFolderType(NmFolderInbox),
+  mIgnoreFolderIds(false)
 {
+    NM_FUNCTION;
+    
     // Check for setting whether dividers are active
     // mDividersActive = ...
     // update also the test cases
 }
 
+
 /*!
-	Destructor
- */
+	Class destructor.
+*/
 NmMessageListModel::~NmMessageListModel()
 {
+    NM_FUNCTION;
+    
     clear();
 }
 
+
 /*!
     Returns data specified by \a index. Only Qt::DisplayRole is supported in \a role.
     The refresh method must have been called before this method can return any real data.
- */
-
+*/
 QVariant NmMessageListModel::data(const QModelIndex &index, int role) const
 {
+    NM_FUNCTION;
+    
     QVariant qVariant;
-    if (index.isValid() && Qt::DisplayRole == role) {
-    	NmMessageListModelItem *item = static_cast<NmMessageListModelItem*>(itemFromIndex(index));
-        qVariant = QVariant::fromValue(item);
+
+    if (index.isValid()){
+        if (role == Qt::DisplayRole) {
+            NmMessageListModelItem *item =
+                static_cast<NmMessageListModelItem*>(itemFromIndex(index));
+            qVariant = QVariant::fromValue(item);
+        }
+        else if (role == NmFolderTypeRole) {
+            qVariant = QVariant(mCurrentFolderType);
+        }    
     }
+
     return qVariant;
 }
 
+
 /*!
     This refreshes the data of the model.
- */
+
+    \param mailboxId The ID of the mailbox.
+    \param folderId The ID of the folder.
+    \param messageEnvelopeList A list containing the message meta data.
+*/
 void NmMessageListModel::refresh(
-                    const NmId mailboxId, 
-                    const NmId folderId,
-                    const QList<NmMessageEnvelope*> &messageEnvelopeList)
+        const NmId mailboxId, 
+        const NmId folderId,
+        const QList<NmMessageEnvelope*> &messageEnvelopeList)
 {
-    // Store current mailbox and folder id
+    NM_FUNCTION;
+
+    // Store the current mailbox and folder IDs.
     mCurrentMailboxId = mailboxId;
     mCurrentFolderId = folderId;
-    // clear the model
+
+    // Store the type of the currently displayed folder.
+    mCurrentFolderType = mDataManager.folderTypeById(mailboxId, folderId);
+
+    // Clear the model.
     clear();
-    // Add items
+
+    // Add the items from the given list.
     NmMessageEnvelope* insertedMessage(NULL);
     int parentCount(0);
     int childCount(0);
+
     for (int i(0); i < messageEnvelopeList.count(); i++) {
-        NmMessageEnvelope* nextMessage = messageEnvelopeList[i];
-        if (mDividersActive && !messagesBelongUnderSameDivider(
-        		insertedMessage, nextMessage)) {
-            insertDividerIntoModel(nextMessage, parentCount);
-            parentCount++;
-            childCount = 0;
+        NmMessageEnvelope *nextMessage = messageEnvelopeList[i];
+        // imap and pop is using common sent, outbox or draft folder
+        // for all mailboxes, here we want to filter out messages that
+        // are not under this mailbox
+        bool insert(true);
+        if (nextMessage 
+            && (NmFolderSent == mCurrentFolderType
+             || NmFolderOutbox == mCurrentFolderType
+             || NmFolderDrafts == mCurrentFolderType)) {
+            insert = (mCurrentMailboxId == nextMessage->mailboxId());  
         }
-        insertMessageIntoModel(nextMessage, childCount, false);
-        insertedMessage = nextMessage;
-        childCount++;
+        if (insert) {
+            if (mDividersActive &&
+                !messagesBelongUnderSameDivider(insertedMessage, nextMessage)) {
+                insertDividerIntoModel(nextMessage, parentCount);
+                parentCount++;
+                childCount = 0;
+            }
+    
+            insertMessageIntoModel(nextMessage, childCount, false);
+            insertedMessage = nextMessage;
+            childCount++;
+        }
     }
-    //NMLOG(QString("nmailuiengine: model row count = %1").arg(rowCount()));
 }
 
+
 /*!
     insertDividerIntoModel. Function inserts divider into model.
- */
+*/
 void NmMessageListModel::insertDividerIntoModel(
     NmMessageEnvelope *messageForDivider,
     int parentRow)
 {
+    NM_FUNCTION;
+    
     mParentPtr = createTitleDividerItem(messageForDivider);
     insertRow(parentRow,mParentPtr);
     mParentPtr->callEmitDataChanged();
@@ -112,10 +159,12 @@
 /*!
     Function inserts message into model. Message can be inserted
     either to root or to parent. If parent is zero, item is added into root.
- */
+*/
 void NmMessageListModel::insertMessageIntoModel(
 		NmMessageEnvelope *messageEnvelope, int childRow, bool emitSignal)
 {
+    NM_FUNCTION;
+    
     NmMessageListModelItem *mailItem = createMessageItem(messageEnvelope);
     if (mParentPtr) {
         // Add under parent divider
@@ -133,11 +182,13 @@
 /*!
     Function checks whether the messages can be drawn under same title divider
     Check is done depending of the current sorting criteria
- */
+*/
 bool NmMessageListModel::messagesBelongUnderSameDivider(
     const NmMessageEnvelope *message1,
     const NmMessageEnvelope *message2) const
 {
+    NM_FUNCTION;
+    
     bool retVal(false);
     // First check pointer validity
     if (message1 && message2) {
@@ -154,59 +205,95 @@
 
 
 /*!
-    Function handles message events
- */
-void NmMessageListModel::handleMessageEvent(
-    NmMessageEvent event,
-    const NmId &folderId,
-    const QList<NmId> &messageIds)
+    Handles the message events.
+
+    \param event The type of the message event.
+    \param folderId The folder containing the message.
+    \param messageIds A list of message IDs related to the event.
+*/
+void NmMessageListModel::handleMessageEvent(NmMessageEvent event,
+                                            const NmId &folderId,
+                                            const QList<NmId> &messageIds,
+                                            const NmId &mailboxId)
 {
-    NmId mailboxId = mCurrentMailboxId;
+    NM_FUNCTION;
+    const int idCount = messageIds.count();
 
-    if (folderId == 0) {
-        // const cast is used here because also the input parameter has to be changed
-        const_cast<NmId&>(folderId) = mDataManager.getStandardFolderId(mailboxId, NmFolderInbox);
-        NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMessageList, mailboxId, folderId);
-        emit setNewParam(startParam);
+    // Folder ID does not concern us if this model instance is used for e.g.
+    // searching messages.
+    if (!mIgnoreFolderIds) {
+        if (folderId == 0) {
+            // Const cast is used here because also the input parameter has to
+            // be changed.
+            const_cast<NmId&>(folderId) =
+                mDataManager.getStandardFolderId(mailboxId, NmFolderInbox);
+            NmUiStartParam *startParam =
+                new NmUiStartParam(NmUiViewMessageList, mailboxId, folderId);
+            emit setNewParam(startParam);
+        }
+
+        if (mCurrentFolderId == 0) {
+            // Folder ID was not known at time when the mailbox opened and we
+            // know that because of events the subscription is valid only for
+            // the current mailbox.
+            mCurrentFolderId = folderId; 
+        }
+        // MailboxId checking here is done because we want to filter out messages
+        // that belongs to other mailboxes in case of imap/pop sent, outbox or draft folder
+        if (mCurrentFolderId != folderId || mCurrentMailboxId != mailboxId) {
+            // The event does not concern the folder currently being displayed.
+            // Thus, ignore it.
+            return;
+        }
     }
-    if (mCurrentFolderId == 0) {
-        // Folder id was not known at time mailbox opened
-        // and we know subscription is valid only for current 
-        // mailbox, because of events.
-        mCurrentFolderId = folderId; 
-    }
-    // Handle events if they concern currently displayed folder
-    if (mCurrentFolderId == folderId) {
-        NMLOG(QString("nmailuiengine: handleMessageEvent"));
-        if (NmMessageChanged == event) {
-            for (int a(0); a < messageIds.count(); a++) {
-                updateMessageEnvelope(mailboxId, folderId,messageIds[a]);
+
+    // Go through the given message IDs and do the appropriate operations
+    // according to the type of the event.
+    for (int i(0); i < idCount; ++i) {
+        switch (event) {
+            case NmMessageChanged: {
+                updateMessageEnvelope(mailboxId, folderId, messageIds[i]);
+                break;
             }
-        }
-        else if (NmMessageCreated == event) {
-            for (int a(0); a < messageIds.count(); a++) {
-                if(!itemFromModel(messageIds[a])) {
-                    insertNewMessageIntoModel(mailboxId, folderId, messageIds[a]);
+            case NmMessageCreated: {
+                // mIgnoreFolderIds is true if (and only if) this model is used
+                // for mail search purposes and thus, we do not want the model
+                // to handle "message created" events. Issue to consider:
+                // renaming mIgonreFolderIds => mModelUsedForSearch or something
+                // similar.
+                if (!mIgnoreFolderIds && !itemFromModel(messageIds[i])) {
+                    insertNewMessageIntoModel(mailboxId, folderId, messageIds[i]);
                 }
+                
+                break;
             }
-        } else {
-            for (int a(0); a < messageIds.count(); a++) {
-                removeMessageFromModel(messageIds[a]);
+            case NmMessageFound: {
+                if (!itemFromModel(messageIds[i])) {
+                    insertNewMessageIntoModel(mailboxId, folderId, messageIds[i]);
+                }
+
+                break;
+            }
+            case NmMessageDeleted: {
+                removeMessageFromModel(messageIds[i]);
+                break;
             }
         }
     }
 }
 
+
 /*!
     Function inserts new message into correct position to model.
     A new title divider is created if it is needed.
- */
+*/
 void NmMessageListModel::insertNewMessageIntoModel(
     const NmId &mailboxId,
     const NmId &folderId,
     const NmId &msgId)
 {
-    NMLOG(QString("NmMessageListModel::insertNewMessageIntoModel"));
+    NM_FUNCTION;
+    
     // envelope ownership is here
     NmMessageEnvelope *newMsgEnve = mDataManager.envelopeById(mailboxId, folderId, msgId);
     if (newMsgEnve) {
@@ -266,11 +353,12 @@
 /*!
     Function check model index in which the new message should be inserted
     with the currently active sort mode.
- */
+*/
 int NmMessageListModel::getInsertionIndex(
     const NmMessageEnvelope &envelope) const
 {
-    // NMLOG(QString("nmailuiengine: getInsertionIndex"));
+    NM_FUNCTION;
+    
     int ret(NmNotFoundError);
     
     // Date+descending sort mode based comparison.
@@ -300,9 +388,11 @@
 /*!
     Function finds preceding title divider index and sets the
     mParentPtr variable.
- */
+*/
 int NmMessageListModel::dividerInsertionIndex(int messageIndex)
 {
+    NM_FUNCTION;
+    
     bool found(false);
     int ret(NmNoError);
     QModelIndex index;
@@ -322,10 +412,12 @@
 
 /*!
     Create title divider item
- */
+*/
 NmMessageListModelItem *NmMessageListModel::createTitleDividerItem(
 		NmMessageEnvelope *messageForDivider)
 {
+    NM_FUNCTION;
+    
     NmMessageListModelItem *item = new NmMessageListModelItem();
     item->setItemType(NmMessageListModelItem::NmMessageItemTitleDivider);
 
@@ -351,11 +443,12 @@
 
 /*!
     Create message item
- */
+*/
 NmMessageListModelItem *NmMessageListModel::createMessageItem(
 		NmMessageEnvelope *envelope)
 {
-
+    NM_FUNCTION;
+    
     NmMessageListModelItem *mailItem = new NmMessageListModelItem();
     mailItem->setEnvelope(*envelope);
     mailItem->setItemType(NmMessageListModelItem::NmMessageItemMessage);
@@ -365,45 +458,72 @@
 
 /*!
     Returns divider state
- */
+*/
 bool NmMessageListModel::dividersActive()
 {
+    NM_FUNCTION;
+    
     return mDividersActive;
 }
 
 /*!
     Set divider state
- */
+*/
 void NmMessageListModel::setDividers(bool active)
 {
+    NM_FUNCTION;
+    
     mDividersActive = active;
 }
 
 /*!
    Change item property if differs
- */
+*/
 void NmMessageListModel::setEnvelopeProperties(
     NmEnvelopeProperties property,
     const QList<NmId> &messageIds)
 {
+    NM_FUNCTION;
+    
     for (int i(0); i < messageIds.count(); i++) {
         updateEnvelope(property, messageIds[i]);
     }
 }
 
+
 /*!
-   Returns the id of the current mailbox
- */
+    Returns the ID of the current mailbox.
+*/
 NmId NmMessageListModel::currentMailboxId()
 {
+    NM_FUNCTION;
+    
     return mCurrentMailboxId;
 }
 
+
+/*!
+    Sets whether the model should ignore the folder IDs or not. The folder IDs
+    should be ignored e.g. when the model is used for searching messages
+    (i.e. used by the search view).
+
+    \param ignore If true, will ignore the folder IDs.
+*/
+void NmMessageListModel::setIgnoreFolderIds(bool ignore)
+{
+    NM_FUNCTION;
+    
+    mIgnoreFolderIds = ignore;
+}
+
+
 /*!
    Remove message from model if message exists in model
- */
+*/
 void NmMessageListModel::removeMessageFromModel(const NmId &msgId)
 {
+    NM_FUNCTION;
+    
     QList<QStandardItem*> items = findItems("*", Qt::MatchWildcard | Qt::MatchRecursive);
     int count(items.count());
     bool found(false);
@@ -453,18 +573,22 @@
 
 /*!
    Helper function to remove row
- */
+*/
 void NmMessageListModel::removeItem(int row, NmMessageListModelItem &item)
 {
+    NM_FUNCTION;
+    
     QStandardItem *parent = item.parent();
     removeRow(row, indexFromItem(parent));
 }
 
 /*!
    Search item from model
- */
+*/
 NmMessageListModelItem *NmMessageListModel::itemFromModel(const NmId &messageId)
 {
+    NM_FUNCTION;
+    
     QList<QStandardItem*> items = findItems("*", Qt::MatchWildcard | Qt::MatchRecursive);
     int count(items.count());
     bool found(false);
@@ -485,19 +609,23 @@
 
 /*!
    Helper function for envelope comparison
- */
+*/
 bool NmMessageListModel::changed(const NmMessageEnvelope &first, const NmMessageEnvelope &second)
 {
+    NM_FUNCTION;
+    
     return first != second;
 }
 
 /*!
    Updates envelope if something is changed
- */
+*/
 void NmMessageListModel::updateMessageEnvelope(const NmId &mailboxId,
         const NmId &folderId,
         const NmId &msgId)
 {
+    NM_FUNCTION;
+    
     NmMessageListModelItem *item = itemFromModel(msgId);
     // envelope ownership is here
     NmMessageEnvelope *newEnvelope = mDataManager.envelopeById(mailboxId, folderId, msgId);
@@ -514,9 +642,11 @@
 
 /*!
    Update envelope property
- */
+*/
 void NmMessageListModel::updateEnvelope(NmEnvelopeProperties property, const NmId &msgId)
 {
+    NM_FUNCTION;
+    
     NmMessageListModelItem *item = itemFromModel(msgId);
     if (item) {
         bool changed(false);
--- a/emailuis/nmailuiengine/src/nmmessagelistmodelitem.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmmessagelistmodelitem.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -51,6 +51,8 @@
 */
 NmMessageListModelItem::NmMessageListModelItem()
 {
+    NM_FUNCTION;
+    
     d = new NmMessageListModelItemPrivate();
 }
 
@@ -60,6 +62,8 @@
 */
 NmMessageListModelItem::~NmMessageListModelItem()
 {
+    NM_FUNCTION;
+    
     delete d;
 }
 
@@ -68,6 +72,8 @@
 */
 void NmMessageListModelItem::setEnvelope(const NmMessageEnvelope &envelope)
 {
+    NM_FUNCTION;
+    
     delete d->mEnvelope;
     d->mEnvelope = new NmMessageEnvelope(envelope);
 	emitDataChanged();
@@ -78,6 +84,8 @@
 */
 void NmMessageListModelItem::setEnvelope(NmMessageEnvelope *envelope)
 {
+    NM_FUNCTION;
+    
     if (envelope) {
         delete d->mEnvelope;
         d->mEnvelope = envelope;
@@ -90,6 +98,8 @@
 */
 const NmMessageEnvelope &NmMessageListModelItem::envelope() const
 {
+    NM_FUNCTION;
+    
     if (!d->mEnvelope) {
         d->mEnvelope = new NmMessageEnvelope();
     }
@@ -102,6 +112,8 @@
 */
 NmMessageEnvelope *NmMessageListModelItem::envelopePtr()
 {
+    NM_FUNCTION;
+    
     if (!d->mEnvelope) {
         d->mEnvelope = new NmMessageEnvelope();
     }
@@ -113,6 +125,8 @@
 */
 NmMessageListModelItem::NmMessageItemType NmMessageListModelItem::itemType() const
 {
+    NM_FUNCTION;
+    
     return d->mType;
 }
 
@@ -121,6 +135,8 @@
 */
 void NmMessageListModelItem::setItemType(NmMessageListModelItem::NmMessageItemType type)
 {
+    NM_FUNCTION;
+    
     d->mType = type;
 }
 
@@ -129,6 +145,8 @@
 */
 QString NmMessageListModelItem::titleDivider() const
 {
+    NM_FUNCTION;
+    
     return d->mDivider;
 }
 
@@ -137,6 +155,8 @@
 */
 void NmMessageListModelItem::setTitleDivider(const QString &divider)
 {
+    NM_FUNCTION;
+    
     d->mDivider = divider;
 }
 
@@ -145,6 +165,8 @@
 */
 bool NmMessageListModelItem::expanded() const
 {
+    NM_FUNCTION;
+    
     return d->mExpanded;
 }
 
@@ -153,6 +175,8 @@
 */
 void NmMessageListModelItem::setExpanded(bool expanded)
 {
+    NM_FUNCTION;
+    
     d->mExpanded = expanded;
 }
 
@@ -161,5 +185,7 @@
  */
 void NmMessageListModelItem::callEmitDataChanged()
 {
+    NM_FUNCTION;
+    
     emitDataChanged();
 }
--- a/emailuis/nmailuiengine/src/nmmessagesearchlistmodel.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +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:
-*
-*/
-
-#include "nmuiengineheaders.h"
-
-/*!
-    \class NmMessageSearchListModel
-    \brief A proxy model used to filter out messages from the message list model
-           that are not amongst the search results.
-*/
-
-/*!
-    Class constructor.
-*/
-NmMessageSearchListModel::NmMessageSearchListModel(QObject *parent)
-: QSortFilterProxyModel(parent)
-{
-    // No implementation required.
-}
-
-
-/*!
-    Class destructor.
-*/
-NmMessageSearchListModel::~NmMessageSearchListModel()
-{
-    clearSearchResults();
-}
-
-
-/*!
-    Clears search results and removes the accepted source model items from this
-    proxy model.
-*/
-void NmMessageSearchListModel::clearSearchResults()
-{
-    mSearchResults.clear();
-    invalidateFilter();
-}
-
-
-/*!
-    Returns the number of search results i.e. IDs in the container.
-
-    \return The number of search results.
-*/
-int NmMessageSearchListModel::searchResultCount() const
-{
-    return mSearchResults.count();
-}
-
-
-/*!
-    From QSortFilterProxyModel.
-    Returns the data from the source model according to the given proxy index.
-
-    \param index The index of this proxy model.
-    \param role The item role.
-
-    \return The item data wrapped in a QVariant.
-*/
-QVariant NmMessageSearchListModel::data(const QModelIndex &index,
-                                        int role /* = Qt::DisplayRole */) const
-{
-    QVariant retVal;
-    QAbstractItemModel *model = sourceModel();
-
-    if (model) {
-        // Return the data from the source model by mapping the given index
-        // in respect to the source model.
-        QModelIndex sourceIndex = mapToSource(index);
-        retVal = model->data(sourceIndex, role);
-    }
-    else {
-        // Since no source model set, use the base class method implementation.
-        retVal = QSortFilterProxyModel::data(index, role);
-    }
-
-    return retVal;
-}
-
-
-/*!
-    From QSortFilterProxyModel.
-    Filters the items of the source model depending on the current search results.
-
-    \param source_row A source model row index.
-    \param source_parent The parent model index of the row.
-
-    \return True if the row should be accepted to the search list model, false
-            otherwise.
-*/
-bool NmMessageSearchListModel::filterAcceptsRow(int source_row,
-                                                const QModelIndex &source_parent) const
-{
-    bool accept(false);
-
-    // Get the source model.
-    NmMessageListModel *model = qobject_cast<NmMessageListModel*>(sourceModel());
-
-    if (model) {
-        // Extract the model item corresponding the given row and index.
-        QModelIndex listIndex = model->index(source_row, 0, source_parent);
-        QVariant qVariant = model->data(listIndex);
-        NmMessageListModelItem *item = qVariant.value<NmMessageListModelItem*>();
-
-        if (item) {
-            // Get the message ID from the item and compare it to the current
-            // search results.
-            const NmId itemId = item->envelope().messageId();
-
-            if (mSearchResults.contains(itemId)) {
-                // The message ID matches the search result => do accept the row.
-                accept = true;
-            }
-        }
-    }
-
-    return accept;
-}
-
-
-/*!
-    Adds the given message ID to the search results.
-
-    \param messageId The ID to add.
-
-    \return True if the given ID was added, false otherwise.
-*/
-bool NmMessageSearchListModel::addSearchResult(const NmId &messageId)
-{
-    bool resultAdded(false);
-
-    // Make sure not to add the same ID twice.
-    if (!mSearchResults.contains(messageId)) {
-        // Add the given ID to the results.
-        mSearchResults.append(messageId);
-        resultAdded = true;
-
-        // Invalidate the filter in order to update the model. This forces
-        // filterAcceptsRow() to be ran again for each row in the source model.
-        invalidateFilter();
-    }
-
-    return resultAdded;
-}
-
-
-/*!
-    Refreshes the content by forcing the model to re-process the source model
-    items using the current filter (search results).
-*/
-void NmMessageSearchListModel::refreshContent()
-{
-    invalidateFilter();
-}
-
-
-// End of file.
--- a/emailuis/nmailuiengine/src/nmoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -25,6 +25,8 @@
 : mProgress(0),
   mIsRunning(true)
 {
+    NM_FUNCTION;
+    
     QMetaObject::invokeMethod(this, "runAsyncOperation", Qt::QueuedConnection);
 }
 
@@ -33,6 +35,8 @@
  */
 NmOperation::~NmOperation()
 {
+    NM_FUNCTION;
+    
     while (!mPreliminaryOperations.isEmpty()) {
         QPointer<NmOperation> operation = mPreliminaryOperations.takeLast();
         if (operation && operation->isRunning()) {
@@ -46,6 +50,8 @@
  */
 bool NmOperation::isRunning() const
 {
+    NM_FUNCTION;
+    
     return mIsRunning;
 }
 
@@ -54,13 +60,19 @@
  */
 void NmOperation::addPreliminaryOperation(NmOperation *operation)
 {
-    connect(operation, SIGNAL(operationCompleted()), this,
-        SLOT(handlePreliminaryOperationFinished()));
-
-    connect(operation, SIGNAL(operationCancelled()), this,
-        SLOT(handlePreliminaryOperationFinished()));
-
-    mPreliminaryOperations.append(operation);
+    NM_FUNCTION;
+    
+    // if the preliminary operation is already completed
+    // the input parameter can be null
+    if (operation && operation->isRunning()) {
+        connect(operation, SIGNAL(operationCompleted()), this,
+            SLOT(handlePreliminaryOperationFinished()));
+    
+        connect(operation, SIGNAL(operationCancelled()), this,
+            SLOT(handlePreliminaryOperationFinished()));
+    
+        mPreliminaryOperations.append(operation);
+    }
 }
 
 /*!
@@ -71,6 +83,8 @@
  */
 void NmOperation::completeOperation(int result)
 {
+    NM_FUNCTION;
+    
     mIsRunning = false;
     // Operation is completed, emit the signal
     doCompleteOperation();
@@ -85,6 +99,8 @@
  */
 void NmOperation::cancelOperation()
 {
+    NM_FUNCTION;
+    
     mIsRunning = false;
     // Operation is canceled, emit the signal
     this->doCancelOperation();
@@ -98,6 +114,8 @@
  */
 void NmOperation::updateOperationProgress(int progress)
 {
+    NM_FUNCTION;
+    
     mProgress = progress;
     this->doUpdateOperationProgress();
     emit this->operationProgressChanged(mProgress);
@@ -111,6 +129,8 @@
  */
 void NmOperation::runAsyncOperation()
 {
+    NM_FUNCTION;
+    
     int count = mPreliminaryOperations.count();
     int ready = 0;
     // go through preliminary operations
@@ -133,6 +153,8 @@
  */
 void NmOperation::handlePreliminaryOperationFinished()
 {
+    NM_FUNCTION;
+    
     QMetaObject::invokeMethod(this, "runAsyncOperation", Qt::QueuedConnection);
 }
 
@@ -144,7 +166,7 @@
  */ 
 void NmOperation::doCompleteOperation()
 {
-    
+    NM_FUNCTION;
 }
 
 /*!
@@ -155,6 +177,7 @@
  */
 void NmOperation::doCancelOperation()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -165,6 +188,7 @@
  */
 void NmOperation::doUpdateOperationProgress()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -174,6 +198,8 @@
  */
 void NmOperation::deleteOperation()
 {
+    NM_FUNCTION;
+    
     this->deleteLater();   
 }
 
--- a/emailuis/nmailuiengine/src/nmuiengine.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiengine/src/nmuiengine.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -27,15 +27,23 @@
 NmUiEngine *NmUiEngine::mInstance;
 int NmUiEngine::mReferenceCount;
 
+const QString syncIndicatorName = "com.nokia.nmail.indicatorplugin.sync/1.0";
+
 /*!
     Constructor
 */
 NmUiEngine::NmUiEngine() 
 : mMailboxListModel(NULL),
+  mInboxListModel(NULL),
   mMessageListModel(NULL),
   mMessageSearchListModel(NULL),
-  mSendOperation(NULL)
+  mSendOperation(NULL),
+  mRemoveDraftOperation(NULL),
+  mSaveDraftOperation(NULL),
+  mDraftMessage(NULL)
 {
+    NM_FUNCTION;
+    
     mPluginFactory = NmDataPluginFactory::instance();
     mDataManager = new NmDataManager();
     // Connect to the plugins to receive change notifications
@@ -74,46 +82,86 @@
 
 
 /*!
-    Destructor
+    Class destructor.
 */
 NmUiEngine::~NmUiEngine()
 {
+    NM_FUNCTION;
+    
+    HbIndicator indicator;
+    indicator.deactivate(syncIndicatorName, QVariant());
+    
     if (mMessageSearchListModel) {
         delete mMessageSearchListModel;
         mMessageSearchListModel = NULL;
     }
 
+    if (mInboxListModel) {
+        delete mInboxListModel;
+        mInboxListModel = NULL;
+    }
+
     if (mMessageListModel) {
         delete mMessageListModel;
         mMessageListModel = NULL;
     }
+
     if (mMailboxListModel) {
         delete mMailboxListModel;
         mMailboxListModel = NULL;
     }
-    // do the unsubscriptions
+
+    // Do the unsubscriptions.
     QList<NmId> mailboxIdList;
     mDataManager->listMailboxIds(mailboxIdList);
+
     for (int i(0); i < mailboxIdList.count(); i++) {
         NmId id = mailboxIdList[i];
-        NmDataPluginInterface *pluginInterface = mPluginFactory->interfaceInstance(id);
+        NmDataPluginInterface *pluginInterface =
+            mPluginFactory->interfaceInstance(id);
+
         if (pluginInterface) {
             pluginInterface->unsubscribeMailboxEvents(id);
         }
     }
+
     mailboxIdList.clear();
+
     NmDataPluginFactory::releaseInstance(mPluginFactory);
+
     delete mDataManager;
+
+    // Cancel all operations.
     if (mSendOperation && mSendOperation->isRunning()) {
         mSendOperation->cancelOperation();
     }
+
+    if (mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) {
+        mRemoveDraftOperation->cancelOperation();        
+    }
+
+    if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
+        mSaveDraftOperation->cancelOperation();
+    }
+
+    // Call processEvents() to ensure that the cancelled operations get the time
+    // they need to destroy themselves.
+    qApp->processEvents();
+
+    if(mDraftMessage) {
+        delete mDraftMessage;
+        mDraftMessage = NULL;
+    }
 }
 
+
 /*!
 
 */
 NmUiEngine *NmUiEngine::instance()
 {
+    NM_FUNCTION;
+    
     if (!mInstance) {
     	mInstance = new NmUiEngine();
     }
@@ -126,6 +174,8 @@
 */
 void NmUiEngine::releaseInstance(NmUiEngine *&instance)
 {
+    NM_FUNCTION;
+    
     //can't have passed out instances if we don't have any
     if (mInstance) {
         if(instance == mInstance) {
@@ -145,6 +195,8 @@
 */
 NmMailboxListModel &NmUiEngine::mailboxListModel()
 {
+    NM_FUNCTION;
+    
     if (!mMailboxListModel) {
         refreshMailboxListModel(); // creates the model too
     }
@@ -158,6 +210,8 @@
 */
 void NmUiEngine::refreshMailboxListModel()
 {
+    NM_FUNCTION;
+    
     if (!mMailboxListModel) {
         mMailboxListModel = new NmMailboxListModel(*mDataManager);
         
@@ -182,59 +236,129 @@
     }
 }
 
+
 /*!
-    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.
+    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.
 */
-NmMessageListModel &NmUiEngine::messageListModel(const NmId &mailboxId, const NmId &folderId)
+NmMessageListModel &NmUiEngine::messageListModel(const NmId &mailboxId,
+                                                 const NmId &folderId)
 {
-    if (!mMessageListModel){
-        mMessageListModel = new NmMessageListModel(*mDataManager);
+    NM_FUNCTION;
+
+    QObject *plugin = mPluginFactory->pluginInstance(mailboxId);
+    bool isInbox(false);
+    if (standardFolderId(mailboxId,NmFolderInbox)==folderId){
+        isInbox=true;
     }
-    else{
-        mMessageListModel->clear();
+    if (plugin) { 
+        // Connect plugin message events to handler slot messageEventForListModel
+        QObject::connect(plugin, SIGNAL(messageEvent(NmMessageEvent, const NmId &, 
+                                const QList<NmId> &, const NmId&)),
+                                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    
+        if ((!mInboxListModel&&isInbox)||
+            (mInboxListModel&&isInbox&&mailboxId!=mInboxListModel->currentMailboxId())){
+            // Delete previous model and set to NULL. Deleting model will also
+            // delete all items in model. 
+            if (mInboxListModel){
+                delete mInboxListModel;
+                mInboxListModel=NULL;
+            }
+            // Create new inbox model 
+            mInboxListModel = new NmMessageListModel(*mDataManager);
+            // Initial fill up of inbox list model, otherwise updated in the background
+            QList<NmMessageEnvelope*> messageEnvelopeList;
+            mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList);
+            mInboxListModel->refresh(mailboxId, folderId, messageEnvelopeList);
+
+            while (!messageEnvelopeList.isEmpty()) {
+                delete messageEnvelopeList.takeFirst();
+            }
+        }
+        // Selected folder is not inbox folder for the mailbox
+        else if (!isInbox){
+            // Recreate model for other folders when needed, previous model
+            // items are deleted from the memory with the old model
+            if (mMessageListModel){
+                delete mMessageListModel;
+                mMessageListModel=NULL;
+            }
+            mMessageListModel = new NmMessageListModel(*mDataManager);
+    
+            // Fill up other model 
+            QList<NmMessageEnvelope*> messageEnvelopeList;
+            mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList);
+            mMessageListModel->refresh(mailboxId, folderId, messageEnvelopeList);
+
+            while (!messageEnvelopeList.isEmpty()) {
+                delete messageEnvelopeList.takeFirst(); 
+            }             
+        }    
     }
-    QObject *plugin =
-        mPluginFactory->pluginInstance(mailboxId);
-    if (plugin) {
-        QObject::connect(plugin,
-            SIGNAL(messageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)),
-        mMessageListModel,
-            SLOT(handleMessageEvent(NmMessageEvent, const NmId &, const QList<NmId> &)),
-            Qt::UniqueConnection );
-
+     
+    // Connect sync state changed
+    if (plugin){
         QObject::connect(
             plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent &)),
             this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent &)),
-            Qt::UniqueConnection);        
-        // no need for mailbox event subscription here, already done in constructor
+            Qt::UniqueConnection);
     }
-    QList<NmMessageEnvelope*> messageEnvelopeList;
-    mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList);
-    mMessageListModel->refresh(mailboxId, folderId, messageEnvelopeList);
-    while (!messageEnvelopeList.isEmpty()) {
-        delete messageEnvelopeList.takeFirst();
+    NmMessageListModel* ret(NULL);
+    if (isInbox){
+        ret = mInboxListModel;    
+        // Inbox list model is queried, other model is not
+        // needed anymore and memory should be freeded
+        if (mMessageListModel){
+            delete mMessageListModel;
+            mMessageListModel=NULL;
+        }
     }
-    return *mMessageListModel;
+    else {
+        ret = mMessageListModel;    
+    }
+    return *ret;
 }
 
 
 /*!
-    Returns a reference of the message search list model. If the model does not
-    exist yet, one is constructed.
+    Returns a message list model used in the search view.
 
-    \param sourceModel The source model for the search list model.
+    \param mailboxId The ID of the mailbox to search messages from.
 
-    \return The message search list model.
+    \return A message list model.
 */
-NmMessageSearchListModel &NmUiEngine::messageSearchListModel(
-    QAbstractItemModel *sourceModel)
+NmMessageListModel &NmUiEngine::messageListModelForSearch(const NmId &mailboxId)
 {
+    NM_FUNCTION;
+    
+    Q_UNUSED(mailboxId);
+
     if (!mMessageSearchListModel) {
-        mMessageSearchListModel = new NmMessageSearchListModel();
+        mMessageSearchListModel = new NmMessageListModel(*mDataManager);
+        mMessageSearchListModel->setIgnoreFolderIds(true);
+    }
+    else {
+        mMessageSearchListModel->clear();
     }
 
-    mMessageSearchListModel->setSourceModel(sourceModel);
+    QObject *plugin = mPluginFactory->pluginInstance(mailboxId);
+
+    if (plugin) {
+        QObject::connect(plugin,
+            SIGNAL(messageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)),
+            mMessageSearchListModel,
+            SLOT(handleMessageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)),
+            Qt::UniqueConnection);
+    }
+
+    // Refresh to set the mailbox ID.
+    QList<NmMessageEnvelope*> messageEnvelopeList;
+    mMessageSearchListModel->refresh(mailboxId, 0, messageEnvelopeList);
+
     return *mMessageSearchListModel;
 }
 
@@ -247,6 +371,8 @@
     const NmId &mailboxId,
     NmFolderType folderType)
 {
+    NM_FUNCTION;
+    
     NmId value;
     if (folderType != NmFolderOther) {
         NmDataPluginInterface *plugin =
@@ -267,6 +393,8 @@
                       const NmId &folderId,
                       const NmId &messageId)
 {
+    NM_FUNCTION;
+    
     NmMessage *message = mDataManager->message(mailboxId, folderId, messageId);
     return message;
 }
@@ -278,7 +406,8 @@
     const NmId &folderId,
     const NmId &messageId )
 {
-    NMLOG("NmUiEngine::fetchMessage() <---");
+    NM_FUNCTION;
+    
     QPointer<NmOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -297,7 +426,8 @@
     const NmId &messageId,
     const NmId &messagePartId)
 {
-    NMLOG("NmUiEngine::fetchMessagePart() <---");
+    NM_FUNCTION;
+    
     QPointer<NmOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -310,12 +440,34 @@
 /*!
 
 */
+QPointer<NmOperation> NmUiEngine::fetchMessageParts(
+    const NmId &mailboxId,
+    const NmId &folderId,
+    const NmId &messageId,
+    const QList<NmId> &messagePartIds)
+{
+    NM_FUNCTION;
+    
+    QPointer<NmOperation> value(NULL);
+    NmDataPluginInterface *plugin =
+        mPluginFactory->interfaceInstance(mailboxId);
+    if (plugin) {
+        value = plugin->fetchMessageParts(mailboxId, folderId, messageId, messagePartIds);
+    }
+    return value;
+}
+
+/*!
+
+*/
 XQSharableFile NmUiEngine::messagePartFile(
         const NmId &mailboxId,
         const NmId &folderId,
         const NmId &messageId,
         const NmId &messagePartId)
 {
+    NM_FUNCTION;
+    
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
@@ -335,33 +487,70 @@
     const NmId &messageId,
     NmMessagePart &messagePart)
 {
+    NM_FUNCTION;
+    
     return mDataManager->contentToMessagePart(mailboxId, folderId, messageId, messagePart);
 }
 
+
 /*!
-    Deletes messages from model and routes call to plugin
+    Deletes messages from the model and forwards the call to plugin.
+
+    \param mailboxId The ID of the mailbox which contains the deleted message(s).
+    \param folderId The ID of the folder which contains the deleted message(s).
+    \param messageIdList A list containing the IDs of the message to be deleted.
+
+    \return A possible error code (returned by the plugin).
 */
-int NmUiEngine::deleteMessages(
-	const NmId &mailboxId,
-	const NmId &folderId,
-	const QList<NmId> &messageIdList)
+int NmUiEngine::deleteMessages(const NmId &mailboxId,
+                               const NmId &folderId,
+                               const QList<NmId> &messageIdList)
 {
+    NM_FUNCTION;
+    
     int result(NmNotFoundError);
-	if (mMessageListModel) {
-	    mMessageListModel->handleMessageEvent(NmMessageDeleted, folderId, messageIdList);
+    
+    bool isInbox(false);
+    if (standardFolderId(mailboxId,NmFolderInbox)==folderId){
+        isInbox=true;
+    } 
+    if (isInbox&&mInboxListModel){
+        mInboxListModel->handleMessageEvent(NmMessageDeleted, folderId,
+                                               messageIdList, mailboxId);   
+    }   
+    else if (mMessageListModel) {
+	    mMessageListModel->handleMessageEvent(NmMessageDeleted, folderId,
+                                              messageIdList, mailboxId);
 	}
+
+	// If the search list model exists and contains message, remove the
+	// message from it too.
+	if (mMessageSearchListModel && mMessageSearchListModel->rowCount()) {
+        mMessageSearchListModel->handleMessageEvent(NmMessageDeleted, folderId,
+                                                    messageIdList, mailboxId);
+	}
+
     NmDataPluginInterface *plugin =
-            mPluginFactory->interfaceInstance(mailboxId);
+        mPluginFactory->interfaceInstance(mailboxId);
+
     if (plugin) {
-          result = plugin->deleteMessages(
-	            mailboxId, folderId, messageIdList);
+          result = plugin->deleteMessages(mailboxId, folderId, messageIdList);
     }
+
 	return result;
 }
 
+
 /*!
-    Sets envelope property given in argument.
-    Operation is automatically deleted after completion or cancelling.
+    Sets the envelope property for the given envelopes.
+    The operation is automatically deleted after the completion or cancelling.
+
+    \param mailboxId The ID of the mailbox containing the envelope(s).
+    \param folderId The ID of the folder containing the envelope(s).
+    \param property The property to set.
+    \param envelopeList The list containing the envelopes.
+
+    \return The constructed operation.
 */
 QPointer<NmStoreEnvelopesOperation> NmUiEngine::setEnvelopes(
         const NmId &mailboxId,
@@ -369,26 +558,42 @@
         NmEnvelopeProperties property,
         const QList<const NmMessageEnvelope*> &envelopeList)
 {
-    NMLOG("NmUiEngine::setEnvelopes() <---");
+    NM_FUNCTION;
+    
     QPointer<NmStoreEnvelopesOperation> operation(NULL);
-    if (mMessageListModel && envelopeList.count()) {
+    NmMessageListModel *theMessageListModel = mMessageListModel;
+
+    if (!theMessageListModel) {
+        theMessageListModel = &messageListModel(mailboxId, folderId);
+    }
+
+    if (theMessageListModel && envelopeList.count()) {
         QList<NmId> messageIdList;
         
         for (int i(0); i < envelopeList.count(); i++){
             messageIdList.append(envelopeList[i]->messageId());
         }
-        mMessageListModel->setEnvelopeProperties(
-                           property, messageIdList);
-        // Store new envelopes to plugin
+
+        theMessageListModel->setEnvelopeProperties(property, messageIdList);
+
+        if (mMessageSearchListModel && mMessageSearchListModel->rowCount()) {
+            // Update the envelopes in the search list model as well.
+            mMessageSearchListModel->setEnvelopeProperties(property,
+                                                           messageIdList);
+        }
+
+        // Store the new envelopes to plugin.
         NmDataPluginInterface *plugin =
             mPluginFactory->interfaceInstance(mailboxId);
+
         if (plugin) {
-            operation = plugin->storeEnvelopes(
-                    mailboxId, folderId, envelopeList);
+            operation =
+                plugin->storeEnvelopes(mailboxId, folderId, envelopeList);
         }
+
         messageIdList.clear();
-    }  
-    NMLOG("NmUiEngine::setEnvelopes() --->");
+    }
+
     return operation;
 }
 
@@ -422,7 +627,8 @@
 */
 QPointer<NmMessageCreationOperation> NmUiEngine::createNewMessage(const NmId &mailboxId)
 {
-    NMLOG("NmUiEngine::createNewMessage() <---");
+    NM_FUNCTION;
+    
     QPointer<NmMessageCreationOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -440,7 +646,8 @@
         const NmId &mailboxId,
         const NmId &originalMessageId)
 {
-    NMLOG("NmUiEngine::createForwardMessage() <---");
+    NM_FUNCTION;
+    
     QPointer<NmMessageCreationOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -459,7 +666,8 @@
         const NmId &originalMessageId,
         bool replyAll)
 {
-    NMLOG("NmUiEngine::createReplyMessage() <---");
+    NM_FUNCTION;
+    
     QPointer<NmMessageCreationOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -474,6 +682,8 @@
 */
 int NmUiEngine::saveMessage(const NmMessage &message)
 {
+    NM_FUNCTION;
+    
     const NmId &mailboxId = message.envelope().mailboxId();
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
@@ -489,11 +699,17 @@
 */
 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());
+        }
     }
     return ret;
 }
@@ -503,6 +719,8 @@
 */
 int NmUiEngine::goOnline(const NmId &mailboxId )
 {
+    NM_FUNCTION;
+    
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -517,6 +735,8 @@
 */
 int NmUiEngine::goOffline(const NmId &mailboxId )
 {
+    NM_FUNCTION;
+    
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -535,6 +755,8 @@
     const NmId &folderId,
     const NmId &messageId)
 {
+    NM_FUNCTION;
+    
     int result(NmNotFoundError);
     NmDataPluginInterface *plugin =
             mPluginFactory->interfaceInstance(mailboxId);
@@ -546,10 +768,89 @@
 
 
 /*!
+  Handles draft message deletion after editor has closed, takes ownership of message. 
+ */
+void NmUiEngine::removeDraftMessage(NmMessage *message)
+{
+    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 mRemoveDraftOperation != NULL
+            if (mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) {
+                mRemoveDraftOperation->cancelOperation();
+            }
+            // ownership of message changes
+            mRemoveDraftOperation = plugin->removeDraftMessage(message);
+            
+            if (mRemoveDraftOperation) {
+                connect(mRemoveDraftOperation, 
+                        SIGNAL(operationCompleted(int)), 
+                        this, 
+                        SLOT(handleCompletedRemoveDraftOperation()));
+            }
+        }
+    }    
+}
+
+/*!
+    Handles draft message saving after editor has closed, takes ownership of message.
+ */
+void NmUiEngine::saveDraftMessage(NmMessage *message,
+                                  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 
+                // copy so we handle the msg object deletion in engine. mDraftMessage is deleted
+                // 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, 
+                        SLOT(handleCompletedSaveDraftOperation()));
+                
+            }
+        }
+    }
+}
+
+/*!
     Sends the given message.
  */
 void NmUiEngine::sendMessage(NmMessage *message, const QList<NmOperation *> &preliminaryOperations)
 {
+    NM_FUNCTION;
+    
     //First trigger message storing
     if (message) {
         NmDataPluginInterface *plugin =
@@ -585,6 +886,8 @@
  */
 bool NmUiEngine::isSendingMessage() const
 {
+    NM_FUNCTION;
+    
     int ret(false);
     if (mSendOperation && mSendOperation->isRunning()) {
         ret = true;
@@ -597,6 +900,8 @@
  */
 const NmMessage *NmUiEngine::messageBeingSent() const
 {
+    NM_FUNCTION;
+    
     const NmMessage *message = NULL;
     
     if (mSendOperation != NULL) {
@@ -614,7 +919,8 @@
     const NmMessage &message,
     const QList<QString> &fileList)
 {
-    NMLOG("NmUiEngine::addAttachments() <---");
+    NM_FUNCTION;
+    
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(message.envelope().mailboxId());
     
@@ -633,7 +939,8 @@
     const NmMessage &message,
     const NmId &attachmentPartId)
 {
-    NMLOG("NmUiEngine::removeAttachments() <---");
+    NM_FUNCTION;
+    
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(message.envelope().mailboxId());
     
@@ -645,26 +952,12 @@
 }
 
 /*!
-    Operation is automatically deleted after completion or cancelling.
- */
-QPointer<NmCheckOutboxOperation> NmUiEngine::checkOutbox(const NmId &mailboxId)
-{
-    NMLOG("NmUiEngine::checkOutbox() <---");
-    NmDataPluginInterface *plugin =
-        mPluginFactory->interfaceInstance(mailboxId);
-
-    QPointer<NmCheckOutboxOperation> ret(NULL); 
-    if (plugin) {
-        ret = plugin->checkOutbox(mailboxId);
-    }  
-    return ret;
-}
-
-/*!
     Returns the current sync state of the mailbox
  */
 NmSyncState NmUiEngine::syncState(const NmId& mailboxId)
 {
+    NM_FUNCTION;
+    
     NmDataPluginInterface *plugin =
                 mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
@@ -680,6 +973,8 @@
  */
 NmConnectState NmUiEngine::connectionState(const NmId& mailboxId)
 {
+    NM_FUNCTION;
+    
     NmDataPluginInterface *plugin =
                 mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
@@ -702,18 +997,24 @@
 int NmUiEngine::search(const NmId &mailboxId,
                        const QStringList &searchStrings)
 {
+    NM_FUNCTION;
+    
     // Get the plugin instance.
     QObject *pluginInstance = mPluginFactory->pluginInstance(mailboxId);
 
     if (pluginInstance) {
         // Make sure the required signals are connected.
-        connect(pluginInstance, SIGNAL(matchFound(const NmId &)),
-                this, SIGNAL(matchFound(const NmId &)), Qt::UniqueConnection);    
-        connect(pluginInstance, SIGNAL(matchFound(const NmId &)),
-                mMessageSearchListModel, SLOT(addSearchResult(const NmId &)),
+        connect(pluginInstance, SIGNAL(matchFound(const NmId &, const NmId &)),
+                this, SIGNAL(matchFound(const NmId &, const NmId &)),
+                Qt::UniqueConnection);
+
+        connect(pluginInstance, SIGNAL(matchFound(const NmId &, const NmId &)),
+                this, SLOT(handleMatchFound(const NmId &, const NmId &)),
+                Qt::UniqueConnection); 
+
+        connect(pluginInstance, SIGNAL(searchComplete()),
+                this, SIGNAL(searchComplete()),
                 Qt::UniqueConnection);    
-        connect(pluginInstance, SIGNAL(searchComplete()),
-                this, SIGNAL(searchComplete()), Qt::UniqueConnection);    
     }
 
     int retVal(NmNoError);
@@ -740,6 +1041,8 @@
 */
 int NmUiEngine::cancelSearch(const NmId &mailboxId)
 {
+    NM_FUNCTION;
+    
     int retVal(NmNoError);
 
     // Get the plugin interface.
@@ -754,53 +1057,81 @@
 }
 
 /*!
-    Cancels the search operation if one is ongoing.
-
-    \param mailboxId The ID of the mailbox containing the folder
-
-    \param folderId The ID of the folder 
-
     \return Folder type
 */
 NmFolderType NmUiEngine::folderTypeById(NmId mailboxId, NmId folderId)
 {
-    NmFolderType folderType(NmFolderOther);
-    if (standardFolderId(mailboxId,NmFolderInbox)==folderId){
-        folderType=NmFolderInbox;
-    }
-    else if (standardFolderId(mailboxId,NmFolderOutbox)==folderId){
-        folderType=NmFolderOutbox; 
+    NM_FUNCTION;
+    
+    NmFolderType ret(NmFolderInbox);
+    if (mDataManager){
+        ret = mDataManager->folderTypeById(mailboxId,folderId);    
     }
-    else if (standardFolderId(mailboxId,NmFolderDrafts)==folderId){
-        folderType=NmFolderDrafts;
+    return ret;
+}
+
+/*!
+    Indicates application state information to protocol plugin
+    \param mailboxId Id of active mailbox, 0 if application is closed.
+    \param folderId Id of active folder, 0 if application is closed.
+*/
+void NmUiEngine::updateActiveFolder(const NmId &mailboxId, const NmId &folderId)
+{
+    NM_FUNCTION;
+    
+    NmApplicationStateInterface *interface = 
+        mPluginFactory->applicationStateInterfaceInstance(mailboxId);
+    if (interface) {
+        interface->updateActiveFolder(mailboxId, folderId);
     }
-    else if (standardFolderId(mailboxId,NmFolderSent)==folderId){
-        folderType=NmFolderSent; 
-    }    
-    else if (standardFolderId(mailboxId,NmFolderDeleted)==folderId){
-        folderType=NmFolderDeleted;  
-    }    
-    return folderType;
 }
+
 /*!
     Handle completed send operation.
 */
 void NmUiEngine::handleCompletedSendOperation()
 {
-    NMLOG("NmUiEngine::handleCompletedSendOperation()");
+    NM_FUNCTION;
+    
     emit sendOperationCompleted();
 }
 
 /*!
+    Handle completed remove draft operation.
+*/
+void NmUiEngine::handleCompletedRemoveDraftOperation()
+{
+    NM_FUNCTION;
+    
+    // draft message deletion observing not yet implemented...
+}
+
+/*!
+    Handle completed save draft operation.
+*/
+void NmUiEngine::handleCompletedSaveDraftOperation()
+{
+    NM_FUNCTION;
+    
+    // delete message object since it's not needed anymore
+    if(mDraftMessage) {
+        delete mDraftMessage;
+        mDraftMessage = NULL;
+    }
+}
+
+/*!
     Handles synch operation related events
  */
 void NmUiEngine::handleSyncStateEvent(NmSyncState syncState, const NmOperationCompletionEvent &event)
 {
-    NMLOG("NmUiEngine::handleSyncStateEvent()");
-
+    NM_FUNCTION;
+    
     if ( syncState == SyncComplete ) {
         // signal for reporting about (sync) operation completion status
         emit operationCompleted(event);
+        HbIndicator indicator;
+        indicator.deactivate(syncIndicatorName, QVariant());
     }
 
     // signal for handling sync state icons
@@ -816,6 +1147,8 @@
                                     const QList<NmId> &messageIds, 
                                     const NmId& mailboxId)
 {
+    NM_FUNCTION;
+    
     switch (event) {
         case NmMessageDeleted:
         {
@@ -836,6 +1169,8 @@
 void NmUiEngine::handleMailboxEvent(NmMailboxEvent event,
                                     const QList<NmId> &mailboxIds)
 {
+    NM_FUNCTION;
+    
     switch (event) {
         case NmMailboxDeleted:
         {
@@ -849,11 +1184,68 @@
     }
 }
 
+
+/*!
+    Adds the found message into the search model.
+
+    \param messageId The ID of the found message.
+    \param folderId The ID of the folder where the message is located.
+*/
+void NmUiEngine::handleMatchFound(const NmId &messageId, const NmId &folderId)
+{
+    NM_FUNCTION;
+    
+    if (!mMessageSearchListModel) {
+        // No search list model!
+        return;
+    }
+
+    // Resolve the folder type.
+    NmId mailboxId = mMessageSearchListModel->currentMailboxId();
+    NmFolderType folderType = folderTypeById(mailboxId, folderId);
+
+    // Do not display matches from outbox or draft folders.
+    if (folderType != NmFolderOutbox && folderType != NmFolderDrafts) {
+        // Add the found message into the search model.
+        QList<NmId> messageIdList;
+        messageIdList.append(messageId);
+
+        mMessageSearchListModel->handleMessageEvent(NmMessageFound, folderId,
+                                                    messageIdList, mailboxId);
+    }
+}
+
+/*!
+    Function sens events from plugin to both models. Inbox model for
+    active mailbox is always alove whereas mMessageListModel can represent
+    other folder in the device (sent, outbox, drafts, etc.)
+*/
+void NmUiEngine::messageEventForListModel(NmMessageEvent event,
+                        const NmId &folderId,
+                        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);   
+    }
+    if (mMessageListModel){
+        mMessageListModel->handleMessageEvent(event, folderId,
+                                              messageIds, mailboxId);    
+    }  
+}
+
 /*!
     receives events when going online, and offline.
 */
 void NmUiEngine::handleConnectEvent(NmConnectState connectState, const NmId &mailboxId, const int errorCode)
 {
+    NM_FUNCTION;
+    
     // signal for connection state icon handling
     emit connectionEvent(connectState, mailboxId);
 
@@ -863,3 +1255,23 @@
         emit operationCompleted(event);
     }
 }
+
+/*!
+    returns full mailbox id from plain account id
+*/
+NmId NmUiEngine::getPluginIdByMailboxId(quint32 accountId)
+{
+    NM_FUNCTION;
+    
+    NmId fullId = NULL;
+    fullId.setId32(accountId);
+    QList<NmId> mailboxList;
+    if(mDataManager){
+        mDataManager->listMailboxIds(mailboxList);
+        for(int i=0;i<mailboxList.count();i++){
+            if(mailboxList.at(i).id32() == accountId)
+                fullId.setPluginId32(mailboxList.at(i).pluginId32());
+            }
+        }
+    return fullId;
+}
--- a/emailuis/nmailuiwidgets/bwins/nmailuiwidgetsu.def	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/bwins/nmailuiwidgetsu.def	Thu Jul 22 16:30:28 2010 +0100
@@ -1,146 +1,133 @@
 EXPORTS
 	?trUtf8@NmAttachmentListItem@@SA?AVQString@@PBD0H@Z @ 1 NONAME ; class QString NmAttachmentListItem::trUtf8(char const *, char const *, int)
-	?screenSize@NmAttachmentListItem@@AAE?AVQSize@@W4Orientation@Qt@@@Z @ 2 NONAME ; class QSize NmAttachmentListItem::screenSize(enum Qt::Orientation)
-	?itemActivated@NmAttachmentListWidget@@IAEXH@Z @ 3 NONAME ; void NmAttachmentListWidget::itemActivated(int)
-	?textCursor@NmHtmlLineEdit@@QBE?AVQTextCursor@@XZ @ 4 NONAME ; class QTextCursor NmHtmlLineEdit::textCursor(void) const
-	?keyPressEvent@NmRecipientLineEdit@@MAEXPAVQKeyEvent@@@Z @ 5 NONAME ; void NmRecipientLineEdit::keyPressEvent(class QKeyEvent *)
-	?sendMouseReleaseEvent@NmEditorTextEdit@@QAEXPAVQGraphicsSceneMouseEvent@@@Z @ 6 NONAME ; void NmEditorTextEdit::sendMouseReleaseEvent(class QGraphicsSceneMouseEvent *)
-	?paint@NmAttachmentListWidget@@UAEXPAVQPainter@@PBVQStyleOptionGraphicsItem@@PAVQWidget@@@Z @ 7 NONAME ; void NmAttachmentListWidget::paint(class QPainter *, class QStyleOptionGraphicsItem const *, class QWidget *)
-	?tr@NmEditorTextEdit@@SA?AVQString@@PBD0H@Z @ 8 NONAME ; class QString NmEditorTextEdit::tr(char const *, char const *, int)
-	?toHtml@NmHtmlLineEdit@@QBE?AVQString@@XZ @ 9 NONAME ; class QString NmHtmlLineEdit::toHtml(void) const
-	?resetFileNameLength@NmAttachmentListItem@@QAEXW4Orientation@Qt@@@Z @ 10 NONAME ; void NmAttachmentListItem::resetFileNameLength(enum Qt::Orientation)
-	?metaObject@NmBaseViewScrollArea@@UBEPBUQMetaObject@@XZ @ 11 NONAME ; struct QMetaObject const * NmBaseViewScrollArea::metaObject(void) const
-	?init@NmEditorTextEdit@@QAEXPAVNmBaseViewScrollArea@@@Z @ 12 NONAME ; void NmEditorTextEdit::init(class NmBaseViewScrollArea *)
-	?emailAddressList@NmRecipientLineEdit@@QAE?AV?$QList@VNmAddress@@@@XZ @ 13 NONAME ; class QList<class NmAddress> NmRecipientLineEdit::emailAddressList(void)
-	?getStaticMetaObject@NmAttachmentListItem@@SAABUQMetaObject@@XZ @ 14 NONAME ; struct QMetaObject const & NmAttachmentListItem::getStaticMetaObject(void)
-	?getStaticMetaObject@NmBaseViewScrollArea@@SAABUQMetaObject@@XZ @ 15 NONAME ; struct QMetaObject const & NmBaseViewScrollArea::getStaticMetaObject(void)
-	?getStaticMetaObject@NmAttachmentListWidget@@SAABUQMetaObject@@XZ @ 16 NONAME ; struct QMetaObject const & NmAttachmentListWidget::getStaticMetaObject(void)
-	??_ENmAttachmentListItem@@UAE@I@Z @ 17 NONAME ; NmAttachmentListItem::~NmAttachmentListItem(unsigned int)
-	?sendMouseMoveEvent@NmEditorTextEdit@@QAEXPAVQGraphicsSceneMouseEvent@@@Z @ 18 NONAME ; void NmEditorTextEdit::sendMouseMoveEvent(class QGraphicsSceneMouseEvent *)
-	?updateEditorHeight@NmEditorTextEdit@@QAEXXZ @ 19 NONAME ; void NmEditorTextEdit::updateEditorHeight(void)
-	?qt_metacast@NmHtmlLineEdit@@UAEPAXPBD@Z @ 20 NONAME ; void * NmHtmlLineEdit::qt_metacast(char const *)
-	?metaObject@NmEditorTextEdit@@UBEPBUQMetaObject@@XZ @ 21 NONAME ; struct QMetaObject const * NmEditorTextEdit::metaObject(void) const
-	?setFileNameText@NmAttachmentListItem@@QAEXABVQString@@@Z @ 22 NONAME ; void NmAttachmentListItem::setFileNameText(class QString const &)
-	?qt_metacast@NmBaseViewScrollArea@@UAEPAXPBD@Z @ 23 NONAME ; void * NmBaseViewScrollArea::qt_metacast(char const *)
-	?tr@NmBaseViewScrollArea@@SA?AVQString@@PBD0H@Z @ 24 NONAME ; class QString NmBaseViewScrollArea::tr(char const *, char const *, int)
-	?qt_metacall@NmAttachmentListWidget@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 25 NONAME ; int NmAttachmentListWidget::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?trUtf8@NmAttachmentListWidget@@SA?AVQString@@PBD0H@Z @ 26 NONAME ; class QString NmAttachmentListWidget::trUtf8(char const *, char const *, int)
-	?qt_metacall@NmRecipientLineEdit@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 27 NONAME ; int NmRecipientLineEdit::qt_metacall(enum QMetaObject::Call, int, void * *)
-	??0NmAttachmentListItem@@QAE@PAVQGraphicsItem@@@Z @ 28 NONAME ; NmAttachmentListItem::NmAttachmentListItem(class QGraphicsItem *)
-	?trUtf8@NmBaseViewScrollArea@@SA?AVQString@@PBD0H@Z @ 29 NONAME ; class QString NmBaseViewScrollArea::trUtf8(char const *, char const *, int)
-	??1NmHtmlLineEdit@@UAE@XZ @ 30 NONAME ; NmHtmlLineEdit::~NmHtmlLineEdit(void)
-	?setProgressBarValue@NmAttachmentListItem@@QAEXH@Z @ 31 NONAME ; void NmAttachmentListItem::setProgressBarValue(int)
-	?trUtf8@NmHtmlLineEdit@@SA?AVQString@@PBD0@Z @ 32 NONAME ; class QString NmHtmlLineEdit::trUtf8(char const *, char const *)
-	??0NmRecipientLineEdit@@QAE@PAVQGraphicsItem@@@Z @ 33 NONAME ; NmRecipientLineEdit::NmRecipientLineEdit(class QGraphicsItem *)
-	?setAttachmentSize@NmAttachmentListWidget@@QAEXHABVQString@@@Z @ 34 NONAME ; void NmAttachmentListWidget::setAttachmentSize(int, class QString const &)
-	?trUtf8@NmEditorTextEdit@@SA?AVQString@@PBD0H@Z @ 35 NONAME ; class QString NmEditorTextEdit::trUtf8(char const *, char const *, int)
-	?setPlainText@NmHtmlLineEdit@@QAEXABVQString@@@Z @ 36 NONAME ; void NmHtmlLineEdit::setPlainText(class QString const &)
-	?longPressGesture@NmBaseViewScrollArea@@MAEXABVQPointF@@@Z @ 37 NONAME ; void NmBaseViewScrollArea::longPressGesture(class QPointF const &)
-	?updateCustomTextColor@NmEditorTextEdit@@QAEXXZ @ 38 NONAME ; void NmEditorTextEdit::updateCustomTextColor(void)
-	?orientationChanged@NmAttachmentListWidget@@AAEXW4Orientation@Qt@@@Z @ 39 NONAME ; void NmAttachmentListWidget::orientationChanged(enum Qt::Orientation)
-	?insertSelectedContacts@NmRecipientLineEdit@@QAEXABVQVariant@@@Z @ 40 NONAME ; void NmRecipientLineEdit::insertSelectedContacts(class QVariant const &)
-	?qt_metacast@NmAttachmentListWidget@@UAEPAXPBD@Z @ 41 NONAME ; void * NmAttachmentListWidget::qt_metacast(char const *)
-	?getStaticMetaObject@NmHtmlLineEdit@@SAABUQMetaObject@@XZ @ 42 NONAME ; struct QMetaObject const & NmHtmlLineEdit::getStaticMetaObject(void)
-	?qt_metacall@NmEditorTextEdit@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 43 NONAME ; int NmEditorTextEdit::qt_metacall(enum QMetaObject::Call, int, void * *)
-	??1NmAttachmentListWidget@@UAE@XZ @ 44 NONAME ; NmAttachmentListWidget::~NmAttachmentListWidget(void)
-	??_ENmRecipientLineEdit@@UAE@I@Z @ 45 NONAME ; NmRecipientLineEdit::~NmRecipientLineEdit(unsigned int)
-	?qt_metacast@NmRecipientLineEdit@@UAEPAXPBD@Z @ 46 NONAME ; void * NmRecipientLineEdit::qt_metacast(char const *)
-	?setCustomTextColor@NmEditorTextEdit@@QAEXABU?$QPair@_NVQColor@@@@@Z @ 47 NONAME ; void NmEditorTextEdit::setCustomTextColor(struct QPair<bool, class QColor> const &)
-	?setDocument@NmHtmlLineEdit@@QAEXPAVQTextDocument@@@Z @ 48 NONAME ; void NmHtmlLineEdit::setDocument(class QTextDocument *)
-	?trUtf8@NmEditorTextEdit@@SA?AVQString@@PBD0@Z @ 49 NONAME ; class QString NmEditorTextEdit::trUtf8(char const *, char const *)
-	??0NmBaseViewScrollArea@@QAE@PAVQGraphicsItem@@@Z @ 50 NONAME ; NmBaseViewScrollArea::NmBaseViewScrollArea(class QGraphicsItem *)
-	?longPressed@NmAttachmentListWidget@@IAEXHVQPointF@@@Z @ 51 NONAME ; void NmAttachmentListWidget::longPressed(int, class QPointF)
-	?staticMetaObject@NmEditorTextEdit@@2UQMetaObject@@B @ 52 NONAME ; struct QMetaObject const NmEditorTextEdit::staticMetaObject
-	??0NmEditorTextEdit@@QAE@PAVQGraphicsItem@@@Z @ 53 NONAME ; NmEditorTextEdit::NmEditorTextEdit(class QGraphicsItem *)
-	??_ENmEditorTextEdit@@UAE@I@Z @ 54 NONAME ; NmEditorTextEdit::~NmEditorTextEdit(unsigned int)
-	?sendLongPressEvent@NmEditorTextEdit@@QAEXABVQPointF@@@Z @ 55 NONAME ; void NmEditorTextEdit::sendLongPressEvent(class QPointF const &)
-	?hideProgressBar@NmAttachmentListItem@@QAEXXZ @ 56 NONAME ; void NmAttachmentListItem::hideProgressBar(void)
-	?qt_metacast@NmAttachmentListItem@@UAEPAXPBD@Z @ 57 NONAME ; void * NmAttachmentListItem::qt_metacast(char const *)
-	?handleMouseReleaseEvent@NmBaseViewScrollArea@@IAEXPAVQGraphicsSceneMouseEvent@@@Z @ 58 NONAME ; void NmBaseViewScrollArea::handleMouseReleaseEvent(class QGraphicsSceneMouseEvent *)
-	?removeProgressBar@NmAttachmentListItem@@AAEXXZ @ 59 NONAME ; void NmAttachmentListItem::removeProgressBar(void)
-	??1NmBaseViewScrollArea@@UAE@XZ @ 60 NONAME ; NmBaseViewScrollArea::~NmBaseViewScrollArea(void)
-	?sendMousePressEvent@NmEditorTextEdit@@QAEXPAVQGraphicsSceneMouseEvent@@@Z @ 61 NONAME ; void NmEditorTextEdit::sendMousePressEvent(class QGraphicsSceneMouseEvent *)
-	??_ENmHtmlLineEdit@@UAE@I@Z @ 62 NONAME ; NmHtmlLineEdit::~NmHtmlLineEdit(unsigned int)
-	?tr@NmAttachmentListWidget@@SA?AVQString@@PBD0H@Z @ 63 NONAME ; class QString NmAttachmentListWidget::tr(char const *, char const *, int)
-	?handleMousePressEvent@NmBaseViewScrollArea@@IAEXPAVQGraphicsSceneMouseEvent@@@Z @ 64 NONAME ; void NmBaseViewScrollArea::handleMousePressEvent(class QGraphicsSceneMouseEvent *)
-	?insertItemToLayout@NmAttachmentListWidget@@AAEXPAVNmAttachmentListItem@@@Z @ 65 NONAME ; void NmAttachmentListWidget::insertItemToLayout(class NmAttachmentListItem *)
-	?metaObject@NmHtmlLineEdit@@UBEPBUQMetaObject@@XZ @ 66 NONAME ; struct QMetaObject const * NmHtmlLineEdit::metaObject(void) const
-	?editorContentHeightChanged@NmEditorTextEdit@@IAEXXZ @ 67 NONAME ; void NmEditorTextEdit::editorContentHeightChanged(void)
-	?setTextColor@NmAttachmentListItem@@QAEXVQColor@@@Z @ 68 NONAME ; void NmAttachmentListItem::setTextColor(class QColor)
-	??1NmAttachmentListItem@@UAE@XZ @ 69 NONAME ; NmAttachmentListItem::~NmAttachmentListItem(void)
-	?count@NmAttachmentListWidget@@QBEHXZ @ 70 NONAME ; int NmAttachmentListWidget::count(void) const
-	?handleTextChanged@NmRecipientLineEdit@@AAEXABVQString@@@Z @ 71 NONAME ; void NmRecipientLineEdit::handleTextChanged(class QString const &)
-	?longPressedActivated@NmAttachmentListItem@@AAEXXZ @ 72 NONAME ; void NmAttachmentListItem::longPressedActivated(void)
-	?handleLongPressGesture@NmBaseViewScrollArea@@IAEXABVQPointF@@@Z @ 73 NONAME ; void NmBaseViewScrollArea::handleLongPressGesture(class QPointF const &)
-	?updateScrollPosition@NmEditorTextEdit@@QAEXABVQPointF@@@Z @ 74 NONAME ; void NmEditorTextEdit::updateScrollPosition(class QPointF const &)
-	?contentHeight@NmEditorTextEdit@@QBEMXZ @ 75 NONAME ; float NmEditorTextEdit::contentHeight(void) const
-	?qt_metacast@NmEditorTextEdit@@UAEPAXPBD@Z @ 76 NONAME ; void * NmEditorTextEdit::qt_metacast(char const *)
-	?mouseMoveEvent@NmBaseViewScrollArea@@UAEXPAVQGraphicsSceneMouseEvent@@@Z @ 77 NONAME ; void NmBaseViewScrollArea::mouseMoveEvent(class QGraphicsSceneMouseEvent *)
-	?qt_metacall@NmAttachmentListItem@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 78 NONAME ; int NmAttachmentListItem::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?handleLongPressed@NmAttachmentListWidget@@AAEXVQPointF@@@Z @ 79 NONAME ; void NmAttachmentListWidget::handleLongPressed(class QPointF)
-	?staticMetaObject@NmBaseViewScrollArea@@2UQMetaObject@@B @ 80 NONAME ; struct QMetaObject const NmBaseViewScrollArea::staticMetaObject
-	?setHeaderHeight@NmEditorTextEdit@@QAEXH@Z @ 81 NONAME ; void NmEditorTextEdit::setHeaderHeight(int)
-	?init@NmAttachmentListWidget@@AAEXXZ @ 82 NONAME ; void NmAttachmentListWidget::init(void)
-	?rearrangeLayout@NmAttachmentListWidget@@AAEXXZ @ 83 NONAME ; void NmAttachmentListWidget::rearrangeLayout(void)
-	?trUtf8@NmRecipientLineEdit@@SA?AVQString@@PBD0@Z @ 84 NONAME ; class QString NmRecipientLineEdit::trUtf8(char const *, char const *)
-	?trUtf8@NmAttachmentListItem@@SA?AVQString@@PBD0@Z @ 85 NONAME ; class QString NmAttachmentListItem::trUtf8(char const *, char const *)
-	?metaObject@NmRecipientLineEdit@@UBEPBUQMetaObject@@XZ @ 86 NONAME ; struct QMetaObject const * NmRecipientLineEdit::metaObject(void) const
-	?tr@NmAttachmentListItem@@SA?AVQString@@PBD0@Z @ 87 NONAME ; class QString NmAttachmentListItem::tr(char const *, char const *)
-	?trUtf8@NmBaseViewScrollArea@@SA?AVQString@@PBD0@Z @ 88 NONAME ; class QString NmBaseViewScrollArea::trUtf8(char const *, char const *)
-	?tr@NmBaseViewScrollArea@@SA?AVQString@@PBD0@Z @ 89 NONAME ; class QString NmBaseViewScrollArea::tr(char const *, char const *)
-	?setFileSizeText@NmAttachmentListItem@@QAEXABVQString@@@Z @ 90 NONAME ; void NmAttachmentListItem::setFileSizeText(class QString const &)
-	?customTextColor@NmEditorTextEdit@@QBE?AU?$QPair@_NVQColor@@@@XZ @ 91 NONAME ; struct QPair<bool, class QColor> NmEditorTextEdit::customTextColor(void) const
-	?staticMetaObject@NmHtmlLineEdit@@2UQMetaObject@@B @ 92 NONAME ; struct QMetaObject const NmHtmlLineEdit::staticMetaObject
-	?inputMethodEvent@NmRecipientLineEdit@@MAEXPAVQInputMethodEvent@@@Z @ 93 NONAME ; void NmRecipientLineEdit::inputMethodEvent(class QInputMethodEvent *)
-	?mouseReleaseEvent@NmBaseViewScrollArea@@UAEXPAVQGraphicsSceneMouseEvent@@@Z @ 94 NONAME ; void NmBaseViewScrollArea::mouseReleaseEvent(class QGraphicsSceneMouseEvent *)
-	?constructUi@NmAttachmentListWidget@@AAEXXZ @ 95 NONAME ; void NmAttachmentListWidget::constructUi(void)
-	?toPlainText@NmHtmlLineEdit@@QBE?AVQString@@XZ @ 96 NONAME ; class QString NmHtmlLineEdit::toPlainText(void) const
-	?getStaticMetaObject@NmEditorTextEdit@@SAABUQMetaObject@@XZ @ 97 NONAME ; struct QMetaObject const & NmEditorTextEdit::getStaticMetaObject(void)
-	?setScrollPosition@NmEditorTextEdit@@QAEXHH@Z @ 98 NONAME ; void NmEditorTextEdit::setScrollPosition(int, int)
-	?tr@NmEditorTextEdit@@SA?AVQString@@PBD0@Z @ 99 NONAME ; class QString NmEditorTextEdit::tr(char const *, char const *)
-	?staticMetaObject@NmAttachmentListItem@@2UQMetaObject@@B @ 100 NONAME ; struct QMetaObject const NmAttachmentListItem::staticMetaObject
-	??_ENmBaseViewScrollArea@@UAE@I@Z @ 101 NONAME ; NmBaseViewScrollArea::~NmBaseViewScrollArea(unsigned int)
-	?itemLongPressed@NmAttachmentListItem@@IAEXVQPointF@@@Z @ 102 NONAME ; void NmAttachmentListItem::itemLongPressed(class QPointF)
-	?progressBarValue@NmAttachmentListItem@@QBEHXZ @ 103 NONAME ; int NmAttachmentListItem::progressBarValue(void) const
-	?setCustomTextColor@NmEditorTextEdit@@QAEX_NABVQColor@@@Z @ 104 NONAME ; void NmEditorTextEdit::setCustomTextColor(bool, class QColor const &)
-	??0NmHtmlLineEdit@@QAE@PAVQGraphicsItem@@@Z @ 105 NONAME ; NmHtmlLineEdit::NmHtmlLineEdit(class QGraphicsItem *)
-	?init@NmAttachmentListItem@@AAEXXZ @ 106 NONAME ; void NmAttachmentListItem::init(void)
-	?tr@NmRecipientLineEdit@@SA?AVQString@@PBD0@Z @ 107 NONAME ; class QString NmRecipientLineEdit::tr(char const *, char const *)
-	??1NmEditorTextEdit@@UAE@XZ @ 108 NONAME ; NmEditorTextEdit::~NmEditorTextEdit(void)
-	?generateEmailAddressList@NmRecipientLineEdit@@AAEXXZ @ 109 NONAME ; void NmRecipientLineEdit::generateEmailAddressList(void)
-	?trUtf8@NmAttachmentListWidget@@SA?AVQString@@PBD0@Z @ 110 NONAME ; class QString NmAttachmentListWidget::trUtf8(char const *, char const *)
-	?mousePressEvent@NmBaseViewScrollArea@@UAEXPAVQGraphicsSceneMouseEvent@@@Z @ 111 NONAME ; void NmBaseViewScrollArea::mousePressEvent(class QGraphicsSceneMouseEvent *)
-	?handleItemActivated@NmAttachmentListWidget@@AAEXXZ @ 112 NONAME ; void NmAttachmentListWidget::handleItemActivated(void)
-	?metaObject@NmAttachmentListWidget@@UBEPBUQMetaObject@@XZ @ 113 NONAME ; struct QMetaObject const * NmAttachmentListWidget::metaObject(void) const
-	?constructUi@NmAttachmentListItem@@AAEXXZ @ 114 NONAME ; void NmAttachmentListItem::constructUi(void)
-	?trUtf8@NmHtmlLineEdit@@SA?AVQString@@PBD0H@Z @ 115 NONAME ; class QString NmHtmlLineEdit::trUtf8(char const *, char const *, int)
-	?setHtml@NmHtmlLineEdit@@QAEXABVQString@@@Z @ 116 NONAME ; void NmHtmlLineEdit::setHtml(class QString const &)
-	?tr@NmHtmlLineEdit@@SA?AVQString@@PBD0H@Z @ 117 NONAME ; class QString NmHtmlLineEdit::tr(char const *, char const *, int)
-	?itemActivated@NmAttachmentListItem@@IAEXXZ @ 118 NONAME ; void NmAttachmentListItem::itemActivated(void)
-	?mouseReleaseEvent@NmAttachmentListItem@@MAEXPAVQGraphicsSceneMouseEvent@@@Z @ 119 NONAME ; void NmAttachmentListItem::mouseReleaseEvent(class QGraphicsSceneMouseEvent *)
-	?tr@NmAttachmentListWidget@@SA?AVQString@@PBD0@Z @ 120 NONAME ; class QString NmAttachmentListWidget::tr(char const *, char const *)
-	?getStaticMetaObject@NmRecipientLineEdit@@SAABUQMetaObject@@XZ @ 121 NONAME ; struct QMetaObject const & NmRecipientLineEdit::getStaticMetaObject(void)
-	?findItem@NmAttachmentListWidget@@AAEHPBVQObject@@@Z @ 122 NONAME ; int NmAttachmentListWidget::findItem(class QObject const *)
-	??1NmRecipientLineEdit@@UAE@XZ @ 123 NONAME ; NmRecipientLineEdit::~NmRecipientLineEdit(void)
-	?removeAttachment@NmAttachmentListWidget@@QAEXH@Z @ 124 NONAME ; void NmAttachmentListWidget::removeAttachment(int)
-	?trUtf8@NmRecipientLineEdit@@SA?AVQString@@PBD0H@Z @ 125 NONAME ; class QString NmRecipientLineEdit::trUtf8(char const *, char const *, int)
-	?tr@NmRecipientLineEdit@@SA?AVQString@@PBD0H@Z @ 126 NONAME ; class QString NmRecipientLineEdit::tr(char const *, char const *, int)
-	?progressValue@NmAttachmentListWidget@@QBEHH@Z @ 127 NONAME ; int NmAttachmentListWidget::progressValue(int) const
-	?staticMetaObject@NmAttachmentListWidget@@2UQMetaObject@@B @ 128 NONAME ; struct QMetaObject const NmAttachmentListWidget::staticMetaObject
-	??_ENmAttachmentListWidget@@UAE@I@Z @ 129 NONAME ; NmAttachmentListWidget::~NmAttachmentListWidget(unsigned int)
-	?setTextColor@NmAttachmentListWidget@@QAEXVQColor@@@Z @ 130 NONAME ; void NmAttachmentListWidget::setTextColor(class QColor)
-	?setTextCursor@NmHtmlLineEdit@@QAEXABVQTextCursor@@@Z @ 131 NONAME ; void NmHtmlLineEdit::setTextCursor(class QTextCursor const &)
-	?handleMouseMoveEvent@NmBaseViewScrollArea@@IAEXPAVQGraphicsSceneMouseEvent@@@Z @ 132 NONAME ; void NmBaseViewScrollArea::handleMouseMoveEvent(class QGraphicsSceneMouseEvent *)
-	?staticMetaObject@NmRecipientLineEdit@@2UQMetaObject@@B @ 133 NONAME ; struct QMetaObject const NmRecipientLineEdit::staticMetaObject
-	?setProgressBarValue@NmAttachmentListWidget@@QAEXHH@Z @ 134 NONAME ; void NmAttachmentListWidget::setProgressBarValue(int, int)
-	?metaObject@NmAttachmentListItem@@UBEPBUQMetaObject@@XZ @ 135 NONAME ; struct QMetaObject const * NmAttachmentListItem::metaObject(void) const
-	?insertAttachment@NmAttachmentListWidget@@QAEXHABVQString@@0@Z @ 136 NONAME ; void NmAttachmentListWidget::insertAttachment(int, class QString const &, class QString const &)
-	?hideProgressBar@NmAttachmentListWidget@@QAEXH@Z @ 137 NONAME ; void NmAttachmentListWidget::hideProgressBar(int)
-	??0NmAttachmentListWidget@@QAE@PAVQGraphicsItem@@@Z @ 138 NONAME ; NmAttachmentListWidget::NmAttachmentListWidget(class QGraphicsItem *)
-	?mousePressEvent@NmAttachmentListItem@@MAEXPAVQGraphicsSceneMouseEvent@@@Z @ 139 NONAME ; void NmAttachmentListItem::mousePressEvent(class QGraphicsSceneMouseEvent *)
-	?tr@NmAttachmentListItem@@SA?AVQString@@PBD0H@Z @ 140 NONAME ; class QString NmAttachmentListItem::tr(char const *, char const *, int)
-	?document@NmHtmlLineEdit@@QBEPAVQTextDocument@@XZ @ 141 NONAME ; class QTextDocument * NmHtmlLineEdit::document(void) const
-	?qt_metacall@NmBaseViewScrollArea@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 142 NONAME ; int NmBaseViewScrollArea::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?qt_metacall@NmHtmlLineEdit@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 143 NONAME ; int NmHtmlLineEdit::qt_metacall(enum QMetaObject::Call, int, void * *)
-	?tr@NmHtmlLineEdit@@SA?AVQString@@PBD0@Z @ 144 NONAME ; class QString NmHtmlLineEdit::tr(char const *, char const *)
+	?handleLongPressGesture@NmBaseViewScrollArea@@IAEXABVQPointF@@@Z @ 2 NONAME ; void NmBaseViewScrollArea::handleLongPressGesture(class QPointF const &)
+	?qt_metacast@NmEditorTextEdit@@UAEPAXPBD@Z @ 3 NONAME ; void * NmEditorTextEdit::qt_metacast(char const *)
+	?itemActivated@NmAttachmentListWidget@@IAEXH@Z @ 4 NONAME ; void NmAttachmentListWidget::itemActivated(int)
+	?mouseMoveEvent@NmBaseViewScrollArea@@UAEXPAVQGraphicsSceneMouseEvent@@@Z @ 5 NONAME ; void NmBaseViewScrollArea::mouseMoveEvent(class QGraphicsSceneMouseEvent *)
+	?textCursor@NmHtmlLineEdit@@QBE?AVQTextCursor@@XZ @ 6 NONAME ; class QTextCursor NmHtmlLineEdit::textCursor(void) const
+	?qt_metacall@NmAttachmentListItem@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 7 NONAME ; int NmAttachmentListItem::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?keyPressEvent@NmRecipientLineEdit@@MAEXPAVQKeyEvent@@@Z @ 8 NONAME ; void NmRecipientLineEdit::keyPressEvent(class QKeyEvent *)
+	?handleLongPressed@NmAttachmentListWidget@@AAEXVQPointF@@@Z @ 9 NONAME ; void NmAttachmentListWidget::handleLongPressed(class QPointF)
+	?staticMetaObject@NmBaseViewScrollArea@@2UQMetaObject@@B @ 10 NONAME ; struct QMetaObject const NmBaseViewScrollArea::staticMetaObject
+	?paint@NmAttachmentListWidget@@UAEXPAVQPainter@@PBVQStyleOptionGraphicsItem@@PAVQWidget@@@Z @ 11 NONAME ; void NmAttachmentListWidget::paint(class QPainter *, class QStyleOptionGraphicsItem const *, class QWidget *)
+	?tr@NmEditorTextEdit@@SA?AVQString@@PBD0H@Z @ 12 NONAME ; class QString NmEditorTextEdit::tr(char const *, char const *, int)
+	?init@NmAttachmentListWidget@@AAEXXZ @ 13 NONAME ; void NmAttachmentListWidget::init(void)
+	?rearrangeLayout@NmAttachmentListWidget@@AAEXXZ @ 14 NONAME ; void NmAttachmentListWidget::rearrangeLayout(void)
+	?trUtf8@NmRecipientLineEdit@@SA?AVQString@@PBD0@Z @ 15 NONAME ; class QString NmRecipientLineEdit::trUtf8(char const *, char const *)
+	?toHtml@NmHtmlLineEdit@@QBE?AVQString@@XZ @ 16 NONAME ; class QString NmHtmlLineEdit::toHtml(void) const
+	?trUtf8@NmAttachmentListItem@@SA?AVQString@@PBD0@Z @ 17 NONAME ; class QString NmAttachmentListItem::trUtf8(char const *, char const *)
+	?tr@NmAttachmentListItem@@SA?AVQString@@PBD0@Z @ 18 NONAME ; class QString NmAttachmentListItem::tr(char const *, char const *)
+	?metaObject@NmRecipientLineEdit@@UBEPBUQMetaObject@@XZ @ 19 NONAME ; struct QMetaObject const * NmRecipientLineEdit::metaObject(void) const
+	?metaObject@NmBaseViewScrollArea@@UBEPBUQMetaObject@@XZ @ 20 NONAME ; struct QMetaObject const * NmBaseViewScrollArea::metaObject(void) const
+	?emailAddressList@NmRecipientLineEdit@@QAE?AV?$QList@VNmAddress@@@@XZ @ 21 NONAME ; class QList<class NmAddress> NmRecipientLineEdit::emailAddressList(void)
+	?trUtf8@NmBaseViewScrollArea@@SA?AVQString@@PBD0@Z @ 22 NONAME ; class QString NmBaseViewScrollArea::trUtf8(char const *, char const *)
+	?tr@NmBaseViewScrollArea@@SA?AVQString@@PBD0@Z @ 23 NONAME ; class QString NmBaseViewScrollArea::tr(char const *, char const *)
+	?getStaticMetaObject@NmAttachmentListItem@@SAABUQMetaObject@@XZ @ 24 NONAME ; struct QMetaObject const & NmAttachmentListItem::getStaticMetaObject(void)
+	?getStaticMetaObject@NmBaseViewScrollArea@@SAABUQMetaObject@@XZ @ 25 NONAME ; struct QMetaObject const & NmBaseViewScrollArea::getStaticMetaObject(void)
+	?getStaticMetaObject@NmAttachmentListWidget@@SAABUQMetaObject@@XZ @ 26 NONAME ; struct QMetaObject const & NmAttachmentListWidget::getStaticMetaObject(void)
+	??_ENmAttachmentListItem@@UAE@I@Z @ 27 NONAME ; NmAttachmentListItem::~NmAttachmentListItem(unsigned int)
+	?rectForCursorPosition@NmEditorTextEdit@@QBE?AVQRectF@@XZ @ 28 NONAME ; class QRectF NmEditorTextEdit::rectForCursorPosition(void) const
+	?setFileSizeText@NmAttachmentListItem@@QAEXABVQString@@@Z @ 29 NONAME ; void NmAttachmentListItem::setFileSizeText(class QString const &)
+	?qt_metacast@NmHtmlLineEdit@@UAEPAXPBD@Z @ 30 NONAME ; void * NmHtmlLineEdit::qt_metacast(char const *)
+	?metaObject@NmEditorTextEdit@@UBEPBUQMetaObject@@XZ @ 31 NONAME ; struct QMetaObject const * NmEditorTextEdit::metaObject(void) const
+	?staticMetaObject@NmHtmlLineEdit@@2UQMetaObject@@B @ 32 NONAME ; struct QMetaObject const NmHtmlLineEdit::staticMetaObject
+	?setFileNameText@NmAttachmentListItem@@QAEXABVQString@@@Z @ 33 NONAME ; void NmAttachmentListItem::setFileNameText(class QString const &)
+	?customTextColor@NmEditorTextEdit@@QBE?AU?$QPair@_NVQColor@@@@XZ @ 34 NONAME ; struct QPair<bool, class QColor> NmEditorTextEdit::customTextColor(void) const
+	?qt_metacast@NmBaseViewScrollArea@@UAEPAXPBD@Z @ 35 NONAME ; void * NmBaseViewScrollArea::qt_metacast(char const *)
+	?inputMethodEvent@NmRecipientLineEdit@@MAEXPAVQInputMethodEvent@@@Z @ 36 NONAME ; void NmRecipientLineEdit::inputMethodEvent(class QInputMethodEvent *)
+	?mouseReleaseEvent@NmBaseViewScrollArea@@UAEXPAVQGraphicsSceneMouseEvent@@@Z @ 37 NONAME ; void NmBaseViewScrollArea::mouseReleaseEvent(class QGraphicsSceneMouseEvent *)
+	?tr@NmBaseViewScrollArea@@SA?AVQString@@PBD0H@Z @ 38 NONAME ; class QString NmBaseViewScrollArea::tr(char const *, char const *, int)
+	?qt_metacall@NmAttachmentListWidget@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 39 NONAME ; int NmAttachmentListWidget::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?trUtf8@NmAttachmentListWidget@@SA?AVQString@@PBD0H@Z @ 40 NONAME ; class QString NmAttachmentListWidget::trUtf8(char const *, char const *, int)
+	?constructUi@NmAttachmentListWidget@@AAEXXZ @ 41 NONAME ; void NmAttachmentListWidget::constructUi(void)
+	?qt_metacall@NmRecipientLineEdit@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 42 NONAME ; int NmRecipientLineEdit::qt_metacall(enum QMetaObject::Call, int, void * *)
+	??0NmAttachmentListItem@@QAE@PAVQGraphicsItem@@@Z @ 43 NONAME ; NmAttachmentListItem::NmAttachmentListItem(class QGraphicsItem *)
+	?addSelectedContacts@NmRecipientLineEdit@@QAEXABVQVariant@@@Z @ 44 NONAME ; void NmRecipientLineEdit::addSelectedContacts(class QVariant const &)
+	?toPlainText@NmHtmlLineEdit@@QBE?AVQString@@XZ @ 45 NONAME ; class QString NmHtmlLineEdit::toPlainText(void) const
+	?trUtf8@NmBaseViewScrollArea@@SA?AVQString@@PBD0H@Z @ 46 NONAME ; class QString NmBaseViewScrollArea::trUtf8(char const *, char const *, int)
+	?tr@NmEditorTextEdit@@SA?AVQString@@PBD0@Z @ 47 NONAME ; class QString NmEditorTextEdit::tr(char const *, char const *)
+	?getStaticMetaObject@NmEditorTextEdit@@SAABUQMetaObject@@XZ @ 48 NONAME ; struct QMetaObject const & NmEditorTextEdit::getStaticMetaObject(void)
+	?staticMetaObject@NmAttachmentListItem@@2UQMetaObject@@B @ 49 NONAME ; struct QMetaObject const NmAttachmentListItem::staticMetaObject
+	??1NmHtmlLineEdit@@UAE@XZ @ 50 NONAME ; NmHtmlLineEdit::~NmHtmlLineEdit(void)
+	?setProgressBarValue@NmAttachmentListItem@@QAEXH@Z @ 51 NONAME ; void NmAttachmentListItem::setProgressBarValue(int)
+	?trUtf8@NmHtmlLineEdit@@SA?AVQString@@PBD0@Z @ 52 NONAME ; class QString NmHtmlLineEdit::trUtf8(char const *, char const *)
+	??_ENmBaseViewScrollArea@@UAE@I@Z @ 53 NONAME ; NmBaseViewScrollArea::~NmBaseViewScrollArea(unsigned int)
+	?progressBarValue@NmAttachmentListItem@@QBEHXZ @ 54 NONAME ; int NmAttachmentListItem::progressBarValue(void) const
+	?itemLongPressed@NmAttachmentListItem@@IAEXVQPointF@@@Z @ 55 NONAME ; void NmAttachmentListItem::itemLongPressed(class QPointF)
+	?gestureEvent@NmAttachmentListItem@@MAEXPAVQGestureEvent@@@Z @ 56 NONAME ; void NmAttachmentListItem::gestureEvent(class QGestureEvent *)
+	?setCustomTextColor@NmEditorTextEdit@@QAEX_NABVQColor@@@Z @ 57 NONAME ; void NmEditorTextEdit::setCustomTextColor(bool, class QColor const &)
+	?init@NmAttachmentListItem@@AAEXXZ @ 58 NONAME ; void NmAttachmentListItem::init(void)
+	??0NmRecipientLineEdit@@QAE@PAVQGraphicsItem@@@Z @ 59 NONAME ; NmRecipientLineEdit::NmRecipientLineEdit(class QGraphicsItem *)
+	??0NmHtmlLineEdit@@QAE@PAVQGraphicsItem@@@Z @ 60 NONAME ; NmHtmlLineEdit::NmHtmlLineEdit(class QGraphicsItem *)
+	?tr@NmRecipientLineEdit@@SA?AVQString@@PBD0@Z @ 61 NONAME ; class QString NmRecipientLineEdit::tr(char const *, char const *)
+	?setAttachmentSize@NmAttachmentListWidget@@QAEXHABVQString@@@Z @ 62 NONAME ; void NmAttachmentListWidget::setAttachmentSize(int, class QString const &)
+	?trUtf8@NmEditorTextEdit@@SA?AVQString@@PBD0H@Z @ 63 NONAME ; class QString NmEditorTextEdit::trUtf8(char const *, char const *, int)
+	?setPlainText@NmHtmlLineEdit@@QAEXABVQString@@@Z @ 64 NONAME ; void NmHtmlLineEdit::setPlainText(class QString const &)
+	?longPressGesture@NmBaseViewScrollArea@@MAEXABVQPointF@@@Z @ 65 NONAME ; void NmBaseViewScrollArea::longPressGesture(class QPointF const &)
+	?updateCustomTextColor@NmEditorTextEdit@@QAEXXZ @ 66 NONAME ; void NmEditorTextEdit::updateCustomTextColor(void)
+	?orientationChanged@NmAttachmentListWidget@@AAEXW4Orientation@Qt@@@Z @ 67 NONAME ; void NmAttachmentListWidget::orientationChanged(enum Qt::Orientation)
+	?qt_metacast@NmAttachmentListWidget@@UAEPAXPBD@Z @ 68 NONAME ; void * NmAttachmentListWidget::qt_metacast(char const *)
+	?getStaticMetaObject@NmHtmlLineEdit@@SAABUQMetaObject@@XZ @ 69 NONAME ; struct QMetaObject const & NmHtmlLineEdit::getStaticMetaObject(void)
+	?qt_metacall@NmEditorTextEdit@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 70 NONAME ; int NmEditorTextEdit::qt_metacall(enum QMetaObject::Call, int, void * *)
+	??1NmEditorTextEdit@@UAE@XZ @ 71 NONAME ; NmEditorTextEdit::~NmEditorTextEdit(void)
+	?generateEmailAddressList@NmRecipientLineEdit@@AAEXXZ @ 72 NONAME ; void NmRecipientLineEdit::generateEmailAddressList(void)
+	?trUtf8@NmAttachmentListWidget@@SA?AVQString@@PBD0@Z @ 73 NONAME ; class QString NmAttachmentListWidget::trUtf8(char const *, char const *)
+	??1NmAttachmentListWidget@@UAE@XZ @ 74 NONAME ; NmAttachmentListWidget::~NmAttachmentListWidget(void)
+	??_ENmRecipientLineEdit@@UAE@I@Z @ 75 NONAME ; NmRecipientLineEdit::~NmRecipientLineEdit(unsigned int)
+	?mousePressEvent@NmBaseViewScrollArea@@UAEXPAVQGraphicsSceneMouseEvent@@@Z @ 76 NONAME ; void NmBaseViewScrollArea::mousePressEvent(class QGraphicsSceneMouseEvent *)
+	?qt_metacast@NmRecipientLineEdit@@UAEPAXPBD@Z @ 77 NONAME ; void * NmRecipientLineEdit::qt_metacast(char const *)
+	?setCustomTextColor@NmEditorTextEdit@@QAEXABU?$QPair@_NVQColor@@@@@Z @ 78 NONAME ; void NmEditorTextEdit::setCustomTextColor(struct QPair<bool, class QColor> const &)
+	?setDocument@NmHtmlLineEdit@@QAEXPAVQTextDocument@@@Z @ 79 NONAME ; void NmHtmlLineEdit::setDocument(class QTextDocument *)
+	?handleItemActivated@NmAttachmentListWidget@@AAEXXZ @ 80 NONAME ; void NmAttachmentListWidget::handleItemActivated(void)
+	?trUtf8@NmEditorTextEdit@@SA?AVQString@@PBD0@Z @ 81 NONAME ; class QString NmEditorTextEdit::trUtf8(char const *, char const *)
+	??0NmBaseViewScrollArea@@QAE@PAVQGraphicsItem@@@Z @ 82 NONAME ; NmBaseViewScrollArea::NmBaseViewScrollArea(class QGraphicsItem *)
+	?metaObject@NmAttachmentListWidget@@UBEPBUQMetaObject@@XZ @ 83 NONAME ; struct QMetaObject const * NmAttachmentListWidget::metaObject(void) const
+	?constructUi@NmAttachmentListItem@@AAEXXZ @ 84 NONAME ; void NmAttachmentListItem::constructUi(void)
+	?longPressed@NmAttachmentListWidget@@IAEXHVQPointF@@@Z @ 85 NONAME ; void NmAttachmentListWidget::longPressed(int, class QPointF)
+	?trUtf8@NmHtmlLineEdit@@SA?AVQString@@PBD0H@Z @ 86 NONAME ; class QString NmHtmlLineEdit::trUtf8(char const *, char const *, int)
+	?staticMetaObject@NmEditorTextEdit@@2UQMetaObject@@B @ 87 NONAME ; struct QMetaObject const NmEditorTextEdit::staticMetaObject
+	??0NmEditorTextEdit@@QAE@PAVQGraphicsItem@@@Z @ 88 NONAME ; NmEditorTextEdit::NmEditorTextEdit(class QGraphicsItem *)
+	?tr@NmHtmlLineEdit@@SA?AVQString@@PBD0H@Z @ 89 NONAME ; class QString NmHtmlLineEdit::tr(char const *, char const *, int)
+	?setHtml@NmHtmlLineEdit@@QAEXABVQString@@@Z @ 90 NONAME ; void NmHtmlLineEdit::setHtml(class QString const &)
+	??_ENmEditorTextEdit@@UAE@I@Z @ 91 NONAME ; NmEditorTextEdit::~NmEditorTextEdit(unsigned int)
+	?tr@NmAttachmentListWidget@@SA?AVQString@@PBD0@Z @ 92 NONAME ; class QString NmAttachmentListWidget::tr(char const *, char const *)
+	?itemActivated@NmAttachmentListItem@@IAEXXZ @ 93 NONAME ; void NmAttachmentListItem::itemActivated(void)
+	?hideProgressBar@NmAttachmentListItem@@QAEXXZ @ 94 NONAME ; void NmAttachmentListItem::hideProgressBar(void)
+	?qt_metacast@NmAttachmentListItem@@UAEPAXPBD@Z @ 95 NONAME ; void * NmAttachmentListItem::qt_metacast(char const *)
+	?getStaticMetaObject@NmRecipientLineEdit@@SAABUQMetaObject@@XZ @ 96 NONAME ; struct QMetaObject const & NmRecipientLineEdit::getStaticMetaObject(void)
+	?findItem@NmAttachmentListWidget@@AAEHPBVQObject@@@Z @ 97 NONAME ; int NmAttachmentListWidget::findItem(class QObject const *)
+	?removeAttachment@NmAttachmentListWidget@@QAEXH@Z @ 98 NONAME ; void NmAttachmentListWidget::removeAttachment(int)
+	??1NmRecipientLineEdit@@UAE@XZ @ 99 NONAME ; NmRecipientLineEdit::~NmRecipientLineEdit(void)
+	?trUtf8@NmRecipientLineEdit@@SA?AVQString@@PBD0H@Z @ 100 NONAME ; class QString NmRecipientLineEdit::trUtf8(char const *, char const *, int)
+	?tr@NmRecipientLineEdit@@SA?AVQString@@PBD0H@Z @ 101 NONAME ; class QString NmRecipientLineEdit::tr(char const *, char const *, int)
+	?progressValue@NmAttachmentListWidget@@QBEHH@Z @ 102 NONAME ; int NmAttachmentListWidget::progressValue(int) const
+	?staticMetaObject@NmAttachmentListWidget@@2UQMetaObject@@B @ 103 NONAME ; struct QMetaObject const NmAttachmentListWidget::staticMetaObject
+	??_ENmAttachmentListWidget@@UAE@I@Z @ 104 NONAME ; NmAttachmentListWidget::~NmAttachmentListWidget(unsigned int)
+	?setTextCursor@NmHtmlLineEdit@@QAEXABVQTextCursor@@@Z @ 105 NONAME ; void NmHtmlLineEdit::setTextCursor(class QTextCursor const &)
+	?setTextColor@NmAttachmentListWidget@@QAEXVQColor@@@Z @ 106 NONAME ; void NmAttachmentListWidget::setTextColor(class QColor)
+	?rectForCursorPosition@NmHtmlLineEdit@@QBE?AVQRectF@@XZ @ 107 NONAME ; class QRectF NmHtmlLineEdit::rectForCursorPosition(void) const
+	?handleMouseMoveEvent@NmBaseViewScrollArea@@IAEXPAVQGraphicsSceneMouseEvent@@@Z @ 108 NONAME ; void NmBaseViewScrollArea::handleMouseMoveEvent(class QGraphicsSceneMouseEvent *)
+	?staticMetaObject@NmRecipientLineEdit@@2UQMetaObject@@B @ 109 NONAME ; struct QMetaObject const NmRecipientLineEdit::staticMetaObject
+	?setProgressBarValue@NmAttachmentListWidget@@QAEXHH@Z @ 110 NONAME ; void NmAttachmentListWidget::setProgressBarValue(int, int)
+	?handleMouseReleaseEvent@NmBaseViewScrollArea@@IAEXPAVQGraphicsSceneMouseEvent@@@Z @ 111 NONAME ; void NmBaseViewScrollArea::handleMouseReleaseEvent(class QGraphicsSceneMouseEvent *)
+	?insertAttachment@NmAttachmentListWidget@@QAEXHABVQString@@0@Z @ 112 NONAME ; void NmAttachmentListWidget::insertAttachment(int, class QString const &, class QString const &)
+	?metaObject@NmAttachmentListItem@@UBEPBUQMetaObject@@XZ @ 113 NONAME ; struct QMetaObject const * NmAttachmentListItem::metaObject(void) const
+	?removeProgressBar@NmAttachmentListItem@@AAEXXZ @ 114 NONAME ; void NmAttachmentListItem::removeProgressBar(void)
+	??1NmBaseViewScrollArea@@UAE@XZ @ 115 NONAME ; NmBaseViewScrollArea::~NmBaseViewScrollArea(void)
+	?hideProgressBar@NmAttachmentListWidget@@QAEXH@Z @ 116 NONAME ; void NmAttachmentListWidget::hideProgressBar(int)
+	??0NmAttachmentListWidget@@QAE@PAVQGraphicsItem@@@Z @ 117 NONAME ; NmAttachmentListWidget::NmAttachmentListWidget(class QGraphicsItem *)
+	??_ENmHtmlLineEdit@@UAE@I@Z @ 118 NONAME ; NmHtmlLineEdit::~NmHtmlLineEdit(unsigned int)
+	?tr@NmAttachmentListWidget@@SA?AVQString@@PBD0H@Z @ 119 NONAME ; class QString NmAttachmentListWidget::tr(char const *, char const *, int)
+	?handleMousePressEvent@NmBaseViewScrollArea@@IAEXPAVQGraphicsSceneMouseEvent@@@Z @ 120 NONAME ; void NmBaseViewScrollArea::handleMousePressEvent(class QGraphicsSceneMouseEvent *)
+	?insertItemToLayout@NmAttachmentListWidget@@AAEXPAVNmAttachmentListItem@@@Z @ 121 NONAME ; void NmAttachmentListWidget::insertItemToLayout(class NmAttachmentListItem *)
+	?metaObject@NmHtmlLineEdit@@UBEPBUQMetaObject@@XZ @ 122 NONAME ; struct QMetaObject const * NmHtmlLineEdit::metaObject(void) const
+	?setTextColor@NmAttachmentListItem@@QAEXVQColor@@@Z @ 123 NONAME ; void NmAttachmentListItem::setTextColor(class QColor)
+	??1NmAttachmentListItem@@UAE@XZ @ 124 NONAME ; NmAttachmentListItem::~NmAttachmentListItem(void)
+	?count@NmAttachmentListWidget@@QBEHXZ @ 125 NONAME ; int NmAttachmentListWidget::count(void) const
+	?tr@NmAttachmentListItem@@SA?AVQString@@PBD0H@Z @ 126 NONAME ; class QString NmAttachmentListItem::tr(char const *, char const *, int)
+	?handleTextChanged@NmRecipientLineEdit@@AAEXABVQString@@@Z @ 127 NONAME ; void NmRecipientLineEdit::handleTextChanged(class QString const &)
+	?document@NmHtmlLineEdit@@QBEPAVQTextDocument@@XZ @ 128 NONAME ; class QTextDocument * NmHtmlLineEdit::document(void) const
+	?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 * *)
 
--- a/emailuis/nmailuiwidgets/eabi/nmailuiwidgetsu.def	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/eabi/nmailuiwidgetsu.def	Thu Jul 22 16:30:28 2010 +0100
@@ -14,165 +14,150 @@
 	_ZN14NmHtmlLineEditD2Ev @ 13 NONAME
 	_ZN16NmEditorTextEdit11qt_metacallEN11QMetaObject4CallEiPPv @ 14 NONAME
 	_ZN16NmEditorTextEdit11qt_metacastEPKc @ 15 NONAME
-	_ZN16NmEditorTextEdit15setHeaderHeightEi @ 16 NONAME
-	_ZN16NmEditorTextEdit16staticMetaObjectE @ 17 NONAME DATA 16
-	_ZN16NmEditorTextEdit17setScrollPositionEii @ 18 NONAME
-	_ZN16NmEditorTextEdit18sendLongPressEventERK7QPointF @ 19 NONAME
-	_ZN16NmEditorTextEdit18sendMouseMoveEventEP24QGraphicsSceneMouseEvent @ 20 NONAME
-	_ZN16NmEditorTextEdit18setCustomTextColorERK5QPairIb6QColorE @ 21 NONAME
-	_ZN16NmEditorTextEdit18setCustomTextColorEbRK6QColor @ 22 NONAME
-	_ZN16NmEditorTextEdit18updateEditorHeightEv @ 23 NONAME
-	_ZN16NmEditorTextEdit19getStaticMetaObjectEv @ 24 NONAME
-	_ZN16NmEditorTextEdit19sendMousePressEventEP24QGraphicsSceneMouseEvent @ 25 NONAME
-	_ZN16NmEditorTextEdit20updateScrollPositionERK7QPointF @ 26 NONAME
-	_ZN16NmEditorTextEdit21sendMouseReleaseEventEP24QGraphicsSceneMouseEvent @ 27 NONAME
-	_ZN16NmEditorTextEdit21updateCustomTextColorEv @ 28 NONAME
-	_ZN16NmEditorTextEdit26editorContentHeightChangedEv @ 29 NONAME
-	_ZN16NmEditorTextEdit4initEP20NmBaseViewScrollArea @ 30 NONAME
-	_ZN16NmEditorTextEditC1EP13QGraphicsItem @ 31 NONAME
-	_ZN16NmEditorTextEditC2EP13QGraphicsItem @ 32 NONAME
-	_ZN16NmEditorTextEditD0Ev @ 33 NONAME
-	_ZN16NmEditorTextEditD1Ev @ 34 NONAME
-	_ZN16NmEditorTextEditD2Ev @ 35 NONAME
-	_ZN19NmRecipientLineEdit11qt_metacallEN11QMetaObject4CallEiPPv @ 36 NONAME
-	_ZN19NmRecipientLineEdit11qt_metacastEPKc @ 37 NONAME
-	_ZN19NmRecipientLineEdit13keyPressEventEP9QKeyEvent @ 38 NONAME
-	_ZN19NmRecipientLineEdit16emailAddressListEv @ 39 NONAME
-	_ZN19NmRecipientLineEdit16inputMethodEventEP17QInputMethodEvent @ 40 NONAME
-	_ZN19NmRecipientLineEdit16staticMetaObjectE @ 41 NONAME DATA 16
-	_ZN19NmRecipientLineEdit17handleTextChangedERK7QString @ 42 NONAME
-	_ZN19NmRecipientLineEdit19getStaticMetaObjectEv @ 43 NONAME
-	_ZN19NmRecipientLineEdit22insertSelectedContactsERK8QVariant @ 44 NONAME
-	_ZN19NmRecipientLineEdit24generateEmailAddressListEv @ 45 NONAME
-	_ZN19NmRecipientLineEditC1EP13QGraphicsItem @ 46 NONAME
-	_ZN19NmRecipientLineEditC2EP13QGraphicsItem @ 47 NONAME
-	_ZN19NmRecipientLineEditD0Ev @ 48 NONAME
-	_ZN19NmRecipientLineEditD1Ev @ 49 NONAME
-	_ZN19NmRecipientLineEditD2Ev @ 50 NONAME
-	_ZN20NmAttachmentListItem10screenSizeEN2Qt11OrientationE @ 51 NONAME
-	_ZN20NmAttachmentListItem11constructUiEv @ 52 NONAME
-	_ZN20NmAttachmentListItem11qt_metacallEN11QMetaObject4CallEiPPv @ 53 NONAME
-	_ZN20NmAttachmentListItem11qt_metacastEPKc @ 54 NONAME
-	_ZN20NmAttachmentListItem12setTextColorE6QColor @ 55 NONAME
-	_ZN20NmAttachmentListItem13itemActivatedEv @ 56 NONAME
-	_ZN20NmAttachmentListItem15hideProgressBarEv @ 57 NONAME
-	_ZN20NmAttachmentListItem15itemLongPressedE7QPointF @ 58 NONAME
-	_ZN20NmAttachmentListItem15mousePressEventEP24QGraphicsSceneMouseEvent @ 59 NONAME
-	_ZN20NmAttachmentListItem15setFileNameTextERK7QString @ 60 NONAME
-	_ZN20NmAttachmentListItem15setFileSizeTextERK7QString @ 61 NONAME
-	_ZN20NmAttachmentListItem16staticMetaObjectE @ 62 NONAME DATA 16
-	_ZN20NmAttachmentListItem17mouseReleaseEventEP24QGraphicsSceneMouseEvent @ 63 NONAME
-	_ZN20NmAttachmentListItem17removeProgressBarEv @ 64 NONAME
-	_ZN20NmAttachmentListItem19getStaticMetaObjectEv @ 65 NONAME
-	_ZN20NmAttachmentListItem19resetFileNameLengthEN2Qt11OrientationE @ 66 NONAME
-	_ZN20NmAttachmentListItem19setProgressBarValueEi @ 67 NONAME
-	_ZN20NmAttachmentListItem20longPressedActivatedEv @ 68 NONAME
-	_ZN20NmAttachmentListItem4initEv @ 69 NONAME
-	_ZN20NmAttachmentListItemC1EP13QGraphicsItem @ 70 NONAME
-	_ZN20NmAttachmentListItemC2EP13QGraphicsItem @ 71 NONAME
-	_ZN20NmAttachmentListItemD0Ev @ 72 NONAME
-	_ZN20NmAttachmentListItemD1Ev @ 73 NONAME
-	_ZN20NmAttachmentListItemD2Ev @ 74 NONAME
-	_ZN20NmBaseViewScrollArea11qt_metacallEN11QMetaObject4CallEiPPv @ 75 NONAME
-	_ZN20NmBaseViewScrollArea11qt_metacastEPKc @ 76 NONAME
-	_ZN20NmBaseViewScrollArea14mouseMoveEventEP24QGraphicsSceneMouseEvent @ 77 NONAME
-	_ZN20NmBaseViewScrollArea15mousePressEventEP24QGraphicsSceneMouseEvent @ 78 NONAME
-	_ZN20NmBaseViewScrollArea16longPressGestureERK7QPointF @ 79 NONAME
-	_ZN20NmBaseViewScrollArea16staticMetaObjectE @ 80 NONAME DATA 16
-	_ZN20NmBaseViewScrollArea17mouseReleaseEventEP24QGraphicsSceneMouseEvent @ 81 NONAME
-	_ZN20NmBaseViewScrollArea19getStaticMetaObjectEv @ 82 NONAME
-	_ZN20NmBaseViewScrollArea20handleMouseMoveEventEP24QGraphicsSceneMouseEvent @ 83 NONAME
-	_ZN20NmBaseViewScrollArea21handleMousePressEventEP24QGraphicsSceneMouseEvent @ 84 NONAME
-	_ZN20NmBaseViewScrollArea22handleLongPressGestureERK7QPointF @ 85 NONAME
-	_ZN20NmBaseViewScrollArea23handleMouseReleaseEventEP24QGraphicsSceneMouseEvent @ 86 NONAME
-	_ZN20NmBaseViewScrollAreaC1EP13QGraphicsItem @ 87 NONAME
-	_ZN20NmBaseViewScrollAreaC2EP13QGraphicsItem @ 88 NONAME
-	_ZN20NmBaseViewScrollAreaD0Ev @ 89 NONAME
-	_ZN20NmBaseViewScrollAreaD1Ev @ 90 NONAME
-	_ZN20NmBaseViewScrollAreaD2Ev @ 91 NONAME
-	_ZN22NmAttachmentListWidget11constructUiEv @ 92 NONAME
-	_ZN22NmAttachmentListWidget11longPressedEi7QPointF @ 93 NONAME
-	_ZN22NmAttachmentListWidget11qt_metacallEN11QMetaObject4CallEiPPv @ 94 NONAME
-	_ZN22NmAttachmentListWidget11qt_metacastEPKc @ 95 NONAME
-	_ZN22NmAttachmentListWidget12setTextColorE6QColor @ 96 NONAME
-	_ZN22NmAttachmentListWidget13itemActivatedEi @ 97 NONAME
-	_ZN22NmAttachmentListWidget15hideProgressBarEi @ 98 NONAME
-	_ZN22NmAttachmentListWidget15rearrangeLayoutEv @ 99 NONAME
-	_ZN22NmAttachmentListWidget16insertAttachmentEiRK7QStringS2_ @ 100 NONAME
-	_ZN22NmAttachmentListWidget16removeAttachmentEi @ 101 NONAME
-	_ZN22NmAttachmentListWidget16staticMetaObjectE @ 102 NONAME DATA 16
-	_ZN22NmAttachmentListWidget17handleLongPressedE7QPointF @ 103 NONAME
-	_ZN22NmAttachmentListWidget17setAttachmentSizeEiRK7QString @ 104 NONAME
-	_ZN22NmAttachmentListWidget18insertItemToLayoutEP20NmAttachmentListItem @ 105 NONAME
-	_ZN22NmAttachmentListWidget18orientationChangedEN2Qt11OrientationE @ 106 NONAME
-	_ZN22NmAttachmentListWidget19getStaticMetaObjectEv @ 107 NONAME
-	_ZN22NmAttachmentListWidget19handleItemActivatedEv @ 108 NONAME
-	_ZN22NmAttachmentListWidget19setProgressBarValueEii @ 109 NONAME
-	_ZN22NmAttachmentListWidget4initEv @ 110 NONAME
-	_ZN22NmAttachmentListWidget5paintEP8QPainterPK24QStyleOptionGraphicsItemP7QWidget @ 111 NONAME
-	_ZN22NmAttachmentListWidget8findItemEPK7QObject @ 112 NONAME
-	_ZN22NmAttachmentListWidgetC1EP13QGraphicsItem @ 113 NONAME
-	_ZN22NmAttachmentListWidgetC2EP13QGraphicsItem @ 114 NONAME
-	_ZN22NmAttachmentListWidgetD0Ev @ 115 NONAME
-	_ZN22NmAttachmentListWidgetD1Ev @ 116 NONAME
-	_ZN22NmAttachmentListWidgetD2Ev @ 117 NONAME
-	_ZNK14NmHtmlLineEdit10metaObjectEv @ 118 NONAME
-	_ZNK14NmHtmlLineEdit10textCursorEv @ 119 NONAME
-	_ZNK14NmHtmlLineEdit11toPlainTextEv @ 120 NONAME
-	_ZNK14NmHtmlLineEdit6toHtmlEv @ 121 NONAME
-	_ZNK14NmHtmlLineEdit8documentEv @ 122 NONAME
-	_ZNK16NmEditorTextEdit10metaObjectEv @ 123 NONAME
-	_ZNK16NmEditorTextEdit13contentHeightEv @ 124 NONAME
-	_ZNK16NmEditorTextEdit15customTextColorEv @ 125 NONAME
-	_ZNK19NmRecipientLineEdit10metaObjectEv @ 126 NONAME
-	_ZNK20NmAttachmentListItem10metaObjectEv @ 127 NONAME
-	_ZNK20NmAttachmentListItem16progressBarValueEv @ 128 NONAME
-	_ZNK20NmBaseViewScrollArea10metaObjectEv @ 129 NONAME
-	_ZNK22NmAttachmentListWidget10metaObjectEv @ 130 NONAME
-	_ZNK22NmAttachmentListWidget13progressValueEi @ 131 NONAME
-	_ZNK22NmAttachmentListWidget5countEv @ 132 NONAME
-	_ZTI14NmHtmlLineEdit @ 133 NONAME
-	_ZTI16NmEditorTextEdit @ 134 NONAME
-	_ZTI19NmRecipientLineEdit @ 135 NONAME
-	_ZTI20NmAttachmentListItem @ 136 NONAME
-	_ZTI20NmBaseViewScrollArea @ 137 NONAME
-	_ZTI22NmAttachmentListWidget @ 138 NONAME
-	_ZTV14NmHtmlLineEdit @ 139 NONAME
-	_ZTV16NmEditorTextEdit @ 140 NONAME
-	_ZTV19NmRecipientLineEdit @ 141 NONAME
-	_ZTV20NmAttachmentListItem @ 142 NONAME
-	_ZTV20NmBaseViewScrollArea @ 143 NONAME
-	_ZTV22NmAttachmentListWidget @ 144 NONAME
-	_ZThn16_N14NmHtmlLineEditD0Ev @ 145 NONAME
-	_ZThn16_N14NmHtmlLineEditD1Ev @ 146 NONAME
-	_ZThn16_N16NmEditorTextEditD0Ev @ 147 NONAME
-	_ZThn16_N16NmEditorTextEditD1Ev @ 148 NONAME
-	_ZThn16_N19NmRecipientLineEditD0Ev @ 149 NONAME
-	_ZThn16_N19NmRecipientLineEditD1Ev @ 150 NONAME
-	_ZThn16_N20NmAttachmentListItemD0Ev @ 151 NONAME
-	_ZThn16_N20NmAttachmentListItemD1Ev @ 152 NONAME
-	_ZThn16_N20NmBaseViewScrollAreaD0Ev @ 153 NONAME
-	_ZThn16_N20NmBaseViewScrollAreaD1Ev @ 154 NONAME
-	_ZThn16_N22NmAttachmentListWidgetD0Ev @ 155 NONAME
-	_ZThn16_N22NmAttachmentListWidgetD1Ev @ 156 NONAME
-	_ZThn8_N14NmHtmlLineEditD0Ev @ 157 NONAME
-	_ZThn8_N14NmHtmlLineEditD1Ev @ 158 NONAME
-	_ZThn8_N16NmEditorTextEditD0Ev @ 159 NONAME
-	_ZThn8_N16NmEditorTextEditD1Ev @ 160 NONAME
-	_ZThn8_N19NmRecipientLineEdit13keyPressEventEP9QKeyEvent @ 161 NONAME
-	_ZThn8_N19NmRecipientLineEdit16inputMethodEventEP17QInputMethodEvent @ 162 NONAME
-	_ZThn8_N19NmRecipientLineEditD0Ev @ 163 NONAME
-	_ZThn8_N19NmRecipientLineEditD1Ev @ 164 NONAME
-	_ZThn8_N20NmAttachmentListItem15mousePressEventEP24QGraphicsSceneMouseEvent @ 165 NONAME
-	_ZThn8_N20NmAttachmentListItem17mouseReleaseEventEP24QGraphicsSceneMouseEvent @ 166 NONAME
-	_ZThn8_N20NmAttachmentListItemD0Ev @ 167 NONAME
-	_ZThn8_N20NmAttachmentListItemD1Ev @ 168 NONAME
-	_ZThn8_N20NmBaseViewScrollArea14mouseMoveEventEP24QGraphicsSceneMouseEvent @ 169 NONAME
-	_ZThn8_N20NmBaseViewScrollArea15mousePressEventEP24QGraphicsSceneMouseEvent @ 170 NONAME
-	_ZThn8_N20NmBaseViewScrollArea17mouseReleaseEventEP24QGraphicsSceneMouseEvent @ 171 NONAME
-	_ZThn8_N20NmBaseViewScrollAreaD0Ev @ 172 NONAME
-	_ZThn8_N20NmBaseViewScrollAreaD1Ev @ 173 NONAME
-	_ZThn8_N22NmAttachmentListWidget5paintEP8QPainterPK24QStyleOptionGraphicsItemP7QWidget @ 174 NONAME
-	_ZThn8_N22NmAttachmentListWidgetD0Ev @ 175 NONAME
-	_ZThn8_N22NmAttachmentListWidgetD1Ev @ 176 NONAME
+	_ZN16NmEditorTextEdit16staticMetaObjectE @ 16 NONAME DATA 16
+	_ZN16NmEditorTextEdit18setCustomTextColorERK5QPairIb6QColorE @ 17 NONAME
+	_ZN16NmEditorTextEdit18setCustomTextColorEbRK6QColor @ 18 NONAME
+	_ZN16NmEditorTextEdit19getStaticMetaObjectEv @ 19 NONAME
+	_ZN16NmEditorTextEdit21updateCustomTextColorEv @ 20 NONAME
+	_ZN16NmEditorTextEditC1EP13QGraphicsItem @ 21 NONAME
+	_ZN16NmEditorTextEditC2EP13QGraphicsItem @ 22 NONAME
+	_ZN16NmEditorTextEditD0Ev @ 23 NONAME
+	_ZN16NmEditorTextEditD1Ev @ 24 NONAME
+	_ZN16NmEditorTextEditD2Ev @ 25 NONAME
+	_ZN19NmRecipientLineEdit11qt_metacallEN11QMetaObject4CallEiPPv @ 26 NONAME
+	_ZN19NmRecipientLineEdit11qt_metacastEPKc @ 27 NONAME
+	_ZN19NmRecipientLineEdit13keyPressEventEP9QKeyEvent @ 28 NONAME
+	_ZN19NmRecipientLineEdit16emailAddressListEv @ 29 NONAME
+	_ZN19NmRecipientLineEdit16inputMethodEventEP17QInputMethodEvent @ 30 NONAME
+	_ZN19NmRecipientLineEdit16staticMetaObjectE @ 31 NONAME DATA 16
+	_ZN19NmRecipientLineEdit17handleTextChangedERK7QString @ 32 NONAME
+	_ZN19NmRecipientLineEdit19addSelectedContactsERK8QVariant @ 33 NONAME
+	_ZN19NmRecipientLineEdit19getStaticMetaObjectEv @ 34 NONAME
+	_ZN19NmRecipientLineEdit24generateEmailAddressListEv @ 35 NONAME
+	_ZN19NmRecipientLineEditC1EP13QGraphicsItem @ 36 NONAME
+	_ZN19NmRecipientLineEditC2EP13QGraphicsItem @ 37 NONAME
+	_ZN19NmRecipientLineEditD0Ev @ 38 NONAME
+	_ZN19NmRecipientLineEditD1Ev @ 39 NONAME
+	_ZN19NmRecipientLineEditD2Ev @ 40 NONAME
+	_ZN20NmAttachmentListItem11constructUiEv @ 41 NONAME
+	_ZN20NmAttachmentListItem11qt_metacallEN11QMetaObject4CallEiPPv @ 42 NONAME
+	_ZN20NmAttachmentListItem11qt_metacastEPKc @ 43 NONAME
+	_ZN20NmAttachmentListItem12gestureEventEP13QGestureEvent @ 44 NONAME
+	_ZN20NmAttachmentListItem12setTextColorE6QColor @ 45 NONAME
+	_ZN20NmAttachmentListItem13itemActivatedEv @ 46 NONAME
+	_ZN20NmAttachmentListItem15hideProgressBarEv @ 47 NONAME
+	_ZN20NmAttachmentListItem15itemLongPressedE7QPointF @ 48 NONAME
+	_ZN20NmAttachmentListItem15setFileNameTextERK7QString @ 49 NONAME
+	_ZN20NmAttachmentListItem15setFileSizeTextERK7QString @ 50 NONAME
+	_ZN20NmAttachmentListItem16staticMetaObjectE @ 51 NONAME DATA 16
+	_ZN20NmAttachmentListItem17removeProgressBarEv @ 52 NONAME
+	_ZN20NmAttachmentListItem19getStaticMetaObjectEv @ 53 NONAME
+	_ZN20NmAttachmentListItem19setProgressBarValueEi @ 54 NONAME
+	_ZN20NmAttachmentListItem4initEv @ 55 NONAME
+	_ZN20NmAttachmentListItemC1EP13QGraphicsItem @ 56 NONAME
+	_ZN20NmAttachmentListItemC2EP13QGraphicsItem @ 57 NONAME
+	_ZN20NmAttachmentListItemD0Ev @ 58 NONAME
+	_ZN20NmAttachmentListItemD1Ev @ 59 NONAME
+	_ZN20NmAttachmentListItemD2Ev @ 60 NONAME
+	_ZN20NmBaseViewScrollArea11qt_metacallEN11QMetaObject4CallEiPPv @ 61 NONAME
+	_ZN20NmBaseViewScrollArea11qt_metacastEPKc @ 62 NONAME
+	_ZN20NmBaseViewScrollArea14mouseMoveEventEP24QGraphicsSceneMouseEvent @ 63 NONAME
+	_ZN20NmBaseViewScrollArea15mousePressEventEP24QGraphicsSceneMouseEvent @ 64 NONAME
+	_ZN20NmBaseViewScrollArea16longPressGestureERK7QPointF @ 65 NONAME
+	_ZN20NmBaseViewScrollArea16staticMetaObjectE @ 66 NONAME DATA 16
+	_ZN20NmBaseViewScrollArea17mouseReleaseEventEP24QGraphicsSceneMouseEvent @ 67 NONAME
+	_ZN20NmBaseViewScrollArea19getStaticMetaObjectEv @ 68 NONAME
+	_ZN20NmBaseViewScrollArea20handleMouseMoveEventEP24QGraphicsSceneMouseEvent @ 69 NONAME
+	_ZN20NmBaseViewScrollArea21handleMousePressEventEP24QGraphicsSceneMouseEvent @ 70 NONAME
+	_ZN20NmBaseViewScrollArea22handleLongPressGestureERK7QPointF @ 71 NONAME
+	_ZN20NmBaseViewScrollArea23handleMouseReleaseEventEP24QGraphicsSceneMouseEvent @ 72 NONAME
+	_ZN20NmBaseViewScrollAreaC1EP13QGraphicsItem @ 73 NONAME
+	_ZN20NmBaseViewScrollAreaC2EP13QGraphicsItem @ 74 NONAME
+	_ZN20NmBaseViewScrollAreaD0Ev @ 75 NONAME
+	_ZN20NmBaseViewScrollAreaD1Ev @ 76 NONAME
+	_ZN20NmBaseViewScrollAreaD2Ev @ 77 NONAME
+	_ZN22NmAttachmentListWidget11constructUiEv @ 78 NONAME
+	_ZN22NmAttachmentListWidget11longPressedEi7QPointF @ 79 NONAME
+	_ZN22NmAttachmentListWidget11qt_metacallEN11QMetaObject4CallEiPPv @ 80 NONAME
+	_ZN22NmAttachmentListWidget11qt_metacastEPKc @ 81 NONAME
+	_ZN22NmAttachmentListWidget12setTextColorE6QColor @ 82 NONAME
+	_ZN22NmAttachmentListWidget13itemActivatedEi @ 83 NONAME
+	_ZN22NmAttachmentListWidget15hideProgressBarEi @ 84 NONAME
+	_ZN22NmAttachmentListWidget15rearrangeLayoutEv @ 85 NONAME
+	_ZN22NmAttachmentListWidget16insertAttachmentEiRK7QStringS2_ @ 86 NONAME
+	_ZN22NmAttachmentListWidget16removeAttachmentEi @ 87 NONAME
+	_ZN22NmAttachmentListWidget16staticMetaObjectE @ 88 NONAME DATA 16
+	_ZN22NmAttachmentListWidget17handleLongPressedE7QPointF @ 89 NONAME
+	_ZN22NmAttachmentListWidget17setAttachmentSizeEiRK7QString @ 90 NONAME
+	_ZN22NmAttachmentListWidget18insertItemToLayoutEP20NmAttachmentListItem @ 91 NONAME
+	_ZN22NmAttachmentListWidget18orientationChangedEN2Qt11OrientationE @ 92 NONAME
+	_ZN22NmAttachmentListWidget19getStaticMetaObjectEv @ 93 NONAME
+	_ZN22NmAttachmentListWidget19handleItemActivatedEv @ 94 NONAME
+	_ZN22NmAttachmentListWidget19setProgressBarValueEii @ 95 NONAME
+	_ZN22NmAttachmentListWidget4initEv @ 96 NONAME
+	_ZN22NmAttachmentListWidget5paintEP8QPainterPK24QStyleOptionGraphicsItemP7QWidget @ 97 NONAME
+	_ZN22NmAttachmentListWidget8findItemEPK7QObject @ 98 NONAME
+	_ZN22NmAttachmentListWidgetC1EP13QGraphicsItem @ 99 NONAME
+	_ZN22NmAttachmentListWidgetC2EP13QGraphicsItem @ 100 NONAME
+	_ZN22NmAttachmentListWidgetD0Ev @ 101 NONAME
+	_ZN22NmAttachmentListWidgetD1Ev @ 102 NONAME
+	_ZN22NmAttachmentListWidgetD2Ev @ 103 NONAME
+	_ZNK14NmHtmlLineEdit10metaObjectEv @ 104 NONAME
+	_ZNK14NmHtmlLineEdit10textCursorEv @ 105 NONAME
+	_ZNK14NmHtmlLineEdit11toPlainTextEv @ 106 NONAME
+	_ZNK14NmHtmlLineEdit21rectForCursorPositionEv @ 107 NONAME
+	_ZNK14NmHtmlLineEdit6toHtmlEv @ 108 NONAME
+	_ZNK14NmHtmlLineEdit8documentEv @ 109 NONAME
+	_ZNK16NmEditorTextEdit10metaObjectEv @ 110 NONAME
+	_ZNK16NmEditorTextEdit15customTextColorEv @ 111 NONAME
+	_ZNK16NmEditorTextEdit21rectForCursorPositionEv @ 112 NONAME
+	_ZNK19NmRecipientLineEdit10metaObjectEv @ 113 NONAME
+	_ZNK20NmAttachmentListItem10metaObjectEv @ 114 NONAME
+	_ZNK20NmAttachmentListItem16progressBarValueEv @ 115 NONAME
+	_ZNK20NmBaseViewScrollArea10metaObjectEv @ 116 NONAME
+	_ZNK22NmAttachmentListWidget10metaObjectEv @ 117 NONAME
+	_ZNK22NmAttachmentListWidget13progressValueEi @ 118 NONAME
+	_ZNK22NmAttachmentListWidget5countEv @ 119 NONAME
+	_ZTI14NmHtmlLineEdit @ 120 NONAME
+	_ZTI16NmEditorTextEdit @ 121 NONAME
+	_ZTI19NmRecipientLineEdit @ 122 NONAME
+	_ZTI20NmAttachmentListItem @ 123 NONAME
+	_ZTI20NmBaseViewScrollArea @ 124 NONAME
+	_ZTI22NmAttachmentListWidget @ 125 NONAME
+	_ZTV14NmHtmlLineEdit @ 126 NONAME
+	_ZTV16NmEditorTextEdit @ 127 NONAME
+	_ZTV19NmRecipientLineEdit @ 128 NONAME
+	_ZTV20NmAttachmentListItem @ 129 NONAME
+	_ZTV20NmBaseViewScrollArea @ 130 NONAME
+	_ZTV22NmAttachmentListWidget @ 131 NONAME
+	_ZThn16_N14NmHtmlLineEditD0Ev @ 132 NONAME
+	_ZThn16_N14NmHtmlLineEditD1Ev @ 133 NONAME
+	_ZThn16_N16NmEditorTextEditD0Ev @ 134 NONAME
+	_ZThn16_N16NmEditorTextEditD1Ev @ 135 NONAME
+	_ZThn16_N19NmRecipientLineEditD0Ev @ 136 NONAME
+	_ZThn16_N19NmRecipientLineEditD1Ev @ 137 NONAME
+	_ZThn16_N20NmAttachmentListItemD0Ev @ 138 NONAME
+	_ZThn16_N20NmAttachmentListItemD1Ev @ 139 NONAME
+	_ZThn16_N20NmBaseViewScrollAreaD0Ev @ 140 NONAME
+	_ZThn16_N20NmBaseViewScrollAreaD1Ev @ 141 NONAME
+	_ZThn16_N22NmAttachmentListWidgetD0Ev @ 142 NONAME
+	_ZThn16_N22NmAttachmentListWidgetD1Ev @ 143 NONAME
+	_ZThn8_N14NmHtmlLineEditD0Ev @ 144 NONAME
+	_ZThn8_N14NmHtmlLineEditD1Ev @ 145 NONAME
+	_ZThn8_N16NmEditorTextEditD0Ev @ 146 NONAME
+	_ZThn8_N16NmEditorTextEditD1Ev @ 147 NONAME
+	_ZThn8_N19NmRecipientLineEdit13keyPressEventEP9QKeyEvent @ 148 NONAME
+	_ZThn8_N19NmRecipientLineEdit16inputMethodEventEP17QInputMethodEvent @ 149 NONAME
+	_ZThn8_N19NmRecipientLineEditD0Ev @ 150 NONAME
+	_ZThn8_N19NmRecipientLineEditD1Ev @ 151 NONAME
+	_ZThn8_N20NmAttachmentListItemD0Ev @ 152 NONAME
+	_ZThn8_N20NmAttachmentListItemD1Ev @ 153 NONAME
+	_ZThn8_N20NmBaseViewScrollArea14mouseMoveEventEP24QGraphicsSceneMouseEvent @ 154 NONAME
+	_ZThn8_N20NmBaseViewScrollArea15mousePressEventEP24QGraphicsSceneMouseEvent @ 155 NONAME
+	_ZThn8_N20NmBaseViewScrollArea17mouseReleaseEventEP24QGraphicsSceneMouseEvent @ 156 NONAME
+	_ZThn8_N20NmBaseViewScrollAreaD0Ev @ 157 NONAME
+	_ZThn8_N20NmBaseViewScrollAreaD1Ev @ 158 NONAME
+	_ZThn8_N22NmAttachmentListWidget5paintEP8QPainterPK24QStyleOptionGraphicsItemP7QWidget @ 159 NONAME
+	_ZThn8_N22NmAttachmentListWidgetD0Ev @ 160 NONAME
+	_ZThn8_N22NmAttachmentListWidgetD1Ev @ 161 NONAME
 
--- a/emailuis/nmailuiwidgets/inc/nmailuiwidgetsheaders.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/inc/nmailuiwidgetsheaders.h	Thu Jul 22 16:30:28 2010 +0100
@@ -32,7 +32,6 @@
 #include <xqservicerequest.h>
 #include <qtcontacts.h>
 #include <qmobilityglobal.h>
-#include <mobcntmodel.h>
 #include <xqserviceutil.h>
 #include <xqappmgr.h>
 #include <xqserviceipcmarshal.h>
@@ -47,6 +46,7 @@
 #include <hbdocumentloader.h>
 #include <hbinstance.h>
 #include <hbcolorscheme.h>
+#include <hbtapgesture.h>
 
 // nmail
 #include <nmaddress.h>
--- a/emailuis/nmailuiwidgets/inc/nmattachmentlistitem.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/inc/nmattachmentlistitem.h	Thu Jul 22 16:30:28 2010 +0100
@@ -24,7 +24,7 @@
 
 class HbProgressBar;
 class HbTextItem;
-class QTimer;
+class HbTapGesture;
 
 class NMAILUIWIDGETS_EXPORT NmAttachmentListItem : public HbWidget
 {
@@ -36,18 +36,15 @@
     void setTextColor(const QColor color);
     void setFileNameText(const QString &fileName);
     void setFileSizeText(const QString &fileSize);
-    void resetFileNameLength(Qt::Orientation orientation);
     void setProgressBarValue(const int value);
     int progressBarValue() const;
     void hideProgressBar();
 
 protected: 
-    void mousePressEvent( QGraphicsSceneMouseEvent *event );
-    void mouseReleaseEvent( QGraphicsSceneMouseEvent *event );
+    virtual void gestureEvent(QGestureEvent *event);
     
 private slots:
     void removeProgressBar();
-    void longPressedActivated();
 
 signals: 
     void itemActivated();
@@ -56,16 +53,12 @@
 private: 
     void init( );
     void constructUi();
-    QSize screenSize(Qt::Orientation orientation);
     
 private:
     Q_DISABLE_COPY(NmAttachmentListItem)
     HbTextItem *mFileNameText; //owned
     HbTextItem *mFileSizeText; //owned
     HbProgressBar *mProgressBar; //owned
-    QTimer *mTimer; //owned
-    bool mButtonPressed;
-    QPointF mLongPressedPoint;
     QColor mTextColor;
 };
 
--- a/emailuis/nmailuiwidgets/inc/nmeditortextedit.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/inc/nmeditortextedit.h	Thu Jul 22 16:30:28 2010 +0100
@@ -21,10 +21,6 @@
 #include <hbtextedit.h>
 #include "nmailuiwidgetsdef.h"
 
-class NmBaseViewScrollArea;
-class HbScrollArea;
-
-
 class NMAILUIWIDGETS_EXPORT NmEditorTextEdit : public HbTextEdit
 {
 Q_OBJECT
@@ -33,35 +29,16 @@
     NmEditorTextEdit(QGraphicsItem *parent = 0);
     virtual ~NmEditorTextEdit();
 
-    void init(NmBaseViewScrollArea *bgScrollArea);
-    qreal contentHeight() const;
-
-    void sendMousePressEvent(QGraphicsSceneMouseEvent *event);
-    void sendMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
-    void sendMouseMoveEvent(QGraphicsSceneMouseEvent *event);
-    void sendLongPressEvent(const QPointF &point);
     void setCustomTextColor(const QPair<bool, QColor> &customColor);
     void setCustomTextColor(bool useCustom, const QColor& color = Qt::black);
     QPair<bool, QColor> customTextColor() const;
 
-signals:
-    void editorContentHeightChanged();
+    QRectF rectForCursorPosition() const;
 
 public slots:
-    void updateEditorHeight();
-    void setHeaderHeight(int);
-    void setScrollPosition(int oldPos, int newPos);
-    void updateScrollPosition(const QPointF &newPosition);
     void updateCustomTextColor();
 
 private:
-    HbScrollArea *mScrollArea;
-    NmBaseViewScrollArea *mBackgroundScrollArea;
-    qreal mPreviousContentsHeight;
-    int mHeaderHeight;
-    QPointF mBgScrollPosition;
-    bool mFirstTime;
-    
     QPair<bool, QColor> mCustomTextColor;//!<This property keeps info about using customTextColor and color to use. 
 };
 
--- a/emailuis/nmailuiwidgets/inc/nmhtmllineedit.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/inc/nmhtmllineedit.h	Thu Jul 22 16:30:28 2010 +0100
@@ -38,6 +38,8 @@
     QString toPlainText() const;
     QString toHtml() const;
 
+    QRectF rectForCursorPosition() const;
+
 public slots:
     void setPlainText(const QString &text);
     void setHtml(const QString &text);
--- a/emailuis/nmailuiwidgets/inc/nmrecipientlineedit.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/inc/nmrecipientlineedit.h	Thu Jul 22 16:30:28 2010 +0100
@@ -38,7 +38,7 @@
 	
 public slots:
 #ifdef Q_OS_SYMBIAN
-    void insertSelectedContacts(const QVariant &selectedContacts);
+    void addSelectedContacts(const QVariant &selectedContacts);
 #endif
 
 protected:	// from HbLineEdit
@@ -54,12 +54,12 @@
 
 private:
     // mEmailAddressList contains all emailaddress that appear in the lineedit and 
-    // all emailaddress corresponding to the name inserted from PhoneBook,
-    // including invalid emailaddress user typed or invalid emailaddress picked from PhoneBook.
+    // all emailaddress corresponding to the contact's name added from Contacts,
+    // including invalid emailaddress user typed or invalid emailaddress added from Contacts.
     // Emailaddress validation check is conducted in nmeditorview.
     QList<NmAddress> mEmailAddressList; 
 	
-    QList<NmAddress> mContactsSelectedFromPhoneBook;
+    QList<NmAddress> mRecipientsAddedFromContacts;
 	
     // Flag "need to generate mEmailAddressList" is used whenever editing made after 
     // the emailaddress validation check failed.
--- a/emailuis/nmailuiwidgets/nmailuiwidgets.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/nmailuiwidgets.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -42,8 +42,7 @@
     LIBS += -lnmailbase \
             -lxqservice \
             -lxqserviceutil \
-            -lqtcontacts \
-            -lmobcntmodel
+            -lqtcontacts
 
     defBlock = \      
       "$${LITERAL_HASH}if defined(MARM)" \
--- a/emailuis/nmailuiwidgets/nmailuiwidgets.qrc	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/nmailuiwidgets.qrc	Thu Jul 22 16:30:28 2010 +0100
@@ -3,5 +3,7 @@
         <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>
 </RCC>
--- a/emailuis/nmailuiwidgets/src/nmattachmentlistitem.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/src/nmattachmentlistitem.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -23,10 +23,6 @@
 static const int PROGRESSBAR_MIN = 0; 
 static const int PROGRESSBAR_MAX = 100;
 static const int PROGRESSBAR_HIDE_COUNTDOWN = 500;
-static const int LONGPRESS_TIMER = 2000;
-
-// Hardcoded file size length. Maximum (999.9 Mb) fits into size field.
-static const int FILE_SIZE_FIELD_LENGTH = 120;
 
 /*!
  @nmailuiwidgets
@@ -47,12 +43,15 @@
     : HbWidget( parent ),
       mFileNameText(NULL),
       mFileSizeText(NULL),
-      mProgressBar(NULL),
-      mTimer(NULL),
-      mButtonPressed(false),
-      mLongPressedPoint(0,0)
+      mProgressBar(NULL)
 {
+    NM_FUNCTION;
+    
     init( );
+	
+    // Informs GestureFramework that NmAttachmentListItem widget is interested 
+    // Tap gesture and TapAndHold gesture.
+    grabGesture(Qt::TapGesture);
 }
 
 /*!
@@ -61,6 +60,8 @@
  */
 void NmAttachmentListItem::setTextColor(const QColor color)
 {
+    NM_FUNCTION;
+    
     mTextColor=color;
 }
 
@@ -69,11 +70,10 @@
  */
 NmAttachmentListItem::~NmAttachmentListItem( )
 {
+    NM_FUNCTION;
+    
     HbStyleLoader::unregisterFilePath(FILE_PATH_WIDGETML);
     HbStyleLoader::unregisterFilePath(FILE_PATH_CSS);
-    
-    delete mTimer;
-    mTimer = NULL; 
 }
 
 /*!
@@ -81,6 +81,8 @@
  */
 void NmAttachmentListItem::setFileNameText(const QString &fileName)
 {
+    NM_FUNCTION;
+    
     if (mFileNameText){
         if (mTextColor.isValid()){
             mFileNameText->setTextColor(mTextColor);
@@ -95,6 +97,8 @@
  */
 void NmAttachmentListItem::setFileSizeText(const QString &fileSize)
 {
+    NM_FUNCTION;
+    
     if (mFileSizeText){
         if (mTextColor.isValid()){
             mFileSizeText->setTextColor(mTextColor);
@@ -105,25 +109,12 @@
 }
 
 /*!
-    Set the length of the filename field.
- */
-void NmAttachmentListItem::resetFileNameLength(Qt::Orientation orientation)
-{
-	QSizeF reso = screenSize(orientation);
-	
-	if (orientation == Qt::Horizontal) {
-        mFileNameText->setPreferredWidth(reso.width() / 2 - FILE_SIZE_FIELD_LENGTH);
-	}
-	else {		
-        mFileNameText->setPreferredWidth(reso.width() - FILE_SIZE_FIELD_LENGTH);
-	}
-}
-
-/*!
     Set the download progress bar value (0-100)%, if value is 0 progress bar is hidden
  */
 void NmAttachmentListItem::setProgressBarValue(const int value)
 {
+    NM_FUNCTION;
+    
     //first check if value is 0 or below -> hide progressbar
     if ( 0 >= value ){
         removeProgressBar();
@@ -150,6 +141,8 @@
 */
 int NmAttachmentListItem::progressBarValue() const
 {
+    NM_FUNCTION;
+    
     int ret = 0;
     if ( mProgressBar ){
         ret = mProgressBar->progressValue();
@@ -163,6 +156,8 @@
 */
 void NmAttachmentListItem::hideProgressBar()
 {
+    NM_FUNCTION;
+    
     QTimer::singleShot(PROGRESSBAR_HIDE_COUNTDOWN,this, SLOT(removeProgressBar()));
 }
 
@@ -171,16 +166,13 @@
 */
 void NmAttachmentListItem::init( )
 {
+    NM_FUNCTION;
+    
     constructUi();
 
     //set default values
     setFlag(QGraphicsItem::ItemIsFocusable);
     setFlag(QGraphicsItem::ItemIsSelectable);
-
-    //set temporary longpress timer
-    mTimer = new QTimer(this);
-    mTimer->setSingleShot(true);
-    connect(mTimer, SIGNAL(timeout()), this, SLOT(longPressedActivated()));
 }
 
 /*!
@@ -188,6 +180,8 @@
 */
 void NmAttachmentListItem::constructUi()
 {
+    NM_FUNCTION;
+    
     //construct default ui.    
     HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML);
     HbStyleLoader::registerFilePath(FILE_PATH_CSS);
@@ -205,38 +199,12 @@
 
 
 /*!
-    \reimp
- */
-void NmAttachmentListItem::mousePressEvent( QGraphicsSceneMouseEvent *event )
-{
-    NMLOG("NmAttachmentListItem::mousePressEvent");
-
-    mButtonPressed = true;
-    mLongPressedPoint = event->scenePos();
-    if(mTimer){
-        mTimer->start(LONGPRESS_TIMER);        
-    }
-}
-
-/*!
-    \reimp
- */
-void NmAttachmentListItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
-    Q_UNUSED(event);
-    NMLOG("NmAttachmentListItem::mouseReleasedEvent");
-    if ( mTimer && mButtonPressed ){
-        emit itemActivated();
-        mButtonPressed = false;
-        mTimer->stop();
-    }
-}
-
-/*!
     Hides the download progress bar
  */
 void NmAttachmentListItem::removeProgressBar()
 {
+    NM_FUNCTION;
+    
 	if ( mProgressBar ){
 	    HbStyle::setItemName( mProgressBar, "" );
 	    mProgressBar->deleteLater();
@@ -245,48 +213,36 @@
 	}
 }
 
+
 /*!
-
+    This function handles gestures
  */
-void NmAttachmentListItem::longPressedActivated()
+void NmAttachmentListItem::gestureEvent(QGestureEvent *event)
 {
-    //check first if button is not released already
-    if ( mButtonPressed ){
-        NMLOG("NmAttachmentListItem::longPressedActivated");
-        emit itemLongPressed(mLongPressedPoint);
-        mButtonPressed = false;
+    NM_FUNCTION;
+    
+    if (HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
+        switch(tap->tapStyleHint()) {
+        case HbTapGesture::Tap:
+            {
+                if (tap->state() == Qt::GestureFinished) {
+                    emit itemActivated();
+                }
+             }
+             break;
+            
+         case HbTapGesture::TapAndHold:
+             {
+                 if (tap->state() == Qt::GestureFinished) {
+                 emit itemLongPressed(event->mapToGraphicsScene(tap->position()));
+                 }
+             }    
+             break;
+        }
+    }
+    else {
+           HbWidget::gestureEvent(event);
     }
 }
 
-/*!
-    This function returns screen size depending on the orientation.
-    Function is copied from NmApplication.
- */
-QSize NmAttachmentListItem::screenSize(Qt::Orientation orientation)
-{
-    QSize ret(0,0);
-    HbDeviceProfile currentP = HbDeviceProfile::current();
-    HbDeviceProfile altP(currentP.alternateProfileName());
-    QSize curPSize = currentP.logicalSize();
-    QSize altPSize = altP.logicalSize();
-    if (orientation == Qt::Horizontal) {
-        // Get wide profile size in landscape
-        if (curPSize.width() > altPSize.width()) {
-            ret = curPSize;
-        }
-        else{
-            ret = altPSize;
-        }
-    }
-    else {
-        // Get narrow profile size in portrait
-        if (curPSize.width() < altPSize.width()) {
-            ret = curPSize;
-        }
-        else{
-            ret = altPSize;
-        }
-    }
-    return ret;
-}
 
--- a/emailuis/nmailuiwidgets/src/nmattachmentlistwidget.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/src/nmattachmentlistwidget.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -106,6 +106,8 @@
     mLayout(NULL),
     mOrientation(Qt::Vertical)
 {
+    NM_FUNCTION;
+    
     init( );
 }
 
@@ -115,7 +117,12 @@
  */
 NmAttachmentListWidget::~NmAttachmentListWidget( )
 {
+    NM_FUNCTION;
+    
+    qDeleteAll(mItemList);
+
     mItemList.clear();
+	
 }
 
 /*!
@@ -124,6 +131,8 @@
  */
 void NmAttachmentListWidget::setTextColor(const QColor color)
 {
+    NM_FUNCTION;
+    
     mTextColor=color;
 }
 
@@ -137,6 +146,8 @@
         const QString &fileName, 
         const QString &fileSize)
 {   
+    NM_FUNCTION;
+    
     NmAttachmentListItem *item = new NmAttachmentListItem(this);
     item->setObjectName(QString("nmattachmentlistitem_%1").arg(index));
 
@@ -163,8 +174,10 @@
  */
 void NmAttachmentListWidget::removeAttachment(int index)
 {
+    NM_FUNCTION;
+    
     if(!mLayout) {
-        NMLOG("NmAttachmentListWidget::removeAttachment: Layout loading failed!");
+        NM_ERROR(1,"NmAttachmentListWidget::removeAttachment(): layout loading failed");
         return;
     }
 
@@ -189,6 +202,8 @@
         int index, 
         const QString &fileSize)
 {
+    NM_FUNCTION;
+    
 	if (index>=0 && index<mItemList.count()) {
 	    mItemList.at(index)->setFileSizeText(fileSize);
 	}
@@ -199,6 +214,8 @@
  */
 int NmAttachmentListWidget::count() const
 {
+    NM_FUNCTION;
+    
     return mItemList.count();
 }
 
@@ -207,6 +224,8 @@
  */
 int NmAttachmentListWidget::progressValue(int index) const
 {
+    NM_FUNCTION;
+    
     int ret(NmNotFoundError);
     if(index >= 0 && index < mItemList.count()){
         ret = mItemList.at(index)->progressBarValue();
@@ -220,6 +239,8 @@
  */
 void NmAttachmentListWidget::hideProgressBar(int index)
 {
+    NM_FUNCTION;
+    
     if(index >= 0 && index < mItemList.count()){
         mItemList.at(index)->hideProgressBar();
     }
@@ -234,9 +255,13 @@
     const QStyleOptionGraphicsItem *option,
     QWidget *widget)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(option);
     Q_UNUSED(widget);
     if (painter&&mLayout){
+        painter->save();
+        
         // Use text color as a line color if set, otherwise use theme
         // normal list content color.
         if (mTextColor.isValid()){
@@ -260,7 +285,8 @@
                               layoutRect.bottomRight().x(), itemRect.bottomRight().y());
                 painter->drawLine(line1);                     
             }     
-        }        
+        }
+        painter->restore();
     }
 }
 
@@ -270,6 +296,8 @@
  */
 void NmAttachmentListWidget::setProgressBarValue(int index, int value)
 {
+    NM_FUNCTION;
+    
     if(index >= 0 && index < mItemList.count()){
         mItemList[index]->setProgressBarValue(value);
     }
@@ -280,6 +308,8 @@
  */
 void NmAttachmentListWidget::init( )
 {
+    NM_FUNCTION;
+    
     //Get mainwindow for orientation changes
     HbMainWindow *mw = hbInstance->allMainWindows().at(0);
 
@@ -288,14 +318,15 @@
         connect(mw, SIGNAL(orientationChanged(Qt::Orientation)),this, SLOT(orientationChanged(Qt::Orientation)));
         mOrientation = mw->orientation();
     } else {
-        NMLOG("NmAttachmentListWidget::init: mainWindow missing!");
+        NM_ERROR(1,"NmAttachmentListWidget::init: mainWindow missing!");
     }
 
     //construct UI after orientation has been figured out
     constructUi();
 
-    //set default values, needed?
-    setFlag(QGraphicsItem::ItemIsFocusable);      
+    //set flags
+    setFlag(QGraphicsItem::ItemIsFocusable);  
+    setFlag(QGraphicsItem::ItemHasNoContents,false);
 }
 
 /*!
@@ -303,6 +334,8 @@
  */
 void NmAttachmentListWidget::constructUi()
 {
+    NM_FUNCTION;
+    
     setObjectName(QString(ATTACHMENT_WIDGET));
     HbDocumentLoader loader;
     bool loadingOk = false;
@@ -313,18 +346,16 @@
     loader.setObjectTree(objectList);
     QObjectList widgetlist = loader.load(FILE_PATH_DOCML, &loadingOk);
 
-    int widgetCount = widgetlist.count();
-    if(loadingOk && widgetCount){
+    if(loadingOk){
         if(layout()){
             mLayout = dynamic_cast<QGraphicsGridLayout*>(layout());
             mLayout->setContentsMargins(0,0,0,0);
         } else {
-            NMLOG("NmAttachmentListWidget::constructUi: Widget doesn't have layout!");
+            NM_ERROR(1,"NmAttachmentListWidget::constructUi: Widget doesn't have layout!");
         }
     } else {
-        NMLOG("NmAttachmentListWidget::constructUi: DocML loading failed.");
+        NM_ERROR(1,"NmAttachmentListWidget::constructUi: DocML loading failed.");
     }
-
 }
 
 /*!
@@ -332,13 +363,15 @@
 */
 void NmAttachmentListWidget::handleLongPressed(QPointF point)
 {
+    NM_FUNCTION;
+    
     QObject *sender = QObject::sender();
     int index = findItem(sender);
     if(NmNotFoundError != index){
         emit longPressed(index, point);
     }
     else {
-        NMLOG("NmAttachmentListWidget::handleLongPressed: item cannot found!");
+        NM_ERROR(1,"NmAttachmentListWidget::handleLongPressed: item cannot found!");
     }
 
 }
@@ -348,13 +381,15 @@
 */
 void NmAttachmentListWidget::handleItemActivated()
 {
+    NM_FUNCTION;
+    
     QObject *sender = QObject::sender();
     int index = findItem(sender);
     if(NmNotFoundError != index){
         emit itemActivated(index);
     }
     else {
-        NMLOG("NmAttachmentListWidget::handleItemActivated: item cannot found!");
+        NM_ERROR(1,"NmAttachmentListWidget::handleItemActivated: item cannot found!");
     }
 }
 
@@ -364,8 +399,8 @@
 */
 void NmAttachmentListWidget::orientationChanged(Qt::Orientation orientation)
 {
-    NMLOG("NmAttachmentListWidget::orientationChanged");
-
+    NM_FUNCTION;
+    
     //be sure that orientation has been changed
     if(mOrientation != orientation){
         mOrientation = orientation;
@@ -381,6 +416,8 @@
 */
 int NmAttachmentListWidget::findItem(const QObject *obj)
 {
+    NM_FUNCTION;
+    
     int found(NmNotFoundError);
     int index(0);
 
@@ -401,8 +438,10 @@
 */
 void NmAttachmentListWidget::insertItemToLayout(NmAttachmentListItem* item)
 {
+    NM_FUNCTION;
+    
     if(!mLayout) {
-        NMLOG("NmAttachmentListWidget::insertItemToLayout: Layout loading failed!");
+        NM_ERROR(1,"NmAttachmentListWidget::insertItemToLayout: Layout loading failed!");
         return;
     }
     int layout_count = mLayout->count();
@@ -412,11 +451,9 @@
     if(Qt::Vertical == mOrientation){
         mLayout->addItem(item,layout_count,0);
     } else {
-        item->setPreferredWidth(preferredWidth() / 2);
+        // Qt FW sets the correct width automatically based on the width of the child widgets
         mLayout->addItem(item,layout_count / 2, layout_count % 2);
     }
-    // Update maximum length of the file name field.
-    item->resetFileNameLength(mOrientation);
 }
 
 /*!
@@ -424,8 +461,10 @@
 */
 void NmAttachmentListWidget::rearrangeLayout()
 {
+    NM_FUNCTION;
+    
     if(!mLayout) {
-        NMLOG("NmAttachmentListWidget::rearrangeLayout: Layout loading failed!");
+        NM_ERROR(1,"NmAttachmentListWidget::rearrangeLayout: Layout loading failed!");
         return;
     }
 
--- a/emailuis/nmailuiwidgets/src/nmbaseviewscrollarea.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/src/nmbaseviewscrollarea.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -23,6 +23,7 @@
 NmBaseViewScrollArea::NmBaseViewScrollArea(QGraphicsItem *parentView) :
     HbScrollArea(parentView)
     {
+    NM_FUNCTION;
     }
 
 /*!
@@ -30,6 +31,7 @@
 */
 NmBaseViewScrollArea::~NmBaseViewScrollArea()
     {
+    NM_FUNCTION;
     }
 
 /*!
@@ -38,6 +40,8 @@
 */
 void NmBaseViewScrollArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
 {
+    NM_FUNCTION;
+    
     if (event){
         emit handleMousePressEvent(event);
         HbScrollArea::mousePressEvent(event);
@@ -50,6 +54,8 @@
 */
 void NmBaseViewScrollArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
 {
+    NM_FUNCTION;
+    
     if (event){
         emit handleMouseReleaseEvent(event);
         HbScrollArea::mouseReleaseEvent(event);
@@ -62,6 +68,8 @@
 */
 void NmBaseViewScrollArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
 {
+    NM_FUNCTION;
+    
     if (event){
         emit handleMouseMoveEvent(event);
         HbScrollArea::mouseMoveEvent(event);
@@ -73,6 +81,8 @@
 */
 void NmBaseViewScrollArea::longPressGesture(const QPointF &point)
 {
+    NM_FUNCTION;
+    
     emit handleLongPressGesture(point);
 }
 
--- a/emailuis/nmailuiwidgets/src/nmeditortextedit.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/src/nmeditortextedit.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -17,14 +17,8 @@
 
 #include "nmailuiwidgetsheaders.h"
 
-// Following constants will be removed later when possible
-static const double Un = 6.66;
-static const double BodyMargin = Un;
-static const int ChromeHeight = 160;
-static const double FieldHeightWhenSecondaryFont = 5 * Un;
-static const int GroupBoxTitleHeight = 42;
-static const double HeightOfTheHeaderOnStartup =
-    2 * FieldHeightWhenSecondaryFont + GroupBoxTitleHeight;
+static const QString FILE_PATH_CSS = ":nmeditortextedit.css";
+static const QString FILE_PATH_WIDGETML = ":nmeditortextedit.widgetml";
 
 /*!
     Constructor
@@ -32,6 +26,43 @@
 NmEditorTextEdit::NmEditorTextEdit(QGraphicsItem *parent) :
     HbTextEdit(parent)
 {
+    NM_FUNCTION;
+    
+    HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML);
+    HbStyleLoader::registerFilePath(FILE_PATH_CSS);
+
+    mCustomTextColor = QPair<bool, QColor>(false, Qt::black);
+    
+    // Disable HbTextEdit scrolling. Background scroll area will handle scrolling.
+    setScrollable(false);
+    scrollArea()->setScrollDirections(0);
+
+    // set background colour to plain white
+    QPixmap whitePixmap(10,10);
+    whitePixmap.fill(Qt::white);
+    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();
+
+    // Sets the selection background colour
+    testPalette.setColor(QPalette::Active, QPalette::Highlight, Qt::cyan);
+    testPalette.setColor(QPalette::Inactive, QPalette::Highlight, Qt::cyan);
+
+    // Sets the link and visited link colours
+    testPalette.setColor(QPalette::Active, QPalette::Link, Qt::darkBlue);
+    testPalette.setColor(QPalette::Inactive, QPalette::Link, Qt::darkBlue);
+    testPalette.setColor(QPalette::Active, QPalette::LinkVisited, Qt::darkMagenta);
+    testPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, Qt::darkMagenta);
+
+    // Update custom palette for this widget
+    setPalette(testPalette);
+
+    connect(this, SIGNAL(contentsChanged()), this, SLOT(updateCustomTextColor()));
 }
 
 /*!
@@ -39,119 +70,10 @@
 */
 NmEditorTextEdit::~NmEditorTextEdit()
 {
-}
-
-void NmEditorTextEdit::init(NmBaseViewScrollArea *bgScrollArea)
-{
-    mPreviousContentsHeight = 0;
-    mFirstTime = true;
-    mCustomTextColor = QPair<bool, QColor>(false,Qt::black);
-    mBackgroundScrollArea = bgScrollArea;
-    mHeaderHeight = (int)HeightOfTheHeaderOnStartup;
-    mBgScrollPosition.setX(0);
-    mBgScrollPosition.setY(0);
-    document()->setDocumentMargin(BodyMargin);
-
-    mScrollArea = this->scrollArea();
-    mScrollArea->setLongPressEnabled(true);
-    // Enable scrolling using cursor
-    setScrollable(true);
-    mScrollArea->setScrollDirections(Qt::Horizontal);
-    // Let all mouse events go into background scroll area which handles the scrolling
-    setAcceptedMouseButtons(Qt::NoButton);
-    mScrollArea->setAcceptedMouseButtons(Qt::NoButton);
-
-    connect(this, SIGNAL(contentsChanged()), this, SLOT(updateEditorHeight()));
-    connect(this, SIGNAL(cursorPositionChanged(int, int)),
-            this, SLOT(setScrollPosition(int, int)));
-    connect(this, SIGNAL(contentsChanged()), this, SLOT(updateCustomTextColor()));
-}
-
-/*!
-    This function returns the height (pixels) of the body fields document content.
- */
-qreal NmEditorTextEdit::contentHeight() const
-{
-    QSizeF s = document()->size();
-    return s.height();
-}
-
-/*!
-   This slot updates the editor height. It is called every time when text edit
-   widget content has been changed.
- */
-void NmEditorTextEdit::updateEditorHeight()
-{
-    // Get current body content height
-    qreal heightOfTheTextEdit = contentHeight();
-
-    // Check if height is changed
-    if (mPreviousContentsHeight != heightOfTheTextEdit) {
-        mPreviousContentsHeight = heightOfTheTextEdit;
-        setPreferredHeight(heightOfTheTextEdit);
-        setMaximumHeight(heightOfTheTextEdit);
-    }
-    // Inform parent that content height has been changed
-    emit editorContentHeightChanged();
-}
-
-/*!
-    This slot is called when cursor position is changed in body area using
-    'pointing stick' or keyboard. Function will update the scroll position
-    of the content so that cursor does not go outside of the screen or
-    behind the virtual keyboard.
- */
-void NmEditorTextEdit::setScrollPosition(int oldPos, int newPos)
-{
-    Q_UNUSED(oldPos);
-
-    if (mFirstTime) {
-        // For some reason content height of the HbTextEdit is wrong
-        // right after construction. That is the reason why this mFirstTime
-        // member is used to set content height bit later.
-        mFirstTime = false;
-        updateEditorHeight();
-    }
-    const QSizeF screenReso = HbDeviceProfile::current().logicalSize();
-    qreal maxHeight = screenReso.height() - ChromeHeight;
-
-    // Get cursor position coordinates
-    QRectF cursorPosPix = rectForPosition(newPos);
-
-    // Calculate the screen top and bottom boundaries, this means the part of the
-    // background scroll area which is currently visible.
-    qreal visibleRectTopBoundary;
-    qreal visibleRectBottomBoundary;
-
-    if (mBgScrollPosition.y() < mHeaderHeight) {
-        // Header is completely or partially visible
-        visibleRectTopBoundary = mHeaderHeight - mBgScrollPosition.y();
-        visibleRectBottomBoundary = maxHeight - visibleRectTopBoundary;
-    }
-    else {
-        // Header is not visible
-        visibleRectTopBoundary = mBgScrollPosition.y() - mHeaderHeight;
-        visibleRectBottomBoundary = visibleRectTopBoundary + maxHeight;
-    }
-
-    // Do scrolling if cursor is out of the screen boundaries
-    if (cursorPosPix.y() > visibleRectBottomBoundary) {
-        // Do scroll forward
-        mBackgroundScrollArea->scrollContentsTo(
-            QPointF(0,cursorPosPix.y() - maxHeight + mHeaderHeight));
-    }
-    else if (cursorPosPix.y() + mHeaderHeight < mBgScrollPosition.y()) {
-        // Do scroll backward
-        mBackgroundScrollArea->scrollContentsTo(QPointF(0,cursorPosPix.y() + mHeaderHeight));
-    }
-}
-
-/*!
-    This slot is called when background scroll areas scroll position has been shanged.
-*/
-void NmEditorTextEdit::updateScrollPosition(const QPointF &newPosition)
-{
-    mBgScrollPosition = newPosition;
+    NM_FUNCTION;
+    
+    HbStyleLoader::unregisterFilePath(FILE_PATH_WIDGETML);
+    HbStyleLoader::unregisterFilePath(FILE_PATH_CSS);    
 }
 
 /*!
@@ -160,6 +82,8 @@
  */
 void NmEditorTextEdit::updateCustomTextColor()
 {
+    NM_FUNCTION;
+    
     if (mCustomTextColor.first) {
         QTextCursor tcursor = textCursor();
         QTextCharFormat fmt;
@@ -175,7 +99,8 @@
                     tcursor.mergeCharFormat(fmt);
                 }
             }
-        } else {
+        }
+        else {
             fmt = tcursor.charFormat();
             fmt.setForeground(mCustomTextColor.second);
             tcursor.mergeCharFormat(fmt);
@@ -185,60 +110,14 @@
 }
 
 /*!
-    This slot is called when header widget height has been changed. Function performs
-    the repositioning of the body field and resizing of the editor and content area.
- */
-void NmEditorTextEdit::setHeaderHeight(int newHeight)
-{
-    mHeaderHeight = newHeight;
-    updateEditorHeight();
-}
-
-/*!
-    sendMousePressEvent. Function is used to relay mouse press event to base class
-*/
-void NmEditorTextEdit::sendMousePressEvent(QGraphicsSceneMouseEvent *event)
-{
-    if (event) {
-        HbAbstractEdit::mousePressEvent(event);
-    }
-}
-
-/*!
-    sendMouseReleaseEvent. Function is used to relay mouse release event to base class
-*/
-void NmEditorTextEdit::sendMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
-    if (event) {
-        HbAbstractEdit::mouseReleaseEvent(event);
-    }
-}
-
-/*!
-    sendMouseMoveEvent. Function is used to relay mouse move event to base class
-*/
-void NmEditorTextEdit::sendMouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
-    if (event) {
-        HbAbstractEdit::mouseMoveEvent(event);
-    }
-}
-
-/*!
-    sendLongPressEvent. Opens the context menu of the editor
-*/
-void NmEditorTextEdit::sendLongPressEvent(const QPointF &point)
-{
-    showContextMenu(point);
-}
-
-/*!
    Sets flag is custom text color should be used and sets the custom color.
    
    Function does not affect the color of existing content, only text that will be entered later.
  */
 void NmEditorTextEdit::setCustomTextColor(const QPair<bool, QColor> &customColor)
 {
+    NM_FUNCTION;
+    
     mCustomTextColor = customColor;
 }
 
@@ -250,6 +129,8 @@
  */
 void NmEditorTextEdit::setCustomTextColor(bool useCustom, const QColor& color)
 {   
+    NM_FUNCTION;
+    
     mCustomTextColor.first = useCustom;
     //check and set custom color
     mCustomTextColor.first ? mCustomTextColor.second = color : 
@@ -264,5 +145,18 @@
  */
 QPair<bool, QColor> NmEditorTextEdit::customTextColor() const
 {
+    NM_FUNCTION;
+    
     return mCustomTextColor;
 }
+
+/*!
+ *  Returns the rectangle for the cursor.
+ */
+QRectF NmEditorTextEdit::rectForCursorPosition() const
+{
+    NM_FUNCTION;
+    
+    return HbTextEdit::rectForPosition(cursorPosition());
+}
+
--- a/emailuis/nmailuiwidgets/src/nmhtmllineedit.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/src/nmhtmllineedit.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -25,6 +25,11 @@
 NmHtmlLineEdit::NmHtmlLineEdit(QGraphicsItem *parent) :
     HbLineEdit(parent)
 {
+    NM_FUNCTION;
+
+    // Disable scrolling so that baunch effect works correctly
+    HbAbstractEdit::setScrollable(false);
+    HbAbstractEdit::scrollArea()->setScrollDirections(0);
 }
 
 /*!
@@ -32,6 +37,7 @@
  */
 NmHtmlLineEdit::~NmHtmlLineEdit()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -41,40 +47,66 @@
  */
 void NmHtmlLineEdit::setDocument(QTextDocument *document)
 {
+    NM_FUNCTION;
+    
     HbAbstractEdit::setDocument(document);
 }
 
 QTextDocument *NmHtmlLineEdit::document() const
 {
+    NM_FUNCTION;
+    
     return HbAbstractEdit::document();
 }
 
 void NmHtmlLineEdit::setTextCursor(const QTextCursor &cursor)
 {
+    NM_FUNCTION;
+    
     HbAbstractEdit::setTextCursor(cursor);
 }
 
 QTextCursor NmHtmlLineEdit::textCursor() const
 {
+    NM_FUNCTION;
+    
     return HbAbstractEdit::textCursor();
 }
 
 QString NmHtmlLineEdit::toHtml() const
 {
+    NM_FUNCTION;
+    
     return HbAbstractEdit::toHtml();
 }
 
 void NmHtmlLineEdit::setHtml(const QString &text)
 {
+    NM_FUNCTION;
+    
     HbAbstractEdit::setHtml(text);
 }
 
 QString NmHtmlLineEdit::toPlainText () const
 {
+    NM_FUNCTION;
+    
     return HbAbstractEdit::toPlainText();
 }
 
 void NmHtmlLineEdit::setPlainText (const QString &text)
 {
+    NM_FUNCTION;
+    
     HbAbstractEdit::setPlainText(text);
 }
+
+/*!
+ *  Returns the rectangle for the cursor.
+ */
+QRectF NmHtmlLineEdit::rectForCursorPosition() const
+{
+    NM_FUNCTION;
+    
+    return HbLineEdit::rectForPosition(cursorPosition());
+}
--- a/emailuis/nmailuiwidgets/src/nmrecipientlineedit.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgets/src/nmrecipientlineedit.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -29,6 +29,8 @@
     : NmHtmlLineEdit(parent),
     mNeedToGenerateEmailAddressList(true)
 {
+    NM_FUNCTION;
+    
     connect(this, SIGNAL(textChanged(QString)), this, SLOT(handleTextChanged(QString)));
 }
 
@@ -38,6 +40,7 @@
 */
 NmRecipientLineEdit::~NmRecipientLineEdit()
 {
+    NM_FUNCTION;
 }
 
 
@@ -46,6 +49,8 @@
 */
 QList<NmAddress> NmRecipientLineEdit::emailAddressList()
 {
+    NM_FUNCTION;
+    
     if (mNeedToGenerateEmailAddressList) {
         // Empty mEmailAddressList.
         mEmailAddressList.clear();
@@ -60,67 +65,78 @@
 
 #ifdef Q_OS_SYMBIAN
 /*!
-   This Slot inserts the selected contacts from Contacts-picker into the lineedit cursor position.    
-   "You shouldn't be able to convert the parameter selectedContacts into a QStringlist or QString,
-   you need to convert selectedContacts into a CntServicesContactList." -- Comments from 
-   Contacts-picker author Erkinheimo Joonas (Nokia-D/Espoo)
-   Contacts-Picker should be working in TB 10.1 MCL wk16 release, 
-   Custom metatypes problem will be fixed in wk16 by QtHighway.
+   This Slot appends the selected contacts to the end of the lineedit content.    
 */
-void NmRecipientLineEdit::insertSelectedContacts(const QVariant &selectedContacts)
+void NmRecipientLineEdit::addSelectedContacts(const QVariant &selectedContacts)
 {
-    if (!selectedContacts.isNull()) {
-        CntServicesContactList contactList;
-        contactList = qVariantValue<CntServicesContactList>(selectedContacts);
+    NM_FUNCTION;
+    
+    // If user selected contact
+    if (!selectedContacts.isNull()) {        
+
+        // If the lineedit is not empty and if there is no ";" or "; " at the end,
+        // add a delimiter("; ") at the end.
+        if (this->text().length() != 0 && !(this->text().endsWith(Semicolon)) && 
+            !(this->text().endsWith(Delimiter))){
+            
+            // Move cursor to the end of the lineedit.
+            this->setCursorPosition(this->text().length());       
+            QTextCursor textCursor(this->textCursor());
+            // Append delimiter("; ") to the end of the lineedit
+            textCursor.insertText(Delimiter);
+        }
+        
+        CntServicesContactList contactList = qVariantValue<CntServicesContactList>(selectedContacts);
 
         // Loop through all the selected contacts.
         for (int i = 0; i < contactList.count(); ++i) {
+            QString contactName = contactList[i].mDisplayName;
             QString contactEmailAddress = contactList[i].mEmailAddress;
-            QString contactName = contactList[i].mDisplayName;
-
-            // If this contact has no name.
-            if(contactName.isEmpty()) {				
-                // Generate a custom keyevent for this contact's emailaddress.
-                QKeyEvent contactEmailAddressKeyEvent(QEvent::KeyPress, Qt::Key_unknown, 
-                		                              Qt::NoModifier, contactEmailAddress);
-                // Forward this contactEmailAddressKeyEvent to base class to handle.
-                NmHtmlLineEdit::keyPressEvent(&contactEmailAddressKeyEvent);
+            
+            // If this contact has no name, use it's emailaddress as the display name
+            if(contactName.isEmpty()) {	
+                // Move cursor to the end of the lineedit.
+                this->setCursorPosition(this->text().length());       
+                QTextCursor textCursor(this->textCursor());
+                // Append contactEmailAddress to the end of the lineedit
+                textCursor.insertText(contactEmailAddress);
             }
+            // If this contact has name, use the name as the display name
             else {
-                // Handle a rare case: there's another contact has same name but has different emailaddress.
-                for (int i = 0; i != mContactsSelectedFromPhoneBook.count(); ++i) {
-                    if (mContactsSelectedFromPhoneBook.at(i).displayName() == contactName &&
-                  	    mContactsSelectedFromPhoneBook.at(i).address() != contactEmailAddress) {
-                        // Differentiate this contact's name by adding a * mark
-                        contactName.append("*");
+                // Handle a rare case: there are contacts has same name but different emailaddress.
+                for (int i = 0; i != mRecipientsAddedFromContacts.count(); ++i) {
+                    if (mRecipientsAddedFromContacts.at(i).displayName() == contactName &&
+                  	    mRecipientsAddedFromContacts.at(i).address() != contactEmailAddress) {
+                        // Differentiate this contact by supplying it's emailaddress
+                        contactName.append("<");
+                        contactName.append(contactEmailAddress);
+                        contactName.append(">");
                     }
                 }
                 
-                // Generate custom keyevent for this contact's name.
-                QKeyEvent contactNameKeyEvent(QEvent::KeyPress, Qt::Key_unknown, 
-                                              Qt::NoModifier, contactName);
-                // Forward this contactNameKeyEvent to base class to handle.
-                NmHtmlLineEdit::keyPressEvent(&contactNameKeyEvent);
+                // Move cursor to the end of the lineedit.
+                this->setCursorPosition(this->text().length());       
+                QTextCursor textCursor(this->textCursor());
+                // Append contactName to the end of the lineedit
+                textCursor.insertText(contactName);
             }
-
-            // Generate custom keyevent for Delimiter("; ").
-            QKeyEvent delimiterKeyEvent(QEvent::KeyPress, Qt::Key_unknown, 
-                                        Qt::NoModifier, Delimiter);
-            // Forward the delimiterKeyEvent to base class to handle.
-            NmHtmlLineEdit::keyPressEvent(&delimiterKeyEvent);
-			
+                
+            QTextCursor textCursor(this->textCursor());
+            // Append delimiter("; ")
+            textCursor.insertText(Delimiter);
+            
             // Form the contact into Qmail NmAddress format.
             NmAddress contact;
             contact.setAddress(contactEmailAddress);
             contact.setDisplayName(contactName);
             
-            // Add this NmAddress formated contact into mContactsSelectedFromPhoneBook.
-            mContactsSelectedFromPhoneBook.append(contact);
-        }
+            // Add this NmAddress formated contact into mRecipientsAddedFromContacts.
+            mRecipientsAddedFromContacts.append(contact);
+        } 
     }
     else {
         //Request returned NULL 
-        NMLOG("ContactsPicker request returned NULL.");
+        NM_COMMENT("ContactsPicker request returned NULL.");
     }
         
 }
@@ -137,6 +153,8 @@
 */
 void NmRecipientLineEdit::keyPressEvent(QKeyEvent *keyEvent)
 {
+    NM_FUNCTION;
+    
 	bool eventHandled = false;
 	
     if (keyEvent) {
@@ -184,6 +202,8 @@
 */
 void NmRecipientLineEdit::inputMethodEvent(QInputMethodEvent *event)
 {
+    NM_FUNCTION;
+    
 	bool eventHandled = false;
 	
     if (event) {
@@ -220,47 +240,67 @@
 
  
 /*!
-   Generate emailaddress list from the content of the lineedit.
+   Generate a list of all the email addresses from the content of the lineedit.
 */
 void NmRecipientLineEdit::generateEmailAddressList()
 {   
+    NM_FUNCTION;
+    
     // Remove whitespace from the start and the end of the lineedit content. 
     QString contentOfLineedit = (this->text()).trimmed();
     
-    // Split the lineedit content into individual items wherever a Semicolon(";") occurs, 
-    // empty entries don't appear in the result.
+    // Split the lineedit content by semicolon(";").
     QStringList itemsOfLineeditContent = contentOfLineedit.split(Semicolon, QString::SkipEmptyParts);
         
-    // Loop through all the items in the itemsOfLineeditContent list.
+    // Loop through all the items of the lineedit content.
     for (int i = 0; i != itemsOfLineeditContent.count(); ++i) {
         // Remove whitespace from the start and the end of the item.
         QString itemInLineedit = itemsOfLineeditContent.at(i).trimmed();
 
-        if (mContactsSelectedFromPhoneBook.count() > 0) {
-            // Loop through all the elements in the mContactsSelectedFromPhoneBook list.
-            for (int j = 0; j != mContactsSelectedFromPhoneBook.count(); ++j) {
-                NmAddress contact = mContactsSelectedFromPhoneBook.at(j);		
-                // If the item matches either the name or the emailaddress of this contact.
-                if (itemInLineedit == contact.displayName() || itemInLineedit == contact.address()) {
-                    // Add the contact into mEmailAddressList.
-                    mEmailAddressList.append(contact);  
-                }
-                else {
-                    // Form the item into Qmail NmAddress format.
-                    NmAddress recipient;
-                    recipient.setAddress(itemInLineedit);
-                    // no display name info available, so don't us it
-                    recipient.setDisplayName(QString()); 
-                    // Add this NmAddress formated lineedit item into mEmailAddressList.
-                    mEmailAddressList.append(recipient);  
-                }
+        // Get the count of the recipients added from Contacts.
+        int countOfRecipientsAddedFromContacts = mRecipientsAddedFromContacts.count();
+        
+        // If there is recipient added from Contacts.
+        if (countOfRecipientsAddedFromContacts > 0) {
+            QStringList listOfAddedContactsName;
+            QStringList listOfAddedContactsAddress;
+            
+            // Loop through all the recipients added from Contacts.
+            for (int j = 0; j != countOfRecipientsAddedFromContacts; ++j) {
+                NmAddress contact = mRecipientsAddedFromContacts.at(j);          
+                listOfAddedContactsName.append(contact.displayName());
+                listOfAddedContactsAddress.append(contact.address());
+            }
+                
+            int indexInAddedContactsName = listOfAddedContactsName.indexOf(itemInLineedit);
+            int indexInAddedContactsAddress = listOfAddedContactsAddress.indexOf(itemInLineedit);
+            
+            // If this itemInLineedit matches the name of one added contact.
+            if (indexInAddedContactsName >= 0) {
+                // Add the recipient into mEmailAddressList.
+                mEmailAddressList.append(mRecipientsAddedFromContacts.at(indexInAddedContactsName));  
+            }
+            // If this itemInLineedit matches the emailaddress of one added contact.
+            else if (indexInAddedContactsAddress >= 0) { 
+                // Add the recipient into mEmailAddressList.
+                mEmailAddressList.append(mRecipientsAddedFromContacts.at(indexInAddedContactsAddress));  
+            }
+            // This itemInLineedit is not added from Contacts
+            else { 
+                // Form the item into NmAddress format.
+                NmAddress recipient;
+                recipient.setAddress(itemInLineedit);
+                // There is no display name info available, so leave display name empty.
+                recipient.setDisplayName(QString()); 
+                // Add this NmAddress formated lineedit item into mEmailAddressList.
+                mEmailAddressList.append(recipient);  
             }
         }
-        else {
-            // Form the item into Qmail NmAddress format.
+        else { // There is no recipient is added from Contacts
+            // Form the item into NmAddress format.
             NmAddress recipient;
             recipient.setAddress(itemInLineedit);
-            // no display name info available, so don't us it
+            // There is no display name info available, so leave display name emapty.
             recipient.setDisplayName(QString()); 
             // Add this NmAddress formated lineedit item into mEmailAddressList.
             mEmailAddressList.append(recipient);  
@@ -274,6 +314,8 @@
 */
 void NmRecipientLineEdit::handleTextChanged(const QString &text)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(text);
     mNeedToGenerateEmailAddressList = true;
 }
--- a/emailuis/nmailuiwidgetsplugin/src/nmailuiwidgetsplugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmailuiwidgetsplugin/src/nmailuiwidgetsplugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
 *
 */
 
+#include "emailtrace.h"
+
 #include "nmailuiwidgetsplugin.h"
 #include <nmrecipientlineedit.h>
 #include <nmhtmllineedit.h>
@@ -24,6 +26,8 @@
 
 QObject *NMailUiWidgetsPlugin::createObject(const QString& type, const QString &name )
 {
+    NM_FUNCTION;
+    
     if( type == NmBaseViewScrollArea::staticMetaObject.className() ) {
         QObject *object = new NmBaseViewScrollArea;
         object->setObjectName(name);
--- a/emailuis/nmframeworkadapter/inc/nmframeworkadapter.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/inc/nmframeworkadapter.h	Thu Jul 22 16:30:28 2010 +0100
@@ -20,6 +20,7 @@
 
 #include <nmcommon.h>
 #include <nmdataplugininterface.h>
+#include <nmapplicationstateinterface.h>
 #include <CFSMailCommon.h>
 #include <MFSMailEventObserver.h>
 
@@ -33,22 +34,25 @@
 class NmOperation;
 class NmMessageCreationOperation;
 class CFSMailClient;
+class CFSMailBox;
+class CFSMailFolder;
 class CFSMailMessage;
 class CFSMailMessagePart;
 class NmStoreEnvelopesOperation;
 class NmAddAttachmentsOperation;
-class NmCheckOutboxOperation;
 class NmMailboxSearchObserver;
 class NmMessageSendingOperation;
+class CEmailExtension;
 
 
 class NmFrameworkAdapter :
     public QObject,
     public NmDataPluginInterface,
+    public NmApplicationStateInterface,
     public MFSMailEventObserver
 {
     Q_OBJECT
-    Q_INTERFACES(NmDataPluginInterface)
+    Q_INTERFACES(NmDataPluginInterface NmApplicationStateInterface)
 
 public:
 
@@ -62,7 +66,7 @@
 
     int getMailboxById(const NmId& id, NmMailbox*& mailbox);
 
-    int deleteMailboxById(const NmId& id);
+    QPointer<NmOperation> deleteMailboxById(const NmId& id);
 
     int getMessageById(
             const NmId& mailboxId,
@@ -78,7 +82,13 @@
             const NmId& mailboxId,
             const NmId& folderId,
             QList<NmMessageEnvelope*> &messageMetaDataList);
-    
+
+    int listMessages(
+            const NmId& mailboxId,
+            const NmId& folderId,
+            QList<NmMessageEnvelope*> &messageMetaDataList,
+            const int maxAmountOfEnvelopes);
+
     int listMessages(
             const NmId& mailboxId,
             const NmId& folderId,
@@ -95,6 +105,12 @@
             const NmId &folderId,
             const NmId &messageId,
             const NmId &messagePartId);
+			
+    QPointer<NmOperation> fetchMessageParts( 
+        const NmId &mailboxId,
+        const NmId &folderId,
+        const NmId &messageId,
+        const QList<NmId> &messagePartIds);
     
     XQSharableFile messagePartFile(
             const NmId &mailboxId,
@@ -167,8 +183,6 @@
             const NmMessage &message, 
             const NmId &attachmentPartId);
 
-    QPointer<NmCheckOutboxOperation> checkOutbox(const NmId& mailboxId);
-    
     NmSyncState syncState(const NmId& mailboxId) const;
     
     NmConnectState connectionState(const NmId& mailboxId) const;
@@ -177,19 +191,22 @@
             const NmId &mailboxId, 
             const NmId &folderId, 
             NmFolder *&folder );
-			
-	int listMessages(
-            const NmId& mailboxId,
-            const NmId& folderId,
-            QList<NmMessageEnvelope*> &messageMetaDataList,
-            const int maxAmountOfEnvelopes);
 
     int search(const NmId &mailboxId,
                const QStringList &searchStrings);
 
     int cancelSearch(const NmId &mailboxId);
 
-
+    void updateActiveFolder(const NmId &mailboxId, const NmId &folderId);
+    
+    QPointer<NmOperation> removeDraftMessage(NmMessage *message);
+	
+	int copyMessages(
+        const NmId &mailboxId,
+        const QList<quint64> &messageIds,
+        const NmId &sourceFolderId,
+        const NmId &destinationFolderId);
+    
 signals:
 
     void mailboxEvent(NmMailboxEvent event, const QList<NmId> &mailboxIds);
@@ -206,7 +223,7 @@
     
     void connectionEvent(NmConnectState state, const NmId mailboxId, int errorCode);
 
-    void matchFound(const NmId &messageId);
+    void matchFound(const NmId &messageId, const NmId &folderId);
 
     void searchComplete();
 
@@ -224,7 +241,11 @@
             const NmId &folderId,
             const NmId &messageId,
             NmMessagePart &messagePart);
-        
+
+    void getMessagesFromFolderL(CFSMailFolder *folder,
+                                QList<NmMessageEnvelope*> &messageEnvelopeList,
+                                const int maxEnvelopeCount);
+
     void listMessagesL(  
             const NmId &mailboxId,
             const NmId &folderId,
@@ -273,16 +294,32 @@
     
     void handleSyncstateEvent(TAny* param1, TFSMailMsgId mailbox);
     
-	void getFolderByIdL(
+    void getFolderByIdL(
             const NmId& mailboxId, 
             const NmId& folderId, 
             NmFolder*& unreadCount );
+    
+    void doUpdateActiveFolderL(const NmId &mailboxId, const NmId &folderId);
+    
+    CEmailExtension* getEMailStateExtensionL();  
+	
+    void copyMessagesL(
+        const NmId &mailboxId, 
+        const QList<quint64> &messageIds,
+        const NmId &sourceFolderId,
+        const NmId &destinationFolderId);
+	
+	void deleteMailboxByIdL(const NmId &mailboxId);    
 
 
 private: // Data
 
     CFSMailClient* mFSfw; // Singleton, not owned
     NmMailboxSearchObserver *mSearchObserver; // Owned
+    CFSMailBox* mCurrentMailBox; // Owned
+    CEmailExtension* mStateExtension; // not owned
+
+
 };
 
 
--- a/emailuis/nmframeworkadapter/inc/nmframeworkadapterheaders.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/inc/nmframeworkadapterheaders.h	Thu Jul 22 16:30:28 2010 +0100
@@ -35,10 +35,11 @@
 // nmailuiengine 
 #include <nmoperation.h>
 #include <nmstoreenvelopesoperation.h>
-#include <nmcheckoutboxoperation.h>
 #include <nmmessagesendingoperation.h>
 #include <nmaddattachmentsoperation.h>
 #include <nmmessagecreationoperation.h>
+#include <nmdataplugininterface.h>
+#include <nmapplicationstateinterface.h>
 
 // nmailbase
 #include <nmmailbox.h>
@@ -49,21 +50,24 @@
 
 // emailcommon
 #include <nmcleanuputils.h>
+#include <cmailboxstateext.h>
 
 // nmframeworkadapter
 #include "nmframeworkadapter.h"
 #include "nmfwaaddattachmentsoperation.h"
 #include "nmfwaremoveattachmentoperation.h"
-#include "nmfwacheckoutboxoperation.h"
 #include "nmfwamessagecreationoperation.h"
 #include "nmfwaforwardmessagecreationoperation.h"
 #include "nmfwareplymessagecreationoperation.h"
 #include "nmfwamessagefetchingoperation.h"
 #include "nmfwamessagepartfetchingoperation.h"
+#include "nmfwamessagepartsfetchingoperation.h"
 #include "nmfwamessagesendingoperation.h"
 #include "nmfwastoreenvelopesoperation.h"
 #include "nmfwastoremessageoperation.h"
 #include "nmmailboxsearchobserver.h"
+#include "nmfwaremovedraftmessageoperation.h"
+#include "nmfwadeletemailboxoperation.h"
 
 // fs email
 #include <CFSMailCommon.h>
--- a/emailuis/nmframeworkadapter/inc/nmfwaaddattachmentsoperation.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/inc/nmfwaaddattachmentsoperation.h	Thu Jul 22 16:30:28 2010 +0100
@@ -42,6 +42,7 @@
     
 protected:
     void doRunAsyncOperation();
+    void doCompleteOperation();
     void doCancelOperation();
 
 private:
--- a/emailuis/nmframeworkadapter/inc/nmfwacheckoutboxoperation.h	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * 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:
- *
- */
-
-#ifndef NMFWACHECKOUTBOXOPERATION_H_
-#define NMFWACHECKOUTBOXOPERATION_H_
-
-#include <nmcheckoutboxoperation.h>
-#include <nmcommon.h>
-
-class CFSMailClient;
-
-class NmFwaCheckOutboxOperation : public NmCheckOutboxOperation
-{
-    Q_OBJECT
-public:
-    NmFwaCheckOutboxOperation(
-        const NmId &mailboxId,
-        CFSMailClient &mailClient);
-    
-    bool getMessageId(NmId &messageId) const;
-
-private:
-    void doRunAsyncOperation();
-    void doRunAsyncOperationL();
-    ~NmFwaCheckOutboxOperation();
-    
-private:
-    NmId mMailboxId;
-    CFSMailClient &mMailClient;
-    bool mFound;
-    NmId mMessageId;
-
-};
-
-#endif /* NMFWACHECKOUTBOXOPERATION_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmframeworkadapter/inc/nmfwadeletemailboxoperation.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,58 @@
+/*
+ * 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:
+ *
+ */
+
+#ifndef NMFWADELETEMAILBOXOPERATION_H_
+#define NMFWADELETEMAILBOXOPERATION_H_
+
+#include <QPointer>
+#include <nmoperation.h>
+#include <nmcommon.h>
+#include <CFSMailCommon.h>
+#include <MFSMailRequestObserver.h>
+
+class NmId;
+class NmDataPluginInterface;
+class CFSMailClient;
+
+class NmFwaDeleteMailboxOperation : public NmOperation,
+                                         public MFSMailRequestObserver
+{
+    Q_OBJECT
+public:
+    NmFwaDeleteMailboxOperation(const NmId &mailboxId,
+                                CFSMailClient &mailClient);
+    
+    // from MFSMailRequestObserver
+    void RequestResponseL(TFSProgress aEvent, TInt aRequestId);
+
+protected:
+    void doRunAsyncOperation();
+    void doCompleteOperation();
+    void doCancelOperation();
+
+private:
+    ~NmFwaDeleteMailboxOperation();
+
+    void deleteMailboxL();
+
+private:
+    const NmId &mMailboxId;    // Owned
+    CFSMailClient &mMailClient;
+    TInt mRequestId;
+};
+
+#endif /* NMFWADELETEMAILBOXOPERATION_H_ */
--- a/emailuis/nmframeworkadapter/inc/nmfwamessagefetchingoperation.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/inc/nmfwamessagefetchingoperation.h	Thu Jul 22 16:30:28 2010 +0100
@@ -39,6 +39,7 @@
 
 protected:
     void doRunAsyncOperation();
+    void doCompleteOperation();
     void doCancelOperation();
     
 private:
--- a/emailuis/nmframeworkadapter/inc/nmfwamessagepartfetchingoperation.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/inc/nmfwamessagepartfetchingoperation.h	Thu Jul 22 16:30:28 2010 +0100
@@ -40,6 +40,7 @@
 
 protected:
     void doRunAsyncOperation();
+    void doCompleteOperation();
     void doCancelOperation();
     
 private:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmframeworkadapter/inc/nmfwamessagepartsfetchingoperation.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,63 @@
+/*
+ * 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 NMFWAMESSAGEPARTSFETCHINGOPERATION_H_
+#define NMFWAMESSAGEPARTSFETCHINGOPERATION_H_
+
+#include <nmoperation.h>
+#include <MFSMailRequestObserver.h>
+
+class NmMessage;
+class CFSMailClient;
+
+class NmFwaMessagePartsFetchingOperation : public NmOperation, public MFSMailRequestObserver
+{
+    Q_OBJECT
+public:
+    NmFwaMessagePartsFetchingOperation(
+        const NmId &mailboxId,
+        const NmId &folderId,
+        const NmId &messageId,
+        const QList<NmId> &messagePartIds,
+        CFSMailClient &mailClient);
+    
+    // from MFSMailRequestObserver
+    void RequestResponseL(TFSProgress aEvent, TInt aRequestId);
+
+protected:
+    void doRunAsyncOperation();
+    void doCompleteOperation();
+    void doCancelOperation();
+    
+private:
+    ~NmFwaMessagePartsFetchingOperation();
+    void doRunAsyncOperationL();
+
+private:
+    NmId mMailboxId;
+    NmId mFolderId;
+    NmId mMessageId;
+    RArray<TFSMailMsgId> mMessagePartIds;
+    
+    CFSMailClient &mMailClient;
+    
+    int mLastProgressValue;
+    
+    TInt mRequestId;
+};
+
+#endif /* NMFWAMESSAGEPARTSFETCHINGOPERATION_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmframeworkadapter/inc/nmfwaremovedraftmessageoperation.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,60 @@
+/*
+ * 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:
+ *
+ */
+
+#ifndef NMFWAREMOVEDRAFTMESSAGEOPERATION_H_
+#define NMFWAREMOVEDRAFTMESSAGEOPERATION_H_
+
+#include <QPointer>
+#include <nmoperation.h>
+#include <nmcommon.h>
+#include <CFSMailCommon.h>
+#include <MFSMailRequestObserver.h>
+
+class NmMessage;
+class NmDataPluginInterface;
+class CFSMailClient;
+
+class NmFwaRemoveDraftMessageOperation : public NmOperation,
+                                         public MFSMailRequestObserver
+{
+    Q_OBJECT
+public:
+    NmFwaRemoveDraftMessageOperation(NmDataPluginInterface &pluginInterface,
+                                 NmMessage *message,
+                                 CFSMailClient &mailClient);
+    
+    // from MFSMailRequestObserver
+    void RequestResponseL(TFSProgress aEvent, TInt aRequestId);
+
+protected:
+    void doRunAsyncOperation();
+    void doCompleteOperation();
+    void doCancelOperation();
+
+private:
+    ~NmFwaRemoveDraftMessageOperation();
+
+    void removeMessageL();
+
+private:
+    NmDataPluginInterface &mPluginInterface;
+    NmMessage *mMessage;    // Owned
+    CFSMailClient &mMailClient;
+    TInt mRequestId;
+};
+
+#endif /* NMFWAREMOVEDRAFTMESSAGEOPERATION_H_ */
--- a/emailuis/nmframeworkadapter/inc/nmmailboxsearchobserver.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/inc/nmmailboxsearchobserver.h	Thu Jul 22 16:30:28 2010 +0100
@@ -47,7 +47,7 @@
     
 signals:
 
-    void matchFound(const NmId &messageId);
+    void matchFound(const NmId &messageId, const NmId &folderId);
 
     void searchComplete();
 };
--- a/emailuis/nmframeworkadapter/nmframeworkadapter.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/nmframeworkadapter.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -13,7 +13,7 @@
 #
 # Description: 
 #
-# Version : %version: 26 %
+# Version : %version: e002sa38#31 %
 TEMPLATE = lib
 TARGET = nmframeworkadapter
 
@@ -36,9 +36,11 @@
            inc/nmfwaaddattachmentsoperation.h \
            inc/nmfwaremoveattachmentoperation.h \
            inc/nmfwastoremessageoperation.h \
-           inc/nmfwacheckoutboxoperation.h \
            inc/nmfwamessagepartfetchingoperation.h \
-           inc/nmmailboxsearchobserver.h
+           inc/nmmailboxsearchobserver.h \
+           inc/nmfwamessagepartsfetchingoperation.h \
+           inc/nmfwaremovedraftmessageoperation.h \
+           inc/nmfwadeletemailboxoperation.h
 
 SOURCES += src/nmframeworkadapter.cpp \
            src/nmfwamessagefetchingoperation.cpp \
@@ -50,9 +52,12 @@
            src/nmfwaaddattachmentsoperation.cpp \
            src/nmfwaremoveattachmentoperation.cpp \
            src/nmfwastoremessageoperation.cpp \
-           src/nmfwacheckoutboxoperation.cpp \
            src/nmfwamessagepartfetchingoperation.cpp \
-           src/nmmailboxsearchobserver.cpp
+           src/nmmailboxsearchobserver.cpp \
+           src/nmfwamessagepartsfetchingoperation.cpp \
+           src/nmfwaremovedraftmessageoperation.cpp \
+           src/nmfwadeletemailboxoperation.cpp
+           
 
 RESOURCES +=
 
@@ -63,7 +68,10 @@
 symbian*: {
     INCLUDEPATH += /epoc32/include/ecom \
     ../../emailservices/emailframework/inc \
-    ../../emailservices/emailframework/commonlib/inc \
+# <qmail>    
+#    ../../emailservices/emailframework/commonlib/inc \
+    ../../emailservices/emailcommon/inc \
+# </qmail>     
     ../../inc
     INCLUDEPATH += /epoc32/include/ecom
 
--- a/emailuis/nmframeworkadapter/src/nmframeworkadapter.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmframeworkadapter.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -38,18 +38,18 @@
 */
 NmFrameworkAdapter::NmFrameworkAdapter()
 : mFSfw(NULL),
-  mSearchObserver(NULL)
+  mSearchObserver(NULL),
+  mCurrentMailBox(NULL),
+  mStateExtension(NULL)
 {
-    NMLOG("NmFrameworkAdapter::NmFrameworkAdapter() <---");
-
+    NM_FUNCTION;
+    
     // get s60 email framework
     TRAP_IGNORE(mFSfw = CFSMailClient::NewL());
 
     if (mFSfw) {
         TRAP_IGNORE(mFSfw->AddObserverL(*this));
     }
-
-    NMLOG("NmFrameworkAdapter::NmFrameworkAdapter() --->");
 }
 
 /*!
@@ -57,6 +57,13 @@
 */
 NmFrameworkAdapter::~NmFrameworkAdapter()
 {
+    NM_FUNCTION;
+    
+    delete mCurrentMailBox;
+    mCurrentMailBox = NULL;
+    
+    mStateExtension = NULL;    
+    
     if (mSearchObserver) {
         delete mSearchObserver;
         mSearchObserver = NULL;
@@ -79,6 +86,8 @@
  */
 int NmFrameworkAdapter::listMailboxIds(QList<NmId>& mailboxIdList)
 {
+    NM_FUNCTION;
+    
     QList<NmMailbox*> mailboxList;
     int ret = listMailboxes(mailboxList);
 
@@ -103,6 +112,8 @@
  */
 int NmFrameworkAdapter::listMailboxes(QList<NmMailbox*>& mailboxList)
 {
+    NM_FUNCTION;
+    
     // get list of mailboxes from all plugins
     TFSMailMsgId id;
     id.SetNullId();
@@ -139,6 +150,8 @@
  */
 int NmFrameworkAdapter::getMailboxById(const NmId& id, NmMailbox*& mailbox)
 {
+    NM_FUNCTION;
+    
     const TFSMailMsgId mailMsgId(id.pluginId32(), id.id32());
     CFSMailBox *box(NULL);
     TRAPD(err, box = mFSfw->GetMailBoxByUidL(mailMsgId));
@@ -151,15 +164,17 @@
 }
 
 /*!
-    Delete the mailbox with the given id. Not implemented yet.
+    Deletes the mailbox with the given id asynchronously.
 
-    \param id Id of the mailbox to be deleted.
+    \param mailboxId Id of the mailbox to be deleted.
 
     \return Error code.
  */
-int NmFrameworkAdapter::deleteMailboxById(const NmId& /*id*/)
+QPointer<NmOperation> NmFrameworkAdapter::deleteMailboxById(const NmId& mailboxId)
 {
-    return 0;
+    NM_FUNCTION;
+    QPointer<NmOperation> oper = new NmFwaDeleteMailboxOperation(mailboxId, *mFSfw);
+    return oper;
 }
 
 /*!
@@ -173,6 +188,8 @@
  */
 int NmFrameworkAdapter::getFolderById( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder )
     {
+    NM_FUNCTION;
+    
     TRAPD(err, getFolderByIdL( mailboxId, folderId, folder ) );
     return err;
     }
@@ -182,6 +199,8 @@
  */
 void NmFrameworkAdapter::getFolderByIdL( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder )
     {
+    NM_FUNCTION;
+    
     CFSMailFolder* fsFolder(NULL);
 	if (mFSfw)
 		{
@@ -217,6 +236,8 @@
     const NmId& messageId,
     NmMessage*& message)
 {
+    NM_FUNCTION;
+    
     TRAPD(err, getMessageByIdL(mailboxId,folderId,messageId,message));
     return err;
 }
@@ -230,6 +251,8 @@
     const NmId& messageId,
     NmMessage*& message)
 {
+    NM_FUNCTION;
+    
     // select message details to be listed
     TFSMailDetails details(EFSMsgDataStructure);
 
@@ -262,6 +285,8 @@
     const NmId& mailboxId,
     QList<NmFolder*>& folderList)
 {
+    NM_FUNCTION;
+    
     CFSMailBox* currentMailbox = NULL;
     TRAPD (err, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId));
     if (KErrNone == err) {
@@ -276,6 +301,91 @@
     }
 }
 
+
+/*!
+    Fetches all the messages from the given folder and appends their meta data
+    into the given list.
+
+    \param folder The folder instance.
+    \param messageEnvelopeList The list where the data is stored to.
+    \param maxEnvelopeCount The maximum number of messages to get.
+*/
+void NmFrameworkAdapter::getMessagesFromFolderL(
+     CFSMailFolder *folder,
+     QList<NmMessageEnvelope*> &messageEnvelopeList,
+     const int maxEnvelopeCount)
+{
+    NM_FUNCTION;
+    
+    if (!folder || maxEnvelopeCount < 1) {
+        return;
+    }
+
+    int blockSize = NmListMessagesBlock;
+    int maxItemCount = NmMaxItemsInMessageList;
+
+    if (maxEnvelopeCount < NmMaxItemsInMessageList) {
+        maxItemCount = maxEnvelopeCount;
+
+        if(maxEnvelopeCount < NmListMessagesBlock) {
+            blockSize = maxEnvelopeCount;
+        }
+    }
+
+    // First prepare all the parameters and select message details to be listed.
+    TFSMailDetails details(EFSMsgDataEnvelope);
+
+    // Set the sorting criteria.
+    TFSMailSortCriteria criteria;
+    criteria.iField = EFSMailSortByDate;
+    criteria.iOrder = EFSMailDescending;
+    RArray<TFSMailSortCriteria> sorting;
+    CleanupClosePushL(sorting);
+    sorting.Append(criteria);
+   
+    // Get the message list from the backend.
+    MFSMailIterator* iterator(NULL);
+    iterator = folder->ListMessagesL(details, sorting);
+
+    if (iterator) {
+        CleanupStack::PushL(iterator);
+        RPointerArray<CFSMailMessage> messages;
+        CleanupResetAndDestroy<CFSMailMessage>::PushL(messages);
+
+        // The message list is fetched in blocks to prevent OOM in protocol
+        // plugin side.
+        bool moreMessagesToFollow(false);
+        moreMessagesToFollow = iterator->NextL(TFSMailMsgId(), blockSize, messages);
+
+        for (int i = blockSize;
+             i < maxItemCount && moreMessagesToFollow;
+             i += blockSize) {
+            moreMessagesToFollow =
+                iterator->NextL(messages[i-1]->GetMessageId(), blockSize, messages);
+        }
+
+        // Add all the found emails into the result list.
+        const TInt messageCount(messages.Count());
+
+        for (TInt i = 0; i < messageCount; ++i) {
+            NmMessageEnvelope *newEnvelope(NULL);
+            newEnvelope = messages[i]->GetNmMessageEnvelope();
+
+            if (newEnvelope) {
+                messageEnvelopeList.append(newEnvelope);
+            }
+        }
+
+        CleanupStack::PopAndDestroy(&messages);
+        CleanupStack::Pop(iterator);
+        delete iterator;
+        iterator = NULL;
+    }
+
+    CleanupStack::PopAndDestroy(); // sorting  
+}
+
+
 /*!
     Returns list of envelopes from the backend for specific mailbox and folder.
 
@@ -291,111 +401,77 @@
     const NmId &folderId,
     QList<NmMessageEnvelope*> &messageEnvelopeList)
 {
+    NM_FUNCTION;
+    
     TRAPD(err, listMessagesL(mailboxId,folderId,messageEnvelopeList, NmMaxItemsInMessageList));
     return err;
 }
 
+
+/*!
+    Fetches the meta data for each message in the given mailbox and given
+    folder.
+
+    \param mailboxId The ID of the mailbox of which messages to list.
+    \param folderId The ID of the folder of which messages to list.
+    \param messageEnvelopeList The list where the message data is stored to.
+                               Note that the ownership is transferred!
+    \param maxAmountOfEnvelopes The maximum number of messages to list.
+
+    \return If success, KErrNone, an error code otherwise.
+*/
 int NmFrameworkAdapter::listMessages(
         const NmId& mailboxId,
         const NmId& folderId,
         QList<NmMessageEnvelope*> &messageEnvelopeList,
         const int maxAmountOfEnvelopes)
-    {
+{
+    NM_FUNCTION;
+    
     TInt err = KErrNone;
     TRAP(err, listMessagesL(mailboxId,folderId, messageEnvelopeList,maxAmountOfEnvelopes) );
     return err;
-    }
+}
+
 
 /*!
-    Leaving version of list messages
- */
+    Fetches the meta data for each message in the given mailbox and given
+    folder. Note that this private method can leave.
+*/
 void NmFrameworkAdapter::listMessagesL(
         const NmId &mailboxId,
         const NmId &folderId,
         QList<NmMessageEnvelope*> &messageEnvelopeList,
         const int maxAmountOfEnvelopes)
 {
-    CFSMailBox * currentMailbox(NULL);
-    CFSMailFolder* folder(NULL);
-
-    //If we are requesting 0 or less mails so we can return
-    if( maxAmountOfEnvelopes <= 0)
-        {
+    NM_FUNCTION;
+    
+    // If we are requesting 0 or less mails, we can just return.
+    if (maxAmountOfEnvelopes <= 0) {
         return;
-        }
+    }
 
-    int blockSize = NmListMessagesBlock;
-    int maxLimit = NmMaxItemsInMessageList;
-    if( maxAmountOfEnvelopes < NmMaxItemsInMessageList )
-        {
-        maxLimit = maxAmountOfEnvelopes;
-        if(maxAmountOfEnvelopes < NmListMessagesBlock)
-            {
-            blockSize = maxAmountOfEnvelopes;
-            }
-        }
-   
+    CFSMailBox *mailbox(NULL);
+    mailbox = mFSfw->GetMailBoxByUidL(mailboxId);
 
-    currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
-    if (!currentMailbox) {
+    if (!mailbox) {
         User::Leave(KErrNotFound);
     }
-    CleanupStack::PushL(currentMailbox);
-    folder = mFSfw->GetFolderByUidL(currentMailbox->GetId(), TFSMailMsgId(folderId));
+
+    CleanupStack::PushL(mailbox);
+
+    CFSMailFolder* folder(NULL);
+    folder = mFSfw->GetFolderByUidL(mailbox->GetId(), TFSMailMsgId(folderId));
 
     if (folder) {
         CleanupStack::PushL(folder);
-        // First prepare all the parameters
-        // select message details to be listed
-        TFSMailDetails details(EFSMsgDataEnvelope);
-
-        // set sorting criteria
-        TFSMailSortCriteria criteria;
-        criteria.iField = EFSMailSortByDate;
-        criteria.iOrder = EFSMailDescending;
-        RArray<TFSMailSortCriteria> sorting;
-        CleanupClosePushL(sorting);
-        sorting.Append(criteria);
-
-        TFSMailMsgId currentMessageId; // first call contains NULL id as begin id
-        // get messages list from the backend
-        MFSMailIterator* iterator(NULL);
-
-        iterator = folder->ListMessagesL(details, sorting);
-        if (iterator) {
-            CleanupStack::PushL(iterator);
-            RPointerArray<CFSMailMessage> messages;
-            CleanupResetAndDestroy<CFSMailMessage>::PushL(messages);
+        getMessagesFromFolderL(folder, messageEnvelopeList, maxAmountOfEnvelopes);
+        CleanupStack::PopAndDestroy(folder);        
+    }
 
-            //Message list is fetched in blocks to prevent OOM in protocol plugin side
-            bool moreMessagesToFollow(false);
-            moreMessagesToFollow = iterator->NextL(
-                TFSMailMsgId(), blockSize, messages);
-            for ( int i = blockSize;
-                  i < maxLimit && moreMessagesToFollow ;
-                  i += blockSize ) {
-                moreMessagesToFollow = iterator->NextL(
-                    messages[i-1]->GetMessageId(), blockSize, messages);
-            }
+    CleanupStack::PopAndDestroy(mailbox);
+}
 
-            //Add all found emails to the result list
-            for(TInt i=0; i<messages.Count(); i++) {
-                NmMessageEnvelope* newEnvelope(NULL);
-                newEnvelope = messages[i]->GetNmMessageEnvelope();
-                if (newEnvelope) {
-                    messageEnvelopeList.append(newEnvelope);
-                }
-            }
-            CleanupStack::PopAndDestroy( &messages );
-            CleanupStack::Pop(iterator);
-            delete iterator;
-           	iterator = NULL;
-        }
-        CleanupStack::PopAndDestroy(); // sorting
-        CleanupStack::PopAndDestroy(folder);
-    }
-    CleanupStack::PopAndDestroy(currentMailbox);
-}
 
 /*! 
     Returns list of messages from the backend for specific mailbox and folder.
@@ -413,10 +489,13 @@
     QList<NmMessage*> &messageList,
     const int maxAmountOfMessages)
 {
+    NM_FUNCTION;
+    
     TRAPD(err, listMessagesL(mailboxId,folderId,messageList, maxAmountOfMessages));
     return err;
 }
 
+
 /*!
     Leaving version of list messages with NmMessageList input
  */
@@ -426,6 +505,8 @@
         QList<NmMessage*> &messageList,
         const int maxAmountOfEnvelopes)
 {
+    NM_FUNCTION;
+    
     CFSMailBox * currentMailbox(NULL);
     CFSMailFolder* folder(NULL);
 
@@ -437,6 +518,7 @@
 
     int blockSize = NmListMessagesBlock;
     int maxLimit = NmMaxItemsInMessageList;
+
     if( maxAmountOfEnvelopes < NmMaxItemsInMessageList )
         {
         maxLimit = maxAmountOfEnvelopes;
@@ -446,7 +528,6 @@
             }
         }
    
-
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
     if (!currentMailbox) {
         User::Leave(KErrNotFound);
@@ -516,6 +597,7 @@
     CleanupStack::PopAndDestroy(currentMailbox);
 }
 
+
 /*!
     Starts an asynchronous search for messages with the given search strings.
     This is part of the public interface.
@@ -530,14 +612,16 @@
 int NmFrameworkAdapter::search(const NmId &mailboxId,
                                const QStringList &searchStrings)
 {
+    NM_FUNCTION;
+    
     if (!mSearchObserver) {
         mSearchObserver = new NmMailboxSearchObserver();
     }
 
     // Set connections for forwarding the signals emitted by the search
     // observer.
-    connect(mSearchObserver, SIGNAL(matchFound(const NmId &)),
-            this, SIGNAL(matchFound(const NmId &)), Qt::UniqueConnection);
+    connect(mSearchObserver, SIGNAL(matchFound(const NmId &, const NmId &)),
+            this, SIGNAL(matchFound(const NmId &, const NmId &)), Qt::UniqueConnection);
     connect(mSearchObserver, SIGNAL(searchComplete()),
             this, SIGNAL(searchComplete()), Qt::UniqueConnection);
 
@@ -550,11 +634,14 @@
     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));
@@ -566,6 +653,59 @@
     return err;
 }
 
+/*!
+    Indicates application state information to protocol plugins
+    \param mailboxId Id of active mailbox, 0 if application is closed.
+    \param folderId Id of active folder, 0 if application is closed.
+*/
+void NmFrameworkAdapter::updateActiveFolder(
+    const NmId &mailboxId, const NmId &folderId)
+{
+    TRAP_IGNORE(doUpdateActiveFolderL(mailboxId, folderId));
+}
+
+/*!
+   Removes draft message asynchronously
+ */
+QPointer<NmOperation> NmFrameworkAdapter::removeDraftMessage(NmMessage *message)
+{
+    NM_FUNCTION;
+    
+    QPointer<NmOperation> oper = new NmFwaRemoveDraftMessageOperation(*this, message, *mFSfw);
+    return oper;
+}
+
+/*!
+   function to process updateActiveFolder. This method may leave.
+ */
+void NmFrameworkAdapter::doUpdateActiveFolderL(
+    const NmId &mailboxId, const NmId &folderId)
+{
+    if ((mFSfw) && (!mCurrentMailBox || mCurrentMailBox->GetId()!=mailboxId)) {
+        delete mCurrentMailBox;
+        mCurrentMailBox = NULL;
+        mCurrentMailBox = mFSfw->GetMailBoxByUidL(mailboxId);
+        }
+    CEmailExtension *extension = getEMailStateExtensionL();
+    CMailboxStateExtension *stateExtension = 
+        static_cast<CMailboxStateExtension*>(extension);        
+    if (stateExtension) {
+        stateExtension->NotifyActiveFolderChanged(mailboxId, folderId);    
+    }
+}
+
+/*!
+   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;
+}
 
 /*!
     Starts an asynchronous search for messages with the given search strings.
@@ -581,6 +721,8 @@
                                  const QStringList &searchStrings,
                                  NmMailboxSearchObserver &searchObserver)
 {
+    NM_FUNCTION;
+    
     // CFSMailBox has no support for search using folder IDs.
     Q_UNUSED(folderIds); 
 
@@ -628,6 +770,8 @@
     const NmId &folderId,
     const NmId &messageId )
 {
+    NM_FUNCTION;
+    
     NmOperation *oper = new NmFwaMessageFetchingOperation(mailboxId, folderId, messageId, *mFSfw);
     return oper;
 }
@@ -648,12 +792,37 @@
     const NmId &messageId,
     const NmId &messagePartId)
 {
+    NM_FUNCTION;
+    
     QPointer<NmOperation> oper = new NmFwaMessagePartFetchingOperation(
             mailboxId, folderId, messageId, messagePartId, *mFSfw);
     return oper;
 }
 
 /*!
+    Starts a message parts fetching operation.
+
+    \param mailboxId Id of the mailbox containing the folder.
+    \param folderId Id of the folder containing the message.
+    \param messageId Id of message containing the message parts
+    \param messagePartIds ids of message parts
+
+    \return An NmOperation object for the operation, ownership is transferred to caller
+ */
+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;  
+}
+
+/*!
     Returns sharable file handle to message part content
 
     \param mailboxId Id of the mailbox containing the folder.
@@ -669,6 +838,8 @@
         const NmId &messageId,
         const NmId &messagePartId)
 {
+    NM_FUNCTION;
+    
     XQSharableFile retFile;
     TFSMailDetails details(EFSMsgDataEnvelope);
     TFSMailMsgId fsMboxId(mailboxId);
@@ -705,6 +876,8 @@
     const NmId& mailboxId,
     NmFolderType folderType )
 {
+    NM_FUNCTION;
+    
     TFSMailMsgId folderId;
     NmId resultId(0);
     CFSMailBox * currentMailbox(NULL);
@@ -754,6 +927,8 @@
  */
 int NmFrameworkAdapter::refreshMailbox(NmId mailboxId)
 {
+    NM_FUNCTION;
+    
     TRAPD(err, RefreshMailboxL(mailboxId)); // return value not used
     return ( err == KErrNone ) ? NmNoError : NmGeneralError;
 }
@@ -766,6 +941,8 @@
  */
 int NmFrameworkAdapter::goOnline(const NmId& mailboxId)
 {
+    NM_FUNCTION;
+    
     TRAPD(err, GoOnlineL(mailboxId)); // return value not used
     return ( err == KErrNone ) ? NmNoError : NmGeneralError;
 }
@@ -778,6 +955,8 @@
  */
 int NmFrameworkAdapter::goOffline(const NmId& mailboxId)
 {
+    NM_FUNCTION;
+    
     TRAPD(err, GoOfflineL(mailboxId)); // return value not used
     return ( err == KErrNone ) ? NmNoError : NmGeneralError;
 }
@@ -800,6 +979,8 @@
     const NmId &messageId,
     NmMessagePart &messagePart)
 {
+    NM_FUNCTION;
+    
     TRAPD(err, contentToMessagePartL(mailboxId,folderId,messageId,messagePart));
     return err;
 }
@@ -813,6 +994,8 @@
     const NmId &messageId,
     NmMessagePart &messagePart)
 {
+    NM_FUNCTION;
+    
     CFSMailMessagePart* cfsPart = CFSMailMessagePart::NewLC(messageId,messagePart);
     cfsPart->SetMailBoxId(TFSMailMsgId(mailboxId));
     cfsPart->SetFolderId(TFSMailMsgId(folderId));
@@ -887,6 +1070,8 @@
 	const NmId &folderId,
 	const QList<NmId> &messageIdList)
 {
+    NM_FUNCTION;
+    
     TInt err = NmNoError;
     RArray<TFSMailMsgId> messageIds;
     for (TInt i=0; i<messageIdList.size(); i++) {
@@ -917,8 +1102,9 @@
 	const NmId &folderId,
 	const QList<const NmMessageEnvelope*> &envelopeList)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(folderId);
-    NMLOG("NmFrameworkAdapter::storeEnvelopes() <---");
 
     QPointer<NmStoreEnvelopesOperation> operation(NULL);
     RPointerArray<CFSMailMessage> envelopeMessages;
@@ -935,7 +1121,6 @@
                 *mFSfw);
         }
 
-    NMLOG("NmFrameworkAdapter::storeEnvelopes() --->");
     return operation;
 }
 
@@ -948,6 +1133,8 @@
  */
 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createNewMessage(const NmId &mailboxId)
 {
+    NM_FUNCTION;
+    
     QPointer<NmMessageCreationOperation> oper =
         new NmFwaMessageCreationOperation(mailboxId, *mFSfw);
     return oper;
@@ -965,6 +1152,8 @@
     const NmId &mailboxId,
     const NmId &originalMessageId)
 {
+    NM_FUNCTION;
+    
     QPointer<NmMessageCreationOperation> oper =
         new NmFwaForwardMessageCreationOperation(mailboxId, originalMessageId, *mFSfw);
     return oper;
@@ -984,6 +1173,8 @@
     const NmId &originalMessageId,
     const bool replyAll)
 {
+    NM_FUNCTION;
+    
     QPointer<NmMessageCreationOperation> oper =
         new NmFwaReplyMessageCreationOperation(mailboxId, originalMessageId, replyAll, *mFSfw);
     return oper;
@@ -994,6 +1185,8 @@
  */
 int NmFrameworkAdapter::saveMessage(const NmMessage &message)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(message);
     return NmNoError;
 }
@@ -1003,6 +1196,8 @@
  */
 QPointer<NmOperation> NmFrameworkAdapter::saveMessageWithSubparts(const NmMessage &message)
 {
+    NM_FUNCTION;
+    
     CFSMailMessage * cfsMessage = NULL;
     QPointer<NmOperation> oper(NULL);
 
@@ -1028,6 +1223,8 @@
     TAny* param2,
     TAny* param3)
 {
+    NM_FUNCTION;
+    
     switch (aEvent) {
         // Mailbox related events:
         case TFSEventNewMailbox:
@@ -1141,17 +1338,41 @@
     const NmId& folderId,
     const NmId& messageId)
 {
+    NM_FUNCTION;
+    
     TRAPD(error, removeMessageL(mailboxId, folderId, messageId));
     return error;
 }
 
 /*!
+    Copy messages between folders from specific mailbox.
+
+    \param mailboxId Id of the mailbox containing messages.
+    \param messageIds The list of source message Ids.
+    \param newMessages The list of destination message Ids.
+    \param sourceFolderId Id of source folder.
+    \param destinationFolderId Id of destination folder.
+ */
+int NmFrameworkAdapter::copyMessages(
+    const NmId &mailboxId,
+    const QList<quint64>& messageIds,
+    const NmId& sourceFolderId,
+    const NmId& destinationFolderId)
+{
+    NM_FUNCTION;
+    TRAPD(error, copyMessagesL(mailboxId, messageIds, sourceFolderId, destinationFolderId));
+    return error;
+}
+
+/*!
     Subscribe to events from a mailbox.
 
     \param mailboxId Id of the mailbox.
 */
 void NmFrameworkAdapter::subscribeMailboxEvents(const NmId& mailboxId)
 {
+    NM_FUNCTION;
+    
     TRAP_IGNORE(mFSfw->SubscribeMailboxEventsL(mailboxId, *this));
 }
 
@@ -1162,11 +1383,15 @@
 */
 void NmFrameworkAdapter::unsubscribeMailboxEvents(const NmId& mailboxId)
 {
+    NM_FUNCTION;
+    
     mFSfw->UnsubscribeMailboxEvents(mailboxId, *this);
 }
 
 NmId NmFrameworkAdapter::getMailboxIdByMailMsgId(TFSMailMsgId mailbox)
 {
+    NM_FUNCTION;
+    
     NmId nmId(0);
 
     QList<NmId> mailboxIds;
@@ -1191,6 +1416,8 @@
     const NmId& folderId,
     const NmId& messageId)
 {
+    NM_FUNCTION;
+    
     CFSMailFolder* folder = mFSfw->GetFolderByUidL( TFSMailMsgId(mailboxId), TFSMailMsgId(folderId));
     CleanupStack::PushL(folder);
     if ( folder ) {
@@ -1199,6 +1426,39 @@
     CleanupStack::PopAndDestroy(folder);
 }
 
+/*!
+    Leaving version of copyMessages
+*/
+void NmFrameworkAdapter::copyMessagesL(
+    const NmId &mailboxId,
+    const QList<quint64>& messageIds,
+    const NmId& sourceFolderId,
+    const NmId& destinationFolderId)
+{
+    NM_FUNCTION;
+
+    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), 
+            TFSMailMsgId(destinationFolderId));
+        delete mailBox;
+    }
+    
+    CleanupStack::PopAndDestroy(2,&messages);    
+}
 
 /*!
    Sends the given message.
@@ -1206,6 +1466,8 @@
 QPointer<NmMessageSendingOperation> NmFrameworkAdapter::sendMessage(
     NmMessage *message)
 {
+    NM_FUNCTION;
+    
     QPointer<NmMessageSendingOperation>oper = new NmFwaMessageSendingOperation(*this, message, *mFSfw);
 	return oper;
 }
@@ -1217,6 +1479,8 @@
     const NmMessage &message,
     const QList<QString> &fileList)
 {
+    NM_FUNCTION;
+    
     QPointer<NmAddAttachmentsOperation>oper = new NmFwaAddAttachmentsOperation(message, fileList, *mFSfw);
     return oper;
 }
@@ -1228,26 +1492,19 @@
     const NmMessage &message,
     const NmId &attachmentPartId)
 {
+    NM_FUNCTION;
+    
     QPointer<NmOperation> oper = new NmFwaRemoveAttachmentOperation(message, attachmentPartId, *mFSfw);
     return oper;
 }
 
 /*!
-   Checks outbox for messages
- */
-QPointer<NmCheckOutboxOperation> NmFrameworkAdapter::checkOutbox(const NmId& mailboxId)
-{
-    QPointer<NmCheckOutboxOperation> oper =
-        new NmFwaCheckOutboxOperation(mailboxId, *mFSfw);
-
-    return oper;
-}
-
-/*!
     Returns the current sync state of the given mailbox
  */
 NmSyncState NmFrameworkAdapter::syncState(const NmId& mailboxId) const
 {
+    NM_FUNCTION;
+    
    CFSMailBox* mailBox = NULL;
    TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) );
    if (KErrNone == err && mailBox) {
@@ -1270,6 +1527,8 @@
  */
 NmConnectState NmFrameworkAdapter::connectionState(const NmId& mailboxId) const
 {
+    NM_FUNCTION;
+    
     CFSMailBox* mailBox = NULL;
     TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) );
     if (KErrNone == err && mailBox) {
@@ -1294,6 +1553,8 @@
 CFSMailMessage* NmFrameworkAdapter::mailMessageFromEnvelopeL(
     const NmMessageEnvelope& envelope)
 {
+    NM_FUNCTION;
+    
     NmMessage* nmMessage = new(ELeave) NmMessage( envelope );
     CFSMailMessage* message = CFSMailMessage::NewL( *nmMessage );
     delete nmMessage;
@@ -1309,6 +1570,8 @@
         CFSMailMessagePart *cfsParent,
         NmMessagePart *nmParent)
 {
+    NM_FUNCTION;
+    
     User::LeaveIfNull(cfsParent);
     User::LeaveIfNull(nmParent);
 
@@ -1332,6 +1595,8 @@
  */
 int NmFrameworkAdapter::RefreshMailboxL(NmId mailboxId)
 {
+    NM_FUNCTION;
+    
     int result(KErrNotFound);
     CFSMailBox *currentMailbox(NULL);
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
@@ -1349,6 +1614,8 @@
  */
 int NmFrameworkAdapter::GoOnlineL(const NmId& mailboxId)
 {
+    NM_FUNCTION;
+    
     int result(KErrNotFound);
     CFSMailBox *currentMailbox(NULL);
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
@@ -1366,6 +1633,8 @@
  */
 int NmFrameworkAdapter::GoOfflineL(const NmId& mailboxId)
 {
+    NM_FUNCTION;
+    
 	int result(KErrNotFound);
     CFSMailBox *currentMailbox(NULL);
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
@@ -1383,6 +1652,8 @@
  */
 void NmFrameworkAdapter::handleMailboxEvent( TFSMailMsgId mailbox, NmMailboxEvent event)
 {
+    NM_FUNCTION;
+    
     QList<NmId> mailboxIds;
     NmId nmId;
     if (event == NmMailboxDeleted) {
@@ -1403,6 +1674,8 @@
     NmMessageEvent event,
     TFSMailMsgId mailbox)
 {
+    NM_FUNCTION;
+    
     NmId nmMsgId(0);
     QList<NmId> messageIds;
     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
@@ -1423,6 +1696,8 @@
  */
 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);
@@ -1448,6 +1723,8 @@
  */
 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);
@@ -1466,6 +1743,8 @@
 
 void NmFrameworkAdapter::handleSyncstateEvent(TAny* param1, TFSMailMsgId mailbox)
 {
+    NM_FUNCTION;
+    
     TSSMailSyncState* state = static_cast<TSSMailSyncState*>( param1 );
     NmOperationCompletionEvent event;
     event.mMailboxId = NmConverter::mailMsgIdToNmId(mailbox);
--- a/emailuis/nmframeworkadapter/src/nmfwaaddattachmentsoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmfwaaddattachmentsoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -39,6 +39,8 @@
     CFSMailClient &mailClient) :
         mMailClient(mailClient)
 {
+    NM_FUNCTION;
+    
     // Take own copy of the file list.
     mFileList.clear();
     for (int i=0; i<fileList.count(); ++i) {
@@ -53,6 +55,8 @@
  */
 NmFwaAddAttachmentsOperation::~NmFwaAddAttachmentsOperation()
 {
+    NM_FUNCTION;
+    
     // Cancel all running operations.
     doCancelOperation();
     mFileList.clear(); 
@@ -67,6 +71,8 @@
  */
 void NmFwaAddAttachmentsOperation::doRunAsyncOperation()
 {
+    NM_FUNCTION;
+    
     TRAPD(err, doRunAsyncOperationL());
     // Trap harness catches an error.
     if (err != KErrNone) {
@@ -104,6 +110,8 @@
  */
 void NmFwaAddAttachmentsOperation::doRunAsyncOperationL()
 {
+    NM_FUNCTION;
+    
     if (mFileList.count() > 0) {
         // Add new attachment from first file in the list.
         HBufC *fileName = NmConverter::qstringToHBufCLC(mFileList.first());
@@ -124,6 +132,8 @@
 void NmFwaAddAttachmentsOperation::RequestResponseL(TFSProgress aEvent,
                                                     TInt aRequestId)
 {
+    NM_FUNCTION;
+    
     int err = NmNoError;
 
     // Request id should always be valid. If not,
@@ -192,12 +202,24 @@
 }
 
 /*!
+ * Complete the operation
+ */
+void NmFwaAddAttachmentsOperation::doCompleteOperation()
+{
+    NM_FUNCTION;
+    
+    mRequestId = NmNotFoundError;
+}
+
+/*!
     Cancels the async operation. \sa NmOperation
  */
 void NmFwaAddAttachmentsOperation::doCancelOperation()
 {
-    if (mRequestId != KErrNotFound) {
+    NM_FUNCTION;
+    
+    if (mRequestId >= 0) {
         TRAP_IGNORE(mMailClient.CancelL(mRequestId));
+        mRequestId = NmNotFoundError;
     }
-    mRequestId = NmCancelError;
 }
--- a/emailuis/nmframeworkadapter/src/nmfwacheckoutboxoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/*
- * 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 "nmframeworkadapterheaders.h"
-
-NmFwaCheckOutboxOperation::NmFwaCheckOutboxOperation(
-    const NmId &mailboxId,
-    CFSMailClient &mailClient) :
-        mMailboxId(mailboxId),
-        mMailClient(mailClient),
-        mFound(false),
-        mMessageId(0)
-{
-}
-
-NmFwaCheckOutboxOperation::~NmFwaCheckOutboxOperation()
-{
-}
-
-void NmFwaCheckOutboxOperation::doRunAsyncOperation()
-{
-    TRAPD(err, doRunAsyncOperationL());
-    
-    if (err) {
-        completeOperation(NmGeneralError);
-    }
-}
-
-/*!
-    Gets the id of the message with index '0' in the Outbox .
-
-    \return true if there is a message in Outbox.
- */
-bool NmFwaCheckOutboxOperation::getMessageId(NmId &messageId) const
-{
-    messageId = mMessageId;
-    return mFound;
-}
-
-void NmFwaCheckOutboxOperation::doRunAsyncOperationL()
-{
-    int err = NmNotFoundError;
-
-    TFSMailMsgId mailboxId(mMailboxId.pluginId32(), mMailboxId.id32());
-    
-    CFSMailBox *mailbox = mMailClient.GetMailBoxByUidL(mailboxId);
-    
-    if (mailbox) {
-        CleanupStack::PushL(mailbox);
-    
-        TFSMailMsgId folderId = mailbox->GetStandardFolderId(EFSOutbox);
-
-        CFSMailFolder *folder =
-            mMailClient.GetFolderByUidL(mailboxId, folderId);
-
-        if (folder) {
-            CleanupStack::PushL(folder);
-
-            TFSMailSortCriteria sortCriteria;
-            sortCriteria.iField = EFSMailSortByDate;
-            sortCriteria.iOrder = EFSMailDescending;
-            
-            RArray<TFSMailSortCriteria> sortArray;
-            CleanupClosePushL(sortArray);
-            sortArray.AppendL(sortCriteria);
-            
-            MFSMailIterator *iter = folder->ListMessagesL(
-                EFSMsgDataIdOnly, sortArray);
-            
-            CleanupStack::PopAndDestroy(); // sortArray
-
-            if (iter) {
-                CleanupDeletePushL(iter);
-
-                TFSMailMsgId nullId;
-                TInt numberOfItems = 1;
-                RPointerArray<CFSMailMessage> messages;
-
-                CleanupClosePushL(messages);
-                TBool unused = iter->NextL(nullId, numberOfItems, messages);
-
-                if (messages.Count() > 0) {
-                    mMessageId = messages[0]->GetMessageId().GetNmId();
-                    mFound = true;
-                }
-
-                messages.ResetAndDestroy();
-                CleanupStack::PopAndDestroy(); // messages
-
-                CleanupStack::PopAndDestroy(iter);
-                
-                err = NmNoError;
-            }
-            CleanupStack::PopAndDestroy(folder);
-        }
-        CleanupStack::PopAndDestroy(mailbox);
-    }
-
-    completeOperation(err);
-}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmframeworkadapter/src/nmfwadeletemailboxoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,125 @@
+/*
+ * 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 "nmframeworkadapterheaders.h"
+
+/*!
+    \class NmFwaDeleteMailboxOperation
+    
+    \brief NmFwaDeleteMailboxOperation is an async operation which deletes a mailbox.
+    
+    NmFwaDeleteMailboxOperation is an async operation which deletes a mailbox. 
+    \sa NmOperation
+ */
+
+/*!
+    Constructor
+    
+    \param mailboxId Mailbox id to be deleted.
+    \param mailClient Reference to mail client object.
+ */
+NmFwaDeleteMailboxOperation::NmFwaDeleteMailboxOperation(
+    const NmId &mailboxId,
+    CFSMailClient &mailClient) :
+        mMailboxId(mailboxId),
+        mMailClient(mailClient),
+        mRequestId(NmNotFoundError)
+{
+    NM_FUNCTION;
+    
+    mMailClient.IncReferenceCount();
+}
+
+/*!
+    Destructor
+ */
+NmFwaDeleteMailboxOperation::~NmFwaDeleteMailboxOperation()
+{
+    NM_FUNCTION;
+    
+    doCancelOperation();
+    mMailClient.Close(); // decrease ref count
+}
+
+/*!
+    Called after base object construction via timer event, runs the
+    async operation.
+    
+    \sa NmOperation
+ */
+void NmFwaDeleteMailboxOperation::doRunAsyncOperation()
+{
+    NM_FUNCTION;
+    
+    TRAPD(err, deleteMailboxL());
+        
+    if (err != KErrNone) {
+        completeOperation(NmGeneralError);
+    }
+}
+
+/*!
+    
+ */
+void NmFwaDeleteMailboxOperation::doCompleteOperation()
+{
+    NM_FUNCTION;
+    
+    mRequestId = NmNotFoundError;
+}
+
+/*!
+    
+ */
+void NmFwaDeleteMailboxOperation::doCancelOperation()
+{
+    NM_FUNCTION;
+
+    // delete mailbox operation is not cancellable
+}
+    
+/*!
+    Asynchronous request response message.
+    
+    \param aEvent Plugin event description.
+    \param aRequestId Request id of asyncronous operation.
+ */
+void NmFwaDeleteMailboxOperation::RequestResponseL(TFSProgress aEvent,
+                                                    TInt aRequestId)
+{
+    NM_FUNCTION;
+    
+    TFSProgress::TFSProgressStatus status = aEvent.iProgressStatus;
+
+    if (aRequestId == mRequestId) {
+        if (status == TFSProgress::EFSStatus_RequestComplete && !aEvent.iError) {
+            completeOperation(NmNoError);
+        }
+        else {
+            completeOperation(NmGeneralError);
+        }
+    }
+}
+
+/*!
+    Removes the message.
+ */
+void NmFwaDeleteMailboxOperation::deleteMailboxL()
+{
+    NM_FUNCTION;
+    const TFSMailMsgId mailboxId(mMailboxId);
+    mRequestId = mMailClient.DeleteMailBoxByUidL(mailboxId, *this);
+}
--- a/emailuis/nmframeworkadapter/src/nmfwaforwardmessagecreationoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmfwaforwardmessagecreationoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -24,14 +24,18 @@
     NmFwaMessageCreationOperation(mailboxId, mailClient),
     mOriginalMessageId(originalMessageId)
 {
+    NM_FUNCTION;
 }
 
 NmFwaForwardMessageCreationOperation::~NmFwaForwardMessageCreationOperation()
 {
+    NM_FUNCTION;
 }
 
 void NmFwaForwardMessageCreationOperation::doRunAsyncOperation()
 {
+    NM_FUNCTION;
+    
     const TFSMailMsgId mailMsgId(mMailboxId.pluginId32(), mMailboxId.id32());
 
     CFSMailBox *mailBox = NULL;
--- a/emailuis/nmframeworkadapter/src/nmfwamessagecreationoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmfwamessagecreationoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -40,6 +40,7 @@
         mMailClient(mailClient),
         mRequestId(NmNotFoundError)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -47,9 +48,10 @@
  */
 NmFwaMessageCreationOperation::~NmFwaMessageCreationOperation()
 {
+    NM_FUNCTION;
+    
     doCancelOperation();
     delete mMessage;
-    NMLOG("NmFwaMessageCreationOperation::~NmFwaMessageCreationOperation --->");
 }
 
 /*!
@@ -59,6 +61,8 @@
  */
 void NmFwaMessageCreationOperation::doRunAsyncOperation()
 {
+    NM_FUNCTION;
+    
     const TFSMailMsgId mailMsgId(mMailboxId.pluginId32(), mMailboxId.id32());
 
     CFSMailBox *mailBox = NULL;
@@ -105,6 +109,8 @@
  */
 void NmFwaMessageCreationOperation::doCompleteOperation()
 {
+    NM_FUNCTION;
+    
     mRequestId = NmNotFoundError;
 }
 
@@ -113,6 +119,8 @@
  */
 void NmFwaMessageCreationOperation::doCancelOperation()
 {
+    NM_FUNCTION;
+    
     if (mRequestId >= 0) {
         TRAP_IGNORE(mMailClient.CancelL(mRequestId));
         mRequestId = NmNotFoundError;
@@ -127,6 +135,8 @@
  */
 NmMessage *NmFwaMessageCreationOperation::getMessage()
 {
+    NM_FUNCTION;
+    
     // Ownership changes
     NmMessage *ret = mMessage;
     mMessage = NULL;
@@ -141,6 +151,8 @@
  */
 NmId NmFwaMessageCreationOperation::getMessageId()
 {
+    NM_FUNCTION;
+    
     NmId messageId;
     
     if (mMessage) {
@@ -159,6 +171,8 @@
 void NmFwaMessageCreationOperation::RequestResponseL(TFSProgress aEvent,
                                                      TInt aRequestId)
 {
+    NM_FUNCTION;
+    
     TFSProgress::TFSProgressStatus status = aEvent.iProgressStatus;
 
     if (aRequestId == mRequestId) {
--- a/emailuis/nmframeworkadapter/src/nmfwamessagefetchingoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmfwamessagefetchingoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -29,16 +29,20 @@
         mRequestId(0)
 
 {
+    NM_FUNCTION;
 }
 
 NmFwaMessageFetchingOperation::~NmFwaMessageFetchingOperation()
 {
+    NM_FUNCTION;
+    
     doCancelOperation();
-    NMLOG("NmFwaMessageFetchingOperation::~NmFwaMessageFetchingOperation --->");
 }
 
 void NmFwaMessageFetchingOperation::doRunAsyncOperation()
 {
+    NM_FUNCTION;
+    
     const TFSMailMsgId mailboxId(mMailboxId.pluginId32(), mMailboxId.id32());
     const TFSMailMsgId folderId(mFolderId.pluginId32(), mFolderId.id32());
     const TFSMailMsgId messageId(mMessageId.pluginId32(), mMessageId.id32());
@@ -62,9 +66,27 @@
     }
 }
 
+/*!
+ * Complete the operation
+ */
+void NmFwaMessageFetchingOperation::doCompleteOperation()
+{
+    NM_FUNCTION;
+    
+    mRequestId = NmNotFoundError;
+}
+
+/*!
+    Cancels the async operation. \sa NmOperation
+ */
 void NmFwaMessageFetchingOperation::doCancelOperation()
 {
-    TRAP_IGNORE(mMailClient.CancelL(mRequestId));
+    NM_FUNCTION;
+    
+    if (mRequestId >= 0) {
+        TRAP_IGNORE(mMailClient.CancelL(mRequestId));
+        mRequestId = NmNotFoundError;
+    }
 }
 
 /*!
@@ -75,6 +97,8 @@
  */
 void NmFwaMessageFetchingOperation::RequestResponseL(TFSProgress aEvent, TInt aRequestId)
 {
+    NM_FUNCTION;
+    
     if (aRequestId == mRequestId) {
         if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete ) {
             completeOperation(NmNoError);
--- a/emailuis/nmframeworkadapter/src/nmfwamessagepartfetchingoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmfwamessagepartfetchingoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -35,7 +35,7 @@
     mRequestId(0)
 
 {
-    
+    NM_FUNCTION;
 }
 
 /*!
@@ -43,8 +43,9 @@
  */
 NmFwaMessagePartFetchingOperation::~NmFwaMessagePartFetchingOperation()
 {
+    NM_FUNCTION;
+    
     doCancelOperation();
-    NMLOG("NmFwaMessagePartFetchingOperation::~NmFwaMessagePartFetchingOperation --->");
 }
 
 /*!
@@ -52,6 +53,8 @@
  */
 void NmFwaMessagePartFetchingOperation::RequestResponseL(TFSProgress aEvent, TInt aRequestId)
 {
+    NM_FUNCTION;
+    
     if (aRequestId == mRequestId) {
         if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete ) {
             completeOperation(aEvent.iError);
@@ -81,6 +84,8 @@
  */
 void NmFwaMessagePartFetchingOperation::doRunAsyncOperation()
 {
+    NM_FUNCTION;
+    
     TRAPD(err, doRunAsyncOperationL());
     if (err != KErrNone) {
         completeOperation(NmGeneralError);
@@ -92,6 +97,8 @@
  */
 void NmFwaMessagePartFetchingOperation::doRunAsyncOperationL()
 {
+    NM_FUNCTION;
+    
     const TFSMailMsgId mailboxId(mMailboxId.pluginId32(), mMailboxId.id32());
     const TFSMailMsgId folderId(mFolderId.pluginId32(), mFolderId.id32());
     const TFSMailMsgId messageId(mMessageId.pluginId32(), mMessageId.id32());
@@ -119,9 +126,24 @@
 }
 
 /*!
+ * Complete the operation
+ */
+void NmFwaMessagePartFetchingOperation::doCompleteOperation()
+{
+    NM_FUNCTION;
+    
+    mRequestId = NmNotFoundError;
+}
 
+/*!
+    Cancels the async operation. \sa NmOperation
  */
 void NmFwaMessagePartFetchingOperation::doCancelOperation()
 {
-    TRAP_IGNORE(mMailClient.CancelL(mRequestId));
+    NM_FUNCTION;
+    
+    if (mRequestId >= 0) {
+        TRAP_IGNORE(mMailClient.CancelL(mRequestId));
+        mRequestId = NmNotFoundError;
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmframeworkadapter/src/nmfwamessagepartsfetchingoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,162 @@
+/*
+ * 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 "nmframeworkadapterheaders.h"
+
+/*!
+
+ */
+NmFwaMessagePartsFetchingOperation::NmFwaMessagePartsFetchingOperation(
+        const NmId &mailboxId,
+        const NmId &folderId,
+        const NmId &messageId,
+        const QList<NmId> &messagePartIds,
+        CFSMailClient &mailClient)
+  : mMailboxId(mailboxId), 
+    mFolderId(folderId), 
+    mMessageId(messageId), 
+    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(
+            NmConverter::nmIdToMailMsgId(
+                messagePartIds.at(i)));
+    }
+    
+}
+
+/*!
+
+ */
+NmFwaMessagePartsFetchingOperation::~NmFwaMessagePartsFetchingOperation()
+{
+    NM_FUNCTION;
+    
+    doCancelOperation();
+}
+
+/*!
+
+ */
+void NmFwaMessagePartsFetchingOperation::RequestResponseL(TFSProgress aEvent, TInt aRequestId)
+{
+    NM_FUNCTION;
+    
+    if (aRequestId == mRequestId) {
+        if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete ) {
+            completeOperation(aEvent.iError);
+        }
+        else if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestCancelled) {
+            completeOperation(NmCancelError);
+        }
+        else if (aEvent.iProgressStatus == TFSProgress::EFSStatus_Status) {
+            int progress = 0;
+            if (aEvent.iMaxCount > 0) {
+                // calculate progress per cents
+                qreal counterValue = aEvent.iCounter;
+                qreal maxCount = aEvent.iMaxCount;
+                progress = (counterValue / maxCount)*100;
+            }
+            if (progress > mLastProgressValue) {
+                // send only increasing values to prevent downward changing percentage
+                mLastProgressValue = progress;
+                updateOperationProgress(mLastProgressValue);
+            }
+        }
+    }
+}
+
+/*!
+
+ */
+void NmFwaMessagePartsFetchingOperation::doRunAsyncOperation()
+{
+    NM_FUNCTION;
+    
+    TRAPD(err, doRunAsyncOperationL());
+    if (err != KErrNone) {
+        completeOperation(NmGeneralError);
+    }
+}
+
+/*!
+    Leaving version from doRunAsyncOperation
+ */
+void NmFwaMessagePartsFetchingOperation::doRunAsyncOperationL()
+{
+    NM_FUNCTION;
+    
+    if (mMessagePartIds.Count() > 0) {
+        
+        const TFSMailMsgId mailboxId(mMailboxId.pluginId32(), mMailboxId.id32());
+        const TFSMailMsgId folderId(mFolderId.pluginId32(), mFolderId.id32());
+        const TFSMailMsgId messageId(mMessageId.pluginId32(), mMessageId.id32());
+        
+        CFSMailMessage *message(NULL);
+        message = mMailClient.GetMessageByUidL(mailboxId, folderId, messageId, EFSMsgDataEnvelope);
+        CleanupStack::PushL(message);
+       
+        if (message) {
+            CFSMailMessagePart* messagePart = message->ChildPartL( mMessagePartIds[0] );
+            CleanupStack::PushL(messagePart);
+            if (messagePart) {            
+                mRequestId = messagePart->FetchMessagesPartsL(mMessagePartIds,*this,0);
+            }
+            else {
+                completeOperation(NmNotFoundError);
+            }
+            CleanupStack::PopAndDestroy(messagePart);
+        }
+        else {
+            completeOperation(NmNotFoundError);
+        }
+        CleanupStack::PopAndDestroy(message);
+    }
+    else {
+        completeOperation(NmNotFoundError);
+    }
+}
+
+/*!
+ * Complete the operation
+ */
+void NmFwaMessagePartsFetchingOperation::doCompleteOperation()
+{
+    NM_FUNCTION;
+    
+    mRequestId = NmNotFoundError;
+}
+
+/*!
+    Cancels the async operation. \sa NmOperation
+ */
+void NmFwaMessagePartsFetchingOperation::doCancelOperation()
+{
+    NM_FUNCTION;
+    
+    if (mRequestId >= 0) {
+        TRAP_IGNORE(mMailClient.CancelL(mRequestId));
+        mRequestId = NmNotFoundError;
+    }
+}
--- a/emailuis/nmframeworkadapter/src/nmfwamessagesendingoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmfwamessagesendingoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -43,6 +43,8 @@
         mRequestId(NmNotFoundError),
         mSaved(false)
 {
+    NM_FUNCTION;
+    
     mMailClient.IncReferenceCount();
 }
 
@@ -51,13 +53,14 @@
  */
 NmFwaMessageSendingOperation::~NmFwaMessageSendingOperation()
 {
+    NM_FUNCTION;
+    
     if (mSaveOperation && mSaveOperation->isRunning()) {
         mSaveOperation->cancelOperation();
     }
     doCancelOperation();
     mMailClient.Close(); // decrease ref count
     delete mMessage;
-    NMLOG("NmFwaMessageSendingOperation::~NmFwaMessageSendingOperation --->");
 }
 
 /*!
@@ -65,6 +68,8 @@
  */
 const NmMessage *NmFwaMessageSendingOperation::getMessage() const
 {
+    NM_FUNCTION;
+    
     return mMessage;
 }
 
@@ -76,6 +81,8 @@
  */
 void NmFwaMessageSendingOperation::doRunAsyncOperation()
 {
+    NM_FUNCTION;
+    
     int err = NmNoError;
     
     if (mSaved) {
@@ -103,6 +110,8 @@
  */
 void NmFwaMessageSendingOperation::doCompleteOperation()
 {
+    NM_FUNCTION;
+    
     mRequestId = NmNotFoundError;
 }
 
@@ -111,6 +120,8 @@
  */
 void NmFwaMessageSendingOperation::doCancelOperation()
 {
+    NM_FUNCTION;
+    
     if (mRequestId >= 0) {
         TRAP_IGNORE(mMailClient.CancelL(mRequestId));
         mRequestId = NmNotFoundError;
@@ -129,6 +140,8 @@
 void NmFwaMessageSendingOperation::RequestResponseL(TFSProgress aEvent,
                                                     TInt aRequestId)
 {
+    NM_FUNCTION;
+    
     TFSProgress::TFSProgressStatus status = aEvent.iProgressStatus;
 
     if (aRequestId == mRequestId) {
@@ -149,6 +162,8 @@
  */
 void NmFwaMessageSendingOperation::handleCompletedSaveOperation(int error)
 {
+    NM_FUNCTION;
+    
     if (error == NmNoError) {
         mSaved = true;
         doRunAsyncOperation();
@@ -163,6 +178,8 @@
 */
 int NmFwaMessageSendingOperation::saveMessageWithSubparts()
 {
+    NM_FUNCTION;
+    
     int ret = NmNotFoundError;
     if (mMessage) {
         if (mSaveOperation && mSaveOperation->isRunning()) {
@@ -189,7 +206,8 @@
  */
 int NmFwaMessageSendingOperation::sendMessageL()
 {
-    NMLOG("NmFwaMessageSendingOperation::sendMessageL");
+    NM_FUNCTION;
+    
     int ret = NmNotFoundError;
     
     if (mMessage) {
--- a/emailuis/nmframeworkadapter/src/nmfwaremoveattachmentoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmfwaremoveattachmentoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -40,6 +40,8 @@
         mMessage(message),
         mMailClient(mailClient)
 {
+    NM_FUNCTION;
+    
     // Take a copy because original will be deleted during the operation
     mAttachmentPartId.setId(attachmentPartId.id());
 }
@@ -49,6 +51,8 @@
  */
 NmFwaRemoveAttachmentOperation::~NmFwaRemoveAttachmentOperation()
 {
+    NM_FUNCTION;
+    
     doCancelOperation();
 }
 
@@ -60,6 +64,8 @@
  */
 void NmFwaRemoveAttachmentOperation::doRunAsyncOperation()
 {
+    NM_FUNCTION;
+    
     TRAPD(err, doRunAsyncOperationL());
     if (err != KErrNone) {
         completeOperation(NmGeneralError);
@@ -72,6 +78,8 @@
  */
 void NmFwaRemoveAttachmentOperation::doRunAsyncOperationL()
 {
+    NM_FUNCTION;
+    
     CFSMailMessage *msg = NULL;
 
     msg = CFSMailMessage::NewL(mMessage);
@@ -110,6 +118,8 @@
 void NmFwaRemoveAttachmentOperation::RequestResponseL(TFSProgress aEvent,
                                                       TInt aRequestId)
 {
+    NM_FUNCTION;
+    
     if (aRequestId == mRequestId) {
         TFSProgress::TFSProgressStatus status = aEvent.iProgressStatus;
         if (status == TFSProgress::EFSStatus_RequestComplete) {
@@ -143,6 +153,8 @@
  */
 void NmFwaRemoveAttachmentOperation::doCancelOperation()
 {
+    NM_FUNCTION;
+    
     if (mRequestId >= 0) {
         TRAP_IGNORE(mMailClient.CancelL(mRequestId));
         mRequestId = KErrNotFound;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmframeworkadapter/src/nmfwaremovedraftmessageoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,150 @@
+/*
+ * 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 "nmframeworkadapterheaders.h"
+
+/*!
+    \class NmFwaRemoveDraftMessageOperation
+    
+    \brief NmFwaRemoveDraftMessageOperation is an async operation which deletes a draft message.
+    
+    NmFwaRemoveDraftMessageOperation is an async operation which cdeletes a draft message. 
+    \sa NmOperation
+ */
+
+/*!
+    Constructor
+    
+    \param message pointer to the message under sent, ownership is transferred to operation
+    \param mailClient Reference to mail client object.
+ */
+NmFwaRemoveDraftMessageOperation::NmFwaRemoveDraftMessageOperation(
+    NmDataPluginInterface &pluginInterface,
+    NmMessage *message,
+    CFSMailClient &mailClient) :
+        mPluginInterface(pluginInterface),
+        mMessage(message),
+        mMailClient(mailClient),
+        mRequestId(NmNotFoundError)
+{
+    NM_FUNCTION;
+    
+    mMailClient.IncReferenceCount();
+}
+
+/*!
+    Destructor
+ */
+NmFwaRemoveDraftMessageOperation::~NmFwaRemoveDraftMessageOperation()
+{
+    NM_FUNCTION;
+    
+    doCancelOperation();
+    mMailClient.Close(); // decrease ref count
+    delete mMessage;
+    mMessage = NULL;
+}
+
+/*!
+    Called after base object construction via timer event, runs the
+    async operation.
+    
+    \sa NmOperation
+ */
+void NmFwaRemoveDraftMessageOperation::doRunAsyncOperation()
+{
+    NM_FUNCTION;
+    
+    TRAPD( err, removeMessageL() );
+        
+    if (err != KErrNone) {
+        completeOperation(NmGeneralError);
+    }
+}
+
+/*!
+    
+ */
+void NmFwaRemoveDraftMessageOperation::doCompleteOperation()
+{
+    NM_FUNCTION;
+    
+    mRequestId = NmNotFoundError;
+}
+
+/*!
+    
+ */
+void NmFwaRemoveDraftMessageOperation::doCancelOperation()
+{
+    NM_FUNCTION;
+
+    // remove draft operation is not cancellable
+}
+    
+/*!
+    Asynchronous request response message.
+    
+    \param aEvent Plugin event description.
+    \param aRequestId Request id of asyncronous operation.
+ */
+void NmFwaRemoveDraftMessageOperation::RequestResponseL(TFSProgress aEvent,
+                                                    TInt aRequestId)
+{
+    NM_FUNCTION;
+    
+    TFSProgress::TFSProgressStatus status = aEvent.iProgressStatus;
+
+    if (aRequestId == mRequestId) {
+        if (status == TFSProgress::EFSStatus_RequestComplete && !aEvent.iError) {
+            completeOperation(NmNoError);
+        }
+        else {
+            completeOperation(NmGeneralError);
+        }
+    }
+}
+
+/*!
+    Removes the message.
+ */
+void NmFwaRemoveDraftMessageOperation::removeMessageL()
+{
+    NM_FUNCTION;
+    
+    TFSMailMsgId mailboxId( mMessage->envelope().mailboxId() );
+    TFSMailMsgId folderId( mMessage->envelope().folderId() );
+    TFSMailMsgId messageId( mMessage->envelope().messageId() );
+    
+    CFSMailFolder* folder = mMailClient.GetFolderByUidL( mailboxId, folderId );
+    CleanupStack::PushL(folder);
+    if ( folder ) {
+        // try to use the asynchronous version first
+        TRAPD(err, mRequestId = folder->RemoveMessageL( messageId, *this ));
+        
+        if(err == KErrFSMailPluginNotSupported) {
+            // async version not supported, use sync version
+            folder->RemoveMessageL( messageId );
+            completeOperation(NmNoError);
+        } else if (KErrNone != err) {
+            completeOperation(NmGeneralError);
+        }
+    }
+    else {
+        User::Leave( KErrNotFound );
+    }
+    CleanupStack::PopAndDestroy(folder);
+}
--- a/emailuis/nmframeworkadapter/src/nmfwareplymessagecreationoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmfwareplymessagecreationoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -26,14 +26,18 @@
     mOriginalMessageId(originalMessageId),
     mReplyAll(replyAll)
 {
+    NM_FUNCTION;
 }
 
 NmFwaReplyMessageCreationOperation::~NmFwaReplyMessageCreationOperation()
 {
+    NM_FUNCTION;
 }
 
 void NmFwaReplyMessageCreationOperation::doRunAsyncOperation()
 {
+    NM_FUNCTION;
+    
     const TFSMailMsgId mailMsgId(mMailboxId.pluginId32(), mMailboxId.id32());
 
     CFSMailBox *mailBox(NULL);
--- a/emailuis/nmframeworkadapter/src/nmfwastoreenvelopesoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmfwastoreenvelopesoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -25,19 +25,22 @@
         mMailClient(mailClient),
         mRequestId(0)
 {
+    NM_FUNCTION;
+    
     mMessages = messages;
 }
 
 NmFwaStoreEnvelopesOperation::~NmFwaStoreEnvelopesOperation()
 {
-    NMLOG("NmFwaStoreEnvelopesOperation::~NmFwaStoreEnvelopesOperation() <---");
+    NM_FUNCTION;
+    
     mMessages.ResetAndDestroy();
-    NMLOG("NmFwaStoreEnvelopesOperation::~NmFwaStoreEnvelopesOperation() --->");
 }
 
 void NmFwaStoreEnvelopesOperation::doRunAsyncOperation()
 {
-    NMLOG("NmFwaStoreEnvelopesOperation::doRunAsyncOperation() <---");
+    NM_FUNCTION;
+    
     const TFSMailMsgId mailboxId(mMailboxId.pluginId32(), mMailboxId.id32());
     CFSMailBox *mailbox(NULL);
     TRAP_IGNORE( mailbox = mMailClient.GetMailBoxByUidL(mailboxId) );
@@ -56,14 +59,13 @@
         delete mailbox;
         mailbox = NULL;
     }
-    NMLOG("NmFwaStoreEnvelopesOperation::doRunAsyncOperation() --->");
 }
 
 void NmFwaStoreEnvelopesOperation::doCancelOperation()
 {
-    NMLOG("NmFwaStoreEnvelopesOperation::doCancelOperation() <---");
+    NM_FUNCTION;
+    
     TRAP_IGNORE(mMailClient.CancelL(mRequestId));
-    NMLOG("NmFwaStoreEnvelopesOperation::doCancelOperation() --->");
 }
 
 /**
@@ -74,7 +76,8 @@
  */
 void NmFwaStoreEnvelopesOperation::RequestResponseL(TFSProgress aEvent, TInt aRequestId)
 {
-    NMLOG("NmFwaStoreEnvelopesOperation::RequestResponseL() <---");
+    NM_FUNCTION;
+    
     if (aRequestId == mRequestId) {
         if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete && aEvent.iParam) {
             completeOperation(NmNoError);
@@ -86,5 +89,4 @@
             completeOperation(NmGeneralError);
         }
     }
-    NMLOG("NmFwaStoreEnvelopesOperation::RequestResponseL() --->");
 }
--- a/emailuis/nmframeworkadapter/src/nmfwastoremessageoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmfwastoremessageoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -25,16 +25,21 @@
         mRequestId(NmNotFoundError),
         mStatus(EStoreHeader)
 {
+    NM_FUNCTION;
 }
 
 NmFwaStoreMessageOperation::~NmFwaStoreMessageOperation()
 {
+    NM_FUNCTION;
+    
     doCancelOperation();
     delete mMessage;
 }
 
 void NmFwaStoreMessageOperation::doRunAsyncOperation()
 {
+    NM_FUNCTION;
+    
     TInt err = KErrNone;
 
     if (mMessage) {
@@ -75,11 +80,15 @@
  */
 void NmFwaStoreMessageOperation::doCompleteOperation()
 {
+    NM_FUNCTION;
+    
     mRequestId = NmNotFoundError;
 }
 
 void NmFwaStoreMessageOperation::doCancelOperation()
 {
+    NM_FUNCTION;
+    
     if (mRequestId >= 0) {
         TRAP_IGNORE(mMailClient.CancelL(mRequestId));
         mRequestId = NmNotFoundError;
@@ -95,6 +104,8 @@
 void NmFwaStoreMessageOperation::RequestResponseL(TFSProgress aEvent,
                                                      TInt aRequestId)
 {
+    NM_FUNCTION;
+    
     if (aRequestId == mRequestId) {
         if (aEvent.iProgressStatus ==
                 TFSProgress::EFSStatus_RequestComplete) {
--- a/emailuis/nmframeworkadapter/src/nmmailboxsearchobserver.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmframeworkadapter/src/nmmailboxsearchobserver.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -29,7 +29,7 @@
 */
 NmMailboxSearchObserver::NmMailboxSearchObserver()
 {
-    
+    NM_FUNCTION;
 }
 
 
@@ -38,7 +38,7 @@
 */
 NmMailboxSearchObserver::~NmMailboxSearchObserver()
 {
-    
+    NM_FUNCTION;
 }
 
 
@@ -52,11 +52,14 @@
 */
 void NmMailboxSearchObserver::MatchFoundL(CFSMailMessage *aMatchMessage)
 {
+    NM_FUNCTION;
+    
     if (aMatchMessage) {
         NmMessage *message = aMatchMessage->GetNmMessage();
 
         if (message) {
-            emit matchFound(message->envelope().messageId());
+            NmMessageEnvelope messageEnvelope = message->envelope();
+            emit matchFound(messageEnvelope.messageId(), messageEnvelope.folderId());
             delete message;
         }
     }
@@ -69,6 +72,8 @@
 */
 void NmMailboxSearchObserver::SearchCompletedL()
 {
+    NM_FUNCTION;
+    
     emit searchComplete();
 }
 
@@ -80,6 +85,8 @@
 void NmMailboxSearchObserver::ClientRequiredSearchPriority(
     TInt *apRequiredSearchPriority)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(apRequiredSearchPriority);
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmhswidget/conf/nmhswidget.docml	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+    <widget name="nmhswidgetContainer" type="HbWidget">
+        <widget name="mailRowContainer" type="HbWidget">
+            <widget name="noMailsLabel" type="HbLabel">
+                <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+                <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-tiny)"/>
+                <string locid="txt_mail_widget_info_no_messages" name="plainText" value="No mails!!!"/>
+                <string name="textColor" value="#000000"/>
+                <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
+                <sizehint type="MAXIMUM" width="46un"/>
+                <sizehint height="0un" type="MINIMUM" width="0un"/>
+                <sizehint height="29.75un" type="PREFERRED" width="46un"/>
+            </widget>
+            <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
+            <sizehint height="expr(3*9.75un )" type="PREFERRED" width="46un"/>
+            <sizehint height="0un" type="MINIMUM" width="0un"/>
+            <sizehint height="2504062.01158un" type="MAXIMUM" width="2504062.01158un"/>
+            <layout orientation="Vertical" spacing="0un" type="linear">
+                <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+                <linearitem itemname="noMailsLabel"/>
+            </layout>
+        </widget>
+        <widget name="titleLayoutWidget" type="HbWidget">
+            <widget name="mailboxNameLabel" type="HbLabel">
+                <real name="z" value="1"/>
+                <sizepolicy horizontalPolicy="Ignored" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                <sizehint height="expr(var(hb-param-text-height-secondary) )" type="PREFERRED" width="34.92537un"/>
+                <sizehint height="expr(var(hb-param-text-height-secondary) )" type="MINIMUM"/>
+                <sizehint height="expr(var(hb-param-text-height-secondary) )" type="MAXIMUM"/>
+                <string name="plainText" value="Mailbox gmail"/>
+                <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
+            </widget>
+            <widget name="mailboxIcon" type="HbLabel">
+                <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+                <icon iconName="note_warning" name="icon"/>
+                <real name="z" value="2"/>
+                <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                <sizehint height="11un" type="FIXED" width="11un"/>
+                <sizehint height="11un" type="MINIMUM" width="11un"/>
+                <sizehint height="11un" type="MAXIMUM" width="11un"/>
+            </widget>
+            <widget name="unreadCountLabel" type="HbLabel">
+                <enums name="alignment" value="AlignRight|AlignVCenter|AlignTrailing"/>
+                <real name="z" value="3"/>
+                <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                <sizehint height="expr(var(hb-param-text-height-secondary) )" type="PREFERRED" width="6un"/>
+                <sizehint height="expr(var(hb-param-text-height-secondary) )" type="MINIMUM" width="3un"/>
+                <sizehint height="expr(var(hb-param-text-height-secondary) )" type="MAXIMUM" width="9un"/>
+                <string locid="txt_mail_widget_list_l1" name="plainText" value="(999)"/>
+                <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
+            </widget>
+            <widget name="collapseExpandIcon" type="HbPushButton">
+                <icon iconName="note_warning" name="icon"/>
+                <real name="z" value="4"/>
+                <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                <sizehint height="7un" type="FIXED" width="7un"/>
+                <sizehint height="7un" type="MINIMUM" width="7un"/>
+                <sizehint height="7un" type="MAXIMUM" width="7un"/>
+                <string name="alignment" value="AlignVCenter|AlignHCenter"/>
+            </widget>
+            <real name="z" value="1"/>
+            <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+            <sizehint height="expr(var(hb-param-margin-gene-bottom) + var(hb-param-text-height-secondary)  + var(hb-param-margin-gene-top) )" type="PREFERRED" width="46un"/>
+            <sizehint height="expr(var(hb-param-margin-gene-bottom) + var(hb-param-text-height-secondary)  + var(hb-param-margin-gene-top) )" type="MINIMUM" width="expr(5*var(hb-param-margin-gene-middle-horizontal) + 27un )"/>
+            <sizehint height="expr(var(hb-param-margin-gene-bottom) + var(hb-param-text-height-secondary)  + var(hb-param-margin-gene-top) )" type="MAXIMUM" width="2504062.01158un"/>
+            <layout type="anchor">
+                <anchoritem dst="mailboxIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="" srcEdge="LEFT"/>
+                <anchoritem dst="mailboxIcon" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                <anchoritem dst="collapseExpandIcon" dstEdge="RIGHT" spacing="-0.25" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="collapseExpandIcon" dstEdge="CENTERV" spacing="0un" src="unreadCountLabel" srcEdge="CENTERV"/>
+                <anchoritem dst="unreadCountLabel" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="collapseExpandIcon" srcEdge="LEFT"/>
+                <anchoritem dst="unreadCountLabel" dstEdge="CENTERV" spacing="0un" src="mailboxNameLabel" srcEdge="CENTERV"/>
+                <anchoritem dst="mailboxNameLabel" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="mailboxIcon" srcEdge="RIGHT"/>
+                <anchoritem dst="mailboxNameLabel" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
+                <anchoritem dst="mailboxNameLabel" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="unreadCountLabel" srcEdge="LEFT"/>
+            </layout>
+        </widget>
+        <real name="z" value="1"/>
+        <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
+        <sizehint height="expr(3*9.75un + 7.5un )" type="PREFERRED" width="46un"/>
+        <sizehint height="0un" type="MINIMUM" width="46un"/>
+        <sizehint height="42un" type="MAXIMUM" width="46un"/>
+        <layout type="anchor">
+            <anchoritem dst="titleLayoutWidget" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+            <anchoritem dst="titleLayoutWidget" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+            <anchoritem dst="mailRowContainer" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+            <anchoritem dst="mailRowContainer" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) + var(hb-param-margin-gene-bottom)  + var(hb-param-text-height-secondary))" src="" srcEdge="TOP"/>
+            <anchoritem dst="mailRowContainer" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+            <anchoritem dst="mailRowContainer" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+        </layout>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- a/emailuis/nmhswidget/conf/nmhswidgetmail.docml	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/conf/nmhswidgetmail.docml	Thu Jul 22 16:30:28 2010 +0100
@@ -1,88 +1,93 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hbdocument version="1.0">
-	  <widget name="emailLayoutWidget" type="HbWidget">
-	      <widget name="iconSeparator" type="HbLabel">
-	          <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
-	          <icon iconName="note_warning" name="icon"/>
-	          <real name="z" value="1"/>
-	          <enums name="aspectRatioMode" value="IgnoreAspectRatio"/>
-	          <sizepolicy horizontalPolicy="Ignored" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-	          <sizehint height="2" type="PREFERRED" width="50un"/>
-	      </widget>
-	      <widget name="iconNewMail" type="HbLabel">
-	          <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
-	          <real name="z" value="2"/>
-	          <enums name="aspectRatioMode" value="IgnoreAspectRatio"/>
-	          <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Ignored" verticalStretch="0"/>
-	          <sizehint type="PREFERRED" width="1.25un"/>
-	      </widget>
-	      <widget name="labelSender" type="HbLabel">
-	          <real name="z" value="3"/>
-	          <string name="plainText" value="Mail Spammer"/>
-	          <sizehint height="var(hb-param-text-height-tiny)" type="PREFERRED" width="33.43284un"/>
-	          <sizepolicy horizontalPolicy="Ignored" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-	          <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-tiny)"/>
-	      </widget>
-	      <widget name="labelTime" type="HbLabel">
-	          <real name="z" value="4"/>
-	          <string name="plainText" value="12:45pm"/>
-	          <sizehint height="var(hb-param-text-height-tiny)" type="FIXED" width="13un"/>
-	          <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-	          <enums name="alignment" value="AlignRight|AlignTop|AlignTrailing"/>
-                  <fontspec name="fontSpec" role="Secondary" textheight="2.5un"/>
-	      </widget>
-	      <widget name="labelSubject" type="HbLabel">
-	          <real name="z" value="5"/>
-	          <string name="plainText" value="Check out great new medication.."/>
-	          <sizepolicy horizontalPolicy="Ignored" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-	          <sizehint height="var(hb-param-text-height-tiny)" type="PREFERRED" width="35un"/>
-	          <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-tiny)"/>
-	      </widget>
-	      <widget name="iconThree" type="HbLabel">
-	          <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
-	          <icon iconName="note_warning" name="icon"/>
-	          <real name="z" value="6"/>
-	          <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-	          <sizehint height="var(hb-param-graphic-size-secondary)" type="FIXED" width="var(hb-param-graphic-size-secondary)"/>
-	      </widget>
-	      <widget name="iconTwo" type="HbLabel">
-	          <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
-	          <icon iconName="note_warning" name="icon"/>
-	          <real name="z" value="7"/>
-	          <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-	          <sizehint height="var(hb-param-graphic-size-secondary)" type="FIXED" width="var(hb-param-graphic-size-secondary)"/>
-	      </widget>
-	      <widget name="iconOne" type="HbLabel">
-	          <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
-	          <icon iconName="note_warning" name="icon"/>
-	          <real name="z" value="8"/>
-	          <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-	          <sizehint height="var(hb-param-graphic-size-secondary)" type="FIXED" width="var(hb-param-graphic-size-secondary)"/>
-	      </widget>
-	      <real name="z" value="1"/>
-	      <sizehint height="11.1un" type="FIXED" width="46un"/>
-	      <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-	      <layout type="anchor">
-	          <anchoritem dst="iconSeparator" dstEdge="LEFT" spacing="2" src="" srcEdge="LEFT"/>
-	          <anchoritem dst="iconSeparator" dstEdge="TOP" spacing="0" src="" srcEdge="TOP"/>
-	          <anchoritem dst="iconSeparator" dstEdge="RIGHT" spacing="-2" src="" srcEdge="RIGHT"/>
-	          <anchoritem dst="iconNewMail" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="" srcEdge="LEFT"/>
-	          <anchoritem dst="iconNewMail" dstEdge="TOP" spacing="0.5un" src="iconSeparator" srcEdge="BOTTOM"/>
-	          <anchoritem dst="iconNewMail" dstEdge="BOTTOM" spacing="-0.5un" src="" srcEdge="BOTTOM"/>
-	          <anchoritem dst="labelSender" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="iconNewMail" srcEdge="RIGHT"/>
-	          <anchoritem dst="labelSender" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="iconSeparator" srcEdge="BOTTOM"/>
-	          <anchoritem dst="labelTime" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="" srcEdge="RIGHT"/>
-	          <anchoritem dst="labelTime" dstEdge="TOP" spacing="0" src="labelSender" srcEdge="TOP"/>
-	          <anchoritem dst="labelTime" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="labelSender" srcEdge="RIGHT"/>
-	          <anchoritem dst="labelSubject" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="iconNewMail" srcEdge="RIGHT"/>
-	          <anchoritem dst="labelSubject" dstEdge="TOP" spacing="var(hb-param-margin-gene-middle-vertical)" src="labelSender" srcEdge="BOTTOM"/>
-	          <anchoritem dst="iconThree" dstEdge="TOP" spacing="0" src="labelSubject" srcEdge="TOP"/>
-	          <anchoritem dst="iconThree" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="" srcEdge="RIGHT"/>
-	          <anchoritem dst="iconTwo" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="iconThree" srcEdge="LEFT"/>
-	          <anchoritem dst="iconTwo" dstEdge="TOP" spacing="0" src="labelSubject" srcEdge="TOP"/>
-	          <anchoritem dst="iconOne" dstEdge="TOP" spacing="0" src="labelSubject" srcEdge="TOP"/>
-	          <anchoritem dst="iconOne" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="iconTwo" srcEdge="LEFT"/>
-	          <anchoritem dst="labelSubject" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="iconOne" srcEdge="LEFT"/>
-	      </layout>
-	  </widget>
+<hbdocument version="1.1">
+    <widget name="emailLayoutWidget" type="HbWidget">
+        <widget name="iconSeparator" type="HbLabel">
+            <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+            <icon iconName="note_warning" name="icon"/>
+            <enums name="aspectRatioMode" value="IgnoreAspectRatio"/>
+            <real name="z" value="1"/>
+            <sizepolicy horizontalPolicy="Ignored" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+            <sizehint height="2" type="PREFERRED" width="50un"/>
+        </widget>
+        <widget name="iconNewMail" type="HbLabel">
+            <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+            <enums name="aspectRatioMode" value="IgnoreAspectRatio"/>
+            <real name="z" value="2"/>
+            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Ignored" verticalStretch="0"/>
+            <sizehint type="PREFERRED" width="1.25un"/>
+        </widget>
+        <widget name="labelSender" type="HbLabel">
+            <real name="z" value="3"/>
+            <sizepolicy horizontalPolicy="Ignored" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+            <sizehint height="var(hb-param-text-height-secondary)" type="PREFERRED" width="33.43284un"/>
+            <string name="plainText" value="Mail Spammer"/>
+            <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
+        </widget>
+        <widget name="labelTime" type="HbLabel">
+            <enums name="alignment" value="AlignRight|AlignTop|AlignTrailing"/>
+            <real name="z" value="4"/>
+            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+            <sizehint height="var(hb-param-text-height-tiny)" type="FIXED" width="10un"/>
+            <string name="plainText" value="12:45pm"/>
+            <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-tiny)"/>
+        </widget>
+        <widget name="labelSubject" type="HbLabel">
+            <real name="z" value="5"/>
+            <sizepolicy horizontalPolicy="Ignored" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+            <sizehint height="var(hb-param-text-height-secondary)" type="PREFERRED" width="35un"/>
+            <string name="plainText" value="Check out great new medication.."/>
+            <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-secondary)"/>
+        </widget>
+        <widget name="iconThree" type="HbLabel">
+            <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+            <icon iconName="note_warning" name="icon"/>
+            <real name="z" value="6"/>
+            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+            <sizehint height="var(hb-param-graphic-size-secondary)" type="FIXED" width="var(hb-param-graphic-size-secondary)"/>
+        </widget>
+        <widget name="iconTwo" type="HbLabel">
+            <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+            <icon iconName="note_warning" name="icon"/>
+            <real name="z" value="7"/>
+            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+            <sizehint height="var(hb-param-graphic-size-secondary)" type="FIXED" width="var(hb-param-graphic-size-secondary)"/>
+        </widget>
+        <widget name="iconOne" type="HbLabel">
+            <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+            <icon iconName="note_warning" name="icon"/>
+            <real name="z" value="8"/>
+            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+            <sizehint height="var(hb-param-graphic-size-secondary)" type="FIXED" width="var(hb-param-graphic-size-secondary)"/>
+        </widget>
+        <real name="z" value="1"/>
+        <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+        <sizehint height="expr(1un + var(hb-param-text-height-secondary)  + var(hb-param-margin-gene-middle-vertical) + var(hb-param-text-height-secondary) + 1un )" type="PREFERRED" width="46un"/>
+        <sizehint height="expr(1un + var(hb-param-text-height-secondary)  + var(hb-param-margin-gene-middle-vertical) + var(hb-param-text-height-secondary) + 1un )" type="MINIMUM" width="expr(4*var(hb-param-margin-gene-middle-horizontal)  + 15un )"/>
+        <sizehint height="expr(1un + var(hb-param-text-height-secondary)  + var(hb-param-margin-gene-middle-vertical) + var(hb-param-text-height-secondary) + 1un )" type="MAXIMUM" width="2504062.01158un"/>
+        <layout type="anchor">
+            <anchoritem dst="iconSeparator" dstEdge="LEFT" spacing="2" src="" srcEdge="LEFT"/>
+            <anchoritem dst="iconSeparator" dstEdge="TOP" spacing="0" src="" srcEdge="TOP"/>
+            <anchoritem dst="iconSeparator" dstEdge="RIGHT" spacing="-2" src="" srcEdge="RIGHT"/>
+            <anchoritem dst="iconNewMail" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="" srcEdge="LEFT"/>
+            <anchoritem dst="iconNewMail" dstEdge="TOP" spacing="1un" src="iconSeparator" srcEdge="BOTTOM"/>
+            <anchoritem dst="iconNewMail" dstEdge="BOTTOM" spacing="-1un" src="" srcEdge="BOTTOM"/>
+            <anchoritem dst="labelSubject" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="iconNewMail" srcEdge="RIGHT"/>
+            <anchoritem dst="labelSubject" dstEdge="TOP" spacing="var(hb-param-margin-gene-middle-vertical)" src="labelSender" srcEdge="BOTTOM"/>
+            <anchoritem dst="labelSubject" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="iconOne" srcEdge="LEFT"/>
+            <anchoritem dst="labelSender" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="iconNewMail" srcEdge="RIGHT"/>
+            <anchoritem dst="labelSender" dstEdge="TOP" spacing="1un" src="iconSeparator" srcEdge="BOTTOM"/>
+            <anchoritem dst="labelSender" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="labelTime" srcEdge="LEFT"/>
+            <anchoritem dst="labelTime" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="" srcEdge="RIGHT"/>
+            <anchoritem dst="labelTime" dstEdge="CENTERV" spacing="0un" src="labelSender" srcEdge="CENTERV"/>
+            <anchoritem dst="iconOne" dstEdge="RIGHT" spacing="-0.5un" src="iconTwo" srcEdge="LEFT"/>
+            <anchoritem dst="iconOne" dstEdge="CENTERV" spacing="0un" src="labelSubject" srcEdge="CENTERV"/>
+            <anchoritem dst="iconThree" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="" srcEdge="RIGHT"/>
+            <anchoritem dst="iconThree" dstEdge="CENTERV" spacing="0un" src="iconOne" srcEdge="CENTERV"/>
+            <anchoritem dst="iconTwo" dstEdge="RIGHT" spacing="-0.5un" src="iconThree" srcEdge="LEFT"/>
+            <anchoritem dst="iconTwo" dstEdge="CENTERV" spacing="0un" src="iconOne" srcEdge="CENTERV"/>
+        </layout>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
 </hbdocument>
--- a/emailuis/nmhswidget/conf/nmhswidgettitle.docml	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<hbdocument version="1.0">
-    <widget name="titleLayoutWidget" type="HbWidget">
-        <widget name="mailboxNameLabel" type="HbLabel">
-            <real name="z" value="1"/>
-            <sizepolicy horizontalPolicy="Ignored" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-            <sizehint height="var(hb-param-text-height-tiny)" type="PREFERRED" width="34.92537un"/>
-            <string name="plainText" value="Mailbox gmail"/>
-            <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-tiny)"/>
-        </widget>
-        <widget name="mailboxIcon" type="HbLabel">
-            <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
-            <icon iconName="note_warning" name="icon"/>
-            <real name="z" value="2"/>
-            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-            <sizehint height="11un" type="FIXED" width="11un"/>
-        </widget>
-        <widget name="unreadCountLabel" type="HbLabel">
-            <enums name="alignment" value="AlignRight|AlignVCenter|AlignTrailing"/>
-            <real name="z" value="3"/>
-            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-            <sizehint height="var(hb-param-text-height-tiny)" type="FIXED" width="6un"/>
-            <string locid="txt_mail_widget_list_l1" name="plainText" value="(999)"/>
-            <fontspec name="fontSpec" role="Secondary" textheight="var(hb-param-text-height-tiny)"/>
-        </widget>
-        <widget name="collapseExpandIcon" type="HbPushButton">
-            <icon iconName="note_warning" name="icon"/>
-            <real name="z" value="4"/>
-            <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-            <sizehint height="5.5un" type="FIXED" width="5.5un"/>
-            <string name="alignment" value="AlignVCenter|AlignHCenter"/>
-        </widget>
-        <real name="z" value="1"/>
-        <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
-        <sizehint height="7un" type="FIXED" width="46un"/>
-        <layout type="anchor">
-            <anchoritem dst="mailboxIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="" srcEdge="LEFT"/>
-            <anchoritem dst="mailboxIcon" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
-            <anchoritem dst="mailboxNameLabel" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="mailboxIcon" srcEdge="RIGHT"/>
-            <anchoritem dst="mailboxNameLabel" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
-            <anchoritem dst="mailboxNameLabel" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="unreadCountLabel" srcEdge="LEFT"/>
-            <anchoritem dst="unreadCountLabel" dstEdge="TOP" spacing="0un" src="mailboxNameLabel" srcEdge="TOP"/>
-            <anchoritem dst="unreadCountLabel" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="collapseExpandIcon" srcEdge="LEFT"/>
-            <anchoritem dst="collapseExpandIcon" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)" src="" srcEdge="RIGHT"/>
-            <anchoritem dst="collapseExpandIcon" dstEdge="CENTERV" spacing="0un" src="unreadCountLabel" srcEdge="CENTERV"/>
-        </layout>
-    </widget>
-</hbdocument>
--- a/emailuis/nmhswidget/inc/nmhswidget.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/inc/nmhswidget.h	Thu Jul 22 16:30:28 2010 +0100
@@ -28,6 +28,8 @@
 class QTranslator;
 class HbFrameDrawer;
 class NmHsWidgetDateTimeObserver;
+class HbLabel;
+class HbDocumentLoader;
 
 class NmHsWidget : public HbWidget
 {
@@ -40,13 +42,14 @@
 public:
     NmHsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
     ~NmHsWidget();
+
+    QPainterPath shape() const;
     
 public slots:
     //from home screen fw
     void onInitialize();
     void onShow();
     void onHide();
-    void onUninitialize();
     //engine
     void updateMailData();
     void onEngineException(const int& exc);
@@ -65,26 +68,34 @@
     void setPreferences(const QStringList &names);
     void error();
 private:
-    bool setupLocalization();
+    void setupLocalization();
     void setupUi();
+    bool loadDocML(HbDocumentLoader &loader);
     void updateMailRowsVisibility(const int visibleCount);
+    void addNoMailsLabelToLayout();
+    void removeNoMailsLabelFromLayout();
+    void addEmailRowsToLayout();
+    void removeEmailRowsFromLayout();
+    void updateLayout(const int visibleCount);
     void toggleExpansionState();  
 
 protected:
-    void updateMailRowsList(const int mailCount);
+    void createMailRowsList();
     
 private:
     NmHsWidgetEmailEngine* mEngine;
-    QGraphicsLinearLayout *mRowLayout;
-    NmHsWidgetTitleRow* mTitleRow;
-    QList<NmHsWidgetEmailRow*> mMailRows;
-    NmId mAccountId;
-    QString mAccountIconName;
-    QTranslator *mTranslator;
-    HbFrameDrawer* mBackgroundFrameDrawer;
-    bool mIsExpanded;
-    bool mStaticWidget;
-    NmHsWidgetDateTimeObserver* mDateObserver;
+    NmHsWidgetTitleRow* mTitleRow;          
+    QList<NmHsWidgetEmailRow*> mMailRows;   //list including mail row instances
+    NmId mAccountId;                        //mail account id widget is monitoring
+    QString mAccountIconName;               //name of mailbox icon shown in titlerow
+    QTranslator* mTranslator;
+    HbFrameDrawer* mBackgroundFrameDrawer;  //drawer for widget backgound
+    bool mIsExpanded;                       //true when widget expanded, false when collapsed
+    NmHsWidgetDateTimeObserver* mDateObserver;  //observer for time/locale changes
+    HbLabel* mNoMailsLabel;                 //label shown in widget when no mails in inbox
+    HbWidget* mWidgetContainer;             //container including title row and content container
+    HbWidget* mContentContainer;            //container including mail rows and mNoMailsLabel
+    QGraphicsLinearLayout* mContentLayout;  //layout for mail rows
     
 public:    
     friend class TestNmHsWidget;     
--- a/emailuis/nmhswidget/inc/nmhswidgetconsts.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/inc/nmhswidgetconsts.h	Thu Jul 22 16:30:28 2010 +0100
@@ -23,13 +23,21 @@
  *************************************************/
 //Maximum amount of envelopes that can be provided to client in getData function
 //This is also the amount of envelopes that is kept in mData all the time
-const int KMaxNumberOfEnvelopesProvided = 2;
+const int KMaxNumberOfEnvelopesProvided = 3;
 //Maximum value for unread count
 const int KMaxUnreadCount = 999; 
 
 /**************************************************
  * nmhswidget
  *************************************************/
+/**  docml file including UI definitions */
+const QString KNmHsWidgetDocML = ":/docml/nmhswidget.docml";
+/** container widget including all UI components */
+const QString KNmHsWidgetContainer = "nmhswidgetContainer";
+/** container widget including content (mail rows / no mails label */
+const QString KNmHsWidgetContentContainer = "mailRowContainer";
+/** no mails label - shown when inbox is empty */
+const QString KNmHsWidgetNoMailsLabel = "noMailsLabel";
 /** contents margin/spacing in all layouts / container widgets */
 const int KNmHsWidgetContentsMargin = 0;
 /** Widget's background image*/
@@ -48,41 +56,41 @@
  * Title row widget
  *************************************************/
 /**  docml file including title row UI definitions */
-#define KNmHsWidgetTitleRowDocML ":/docml/nmhswidgettitle.docml"
+/**#define KNmHsWidgetTitleRowDocML ":/docml/nmhswidgettitle.docml" */
 /**  docml file including title row UI definitions */
-#define KNmHsWidgetTitleRowContainer  "titleLayoutWidget"
+const QString KNmHsWidgetTitleRowContainer = "titleLayoutWidget";
 /** mailbox icon */
-#define KNmHsWidgetTitleRowMailboxIcon  "mailboxIcon"
+const QString KNmHsWidgetTitleRowMailboxIcon = "mailboxIcon";
 /** mailbox name label */
-#define KNmHsWidgetTitleRowMailboxNameLabel "mailboxNameLabel"
+const QString KNmHsWidgetTitleRowMailboxNameLabel = "mailboxNameLabel";
 /** unread count label */
-#define KNmHsWidgetTitleRowUnreadCountLabel  "unreadCountLabel"
+const QString KNmHsWidgetTitleRowUnreadCountLabel = "unreadCountLabel";
 /** expand collapse icon */
-#define KNmHsWidgetTitleRowCollapseExpandIconLabel "collapseExpandIcon"
+const QString KNmHsWidgetTitleRowCollapseExpandIconLabel = "collapseExpandIcon";
 
 /**************************************************
  * Mail row widget
  *************************************************/
 /**  docml file including mail row UI definitions */
-#define KNmHsWidgetMailRowDocML   ":/docml/nmhswidgetmail.docml"
+const QString KNmHsWidgetMailRowDocML = ":/docml/nmhswidgetmail.docml";
 /** container widget name for mail row UI items */
-#define KNmHsWidgetMailRowContainer   "emailLayoutWidget"
+const QString KNmHsWidgetMailRowContainer  = "emailLayoutWidget";
 /** sender label */
-#define KNmHsWidgetMailRowSenderLabel   "labelSender"
+const QString KNmHsWidgetMailRowSenderLabel = "labelSender";
 /** time label */
-#define KNmHsWidgetMailRowTimeLabel   "labelTime"
+const QString KNmHsWidgetMailRowTimeLabel = "labelTime";
 /** subject label */
-#define KNmHsWidgetMailRowSubjectLabel   "labelSubject"
+const QString KNmHsWidgetMailRowSubjectLabel = "labelSubject";
 /** new mail icon */
-#define KNmHsWidgetMailRowNewMailIcon   "iconNewMail"
+const QString KNmHsWidgetMailRowNewMailIcon = "iconNewMail";
 /** left status icon */
-#define KNmHsWidgetMailRowLeftIcon   "iconOne"
+const QString KNmHsWidgetMailRowLeftIcon = "iconOne";
 /** middle status icon */
-#define KNmHsWidgetMailRowMiddleIcon   "iconTwo"
+const QString KNmHsWidgetMailRowMiddleIcon = "iconTwo";
 /** right status icon */
-#define KNmHsWidgetMailRowRightIcon   "iconThree"
+const QString KNmHsWidgetMailRowRightIcon = "iconThree";
 /** separator icon */
-#define KNmHsWidgetMailSeparatorIcon   "iconSeparator"
+const QString KNmHsWidgetMailSeparatorIcon = "iconSeparator";
 
 
 #endif  // NMHSWIDGETCONSTS_H
--- a/emailuis/nmhswidget/inc/nmhswidgetemailengine.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/inc/nmhswidgetemailengine.h	Thu Jul 22 16:30:28 2010 +0100
@@ -26,6 +26,7 @@
 class NmDataPluginInterface;
 class QPluginLoader;
 class QTimer;
+class XQAiwRequest;
 
 //Three seconds
 const int NmHsWidgetEmailEngineUpdateTimerValue = 3000;
@@ -48,6 +49,7 @@
     int getEnvelopes(QList<NmMessageEnvelope> &list, int maxEnvelopeAmount);
     int unreadCount();
     QString accountName();
+    void deleteAiwRequest();
         
 public slots:
     void handleMessageEvent( 
@@ -65,6 +67,9 @@
     void launchMailAppMailViewer(const NmId &messageId);
     void handleUpdateTimeout();
     
+    void aiwRequestOk(const QVariant& result);
+    void aiwRequestError(int errorCode, const QString& errorMessage);
+    
 signals:
     void mailDataChanged();    
     void accountNameChanged(const QString& accountName);
@@ -90,6 +95,7 @@
     bool mMessageEventReceivedWhenSuspended;
     bool mSuspended; 
     QTimer* mUpdateTimer;
+    XQAiwRequest* mAiwRequest;
     };
 
 #endif /* NMHSWIDGETEMAILENGINE_H_ */
--- a/emailuis/nmhswidget/inc/nmhswidgetemailrow.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/inc/nmhswidgetemailrow.h	Thu Jul 22 16:30:28 2010 +0100
@@ -22,10 +22,11 @@
 #include <QDateTime>
 #include <hbwidget.h>
 #include "nmcommon.h"
+#include "nmmessageenvelope.h"
 
 //FORWARD DECLARATIONS:
 class HbLabel;
-class NmMessageEnvelope;
+class HbFrameItem;
 
 class NmHsWidgetEmailRow : public HbWidget
 {
@@ -35,7 +36,7 @@
     NmHsWidgetEmailRow(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
     ~NmHsWidgetEmailRow();
     NmId messageId();
-    bool loadDocML();
+    bool setupUI();
 
 public slots:
     void updateMailData( const NmMessageEnvelope& envelope );
@@ -47,10 +48,16 @@
 private:
     void setIconsToWidget( const NmMessageEnvelope& envelope );
     void hideIcons();
+    bool loadDocML();
+    bool setupGraphics();
+    void setFontsSize( bool read );
+    void setHighlighedFontsColor( bool pressed );
+    void showHighlight( bool pressed );
     
 protected:
     void mousePressEvent(QGraphicsSceneMouseEvent *event);
     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+    bool event( QEvent *event );
     
 private:
     HbLabel *mSenderLabel;
@@ -61,6 +68,8 @@
     NmId mMessageId;
     QDateTime mMessageSentTime;
     QList <HbLabel*> mStatusIcons;  
+    NmMessageEnvelope mEnvelope;
+    HbFrameItem* mBackgroundLayoutItem;
     
 };
 
--- a/emailuis/nmhswidget/inc/nmhswidgettitlerow.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/inc/nmhswidgettitlerow.h	Thu Jul 22 16:30:28 2010 +0100
@@ -23,6 +23,8 @@
 //FORWARD DECLARATIONS:
 class HbLabel;
 class HbPushButton;
+class HbFrameItem;
+class HbDocumentLoader;
 
 class NmHsWidgetTitleRow : public HbWidget
 {
@@ -31,13 +33,17 @@
 public:
     NmHsWidgetTitleRow(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
     ~NmHsWidgetTitleRow();
-    bool loadDocML();
-    
+    QPainterPath shape() const;
+    bool setupUI(HbDocumentLoader &loader); 
     void setAccountIcon(const QString& accountIconName );
+    void setExpandCollapseIcon(const bool& expand);
     
 private:
-
+    bool loadDocML(HbDocumentLoader &loader);
+    bool setupGraphics();
     void updateData();
+    void setHighlighedFontsColor( bool pressed );
+    void showHighlight( bool pressed );
     
 public slots: 
     void updateAccountName(const QString& accountName );
@@ -49,6 +55,8 @@
     
 protected:
     void mousePressEvent(QGraphicsSceneMouseEvent *event);
+    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+    bool event( QEvent *event );
     
 private:
     HbLabel *mMailboxIcon;
@@ -57,6 +65,7 @@
     HbPushButton *mCollapseExpIconLabel;
     QString mAccountName;
     int mUnreadCount;
+    HbFrameItem* mBackgroundLayoutItem;
 };
 
 #endif // NMHSWIDGETTITLEROW_H_
--- a/emailuis/nmhswidget/nmhswidget.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/nmhswidget.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -68,7 +68,8 @@
 
 INCLUDEPATH += ./inc \
     ../../inc \
-    ../nmailuiengine/inc \
-    ../inc
+    ../inc \
+    $$APP_LAYER_SYSTEMINCLUDE
+    
 DEPENDPATH += .
 TRANSLATIONS = mailwidget.ts
--- a/emailuis/nmhswidget/nmhswidget.qrc	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/nmhswidget.qrc	Thu Jul 22 16:30:28 2010 +0100
@@ -1,6 +1,6 @@
 <RCC>
     <qresource prefix="/docml">
-        <file alias="nmhswidgettitle.docml">conf/nmhswidgettitle.docml</file>
         <file alias="nmhswidgetmail.docml">conf/nmhswidgetmail.docml</file>
+        <file alias="nmhswidget.docml">conf/nmhswidget.docml</file>
     </qresource>
 </RCC>
--- a/emailuis/nmhswidget/src/nmhswidget.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/src/nmhswidget.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -14,13 +14,14 @@
  * Description: 
  *
  */
-#include <QDebug>
 #include <QtGui>
 #include <QGraphicsLinearLayout>
 #include <hbcolorscheme.h>
+#include <hbdocumentloader.h>
 #include <QTranslator>
 #include <hbframedrawer.h>
 #include <hbframeitem.h>
+#include <hblabel.h>
 #include "nmcommon.h"
 #include "nmhswidget.h"
 #include "nmhswidgetemailengine.h"
@@ -29,186 +30,236 @@
 #include "nmhswidgetemailrow.h"
 #include "nmhswidgetconsts.h"
 #include "nmhswidgetdatetimeobserver.h"
+#include "emailtrace.h"
 
 NmHsWidget::NmHsWidget(QGraphicsItem *parent, Qt::WindowFlags flags)
     : HbWidget(parent, flags), 
       mEngine(0),
-      mRowLayout(0),
       mTitleRow(0),
       mAccountId(0),
-      mAccountIconName(0),
+      mAccountIconName(),
       mTranslator(0),
       mBackgroundFrameDrawer(0),
-      mIsExpanded(true),
-      mStaticWidget(true),
-      mDateObserver(0)
+      mIsExpanded(false),
+      mDateObserver(0),
+      mNoMailsLabel(0),
+      mWidgetContainer(0),
+      mContentContainer(0),
+      mContentLayout(0)
 {
-    qDebug() << "NmHsWidget::NmHsWidget IN -->>";
-       
-    qDebug() << "NmHsWidget::NmHsWidget OUT <<--";
+    NM_FUNCTION;
+}
+
+/*!
+ Destructor
+ */
+NmHsWidget::~NmHsWidget()
+{
+    NM_FUNCTION;
+
+    delete mTranslator;
+    mTranslator = NULL;
+
+    delete mEngine;
+    mEngine = NULL;
+
+    delete mBackgroundFrameDrawer;
+    mBackgroundFrameDrawer = NULL;
+
+    delete mDateObserver;
+    mDateObserver = NULL;
 }
 
 /*!
-    Destructor
-*/
-NmHsWidget::~NmHsWidget()
+ \fn QPainterPath NmHsWidget::shape()
+
+ Called by home screen fw to check widget boundaries, needed to draw
+ outside widget boundingRect.
+ /return QPainterPath path describing actual boundaries of widget 
+  including child items
+ */
+QPainterPath NmHsWidget::shape() const
 {
-    qDebug() << "NmHsWidget::~NmHsWidget IN -->>";
-    if(mTranslator){
-        delete mTranslator;
-        mTranslator = NULL;
-    }
+    NM_FUNCTION;
+    
+    QPainterPath path;
+    path.setFillRule(Qt::WindingFill);
     
-    if(mEngine){
-        delete mEngine;
-        mEngine = NULL;
-        }
-    
-    if(mBackgroundFrameDrawer){
-        delete mBackgroundFrameDrawer;
-        mBackgroundFrameDrawer = NULL;
-        }
-		
-	if(mDateObserver){
-        delete mDateObserver;
-        mDateObserver = NULL;
-        }
-    qDebug() << "NmHsWidget::~NmHsWidget OUT <<--";
+    path.addRect(this->rect());
+    if (mTitleRow){
+        path.addPath(mTitleRow->shape());
+    }
+    return path.simplified();
+}
+
+/*!
+ \fn void NmHsWidget::onShow()
+
+ called by home screen fw when widget gets visible
+ */
+void NmHsWidget::onShow()
+{
+    NM_FUNCTION;
+    if (mEngine) {
+        mEngine->activate();
+    }
 }
 
 /*!
-    \fn void NmHsWidget::onShow()
+ \fn void NmHsWidget::onHide()
 
-    called by home screen fw when widget gets visible
-*/
-void NmHsWidget::onShow()
+ called by home screen fw when widget gets hidden
+ */
+void NmHsWidget::onHide()
 {
-    qDebug() << "NmHsWidget::onShow IN -->>";
-    if (mEngine)
-        {
-        mEngine->activate();
-        }
-    qDebug() << "NmHsWidget::onShow OUT <<--";
+    NM_FUNCTION;
+    if (mEngine) {
+        mEngine->suspend();
+    }
 }
 
 /*!
-    \fn void NmHsWidget::onHide()
-
-    called by home screen fw when widget gets hidden
-*/
-void NmHsWidget::onHide()
+ \fn bool NmHsWidget::loadDocML(HbDocumentLoader &loader)
+ 
+ loads layout data and child items from docml file. Must be called after constructor.
+ /return true if loading succeeded, otherwise false. False indicates that object is unusable
+ */
+bool NmHsWidget::loadDocML(HbDocumentLoader &loader)
 {
-    qDebug() << "NmHsWidget::onHide IN -->>";
-    if (mEngine)
-        {
-        mEngine->suspend();
+    NM_FUNCTION;
+    
+    bool ok(false);
+    loader.load(KNmHsWidgetDocML, &ok);
+    
+    if(ok) {
+        mWidgetContainer = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetContainer));        
+        mContentContainer = static_cast<HbWidget*> (loader.findWidget(KNmHsWidgetContentContainer));
+        mNoMailsLabel = static_cast<HbLabel*> (loader.findWidget(KNmHsWidgetNoMailsLabel));
+        if (!mWidgetContainer || !mContentContainer || !mNoMailsLabel) {
+            //something failed in documentloader, no point to continue
+            NM_ERROR(1,"NmHsWidget::loadDocML fail @ containers or label");
+            ok = false;
         }
-    qDebug() << "NmHsWidget::onHide OUT <<--";
+    }
+    return ok;
 }
 
 /*!
-    Initializes Localization.
-    /post mTranslator constructed & localization file loaded
-    returns false in failure, otherwise true
-*/
-bool NmHsWidget::setupLocalization()
+ Initializes Localization.
+ /post mTranslator constructed & localization file loaded
+ */
+void NmHsWidget::setupLocalization()
 {
-    qDebug() << "NmHsWidget::setupLocalization IN -->>";
-    
+    NM_FUNCTION;
+
     //Use correct localisation
-    bool ret(false); 
     mTranslator = new QTranslator();
     QString lang = QLocale::system().name();
-    ret = mTranslator->load(KNmHsWidgetLocFileName + lang, KNmHsWidgetLocLocation);
-    qDebug() << "NmHsWidget::setupLocalization mTranslator->load loadSucceed:"<<ret;
+    mTranslator->load(KNmHsWidgetLocFileName + lang, KNmHsWidgetLocLocation);
     QCoreApplication::installTranslator(mTranslator);
-
-    qDebug() << "NmHsWidget::setupLocalization OUT <<--";
-    return ret;
-}
-
-/*!
-    Initializes UI. Everything that is not done in docml files should be here.
-    return true if ok, in error false.
-*/
-void NmHsWidget::setupUi()
-{
-    qDebug() << "NmHsWidget::setupUi IN -->>";
-    setContentsMargins( KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin,
-            KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin);
-    
-    //Setup layout
-    mRowLayout = new QGraphicsLinearLayout(Qt::Vertical);
-
-    mRowLayout->setContentsMargins(KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin,
-            KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin);
-    mRowLayout->setSpacing(KNmHsWidgetContentsMargin);
-    setLayout(mRowLayout);
-   
-   //background
-   mBackgroundFrameDrawer = new HbFrameDrawer( KNmHsWidgetBackgroundImage, HbFrameDrawer::NinePieces );
-   HbFrameItem* backgroundLayoutItem = new HbFrameItem( mBackgroundFrameDrawer );
-   //set to NULL to indicate that ownership transferred
-   mBackgroundFrameDrawer = NULL;
-   setBackgroundItem( backgroundLayoutItem );
-   
-   qDebug() << "NmHsWidget::setupUi OUT -->>";
 }
 
 /*!
-    Initializes the widget.
+ Initializes UI. Everything that is not done in docml files should be here.
+ return true if ok, in error false.
+ */
+void NmHsWidget::setupUi()
+{
+    NM_FUNCTION;
+
+    //main level layout needed to control docml objects
+    QGraphicsLinearLayout *widgetLayout = new QGraphicsLinearLayout(Qt::Vertical);
+    widgetLayout->setContentsMargins(KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin,
+            KNmHsWidgetContentsMargin, KNmHsWidgetContentsMargin);
+    widgetLayout->setSpacing(KNmHsWidgetContentsMargin);
+    widgetLayout->addItem(mWidgetContainer);
+    this->setLayout(widgetLayout);
+
+    //fetch pointer to content container layout
+    //to be able to add/remove email rows and no mails label
+    mContentLayout = (QGraphicsLinearLayout*) mContentContainer->layout();
     
-    called by home screen fw when widget is added to home screen
-*/
+    //set noMailsLabel properties not supported by doc loader 
+    QColor newFontColor;
+    newFontColor = HbColorScheme::color("qtc_hs_list_item_content_normal");
+    mNoMailsLabel->setTextColor(newFontColor);
+    mNoMailsLabel->setVisible(true);   
+    
+    mContentLayout->removeItem(mNoMailsLabel);
+    
+    //widget background
+    mBackgroundFrameDrawer = new HbFrameDrawer(KNmHsWidgetBackgroundImage,
+        HbFrameDrawer::NinePieces);
+    HbFrameItem* backgroundLayoutItem = new HbFrameItem(mBackgroundFrameDrawer);
+    //set to NULL to indicate that ownership transferred
+    mBackgroundFrameDrawer = NULL;
+    setBackgroundItem(backgroundLayoutItem);   
+}
+
+
+/*!
+ Initializes the widget.
+ 
+ called by home screen fw when widget is added to home screen
+ */
 void NmHsWidget::onInitialize()
 {
-    QT_TRY{
-        qDebug() << "NmHsWidget::onInitialize IN -->>";
+    NM_FUNCTION;
+
+    QT_TRY {
         
+	    // Use document loader to load the contents
+	    HbDocumentLoader loader;
+		
+	    //load containers and mNoMailsLabel
+        if (!loadDocML(loader)) {
+            NM_ERROR(1,"NmHsWidget::onInitialize Fail @ loader");
+            emit error(); //failure, no point to continue
+            return;
+        }
+
+        //construct title row
+        mTitleRow = new NmHsWidgetTitleRow(this);
+        if (!mTitleRow->setupUI(loader)) {
+            //title row creation failed
+            NM_ERROR(1,"NmHsWidget::onInitialize fail @ titlerow");
+            emit error(); //failure, no point to continue
+            return;            
+        }
+				
         setupUi();
-        //emit error if localization fails
-        if(!setupLocalization()){
+        setupLocalization();
+
+        //Engine construction is 2 phased. 
+        mEngine = new NmHsWidgetEmailEngine(mAccountId);
+        //Client must connect to exception signals before calling the initialize function
+        //because we don't want to miss any signals.
+        connect(mEngine, SIGNAL( exceptionOccured(const int&) ), this,
+            SLOT( onEngineException(const int&) ));
+        if (!mEngine->initialize()) {
+            //engine construction failed. Give up.
+            NM_ERROR(1,"NmHsWidget::onInitialize fail @ engine");
             emit error();
             return;
         }
-        
-        //Engine construction is 2 phased. 
-        mEngine = new NmHsWidgetEmailEngine( mAccountId );
-        //Client must connect to exception signals before calling the initialize function
-        //because we don't want to miss any signals.
-        connect(mEngine, SIGNAL( exceptionOccured(const int&) )
-                ,this, SLOT( onEngineException(const int&) ) );
-        if(!mEngine->initialize())
-            {
-            //engine construction failed. Give up.
-            emit error();
-            return;
-            }
+
+
+        mTitleRow->updateAccountName(mEngine->accountName());
 
-        //construct and load docml for title row
-        mTitleRow = new NmHsWidgetTitleRow(); 
-        if( !mTitleRow->loadDocML()){
-            //if docml loading fails no point to proceed
-            //but memoryleak must be prevented
-            delete mTitleRow;
-            mTitleRow = NULL;
-            emit error();
-            return;
-        }
-        mRowLayout->addItem(mTitleRow);
-        mTitleRow->updateAccountName(mEngine->accountName());
-    
-	    //create observer for date/time change events
-	    mDateObserver = new NmHsWidgetDateTimeObserver();
-    
+        //create observer for date/time change events
+        mDateObserver = new NmHsWidgetDateTimeObserver();
+
+        //Crete MailRows and associated connections
+        createMailRowsList();
+
         updateMailData();
         mTitleRow->updateUnreadCount(mEngine->unreadCount());
         mTitleRow->setAccountIcon(mAccountIconName);
-        
+        mTitleRow->setExpandCollapseIcon(mIsExpanded);
+
         //Get signals about changes in mail data
-        connect(mEngine, SIGNAL( mailDataChanged() )
-                ,this, SLOT( updateMailData() ) );
-        
+        connect(mEngine, SIGNAL( mailDataChanged() ), this, SLOT( updateMailData() ));
+
         //Get Signals about changes in unread count
         connect(mEngine, SIGNAL( unreadCountChanged(const int&) )
                 ,mTitleRow, SLOT( updateUnreadCount(const int&) ) );
@@ -222,271 +273,307 @@
 	            ,mEngine, SLOT( launchMailAppInboxView() ) );
 	    connect(mTitleRow, SIGNAL( expandCollapseButtonPressed() )
 	            ,this, SLOT( handleExpandCollapseEvent() ) );
+	    
+	    setMinimumSize(mTitleRow->minimumSize());
+    }
+    QT_CATCH(...) {
+        NM_ERROR(1,"NmHsWidget::onInitialize fail @ catch");
+        emit error();
+    }
+}
 
-	    //resize here so homescreen will place widget correctly on screen
-	    setPreferredSize( mRowLayout->preferredSize() );
-	    if (parentWidget()) {
-	        //to place widget properly after adding to homescreen
-	        parentWidget()->resize(preferredSize()); 
-		}
-        qDebug() << "NmHsWidget::onInitialize OUT <<--";  
+
+/*!
+ updateMailData slot
+ */
+void NmHsWidget::updateMailData()
+{
+    NM_FUNCTION;
+
+    QList<NmMessageEnvelope> envelopes;
+    int count = 0;
+    if (mIsExpanded) {
+        count = mEngine->getEnvelopes(envelopes, KMaxNumberOfMailsShown);
+    }
+
+    updateLayout(count);
+    //count is safe for envelopes and mMailRows
+    for (int i = 0; i < count; i++) {
+        mMailRows.at(i)->updateMailData(envelopes.at(i));
+    }
+}
+
+/*!
+ Sets monitored account id from given string
+ Needed for home screen framework which supports only QString type properties
+ */
+void NmHsWidget::setAccountId(const QString &text)
+{
+    NM_FUNCTION;
+
+    bool ok;
+    quint64 id = text.toULongLong(&ok);
+    if (!ok) {
+        NM_ERROR(1, "NmHsWidget::setAccountId: invalid account ID data, signal finished()!!!");
+        //No valid account id so give up
+        emit finished();
+        return;
     }
-    QT_CATCH(...){
-        emit error();
+
+    mAccountId.setId(id);
+}
+
+/*!
+ Returns monitored account id as a string
+ Needed for home screen framework which supports only QString type properties
+ */
+QString NmHsWidget::accountId() const
+{
+    NM_FUNCTION;
+    return QString::number(mAccountId.id());
+}
+
+/*!
+ Sets monitored account icon name from given string
+ */
+void NmHsWidget::setAccountIconName(const QString &text)
+{
+    NM_FUNCTION;
+    mAccountIconName = text;
+}
+
+/*!
+ Returns monitored account icon name
+ */
+QString NmHsWidget::accountIconName() const
+{
+    NM_FUNCTION;
+    return mAccountIconName;
+}
+
+/*!
+ Slot to handle expand/collapse trigger event
+ */
+void NmHsWidget::handleExpandCollapseEvent()
+{
+    NM_FUNCTION;
+    toggleExpansionState();
+}
+
+/*!
+ Sets widget expand/collapse state
+ /post widget expansion state is changed
+ */
+void NmHsWidget::toggleExpansionState()
+{
+    NM_FUNCTION;
+
+    mIsExpanded = !mIsExpanded;
+
+    //save new state to home screen
+    QStringList propertiesList;
+    propertiesList.append("widgetState");
+    emit setPreferences(propertiesList);
+
+    //handle state change drawing
+    updateMailData();
+
+    mTitleRow->setExpandCollapseIcon(mIsExpanded);
+}
+
+/*!
+ Sets expand/collapse state from given string (needed by homescreen)
+ */
+void NmHsWidget::setWidgetStateProperty(QString value)
+{
+    NM_FUNCTION;
+    if (value == KNmHsWidgetStateCollapsed) {
+        mIsExpanded = false;
+    }
+    else {
+        mIsExpanded = true;
+    }
+}
+
+/*!
+ Returns widget expand/collapse state as string (needed by homescreen) 
+ */
+QString NmHsWidget::widgetStateProperty()
+{
+    NM_FUNCTION;
+    if (mIsExpanded) {
+        return KNmHsWidgetStateExpanded;
+    }
+    else {
+        return KNmHsWidgetStateCollapsed;
+    }
+}
+
+/*!
+ Updates mMailRows list to include KMaxNumberOfMailsShown mail row widgets
+ /post mMailRows contains KMaxNumberOfMailsShown mailRows 
+ */
+void NmHsWidget::createMailRowsList()
+{
+    NM_FUNCTION;
+
+    //make sure that there are as many email rows as needed
+    while (mMailRows.count() < KMaxNumberOfMailsShown) {
+        NmHsWidgetEmailRow *row = new NmHsWidgetEmailRow(this);
+        if (!row->setupUI()) {
+            NM_ERROR(1, "NmHsWidget::createMailRowsList row->setUpUI() fails");
+            //if setupUI fails no point to proceed
+            emit error();
+            return;
+        }
+        connect(row, SIGNAL(mailViewerLaunchTriggered(const NmId&)), mEngine,
+            SLOT(launchMailAppMailViewer(const NmId&)));
+        connect(mDateObserver, SIGNAL(dateTimeChanged()), row, SLOT(updateDateTime()));
+        mMailRows.append(row);
     }
 
 }
 
 /*!
-    Uninitializes the widget.
-    
-    called by home screen fw when widget is removed from home screen
-*/
-void NmHsWidget::onUninitialize()
+ Updates the Layout to contain the right items
+ /param mailCount defines how many emails is to be shown
+ /post If widget is collapsed, the layout contains only titleRow widget.
+ If widget is expanded and mailCount is 0 layout will contain
+ titlerow & noMailsLabel. 
+ If widget is expanded and mailCount is greter
+ than zero, layout will contain titlerow and KMaxNumberOfMailsShown times
+ emailrow(s)
+ */
+void NmHsWidget::updateLayout(const int mailCount)
 {
-    qDebug() << "NmHsWidget::onUninitialize IN -->>";
-    
-    qDebug() << "NmHsWidget::onUninitialize OUT <<--";
-}
+    NM_FUNCTION;
 
-/*!
-    updateMailData slot
-*/
-void NmHsWidget::updateMailData()
-{
-    qDebug() << "NmHsWidget::updateData IN -->>";
-    QList<NmMessageEnvelope> envelopes;
-    int count = 0;
     if (mIsExpanded) {
-        count = mEngine->getEnvelopes(envelopes, KMaxNumberOfMailsShown);
-        }
-
-    updateMailRowsList(count);
-    
-    for(int i=0; i<envelopes.count(); i++)
-        {
-        mMailRows[i]->updateMailData( envelopes[i] );
+        //set container height to content height 
+        qreal contentHeight = KMaxNumberOfMailsShown
+                * mMailRows.first()->maximumHeight();
+        mContentContainer->setMaximumHeight(contentHeight);
+        mContentContainer->setVisible(true);
+        if (mailCount == 0) {
+            addNoMailsLabelToLayout();
+            removeEmailRowsFromLayout();
         }
-    qDebug() << "NmHsWidget::updateData OUT <<--"; 
-}
+        else {
+            removeNoMailsLabelFromLayout();
+            addEmailRowsToLayout();
+        }
+    }
+    else {
+        removeNoMailsLabelFromLayout();
+        removeEmailRowsFromLayout();
+        mContentContainer->setVisible(false);
+        mContentContainer->setMaximumHeight(0);        
+    }
 
-/*!
-    Sets monitored account id from given string
-    Needed for home screen framework which supports only QString type properties
-*/
-void NmHsWidget::setAccountId(const QString &text)
-{
-    qDebug() << "NmHsWidget::setAccountId IN -->>"; 
-    bool ok;
-    quint64 id = text.toULongLong(&ok);
-    if (!ok)
-        {
-        qDebug() << "NmHsWidget::setAccountId: invalid account ID data, signal finished()!!!"; 
-        //No valid account id so give up
-        emit finished();
-        }
-    else
-        {
-        mAccountId.setId(id);
-        }
-    qDebug() << "NmHsWidget::setAccountId OUT <<--"; 
-}
+    //resize the widget to new layout size
+    qreal totalHeight = mTitleRow->preferredHeight() + mContentContainer->maximumHeight();
+    //set maximum size, otherwise widget will stay huge also when collapsed
+    this->setMaximumHeight(totalHeight);
+    //resize here or widget cannot draw mail rows when expanding
+    this->resize(mTitleRow->preferredWidth(), totalHeight);
 
-/*!
-    Returns monitored account id as a string
-    Needed for home screen framework which supports only QString type properties
-*/
-QString NmHsWidget::accountId() const
-{
-    qDebug() << "NmHsWidget::accountId()"; 
-    return QString::number(mAccountId.id());
+    updateMailRowsVisibility(mailCount);
 }
 
 /*!
-    Sets monitored account icon name from given string
-*/
-void NmHsWidget::setAccountIconName(const QString &text)
+ Updates mNoMailsLabel visibility based on widget state
+ /param mailCount defines how many mail rows is needed
+ /post if mail count is 0 and mIsExpanded equals true, then
+ the mNoMailLabel is added to the mContentLayout. 
+ */
+void NmHsWidget::addNoMailsLabelToLayout()
 {
-    qDebug() << "NmHsWidget::setAccountIconName IN -->>"; 
-    mAccountIconName = text;
-    qDebug() << "NmHsWidget::setAccountIconName OUT <<--"; 
-}
+    NM_FUNCTION;
 
-/*!
-    Returns monitored account icon name
-*/
-QString NmHsWidget::accountIconName() const
-{
-    qDebug() << "NmHsWidget::accountIconName()"; 
-    return mAccountIconName;
-}
-
-/*!
-    Slot to handle expand/collapse trigger event
-*/
-void NmHsWidget::handleExpandCollapseEvent()
-{
-    qDebug() << "NmHsWidget::handleExpandCollapseEvent IN -->>";
-    toggleExpansionState();
-    qDebug() << "NmHsWidget::handleExpandCollapseEvent OUT <<--"; 
+    if (mNoMailsLabel->isVisible() || mMailRows.isEmpty()) {
+        return;
+    }
+    //Add mNoMailsLabel to layout if not yet there and show it
+    mContentLayout->addItem(mNoMailsLabel);
+    //resize the widget to new layout size
+    mNoMailsLabel->show();
 }
 
 /*!
-    Sets widget expand/collapse state
-    /post widget expansion state is changed
-*/
-void NmHsWidget::toggleExpansionState()
+ removeNoMailsLabelFromLayout removes mNoMailsLabel from the layout
+ /post mNoMailsLabel is not in mContentLayout
+ */
+void NmHsWidget::removeNoMailsLabelFromLayout()
 {
-    qDebug() << "NmHsWidget::setExpanded IN -->>"; 
-
-    mIsExpanded = !mIsExpanded;
-    
-    //save new state to home screen
-    QStringList propertiesList;
-    propertiesList.append("widgetState");
-    emit setPreferences(propertiesList);
-    
-    //handle state change drawing
-    updateMailData();
-    
-    qDebug() << "NmHsWidget::setExpanded OUT <<--"; 
+    NM_FUNCTION;
+    //remove mNoMailsLabel from Layout and hide it
+    mContentLayout->removeItem(mNoMailsLabel);
+    mNoMailsLabel->hide();
 }
 
 /*!
-    Sets expand/collapse state from given string (needed by homescreen)
-*/
-void NmHsWidget::setWidgetStateProperty(QString value)
+ addEmailRowsToLayout adds every emailrow to the layout
+ /post all elements in mMailRows are added to mContentLayout
+ */
+void NmHsWidget::addEmailRowsToLayout()
 {
-    qDebug() << "NmHsWidget::setWidgetStateProperty IN -->>"; 
-    if (value == KNmHsWidgetStateCollapsed)
-        {
-        mIsExpanded = false;
-        }
-    else
+    NM_FUNCTION;
+    foreach(NmHsWidgetEmailRow *row, mMailRows)
         {
-        mIsExpanded = true;
-        }
-    qDebug() << "NmHsWidget::setWidgetStateProperty OUT <<--"; 
-}
-
-/*!
-    Returns widget expand/collapse state as string (needed by homescreen) 
-*/
-QString NmHsWidget::widgetStateProperty()
-{
-    qDebug() << "NmHsWidget::widgetStateProperty()";
-    if (mIsExpanded)
-        {
-        return KNmHsWidgetStateExpanded;
-        }
-    else
-        {
-        return KNmHsWidgetStateCollapsed;
+            mContentLayout->addItem(row);
         }
 }
 
 /*!
-    Updates mMailRows list to include correct amount of mail row widgets
-    /param mailCount defines how many mail rows is needed
-    /post mMailRows list includes NmHsWidgetEmailRow for each mail item 
-*/
-void NmHsWidget::updateMailRowsList(const int mailCount)
+ removeEmailRowsFromLayout removes every emailrow from the layout
+ /post none of the elements in mMailRows are in mContentLayout
+ */
+void NmHsWidget::removeEmailRowsFromLayout()
 {
-    qDebug() << "NmHsWidget::updateMailRowsList IN -->>";
-    qDebug() << "NmHsWidget - mMailRows.count() == " <<  mMailRows.count();
-    qDebug() << "NmHsWidget - ordered count == " <<  mailCount;
-    
-    int neededRowsCount = mailCount;
-    //force size when static and expanded
-    if (mStaticWidget && mIsExpanded)
-        {
-        neededRowsCount = KMaxNumberOfMailsShown;
-        }
-    
-    while (mMailRows.count() != neededRowsCount)
+    NM_FUNCTION;
+    foreach(NmHsWidgetEmailRow *row, mMailRows)
         {
-        //more mails to show than rows
-        if (mMailRows.count() < neededRowsCount)
-            {
-            qDebug() << "NmHsWidget - add new mail row";
-            NmHsWidgetEmailRow *row = new NmHsWidgetEmailRow();
-            if( !row->loadDocML()){
-                qDebug() << "NmHsWidget::updateMailRowsList row->loadDocML() fails";
-                //if docml loading fails no point to proceed
-                //but memoryleak must be prevented
-                delete row;
-                row = NULL;
-                emit error();
-                return;
-            }
-            connect(row, SIGNAL(mailViewerLaunchTriggered(const NmId&))
-                    ,mEngine, SLOT(launchMailAppMailViewer(const NmId&)));
-            connect( mDateObserver, SIGNAL(dateTimeChanged())
-                    ,row, SLOT(updateDateTime()) );
-            mMailRows.append(row);
-            mRowLayout->addItem(row);            
-            }
-        //too many rows
-        else if (mMailRows.count() > neededRowsCount)
-            {
-            qDebug() << "NmHsWidget - remove mail row";
-            mRowLayout->removeItem(mMailRows.last());
-            delete mMailRows.takeLast();
-            }
+            mContentLayout->removeItem(row);
         }
-    __ASSERT_ALWAYS( mMailRows.count() == neededRowsCount, User::Panic(_L("Invalid"), 500) );
-    
-    //resize the widget to new layout size
-    setPreferredSize( mRowLayout->preferredSize() );
-    
-    if (mStaticWidget)
-        {
-        this->updateMailRowsVisibility(mailCount);
-        }
-    qDebug() << "NmHsWidget::updateMailRowsList OUT <<--";
 }
 
 /*!
-    Updates mail row visibilities in static widget
-    /param visibleCount defines how many items do have mail data
-    /post all row items having mail data are visible, other rows are hidden
-*/
+ Updates mail row visibilities in static widget
+ /param visibleCount defines how many items do have mail data
+ /post all row items having mail data are visible, other rows are hidden
+ */
 void NmHsWidget::updateMailRowsVisibility(const int visibleCount)
 {
-    qDebug() << "NmHsWidget::updateMailRowsVisibility IN -->>";
-  
+    NM_FUNCTION;
+
     // set visible as many rows as requested by visibleCount param
     bool isVisible;
-    for (int i=0; i < mMailRows.count(); i++) 
-        {
+
+    for (int i = 0; i < mMailRows.count(); i++) {
         isVisible = false;
-        if ((mIsExpanded) && (i < visibleCount)) 
-            {
+        if ((mIsExpanded) && (i < visibleCount)) {
             isVisible = true;
-            }
+        }
         mMailRows.at(i)->setVisible(isVisible);
-        }
-    
-    qDebug() << "NmHsWidget::updateMailRowsVisibility OUT <<--";
+    }
 }
 
 /*!
-    onEngineException (NmHsWidgetEmailEngineExceptionCode exc)
-    signals widget to be finalized
-    /param exc exception type
-*/
+ onEngineException (NmHsWidgetEmailEngineExceptionCode exc)
+ signals widget to be finalized
+ /param exc exception type
+ */
 void NmHsWidget::onEngineException(const int& exc)
-    {
-    qDebug() << "NmHsWidget:onEngineException IN -->>";
-    switch (exc)
-        {
+{
+    NM_FUNCTION;
+    switch (exc) {
         case (NmEngineExcAccountDeleted):
-             emit finished(); //succesful ending
-             break;
+            emit finished(); //succesful ending
+            break;
         case (NmEngineExcFailure):
-             emit error(); //failure
-             break;
-        default: 
-            break; 
-        }
+            emit error(); //failure
+            break;
+        default:
+            break;
     }
+}
--- a/emailuis/nmhswidget/src/nmhswidgetdatetimeobserver.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/src/nmhswidgetdatetimeobserver.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,7 +15,7 @@
 *
 */
 
-#include <QDebug>
+#include "emailtrace.h"
 #include "nmhswidgetdatetimeobserver.h"
 #include "nmhswidgetdatetimeobserver_p.h"
 
@@ -28,9 +28,8 @@
     QObject(parent),
     d_ptr(0)
 {
-    qDebug() << "NmHsWidgetDateTimeObserver::NmHsWidgetDateTimeObserver --> IN";
+    NM_FUNCTION;
     d_ptr = new NmHsWidgetDateTimeObserverPrivate(this);
-    qDebug() << "NmHsWidgetDateTimeObserver::NmHsWidgetDateTimeObserver <-- OUT";
 }
 
 /*!
@@ -40,9 +39,8 @@
 */
 NmHsWidgetDateTimeObserver::~NmHsWidgetDateTimeObserver()
 {
-    qDebug() << "NmHsWidgetDateTimeObserver::~NmHsWidgetDateTimeObserver --> IN";
+    NM_FUNCTION;
     delete d_ptr;
-    qDebug() << "NmHsWidgetDateTimeObserver::~NmHsWidgetDateTimeObserver <-- OUT";
 }
 
 /*!
@@ -52,7 +50,6 @@
 */
 void NmHsWidgetDateTimeObserver::handleCompletion()
 {
-    qDebug() << "NmHsWidgetDateTimeObserver::handleCompletion --> IN";
+    NM_FUNCTION;
     emit dateTimeChanged();
-    qDebug() << "NmHsWidgetDateTimeObserver::handleCompletion <-- OUT";
 }
--- a/emailuis/nmhswidget/src/nmhswidgetdatetimeobserver_p.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/src/nmhswidgetdatetimeobserver_p.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,10 +15,10 @@
 *
 */
 
-#include <QDebug>
 #include <bacntf.h>
 #include "nmhswidgetdatetimeobserver.h"
 #include "nmhswidgetdatetimeobserver_p.h"
+#include "emailtrace.h"
 
 /*!
     \fn NmHsWidgetDateTimeObserverPrivate::NmHsWidgetDateTimeObserverPrivate()
@@ -29,12 +29,15 @@
 NmHsWidgetDateTimeObserverPrivate::NmHsWidgetDateTimeObserverPrivate(NmHsWidgetDateTimeObserver *q) :
     q_ptr(q)
 {
-    qDebug() << "NmHsWidgetDateTimeObserverPrivate::NmHsWidgetDateTimeObserverPrivate --> IN" ;
+    NM_FUNCTION;
     TCallBack callback( LocaleChangeCallback, this );
-    //TODO: Handle leave properly
-    TRAP_IGNORE(iLocaleNotifier = CEnvironmentChangeNotifier::NewL( CActive::EPriorityStandard, callback ));
+    
+    //CTC skipped as last else of macro QT_TRAP_THROWING cannot be tested (panics on purpose)
+#pragma CTC SKIP
+    QT_TRAP_THROWING(iLocaleNotifier = CEnvironmentChangeNotifier::NewL( CActive::EPriorityStandard, callback ));
+#pragma CTC ENDSKIP
+    
     iLocaleNotifier->Start();
-    qDebug() << "NmHsWidgetDateTimeObserverPrivate::NmHsWidgetDateTimeObserverPrivate <-- OUT" ;
 }
 
 /*!
@@ -44,12 +47,9 @@
 */
 NmHsWidgetDateTimeObserverPrivate::~NmHsWidgetDateTimeObserverPrivate()
 {
-    qDebug() << "NmHsWidgetDateTimeObserverPrivate::~NmHsWidgetDateTimeObserverPrivate --> IN" ;
-    if(iLocaleNotifier){
-        delete iLocaleNotifier;
-        iLocaleNotifier = NULL;
-    }
-    qDebug() << "NmHsWidgetDateTimeObserverPrivate::~NmHsWidgetDateTimeObserverPrivate <-- OUT" ;
+    NM_FUNCTION;
+    delete iLocaleNotifier;
+    iLocaleNotifier = NULL;
 }
 
 /*!
@@ -61,7 +61,7 @@
 */
 TInt NmHsWidgetDateTimeObserverPrivate::HandleLocaleChange()
 {
-    qDebug() << "NmHsWidgetDateTimeObserverPrivate::HandleLocaleChange";
+    NM_FUNCTION;
     TInt handled = 0;
     if( iLocaleNotifier->Change() & ( EChangesSystemTime | EChangesLocale | EChangesMidnightCrossover ))
         {
@@ -79,7 +79,7 @@
 */
 TInt NmHsWidgetDateTimeObserverPrivate::LocaleChangeCallback(TAny* aThisPtr)
 {
-    qDebug() << "NmHsWidgetDateTimeObserverPrivate::LocaleChangeCallback" ;
+    NM_FUNCTION;
     TInt ret = static_cast<NmHsWidgetDateTimeObserverPrivate*>(aThisPtr)->HandleLocaleChange();
     return ret;
 }
--- a/emailuis/nmhswidget/src/nmhswidgetemailengine.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/src/nmhswidgetemailengine.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,12 +15,11 @@
  *
  */
 
-#include <xqservicerequest.h>
-#include <QDebug>
 #include <QTimer>
 #include <QDir>
 #include <qpluginloader.h>
-#include "email_services_api.h"
+#include <xqapplicationmanager.h>
+#include <xqaiwdeclplat.h>
 #include "nmcommon.h"
 #include "nmmessageenvelope.h"
 #include "nmhswidgetemailengine.h"
@@ -29,6 +28,7 @@
 #include "nmfolder.h"
 #include "nmdatapluginfactory.h"
 #include "nmhswidgetconsts.h"
+#include "emailtrace.h"
 
 /*!
  Constructor
@@ -36,18 +36,17 @@
 NmHsWidgetEmailEngine::NmHsWidgetEmailEngine(const NmId& monitoredMailboxId) :
     mMailboxId(monitoredMailboxId), 
     mFolderId(0), 
-    mAccountName(0), 
+    mAccountName(), 
     mUnreadCount(-1),
     mEmailInterface(0), 
     mFactory(0), 
     mAccountEventReceivedWhenSuspended(false),
     mMessageEventReceivedWhenSuspended(false), 
     mSuspended(false),
-    mUpdateTimer(0)
+    mUpdateTimer(0),
+    mAiwRequest(0)
 {
-    qDebug() << "NmHsWidgetEmailEngine() -- START";
-
-    qDebug() << "NmHsWidgetEmailEngine() -- END";
+    NM_FUNCTION;
 }
 
 /*!
@@ -58,7 +57,7 @@
  */
 bool NmHsWidgetEmailEngine::initialize()
 {
-    qDebug() << "initialize() -- START";
+    NM_FUNCTION;
         
     if (!constructNmPlugin()) {
         //if plugin connection fails, there's no reason to proceed
@@ -71,7 +70,6 @@
     mUpdateTimer->setInterval(NmHsWidgetEmailEngineUpdateTimerValue);
     connect(mUpdateTimer, SIGNAL(timeout()), this, SLOT(handleUpdateTimeout()) );
     
-    qDebug() << "initialize() -- END";
     return true;
 }
 
@@ -82,20 +80,20 @@
  */
 bool NmHsWidgetEmailEngine::constructNmPlugin()
 {
-    qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- START";
+    NM_FUNCTION;
 
     QObject* pluginInstance(0);
     //Get data plugin factory instance
     mFactory = NmDataPluginFactory::instance();
     if (!mFactory) {
-        qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- mFactory FAILED";
+        NM_ERROR(1,"NmHsWidgetEmailEngine::constructNmPlugin() -- mFactory FAILED");
         return false;
     }
 
     //Get plugin instance
     pluginInstance = mFactory->pluginInstance(mMailboxId);
     if (!pluginInstance) {
-        qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- pluginInstance FAILED";
+        NM_ERROR(1,"NmHsWidgetEmailEngine::constructNmPlugin() -- pluginInstance FAILED");
         return false;
     }
 
@@ -103,7 +101,7 @@
     mEmailInterface = mFactory->interfaceInstance(pluginInstance);
 
     if (!mEmailInterface) {
-        qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- mEmailInterface FAILED";
+        NM_ERROR(1,"NmHsWidgetEmailEngine::constructNmPlugin() -- mEmailInterface FAILED");
         return false;       
     }
     //Verify that the mailbox we are interested actually exists.
@@ -111,7 +109,7 @@
     QList<NmId> ids; 
     mEmailInterface->listMailboxIds(ids);
     if(!ids.contains(mMailboxId)){
-        qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- !ids.contains(mMailboxId) FAILED";
+        NM_ERROR(1,"NmHsWidgetEmailEngine::constructNmPlugin() -- !ids.contains(mMailboxId) FAILED");
         emit exceptionOccured(NmEngineExcAccountDeleted);
         return false;
     }
@@ -121,7 +119,6 @@
     //This is valid at least for IMAP accounts. 
     //Folder ID is then retrieved later when first message event is received
     mFolderId = mEmailInterface->getStandardFolderId(mMailboxId, NmFolderInbox);
-    qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- mFolderId==" << mFolderId.id();
 
     //Subscription is needed - otherwise the signals will not be received
     mEmailInterface->subscribeMailboxEvents(mMailboxId);
@@ -135,8 +132,6 @@
     connect(pluginInstance, SIGNAL( mailboxEvent(NmMailboxEvent, const QList<NmId>& ) ), this,
         SLOT( handleMailboxEvent(NmMailboxEvent, const QList<NmId>&) ));
 
-    qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- OK";
-
     return true;
 }
 
@@ -146,13 +141,11 @@
  */
 void NmHsWidgetEmailEngine::resetEnvelopeList()
 {
-    qDebug() << "NmHsWidgetEmailEngine::resetEnvelopeList() -- START";
+    NM_FUNCTION;
 
     while (!mEnvelopeList.isEmpty()) {
         delete mEnvelopeList.takeFirst();
     }
-
-    qDebug() << "NmHsWidgetEmailEngine::resetEnvelopeList() -- END";
 }
 
 /*!
@@ -160,7 +153,7 @@
  */
 NmHsWidgetEmailEngine::~NmHsWidgetEmailEngine()
 {
-    qDebug() << "~NmHsWidgetEmailEngine -- START";
+    NM_FUNCTION;
 
     resetEnvelopeList();
     if (mFactory) {
@@ -171,8 +164,6 @@
         mUpdateTimer->stop();
         delete mUpdateTimer;
     }
-    
-    qDebug() << "~NmHsWidgetEmailEngine -- END";
 }
 
 /*!
@@ -186,11 +177,11 @@
  */
 int NmHsWidgetEmailEngine::getEnvelopes(QList<NmMessageEnvelope> &list, int maxEnvelopeAmount)
 {
-    qDebug() << "NmHsWidgetEmailEngine::getEnvelopes()";
+    NM_FUNCTION;
     list.clear(); //Reset the parameter list to avoid side effects
     int i = 0;
     for (; i < mEnvelopeList.count() && i < maxEnvelopeAmount; i++) {
-        NmMessageEnvelope env(*mEnvelopeList[i]);
+        NmMessageEnvelope env(*mEnvelopeList.at(i));
         list.append(env);
     }
     return i;
@@ -203,7 +194,7 @@
  */
 int NmHsWidgetEmailEngine::unreadCount()
 {
-    qDebug() << "NmHsWidgetEmailEngine::unreadCount()";
+    NM_FUNCTION;
     return mUnreadCount;
 }
 
@@ -214,7 +205,7 @@
  */
 QString NmHsWidgetEmailEngine::accountName()
 {
-    qDebug() << "NmHsWidgetEmailEngine::accountName()";
+    NM_FUNCTION;
     return mAccountName;
 }
 
@@ -231,9 +222,9 @@
  */
 bool NmHsWidgetEmailEngine::updateData()
 {
-    qDebug() << "NmHsWidgetEmailEngine::updateData() -- START";
+    NM_FUNCTION;
     if (!mEmailInterface) {
-        qDebug() << "NmHsWidgetEmailEngine::updateData() -- Interface missing";
+        NM_ERROR(1,"NmHsWidgetEmailEngine::updateData() -- Interface missing");
         emit exceptionOccured(NmEngineExcFailure); //fatal error
         return false; //if interface is missing there's nothing to do
     }
@@ -259,7 +250,7 @@
     }
     if (folder) {
         //If messageCount in the folder is zero we must indicate unread count to be -1
-        if (folder->messageCount() == 0) {
+        if (mEnvelopeList.count() == 0) {
             mUnreadCount = -1;
         }
         else {
@@ -276,8 +267,6 @@
     }else{
         return false;
     }
-
-    qDebug() << "NmHsWidgetEmailEngine::updateData() -- END";
     return true;
 }
 
@@ -290,12 +279,12 @@
     const QList<NmId> &messageIds,
     const NmId& mailboxId)
 {
-    qDebug() << "NmHsWidgetEmailEngine::handleMessageEvent() -- START";
+    NM_FUNCTION;
     Q_UNUSED(event);
     Q_UNUSED(messageIds);
     
     if (!mEmailInterface) {
-        qDebug() << "NmHsWidgetEmailEngine::handleMessageEvent() -- Interface missing";
+        NM_ERROR(1,"NmHsWidgetEmailEngine::handleMessageEvent() -- Interface missing");
         emit exceptionOccured(NmEngineExcFailure); //fatal error
         return; //if interface is missing there's nothing to do
     }
@@ -315,7 +304,6 @@
             mUpdateTimer->start();
         }
     }
-    qDebug() << "NmHsWidgetEmailEngine::handleMessageEvent() -- END";
 }
 
 /*!
@@ -323,7 +311,7 @@
  */
 void NmHsWidgetEmailEngine::handleMailboxEvent(NmMailboxEvent event, const QList<NmId> &mailboxIds)
 {
-    qDebug() << "NmHsWidgetEmailEngine::handleMailboxEvent() -- START";
+    NM_FUNCTION;
     if (mailboxIds.contains(mMailboxId)) {
         switch (event) {
             case (NmMailboxChanged): {
@@ -344,7 +332,6 @@
                 break;
         }
     }
-    qDebug() << "NmHsWidgetEmailEngine::handleMailboxEvent() -- END";
 }
 
 /*!
@@ -352,12 +339,11 @@
  */
 void NmHsWidgetEmailEngine::handleUpdateTimeout()
 {
-    qDebug() << "NmHsWidgetEmailEngine::handleUpdateTimeout() -- START";
+    NM_FUNCTION;
     if (mUpdateTimer){
         mUpdateTimer->stop();
     }
     updateData();
-    qDebug() << "NmHsWidgetEmailEngine::updateAccount() -- END";
 }
 
 /*!
@@ -367,7 +353,7 @@
  */
 bool NmHsWidgetEmailEngine::updateAccount()
 {
-    qDebug() << "NmHsWidgetEmailEngine::updateAccount() -- START";
+    NM_FUNCTION;
 
     NmMailbox* box = NULL;
     if (mEmailInterface) {
@@ -383,7 +369,6 @@
         box = NULL;
         emit accountNameChanged(mAccountName);
     }
-    qDebug() << "NmHsWidgetEmailEngine::updateAccount() -- END";
     return true;
 }
 
@@ -393,9 +378,8 @@
  */
 void NmHsWidgetEmailEngine::suspend()
 {
-    qDebug() << "NmHsWidgetEmailEngine::suspend() -- START";
+    NM_FUNCTION;
     mSuspended = true;
-    qDebug() << "NmHsWidgetEmailEngine::suspend() -- END";
 }
 
 /*!
@@ -405,7 +389,7 @@
  */
 void NmHsWidgetEmailEngine::activate()
 {
-    qDebug() << "NmHsWidgetEmailEngine::activate() -- START";
+    NM_FUNCTION;
     mSuspended = false;
     if (mAccountEventReceivedWhenSuspended) {
         mAccountEventReceivedWhenSuspended = false;
@@ -415,7 +399,6 @@
         mMessageEventReceivedWhenSuspended = false;
         updateData();
     }
-    qDebug() << "NmHsWidgetEmailEngine::activate() -- END";
 }
 
 /*!
@@ -424,20 +407,34 @@
  */
 void NmHsWidgetEmailEngine::launchMailAppInboxView()
 {
-    qDebug() << "NmHsWidgetEmailEngine::launchMailAppInboxView() -- START";
-
-    XQServiceRequest request(
-        emailFullServiceNameMailbox,
-        emailOperationViewInbox,
-        false);
+    NM_FUNCTION;
     
-    QList<QVariant> list;
-    list.append(QVariant(mMailboxId.id()));
-
-    request.setArguments(list);
-    request.send();
-
-    qDebug() << "NmHsWidgetEmailEngine::launchMailAppInboxView() -- END";
+    QT_TRY{ 
+        if (!mAiwRequest) {
+            XQApplicationManager appManager;
+            mAiwRequest = appManager.create(
+                    XQI_EMAIL_INBOX_VIEW, XQOP_EMAIL_INBOX_VIEW,
+                    false);
+            
+            if (mAiwRequest) {
+                connect(mAiwRequest, SIGNAL( requestError(int, const QString&) ), 
+                        this, SLOT( aiwRequestError(int, const QString&) ));
+                connect(mAiwRequest, SIGNAL( requestOk(const QVariant&) ), 
+                        this, SLOT( aiwRequestOk(const QVariant&) ));
+                QList<QVariant> list;
+                list.append(QVariant(mMailboxId.id()));
+            
+                mAiwRequest->setSynchronous(false);
+                mAiwRequest->setArguments(list);
+                mAiwRequest->send();
+            }
+        }
+    }
+    QT_CATCH(...){
+        // no actions taken.
+        // try-catch mechanism added to avoid crashing widget, in case XQAiwRequest
+        // creation raise exception.
+    }
 }
 
 /*!
@@ -447,20 +444,71 @@
  */
 void NmHsWidgetEmailEngine::launchMailAppMailViewer(const NmId &messageId)
 {
-    qDebug() << "NmHsWidgetEmailEngine::launchMailAppMailViewer() -- START";
+    NM_FUNCTION;
 
-    XQServiceRequest request(
-       emailFullServiceNameMessage,
-       emailOperationViewMessage,
-       false);
+    QT_TRY{
+        if (!mAiwRequest) {
+            XQApplicationManager appManager;
+            mAiwRequest = appManager.create(
+                    XQI_EMAIL_MESSAGE_VIEW, XQOP_EMAIL_MESSAGE_VIEW,
+                    false);
+            
+            if (mAiwRequest) {
+                connect(mAiwRequest, SIGNAL( requestError(int, const QString&) ), 
+                        this, SLOT( aiwRequestError(int, const QString&) ));
+                connect(mAiwRequest, SIGNAL( requestOk(const QVariant&) ), 
+                        this, SLOT( aiwRequestOk(const QVariant&) ));
+                QList<QVariant> list;
+                list.append(QVariant(mMailboxId.id()));
+                list.append(QVariant(mFolderId.id()));
+                list.append(QVariant(messageId.id()));
+            
+                mAiwRequest->setSynchronous(false);
+                mAiwRequest->setArguments(list);
+                mAiwRequest->send();
+            }
+        }
+    }
+    QT_CATCH(...){
+        // no actions taken.
+        // try-catch mechanism added to avoid crashing widget, in case XQAiwRequest
+        // creation raise exception.
+    }
+}
+
+/*!
+ aiwRequestOk slot.
+ */
+void NmHsWidgetEmailEngine::aiwRequestOk(const QVariant& result)
+{
+    NM_FUNCTION;
+
+    Q_UNUSED(result);
     
-    QList<QVariant> list;
-    list.append(QVariant(mMailboxId.id()));
-    list.append(QVariant(mFolderId.id()));
-    list.append(QVariant(messageId.id()));
+    deleteAiwRequest();
+}
+
+/*!
+ aiwRequestError slot.
+ */
+void NmHsWidgetEmailEngine::aiwRequestError(int errorCode, const QString& errorMessage)
+{
+    NM_FUNCTION;
 
-    request.setArguments(list);
-    request.send();
+    Q_UNUSED(errorCode);
+    Q_UNUSED(errorMessage);
+    
+    deleteAiwRequest();
+}
 
-    qDebug() << "NmHsWidgetEmailEngine::launchMailAppMailViewer() -- END";
+/*!
+ deleteAiwRequest function.
+ */
+void NmHsWidgetEmailEngine::deleteAiwRequest()
+{
+    NM_FUNCTION;
+
+    delete mAiwRequest;
+    mAiwRequest = NULL;    
 }
+
--- a/emailuis/nmhswidget/src/nmhswidgetemailrow.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/src/nmhswidgetemailrow.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,18 +15,19 @@
  *
  */
 
-#include <QDebug>
 #include <QGraphicsLinearLayout>
 #include <hbdocumentloader.h>
 #include <hblabel.h>
 #include <hbextendedlocale.h>
-#include <HbFrameDrawer>
-#include <HbFrameItem>
+#include <hbframedrawer.h>
+#include <hbframeitem.h>
+#include <hbcolorscheme.h>
+#include <hbevent.h>
 #include "nmicons.h"
 #include "nmcommon.h"
 #include "nmhswidgetemailrow.h"
 #include "nmhswidgetconsts.h"
-#include "nmmessageenvelope.h"
+#include "emailtrace.h"
 
 NmHsWidgetEmailRow::NmHsWidgetEmailRow(QGraphicsItem *parent, Qt::WindowFlags flags) :
     HbWidget(parent, flags), 
@@ -35,11 +36,10 @@
     mTimeLabel(0), 
     mNewMailIcon(0),
     mSeparatorIcon(0), 
-    mMessageId(0)
+    mMessageId(0),
+    mBackgroundLayoutItem(0)
 {
-    qDebug() << "NmHsWidgetEmailRow::NmHsWidgetEmailRow IN -->>";
-
-    qDebug() << "NmHsWidgetEmailRow::NmHsWidgetEmailRow OUT <<--";
+    NM_FUNCTION;
 }
 
 /*!
@@ -47,9 +47,7 @@
  */
 NmHsWidgetEmailRow::~NmHsWidgetEmailRow()
 {
-    qDebug() << "NmHsWidgetEmailRow::~NmHsWidgetEmailRow IN -->>";
-
-    qDebug() << "NmHsWidgetEmailRow::~NmHsWidgetEmailRow OUT <<--";
+    NM_FUNCTION;
 }
 
 /*!
@@ -57,29 +55,43 @@
  */
 NmId NmHsWidgetEmailRow::messageId()
 {
-    qDebug() << "NmHsWidgetEmailRow::messageId()";
+    NM_FUNCTION;
     return mMessageId;
 
 }
 
+/*
+ Setup email row ui
+  Must be called after constructor.
+   /return true if loading succeeded, otherwise false. False indicates that object is unusable.
+ */
+bool NmHsWidgetEmailRow::setupUI()
+    {
+    NM_FUNCTION;
+    
+    if(!loadDocML() || !setupGraphics()){
+        return false;
+    }
+    return true;
+    }
+
+
+
 /*!
- Loads layout data and child items from docml file
- Must be called after constructor.
+ Loads layout data and child items from docml file 
   /return true if loading succeeded, otherwise false. False indicates that object is unusable.
  */
 bool NmHsWidgetEmailRow::loadDocML()
 {
-    HbFrameDrawer* backgroundFrameDrawer = 0;
-    HbFrameItem* backgroundLayoutItem = 0;
-    QT_TRY{
-        qDebug() << "NmHsWidgetEmailRow::loadDocML IN -->>";
-    
+    NM_FUNCTION;
+
+    QT_TRY{   
         // Use document loader to load the contents
         HbDocumentLoader loader;
         bool ok(false);
         loader.load(KNmHsWidgetMailRowDocML, &ok);
         if (!ok) {
-            qDebug() << "NmHsWidgetEmailRow::loadDocML fail @ loader <<--";
+            NM_ERROR(1,"NmHsWidgetEmailRow::loadDocML fail @ loader");
             return false;
         }
     
@@ -94,7 +106,7 @@
         //find container widget
         QGraphicsWidget *container = loader.findWidget(KNmHsWidgetMailRowContainer);
         if (!container) {
-            qDebug() << "NmHsWidgetEmailRow::loadDocML fail @ container <<--";
+            NM_ERROR(1,"NmHsWidgetEmailRow::loadDocML fail @ container");
             return false;
         }
         layout->addItem(container);
@@ -118,35 +130,62 @@
     
         //Verify that items are valid
         if (!mSenderLabel || !mSubjectLabel || !mTimeLabel || !mNewMailIcon || !mSeparatorIcon) {
-            qDebug() << "NmHsWidgetEmailRow::loadDocML fail @ labels & icons <<--";
+            NM_ERROR(1,"NmHsWidgetEmailRow::loadDocML fail @ labels & icons");
             return false;
         }
         //Verify all mStatusIcons
         for (int i = 0; i < mStatusIcons.length(); i++) {
-            if (!mStatusIcons[i]) {
-                qDebug() << "NmHsWidgetEmailRow::loadDocML status icons <<--";
+            if (!mStatusIcons.at(i)) {
                 return false;
             }
         }
+        
+        return true;
+    }
+    QT_CATCH(...){
+        return false;
+    }
+}
+
+/*
+ Setup graphics that cannot be loaded from docml.
+  /return true if loading succeeded, otherwise false. False indicates that object is unusable.
+ */
+bool NmHsWidgetEmailRow::setupGraphics()
+    {
+    NM_FUNCTION;
     
+    HbFrameDrawer* newMailIconFrameDrawer = 0;
+    HbFrameItem* newMailIconFrameItem = 0;
+    HbFrameDrawer* backgroundFrameDrawer = 0;
+    QT_TRY{ 
         //separator icon
         HbIcon separatorIcon("qtg_graf_divider_h_thin");
         mSeparatorIcon->setIcon(separatorIcon);
         
         //new email icon
-        backgroundFrameDrawer = new HbFrameDrawer("qtg_fr_list_new_item",
+        newMailIconFrameDrawer = new HbFrameDrawer("qtg_fr_list_new_item",
             HbFrameDrawer::ThreePiecesVertical);
-        backgroundLayoutItem = new HbFrameItem(backgroundFrameDrawer);
-        mNewMailIcon->setBackgroundItem(backgroundLayoutItem);
-    
+        newMailIconFrameItem = new HbFrameItem(newMailIconFrameDrawer);
+        mNewMailIcon->setBackgroundItem(newMailIconFrameItem);
+        
         //hide all the icons first to avoid blinking
         hideIcons();
     
-        qDebug() << "NmHsWidgetEmailRow::loadDocML OK OUT <<--";
+        //pressed background
+        backgroundFrameDrawer = new HbFrameDrawer("qtg_fr_hsitems_pressed", HbFrameDrawer::NinePieces);
+        mBackgroundLayoutItem = new HbFrameItem( backgroundFrameDrawer );
+        setBackgroundItem( mBackgroundLayoutItem );
+        mBackgroundLayoutItem->hide();
+            
         return true;
     }
     QT_CATCH(...){
-        if(!backgroundLayoutItem && backgroundFrameDrawer){
+        if(!newMailIconFrameItem && newMailIconFrameDrawer){
+            delete newMailIconFrameDrawer;
+            newMailIconFrameDrawer = NULL;
+        }
+        if(!mBackgroundLayoutItem && backgroundFrameDrawer){
             delete backgroundFrameDrawer;
             backgroundFrameDrawer = NULL;
         }
@@ -160,8 +199,10 @@
  */
 void NmHsWidgetEmailRow::updateMailData(const NmMessageEnvelope& envelope)
 {
-    qDebug() << "NmHsWidgetEmailRow::updateMailData IN -->>";
+    NM_FUNCTION;
 
+    mEnvelope = NmMessageEnvelope(envelope);
+    
     //hide all icons, so no previous data is messing with the new
     hideIcons();
 
@@ -183,7 +224,10 @@
     
     //set new icons to widget based on the data
     setIconsToWidget( envelope );
-    qDebug() << "NmHsWidgetEmailRow::updateMailData OUT <<--";
+    
+    //set fonts color and size
+    setFontsSize(mEnvelope.isRead());
+    setHighlighedFontsColor(false);
     }
 
 /*!
@@ -191,7 +235,7 @@
 */
 void NmHsWidgetEmailRow::updateDateTime()
     {
-    qDebug() << "NmHsWidgetEmailRow::updateDateTime IN -->>";
+    NM_FUNCTION;
     //Set Date with locale support
     //Time shown if message is sent today, otherwise show date
     HbExtendedLocale locale = HbExtendedLocale::system();
@@ -207,7 +251,6 @@
         QString dateSpec = r_qtn_date_without_year;
         mTimeLabel->setPlainText( locale.format(mMessageSentTime.date(), dateSpec) );
         }
-    qDebug() << "NmHsWidgetEmailRow::updateDateTime OUT <<--";
     }
 
 /*!
@@ -215,12 +258,11 @@
  */
 void NmHsWidgetEmailRow::hideIcons()
 {
-    qDebug() << "NmHsWidgetEmailRow::hideIcons IN -->>";
+    NM_FUNCTION;
     for (int i = 0; i < mStatusIcons.count(); i++) {
-        mStatusIcons[i]->hide();
+        mStatusIcons.at(i)->hide();
     }
     mNewMailIcon->hide();
-    qDebug() << "NmHsWidgetEmailRow::hideIcons OUT <<--";
 }
 
 /*!
@@ -228,7 +270,7 @@
  */
 void NmHsWidgetEmailRow::setIconsToWidget(const NmMessageEnvelope& envelope)
 {
-    qDebug() << "NmHsWidgetEmailRow::setIconsToWidget IN -->>";
+    NM_FUNCTION;
 
     bool unreadMail = !envelope.isRead();
     bool attachment = envelope.hasAttachments();
@@ -264,21 +306,89 @@
 
     // Here we show icons added to the iconList in the order they have been added.
     for (int count = 0; count < iconList.count(); count++) {
-        mStatusIcons[count]->setIcon(iconList[count]);
-        mStatusIcons[count]->show();
+        mStatusIcons.at(count)->setIcon(iconList.at(count));
+        mStatusIcons.at(count)->show();
+    }
+}
+
+
+/*!
+    sets fonts size. Unread and read mails are shown differently
+*/
+void NmHsWidgetEmailRow::setFontsSize( bool read )
+    {
+    NM_FUNCTION;
+    HbFontSpec fontSpec;
+    
+    if(!read){
+        fontSpec.setRole(HbFontSpec::Primary);
+        mTimeLabel->fontSpec().setRole(HbFontSpec::Primary);
+    }
+    else{
+        fontSpec.setRole(HbFontSpec::Secondary);
+        mTimeLabel->fontSpec().setRole(HbFontSpec::Secondary);
+    }  
+    
+    HbStyle style;
+    qreal size;
+    bool found = style.parameter(QString("hb-param-text-height-secondary"), size );
+    if (found) {
+        fontSpec.setTextHeight(size);
+    }
+    
+    mSenderLabel->setFontSpec(fontSpec);
+    mSubjectLabel->setFontSpec(fontSpec);
     }
 
-    qDebug() << "NmHsWidgetEmailRow::setIconsToWidget OUT <<--";
-}
+/*!
+    sets fonts color.
+    /param bool pressed indicates if row is pressed down or not
+*/
+void NmHsWidgetEmailRow::setHighlighedFontsColor( bool pressed )
+    {
+    NM_FUNCTION;
+    QColor newFontColor;
+    
+    if(pressed){
+        newFontColor = HbColorScheme::color("qtc_hs_list_item_pressed");
+    }
+    else if(mEnvelope.isRead()){
+        newFontColor = HbColorScheme::color("qtc_hs_list_item_content_normal");
+    }
+    else{
+        newFontColor = HbColorScheme::color("qtc_hs_list_item_title_normal");
+    }
+ 
+    mSenderLabel->setTextColor(newFontColor);
+    mSubjectLabel->setTextColor(newFontColor);
+    mTimeLabel->setTextColor(newFontColor);
+    }
+
+/*!
+    change background highlight
+    /param bool show if true then shown, false hide
+*/
+void NmHsWidgetEmailRow::showHighlight( bool show )
+    {
+    NM_FUNCTION;
+    
+    if(show){
+        mBackgroundLayoutItem->show();
+    }
+    else{
+        mBackgroundLayoutItem->hide();
+    }
+    }
 
 /*!
  mousePressEvent(QGraphicsSceneMouseEvent *event)
  */
 void NmHsWidgetEmailRow::mousePressEvent(QGraphicsSceneMouseEvent *event)
 {
-    qDebug() << "NmHsWidgetTitleRow::mousePressEvent() IN -->>";
+    NM_FUNCTION;
     Q_UNUSED(event); 
-    qDebug() << "NmHsWidgetTitleRow::mousePressEvent() OUT <<--";
+    setHighlighedFontsColor(true);
+    showHighlight(true);
 }
 
 /*!
@@ -286,8 +396,23 @@
 */
 void NmHsWidgetEmailRow::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
 {
-    qDebug() << "NmHsWidgetTitleRow::mouseReleaseEvent() IN -->>";
+    NM_FUNCTION;
     Q_UNUSED(event);
+    setHighlighedFontsColor(false);
+    showHighlight(false);
     emit mailViewerLaunchTriggered(mMessageId);
-    qDebug() << "NmHsWidgetTitleRow::mouseReleaseEvent() OUT <<--";
 }
+
+/*
+ * NmHsWidgetEmailRow::event()
+ */
+bool NmHsWidgetEmailRow::event( QEvent *event )
+{
+    NM_FUNCTION;
+    QEvent::Type eventType = event->type();
+    if( eventType == HbEvent::ThemeChanged ){
+        setHighlighedFontsColor(false);
+        return true;
+    }
+    return HbWidget::event(event);
+}
--- a/emailuis/nmhswidget/src/nmhswidgetplugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/src/nmhswidgetplugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -21,6 +21,7 @@
 
 #include "nmhswidgetplugin.h"
 #include "nmhswidget.h"
+#include "emailtrace.h"
 
 #ifdef COVERAGE_MEASUREMENT
 #pragma CTC SKIP
@@ -40,7 +41,7 @@
                                              QServiceContext *context,
                                              QAbstractSecuritySession *session)
 {
-    qDebug() << "NmHsWidgetPlugin::createInstance";
+    NM_FUNCTION;
     Q_UNUSED(context);
     Q_UNUSED(session);
 
--- a/emailuis/nmhswidget/src/nmhswidgettitlerow.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/src/nmhswidgettitlerow.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,15 +15,19 @@
  *
  */
 
-#include <QDebug>
+#include <qgraphicslinearlayout.h>
 #include <QtGui>
-#include <QGraphicsLinearLayout>
 #include <hbdocumentloader.h>
 #include <hblabel.h>
-#include <HbPushButton>
+#include <hbpushbutton.h>
+#include <hbcolorscheme.h>
+#include <hbevent.h>
+#include <hbframedrawer.h>
+#include <hbframeitem.h>
 #include "nmicons.h"
 #include "nmhswidgettitlerow.h"
 #include "nmhswidgetconsts.h"
+#include "emailtrace.h"
 
 NmHsWidgetTitleRow::NmHsWidgetTitleRow(QGraphicsItem *parent, Qt::WindowFlags flags) :
     HbWidget(parent, flags), 
@@ -31,12 +35,11 @@
     mMailboxInfo(0), 
     mUnreadCountLabel(0),
     mCollapseExpIconLabel(0), 
-    mAccountName(0), 
-    mUnreadCount(0)
+    mAccountName(),
+    mUnreadCount(0),
+    mBackgroundLayoutItem(0)
 {
-    qDebug() << "NmHsWidgetTitleRow::NmHsWidgetTitleRow IN -->>";
-
-    qDebug() << "NmHsWidgetTitleRow::NmHsWidgetTitleRow OUT <<--";
+    NM_FUNCTION;
 }
 
 /*!
@@ -44,29 +47,54 @@
  */
 NmHsWidgetTitleRow::~NmHsWidgetTitleRow()
 {
-    qDebug() << "NmHsWidgetTitleRow::~NmHsWidgetTitleRow IN -->>";
+    NM_FUNCTION; 
+}
+
+/*!
+ \fn QPainterPath NmHsWidgetTitleRow::shape()
 
-    qDebug() << "NmHsWidgetTitleRow::~NmHsWidgetTitleRow OUT <<--";
+ Called by home screen fw to check widget boundaries, needed to draw
+ outside widget boundingRect.
+ /return QPainterPath path describing actual boundaries of widget 
+  including child items
+ */
+QPainterPath NmHsWidgetTitleRow::shape() const
+{
+    NM_FUNCTION;
+    
+    QPainterPath path;
+    path.setFillRule(Qt::WindingFill);
+    
+    path.addRect(this->geometry());
+    if (mMailboxIcon){
+        path.addRect(mMailboxIcon->geometry());
+    }    
+    return path.simplified();
 }
 
+/*
+ Setup email row ui
+  Must be called after constructor.
+   /return true if loading succeeded, otherwise false. False indicates that object is unusable.
+ */
+bool NmHsWidgetTitleRow::setupUI(HbDocumentLoader &loader)
+    {
+    NM_FUNCTION;
+
+    if(!loadDocML(loader) || !setupGraphics()){
+        return false;
+    }
+    return true;
+    }
+
 /*!
  Loads layout data and child items from docml file. Must be called after constructor.
  /return true if loading succeeded, otherwise false. False indicates that object is unusable
  */
-bool NmHsWidgetTitleRow::loadDocML()
+bool NmHsWidgetTitleRow::loadDocML(HbDocumentLoader &loader)
 {
+    NM_FUNCTION;
     QT_TRY{
-        qDebug() << "NmHsWidgetTitleRow::loadDocML IN -->>";
-    
-        // Use document loader to load the contents
-        HbDocumentLoader loader;
-        bool ok(false);
-        loader.load(KNmHsWidgetTitleRowDocML, &ok);
-        if (!ok) {
-            qDebug() << "NmHsWidgetTitleRow::loadDocML Fail @ loader -->>";
-            return false; //failure
-        }
-    
         //Create layout
         QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
     
@@ -78,7 +106,7 @@
         // find container widget
         QGraphicsWidget *container = loader.findWidget(KNmHsWidgetTitleRowContainer);
         if (!container) {
-            qDebug() << "NmHsWidgetTitleRow::loadDocML Fail @ container -->>";
+            NM_ERROR(1,"NmHsWidgetTitleRow::loadDocML Fail @ container");
             return false;
         }
         layout->addItem(container);
@@ -92,14 +120,13 @@
             KNmHsWidgetTitleRowCollapseExpandIconLabel));
     
         if (!mMailboxIcon || !mMailboxInfo || !mUnreadCountLabel || !mCollapseExpIconLabel) {
-            qDebug() << "NmHsWidgetTitleRow::loadDocML Fail @ icons & labels -->>";
+            NM_ERROR(1,"NmHsWidgetTitleRow::loadDocML Fail @ icons & labels");
             return false;
         }
-    
-        //Expand collapse button
+		
+		//Expand collapse button
         connect(mCollapseExpIconLabel, SIGNAL(clicked()), this, SIGNAL(expandCollapseButtonPressed()));
-    
-        qDebug() << "NmHsWidgetTitleRow::loadDocML OUT <<--";
+		
         return true;
     }
     QT_CATCH(...){
@@ -107,15 +134,47 @@
     }
 }
 
+/*
+ Setup graphics that cannot be loaded from docml.
+  /return true if loading succeeded, otherwise false. False indicates that object is unusable.
+ */
+bool NmHsWidgetTitleRow::setupGraphics()
+{
+    NM_FUNCTION;
+    
+    HbFrameDrawer* backgroundFrameDrawer = 0;
+    QT_TRY{
+        //pressed background
+        backgroundFrameDrawer = new HbFrameDrawer("qtg_fr_hsitems_pressed", HbFrameDrawer::NinePieces);
+        mBackgroundLayoutItem = new HbFrameItem( backgroundFrameDrawer );
+        setBackgroundItem( mBackgroundLayoutItem );
+		mBackgroundLayoutItem->hide();
+        
+        //set fonts color
+		setHighlighedFontsColor(false);
+
+        return true;
+    }
+    QT_CATCH(...){
+        if(!mBackgroundLayoutItem && backgroundFrameDrawer){
+            delete backgroundFrameDrawer;
+            backgroundFrameDrawer = NULL;
+        }
+
+        return false;
+    }
+    
+}
+
+
 /*!
  Slot for updating account name, calls updateData to update ui.
  */
 void NmHsWidgetTitleRow::updateAccountName(const QString& accountName)
 {
-    qDebug() << "NmHsWidgetTitleRow::updateAccountName IN -->>";
+    NM_FUNCTION;
     mAccountName = accountName;
     updateData();
-    qDebug() << "NmHsWidgetTitleRow::updateAccountName OUT <<--";
 }
 
 /*!
@@ -123,9 +182,8 @@
  */
 void NmHsWidgetTitleRow::setAccountIcon(const QString& accountIconName)
 {
-    qDebug() << "NmHsWidgetTitleRow::setAccountIcon -- accountIconName" << accountIconName;
+    NM_FUNCTION;
     mMailboxIcon->setIcon(accountIconName);
-    qDebug() << "NmHsWidgetTitleRow::setAccountIcon OUT <<--";
 }
 
 /*!
@@ -133,10 +191,26 @@
  */
 void NmHsWidgetTitleRow::updateUnreadCount(const int& unreadCount)
 {
-    qDebug() << "NmHsWidgetTitleRow::updateUnreadCount IN -->>";
+    NM_FUNCTION;
     mUnreadCount = unreadCount;
     updateData();
-    qDebug() << "NmHsWidgetTitleRow::updateUnreadCount OUT <<--";
+}
+
+
+/*!
+ Slot for updating expand collapse icon
+ */
+void NmHsWidgetTitleRow::setExpandCollapseIcon(const bool& expand)
+{
+    NM_FUNCTION;
+    if(expand){
+        HbIcon icon("qtg_mono_arrow_up");
+        mCollapseExpIconLabel->setIcon(icon);
+    }
+    else{
+        HbIcon icon("qtg_mono_arrow_down");
+        mCollapseExpIconLabel->setIcon(icon);
+    }
 }
 
 /*!
@@ -144,28 +218,101 @@
  */
 void NmHsWidgetTitleRow::updateData()
 {
-    qDebug() << "NmHsWidgetTitleRow::updateData() IN -->>";
+    NM_FUNCTION;
     mMailboxInfo->setPlainText(mAccountName);
     //If unread count is -1, hide the unread count label completely.
     //This indicates that there are no mails at all (or the initial sync is not done)
-    if (mUnreadCount != -1) {
+    if (mUnreadCount >= 0) {
         QString unreadCount(hbTrId("txt_mail_widget_list_l1").arg(mUnreadCount));
         mUnreadCountLabel->setPlainText(unreadCount);
-        mUnreadCountLabel->setVisible(true);
+        QFontMetrics fm(mUnreadCountLabel->font());
+        qreal textWidth = fm.width(unreadCount);
+        mUnreadCountLabel->setMaximumWidth(textWidth);
     }
     else {
-        mUnreadCountLabel->setVisible(false);
+        mUnreadCountLabel->setMaximumWidth(0);
+    }
+}
+
+/*!
+    sets fonts color.
+    /param bool pressed indicates if row is pressed down or not
+*/
+void NmHsWidgetTitleRow::setHighlighedFontsColor( bool pressed )
+    {
+    NM_FUNCTION;
+    QColor newFontColor;
+    
+    if(pressed){
+        newFontColor = HbColorScheme::color("qtc_hs_list_item_pressed");
+    }
+    else{
+        newFontColor = HbColorScheme::color("qtc_hs_list_item_title_normal");
     }
-    qDebug() << "NmHsWidgetTitleRow::updateData() OUT <<--";
-}
+ 
+    mMailboxInfo->setTextColor(newFontColor);
+    mUnreadCountLabel->setTextColor(newFontColor);
+    }
+
+/*!
+    change background pressed state
+    /param bool show if true then shown, false hide
+*/
+void NmHsWidgetTitleRow::showHighlight( bool show )
+    {
+    NM_FUNCTION;;
+    
+    if(show){
+        mBackgroundLayoutItem->show();
+    }
+    else{
+        mBackgroundLayoutItem->hide();
+    }
+    }
 
 /*!
  mousePressEvent(QGraphicsSceneMouseEvent *event)
  */
 void NmHsWidgetTitleRow::mousePressEvent(QGraphicsSceneMouseEvent *event)
 {
-    qDebug() << "NmHsWidgetTitleRow::mousePressEvent() IN -->>";
-    Q_UNUSED(event); 
-	emit mailboxLaunchTriggered();
-    qDebug() << "NmHsWidgetTitleRow::mousePressEvent() OUT <<--";
+    NM_FUNCTION;
+	
+	//to avoid opening email account mistakenly  when tabbing expand/collapse button
+	//we dont handle events that are on the top, down or right side of the button
+    if(event->pos().x() < mUnreadCountLabel->geometry().right())
+        {
+        setHighlighedFontsColor(true);
+        showHighlight(true);
+        }
 }
+
+/*!
+    mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+*/
+void NmHsWidgetTitleRow::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+    NM_FUNCTION;
+	
+	//to avoid opening email account mistakenly when tabbing expand/collapse button
+	//we dont handle events that are on the top, down or right side of the button
+    if(event->pos().x() < mUnreadCountLabel->geometry().right())
+        {
+        setHighlighedFontsColor(false);
+        showHighlight(false);
+        emit mailboxLaunchTriggered();
+        }
+}
+
+/*
+ * NmHsWidgetTitleRow::event()
+ */
+bool NmHsWidgetTitleRow::event( QEvent *event )
+{
+    NM_FUNCTION;
+    QEvent::Type eventType = event->type();
+    if( eventType == HbEvent::ThemeChanged ){
+        setHighlighedFontsColor(false);
+        return true;
+    }
+    return HbWidget::event(event);
+}
--- a/emailuis/nmhswidget/translations/mailwidget.ts	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmhswidget/translations/mailwidget.ts	Thu Jul 22 16:30:28 2010 +0100
@@ -2,14 +2,24 @@
 <!DOCTYPE TS>
 <TS version="3.0" sourcelanguage="en_GB">
 <context>
+<message numerus="no" id="txt_mail_widget_info_no_messages">
+    <comment>Layout ID parent (no children). Same text than in Mail client when mailbox is empty. Informs user that she does not have mail in the Inbox.</comment>        
+    <source>(No messages)</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>txt_mail_widget_info_no_messages</extra-loc-layout_id>    
+    <extra-loc-viewid>Mail widget_04, Mail widget_P04, Mail widget_L04</extra-loc-viewid>
+    <extra-loc-positionid>info</extra-loc-positionid>
+    <extra-loc-feature>Ma</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mail_widget_list_l1">
-    <comment>New mail count in parenthesis after the Mail box name which is the title of the widget. Max number shown 999.</comment>        
+    <comment>Layout ID parent (No children). New mail count in parenthesis after the Mail box name which is the title of the widget. Min number 1 and max number shown 999. Number or brackets are not shown at all if mailbox do not have any new mail. Example in Mail widget_L08.</comment>        
     <source>(%L1)</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_list_tiny</extra-loc-layout_id>    
+    <extra-loc-layout_id>txt_mail_widget_list_l1</extra-loc-layout_id>    
     <extra-loc-viewid>Mail Widget</extra-loc-viewid>
     <extra-loc-positionid>List</extra-loc-positionid>
-    <extra-loc-feature>Mail Widget</extra-loc-feature>
+    <extra-loc-feature>Ma</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 </context>
--- a/emailuis/nmindicatorplugin/inc/nmindicator.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmindicatorplugin/inc/nmindicator.h	Thu Jul 22 16:30:28 2010 +0100
@@ -50,36 +50,22 @@
 
     bool handleInteraction(InteractionType type);
     QVariant indicatorData(int role) const;
-    HbIndicatorInterface::Category category() const;
-    bool acceptIcon(bool sending);
-    void updateGlobalStatus(bool sending);
 
 protected: // From HbIndicatorInterface
 
     bool handleClientRequest(RequestType type, const QVariant &parameter);
 
-signals:
-
-    void indicatorIconLost();
-    void globalStatusChanged(bool sending);
-    void mailboxLaunched(quint64 mailboxId);
-
 private slots:
 
-    void hideSendIndicator();
+    void delayedAction();
     
 private:
 
     void storeMailboxData(QVariant mailboxData);
-    void showSendProgress();
-    bool isSending() const;
 
 private:
 
 	NmMailboxInfo mMailbox;
-    bool mShowIndicator;
-    bool mSendingState;
-    bool mShowSendProgress;
 	bool mActive;
 };
 
--- a/emailuis/nmindicatorplugin/inc/nmindicatorplugin.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmindicatorplugin/inc/nmindicatorplugin.h	Thu Jul 22 16:30:28 2010 +0100
@@ -36,7 +36,6 @@
 public:
 
      NmIndicatorPlugin();
-
     ~NmIndicatorPlugin();
 
 public: // From HbIndicatorPluginInterface
@@ -47,22 +46,13 @@
     HbIndicatorInterface* createIndicator(const QString &indicatorType);
     int error() const;
 
-public slots:
-
-    bool indicatorIconLost();
-    bool showMailbox(quint64 mailboxId);
-    void indicatorDeactivated(QObject *indicator);
-    void globalStatusChanged(bool sending);
-
 private:
+    
     Q_DISABLE_COPY(NmIndicatorPlugin)
 
     int mError;
     QStringList mIndicatorTypes;
     QTranslator *mTranslator; // owned
-    QList<NmIndicator*> mIndicators;
-    NmIndicator *mStatusBarIndicator;
-    bool mSending;
 };
 
 #endif // NMINDICATORPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmindicatorplugin/inc/nmsendingindicator.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,47 @@
+/*
+ * 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 Indicator class for sending progress state
+ *
+ */
+
+#ifndef NMSENDINGINDICATOR_H
+#define NMSENDINGINDICATOR_H
+
+#include <QObject>
+#include <hbindicatorinterface.h>
+
+static const QString NmSendingIndicatorType = "com.nokia.nmail.indicatorplugin.send/1.0";
+
+class NmSendingIndicator : public HbIndicatorInterface
+{
+    Q_OBJECT
+
+public:
+
+    NmSendingIndicator(const QString &indicatorType);
+    ~NmSendingIndicator();
+
+public: // From HbIndicatorInterface
+
+    QVariant indicatorData(int role) const;
+
+    bool handleClientRequest(RequestType type, const QVariant &parameter);
+
+private slots:
+
+    void hideSendIndicator();
+};
+
+#endif // NMSENDINGINDICATOR_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmindicatorplugin/inc/nmsyncindicator.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,32 @@
+/*
+ * 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 Indicator class
+ *
+ */
+
+#include <hbindicatorinterface.h>
+
+#ifndef NMSYNCINDICATOR_H
+#define NMSYNCINDICATOR_H
+
+class NmSyncIndicator : public HbIndicatorInterface
+{
+public:
+    NmSyncIndicator();
+    virtual ~NmSyncIndicator();
+    virtual QVariant indicatorData(int role) const;   
+    static const char IndicatorType[];
+};
+
+#endif /* NMSYNCINDICATOR_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmindicatorplugin/inc/nmunreadindicator.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,41 @@
+/*
+ * 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 Indicator class for showing global unread state
+ *
+ */
+
+#ifndef NMUNREADINDICATOR_H
+#define NMUNREADINDICATOR_H
+
+#include <QObject>
+#include <hbindicatorinterface.h>
+
+static const QString NmUnreadIndicatorType = "com.nokia.nmail.indicatorplugin.unread/1.0";
+
+class NmUnreadIndicator : public HbIndicatorInterface
+{
+    Q_OBJECT
+
+public:
+
+    NmUnreadIndicator(const QString &indicatorType);
+    ~NmUnreadIndicator();
+
+public: // From HbIndicatorInterface
+
+    QVariant indicatorData(int role) const;
+};
+
+#endif // NMUNREADINDICATOR_H
+
--- a/emailuis/nmindicatorplugin/nmindicatorplugin.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmindicatorplugin/nmindicatorplugin.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -26,9 +26,15 @@
 INCLUDEPATH += ../../inc
 
 HEADERS += inc/nmindicatorplugin.h \
-           inc/nmindicator.h
+           inc/nmindicator.h \
+           inc/nmsendingindicator.h \
+           inc/nmsyncindicator.h \
+           inc/nmunreadindicator.h
 SOURCES += src/nmindicatorplugin.cpp \
-           src/nmindicator.cpp
+           src/nmindicator.cpp \
+           src/nmsendingindicator.cpp \
+           src/nmsyncindicator.cpp \
+           src/nmunreadindicator.cpp
 
 symbian {
     TARGET.EPOCALLOWDLLDATA=1
--- a/emailuis/nmindicatorplugin/src/nmindicator.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmindicatorplugin/src/nmindicator.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -27,8 +27,8 @@
 #include <HbStringUtil>
 
 const int NmMailboxInfoItemCount = 8;
-const int NmSendingStateDelay = 2000; // delay for 'send in progress' indicator
 const int NmMaxOutboxCount = 99;
+const int NmActivationDelay = 100; // 0.1s
 
 /*!
     \class NmMailboxInfo
@@ -40,7 +40,8 @@
 */
 NmMailboxInfo::NmMailboxInfo()
 {
-    NMLOG("NmMailboxInfo::NmMailboxInfo");
+    NM_FUNCTION;
+
     mId = 0;
     mSyncState = SyncComplete;
     mConnectState = Disconnected;
@@ -61,10 +62,7 @@
         HbIndicatorInterface::NotificationCategory,
         InteractionActivated)
 {
-    NMLOG("NmIndicator::NmIndicator");
-    mShowIndicator = false;
-    mSendingState = false;
-    mShowSendProgress = false;
+    NM_FUNCTION;
     mActive = false;
 }
 
@@ -73,7 +71,7 @@
 */
 NmIndicator::~NmIndicator()
 {
-    NMLOG("NmIndicator::~NmIndicator");
+    NM_FUNCTION;
 }
 
 /*!
@@ -90,28 +88,31 @@
 */
 bool NmIndicator::handleInteraction(InteractionType type)
 {
-    NMLOG("NmIndicator::handleInteraction");
+    NM_FUNCTION;
+
     bool handled = false;
     if (type == InteractionActivated) {
         mActive = false;
         handled = true;
 
-        // This indicator is responsible showing the status bar icon
-        if (mShowIndicator) {
-            // Do not show any indicators anymore
-            mShowIndicator = false;
-            emit dataChanged();
-
-            // Notify that the icon will be lost now
-            emit indicatorIconLost();
-        }
-        emit mailboxLaunched(mMailbox.mId.id());
-        emit deactivate();
+        QVariantMap data;
+        emit userActivated(data);
+        
+        // The action will be delayed to improve the usability
+        QTimer::singleShot(NmActivationDelay, this, SLOT(delayedAction()));
     }
     return handled;
 }
 
 /*!
+     Deactivate the indicator  
+*/
+void NmIndicator::delayedAction() 
+{
+    emit deactivate();
+}
+
+/*!
     \fn QVariant HbIndicatorInterface::indicatorData(int role) const = 0
 
     Returns the data stored under the given role. The indicator should at least have data elements for
@@ -127,28 +128,30 @@
 */
 QVariant NmIndicator::indicatorData(int role) const
 {
-    NMLOG(QString("NmIndicator::indicatorData %1").arg(role));
+    NM_FUNCTION;
+
     switch(role) {
         case PrimaryTextRole:
-            {
-            return mMailbox.mName;
+            if (mActive) {                
+                return mMailbox.mName;
             }
+            break;
         case SecondaryTextRole:
-            {
-            if (mMailbox.mOutboxMails>0) {
-                int outboxCount = mMailbox.mOutboxMails;
-                if (outboxCount>NmMaxOutboxCount) {
-                    outboxCount = NmMaxOutboxCount;
+            if (mActive) {
+                if (mMailbox.mOutboxMails>0) {
+                    int outboxCount = mMailbox.mOutboxMails;
+                    if (outboxCount>NmMaxOutboxCount) {
+                        outboxCount = NmMaxOutboxCount;
+                    }
+                    QString text = QString(hbTrId("txt_mail_status_menu_waiting_to_send")).
+                        arg(HbStringUtil::convertDigits(QString::number(outboxCount)));
+                    return text;
                 }
-                QString text = QString(hbTrId("txt_mail_status_menu_waiting_to_send")).
-                    arg(HbStringUtil::convertDigits(QString::number(outboxCount)));
-                return text;
-		    }
-            else if (mMailbox.mUnreadMails>0) {
-                return hbTrId("txt_mail_status_menu_new_mail");
-			}
+                else if (mMailbox.mUnreadMails>0) {
+                    return hbTrId("txt_mail_status_menu_new_mail");
+                }
+            }
             break;
-            }
         case DecorationNameRole:
             {
 			// Icon for the mailbox in the menu
@@ -162,11 +165,6 @@
             }
             break;
 		    }
-        case MonoDecorationNameRole:
-			if (mShowIndicator) {
-				return QString("qtg_status_new_email");
-			}
-			break;
         default:
         	break;
     }
@@ -174,40 +172,6 @@
 }
 
 /*!
-    Timer callback for hiding 'send in progress' indicator
-*/
-void NmIndicator::hideSendIndicator()
-{
-    if (mShowSendProgress) {
-        NMLOG("NmIndicator::hideSendIndicator - hide progress state");
-        mShowSendProgress = false;
-        emit dataChanged();
-    }
-}
-
-/*!
-    Checks if any mailbox is in sending state at the moment
-    \return true if any mailbox is in sending state
-*/
-bool NmIndicator::isSending() const
-{
-	return mSendingState;
-}
-
-/*!
-    Return type of the indicator
-    \sa HbIndicatorInterface
-*/
-HbIndicatorInterface::Category NmIndicator::category() const
-{
-	NMLOG("NmIndicatorPlugin::Category");
-    if (mMailbox.mOutboxMails>0 && mShowSendProgress) {
-        return HbIndicatorInterface::ProgressCategory;
-    }
-    return HbIndicatorInterface::NotificationCategory;
-}
-
-/*!
     Handles the requests sent from the client
     \a type is a type of the request.
     \a parameter is extra parameter from the client. Can be invalid, if not given.
@@ -220,7 +184,8 @@
 bool NmIndicator::handleClientRequest( RequestType type,
         const QVariant &parameter)
 {
-    NMLOG("NmIndicator::handleClientRequest");
+    NM_FUNCTION;
+
     bool handled(false);
     switch (type) {
         case RequestActivate:
@@ -239,12 +204,6 @@
             // also the deactivation may give updated data
 			storeMailboxData(parameter);
 
-            // This indicator was responsible showing the status bar icon
-            if (mShowIndicator) {
-                // Notify that the icon will be lost now
-                emit indicatorIconLost();
-            }
-
             emit deactivate();
             }
             break;
@@ -255,25 +214,12 @@
 }
 
 /*!
-    Start showing the 'send in progress' indicator
- */
-void NmIndicator::showSendProgress()
-{
-    // Activate the progress indicator
-    if (!mShowSendProgress && mActive) {
-        mShowSendProgress = true;
-
-        // Hide the progress state after some delay
-        QTimer::singleShot(NmSendingStateDelay, this, SLOT(hideSendIndicator()));
-    }
-}
-
-/*!
 	Stores mailbox data to member variable mMailbox.
  */
 void NmIndicator::storeMailboxData(QVariant mailboxData)
 {
-    NMLOG("NmIndicator::storeMailboxData");
+    NM_FUNCTION;
+
     QList<QVariant> infoList = mailboxData.toList();
 
     if (infoList.count() >= NmMailboxInfoItemCount) {
@@ -284,33 +230,6 @@
         mMailbox.mConnectState = infoList.at(4).value<NmConnectState>();
         mMailbox.mOutboxMails = infoList.at(5).toInt();
         mMailbox.mMailboxIconName = infoList.at(6).toString();
-
-        bool oldSendingState = mSendingState;
-        mSendingState = infoList.at(7).toInt();
-
-        // Sending state now activated
-        if (!oldSendingState && mSendingState) {
-            showSendProgress();
-        }
-
-        // Notify the global state
-        emit globalStatusChanged(mSendingState);
+        bool sendingState = infoList.at(7).toInt();
     }
 }
-
-/*!
-    Used for asking if this indicator can take status bar icon responsibility.
-    \param sending global sending state
-    \return true if the icon was accepted
- */
-bool NmIndicator::acceptIcon(bool sending)
-{
-    mSendingState = sending;
-
-    if (mActive) {
-        mShowIndicator = true;
-        emit dataChanged();
-    }
-    return mActive;
-}
-
--- a/emailuis/nmindicatorplugin/src/nmindicatorplugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmindicatorplugin/src/nmindicatorplugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -17,19 +17,20 @@
 
 #include "nmindicatorplugin.h"
 #include "nmindicator.h"
+#include "nmsendingindicator.h"
+#include "nmsyncindicator.h"
+#include "nmunreadindicator.h"
 
 #include <QCoreApplication>
 #include <QLocale>
 #include <QVariant>
 #include <QTimer>
 
-#include <xqservicerequest.h>
-#include <email_services_api.h>
-
 Q_EXPORT_PLUGIN(NmIndicatorPlugin)
 
 const int NmMaxIndicatorCount = 10;
-static const QString emailServiceNameMailbox = "nmail.com.nokia.symbian.IEmailInboxView";
+static const QString NmIndicatorName = "com.nokia.nmail.indicatorplugin_%1/1.0";
+
 
 /*!
     \class NmIndicatorPlugin
@@ -40,8 +41,9 @@
      Class constructor.
 */
 NmIndicatorPlugin::NmIndicatorPlugin()
-: mError(0), mTranslator(0), mStatusBarIndicator(0), mSending(false)
+: mError(0), mTranslator(0)
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -49,7 +51,8 @@
 */
 NmIndicatorPlugin::~NmIndicatorPlugin()
 {
-    NMLOG("NmIndicatorPlugin::~NmIndicatorPlugin");
+    NM_FUNCTION;
+    
 	delete mTranslator;
 }
 
@@ -58,11 +61,16 @@
  */
 QStringList NmIndicatorPlugin::indicatorTypes() const
 {
+    NM_FUNCTION;
+    
     QStringList types;
     for (int i=0; i<NmMaxIndicatorCount; i++) {
-		QString name = QString("com.nokia.nmail.indicatorplugin_%1/1.0").arg(i);
+		QString name = QString(NmIndicatorName).arg(i);
 		types << name;
     }
+    types << NmSendingIndicatorType;
+	types << NmSyncIndicator::IndicatorType;
+    types << NmUnreadIndicatorType;
     return types;
 }
 
@@ -73,6 +81,8 @@
 bool NmIndicatorPlugin::accessAllowed(const QString &indicatorType,
     const QVariantMap &securityInfo) const
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(indicatorType)
     Q_UNUSED(securityInfo)
 
@@ -81,30 +91,14 @@
     return true;
 }
 
-
-/*!
-    Called when any of the indicator receive updated status of the global status
- */
-void NmIndicatorPlugin::globalStatusChanged(bool sending)
-{
-    mSending = sending;
-
-    // Pass the information to the indicator handling the status bar icon
-    if (mStatusBarIndicator) {
-        mStatusBarIndicator->acceptIcon(sending);
-    }
-    else {
-		// No indicator is showing the status now.
-		indicatorIconLost();
-	}
-}
-
 /*!
 	Creates an indicator of type indicatorType. Ownership is passed to the caller.
  */
 HbIndicatorInterface* NmIndicatorPlugin::createIndicator(
         const QString &indicatorType)
 {
+    NM_FUNCTION;
+
     if (!mTranslator) {
         mTranslator = new QTranslator();
         QString lang = QLocale::system().name();
@@ -114,12 +108,19 @@
         QCoreApplication::installTranslator(mTranslator);
     }
 
-    NmIndicator* indicator = new NmIndicator(indicatorType);
-    connect(indicator, SIGNAL(indicatorIconLost()), this, SLOT(indicatorIconLost()));
-    connect(indicator, SIGNAL(destroyed(QObject *)), this, SLOT(indicatorDeactivated(QObject *)));
-    connect(indicator, SIGNAL(globalStatusChanged(bool)), this, SLOT(globalStatusChanged(bool)));
-    connect(indicator, SIGNAL(mailboxLaunched(quint64)), this, SLOT(showMailbox(quint64)));
-    mIndicators.append(indicator);
+    HbIndicatorInterface *indicator;
+    if (indicatorType == NmSendingIndicatorType) {
+        indicator = new NmSendingIndicator(indicatorType);
+    }
+    else if (indicatorType == NmUnreadIndicatorType) {
+        indicator = new NmUnreadIndicator(indicatorType);
+    }
+    else if (indicatorType == NmSyncIndicator::IndicatorType) {
+        indicator = new NmSyncIndicator();
+    }
+    else {
+        indicator = new NmIndicator(indicatorType);
+    }
 
     return indicator;
 }
@@ -129,65 +130,7 @@
  */
 int NmIndicatorPlugin::error() const
 {
+    NM_FUNCTION;
+    
     return mError;
 }
-
-/*!
-    Called when an indicator signals about lost indicator.
-    \param true if a new indicator was found
- */
-bool NmIndicatorPlugin::indicatorIconLost()
-{
-    bool found(false);
-    mStatusBarIndicator = NULL;
-
-    foreach (NmIndicator* indicator, mIndicators) {
-        // Find a new candidate to handle the status bar icon
-        if (indicator->acceptIcon(mSending)) {
-			mStatusBarIndicator = indicator;
-			found = true;
-            break;
-        }
-    }
-    return found;
-}
-
-/*!
-    Remove destroyed indicators from the list.
-    \param indicator item that has been deleted
- */
-void NmIndicatorPlugin::indicatorDeactivated(QObject *indObject)
-{
-    NMLOG(QString("NmIndicatorPlugin::indicatorDeactivated %1").arg((int)indObject));
-    NmIndicator *indicator = static_cast<NmIndicator*>(indObject);
-    mIndicators.removeAll(indicator);
-    if (mStatusBarIndicator == indicator) {
-		mStatusBarIndicator = NULL;
-
-		// Find new indicator to take care of the status bar icon
-		indicatorIconLost();
-	}
-}
-
-/*!
-    Opens inbox view to specific mailbox
-    \return true if inbox is succesfully opened
-*/
-bool NmIndicatorPlugin::showMailbox(quint64 mailboxId)
-{
-    NMLOG("NmIndicatorPlugin::showMailbox");
-    XQServiceRequest request(
-        emailServiceNameMailbox,
-        emailOperationViewInbox,
-        true);
-
-    QList<QVariant> list;
-    list.append(QVariant(mailboxId));
-
-    request.setArguments(list);
-
-    int returnValue(-1);
-    return request.send(returnValue);
-}
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmindicatorplugin/src/nmsendingindicator.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,96 @@
+/*
+ * 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 "nmsendingindicator.h"
+#include <QTimer>
+#include <nmcommon.h>
+
+const int NmSendingStateDelay = 2000; // delay for 'send in progress' indicator
+
+/*!
+    \class NmSendingIndicator
+    \brief Handles sending progress indicator
+*/
+
+/*!
+     Class constructor.
+*/
+NmSendingIndicator::NmSendingIndicator(const QString &indicatorType)
+:HbIndicatorInterface(indicatorType,
+        HbIndicatorInterface::ProgressCategory,
+        HbIndicatorInterface::NoInteraction)
+{
+}
+
+/*!
+    Class destructor.
+*/
+NmSendingIndicator::~NmSendingIndicator()
+{
+}
+
+/*!
+    \fn QVariant HbIndicatorInterface::indicatorData(int role) const = 0
+
+    No texts or icons show by this indicator
+*/
+QVariant NmSendingIndicator::indicatorData(int role) const
+{
+    if (role==DecorationNameRole) {
+		// Must return non-empty to make the indicator visible
+		return " ";
+	}
+
+    return QVariant();
+}
+
+/*!
+    Timer callback for hiding 'send in progress' indicator
+*/
+void NmSendingIndicator::hideSendIndicator()
+{
+    NM_FUNCTION;
+    emit deactivate();
+}
+
+/*!
+    Handles the requests sent from the client
+    \a type is a type of the request.
+    \a parameter is extra parameter from the client. Can be invalid, if not given.
+
+    Should return true, when the request is handled.
+    Default implementation returns false.
+
+    \sa RequestType, HbIndicator
+*/
+bool NmSendingIndicator::handleClientRequest( RequestType type,
+        const QVariant &parameter)
+{
+    NM_FUNCTION;
+    Q_UNUSED(parameter);
+
+    switch (type) {
+        case RequestActivate:
+            {
+            // Hide the progress state after some delay
+            QTimer::singleShot(NmSendingStateDelay, this, SLOT(hideSendIndicator()));
+            }
+            break;
+        default:
+            break;
+    }
+    return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmindicatorplugin/src/nmsyncindicator.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,40 @@
+/*
+ * 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 "nmsyncindicator.h"
+
+const char NmSyncIndicator::IndicatorType[] = "com.nokia.nmail.indicatorplugin.sync/1.0";
+
+NmSyncIndicator::NmSyncIndicator() :
+HbIndicatorInterface(NmSyncIndicator::IndicatorType, ProgressCategory, NoInteraction)
+{
+}
+
+NmSyncIndicator::~NmSyncIndicator()
+{
+}
+
+QVariant NmSyncIndicator::indicatorData(int role) const
+{
+    if (role == DecorationNameRole ) {
+        // Must return non-empty to make the indicator visible
+        return " ";
+    }
+    else {
+        return QVariant();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmindicatorplugin/src/nmunreadindicator.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -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 "nmunreadindicator.h"
+#include <nmcommon.h>
+
+/*!
+    \class NmUnreadIndicator
+    \brief Handles global unread indicator
+*/
+
+/*!
+     Class constructor.
+*/
+NmUnreadIndicator::NmUnreadIndicator(const QString &indicatorType)
+:HbIndicatorInterface(indicatorType,
+        HbIndicatorInterface::NotificationCategory,
+        HbIndicatorInterface::NoInteraction)
+{
+}
+
+/*!
+    Class destructor.
+*/
+NmUnreadIndicator::~NmUnreadIndicator()
+{
+}
+
+/*!
+    \fn QVariant HbIndicatorInterface::indicatorData(int role)
+
+    This indicator just shows the "@" in the status bar
+*/
+QVariant NmUnreadIndicator::indicatorData(int role) const
+{
+    if (role==MonoDecorationNameRole) {
+        return QString("qtg_status_new_email");
+    }
+
+    return QVariant();
+}
--- a/emailuis/nmsettingui/inc/nmmailboxsettingview.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmsettingui/inc/nmmailboxsettingview.h	Thu Jul 22 16:30:28 2010 +0100
@@ -42,6 +42,7 @@
 
     ~NmMailboxSettingView();
 
+    NmId mailboxId();
 
 private slots:
 
--- a/emailuis/nmsettingui/inc/nmsettingscommon.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmsettingui/inc/nmsettingscommon.h	Thu Jul 22 16:30:28 2010 +0100
@@ -26,7 +26,8 @@
     };
 
     enum MailboxProperty {
-        MailboxName = 0
+        MailboxName = 0,
+        MailboxAddress
     };
 
 }
--- a/emailuis/nmsettingui/src/nmmailboxentryitem.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmsettingui/src/nmmailboxentryitem.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -44,6 +44,7 @@
 : CpSettingFormEntryItemData(itemDataHelper, mailboxName, mailboxDescription, mailboxIcon, parent),
   mMailboxId(mailboxId.id())
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -51,6 +52,7 @@
 */
 NmMailboxEntryItem::~NmMailboxEntryItem()
 {
+    NM_FUNCTION;
 }
 
 /*!
@@ -58,7 +60,8 @@
 */
 CpBaseSettingView *NmMailboxEntryItem::createSettingView() const
 {
-	NMLOG("NmMailboxEntryItem::createSettingView");
+    NM_FUNCTION;
+    
     return 0;
 }
 
@@ -67,5 +70,7 @@
 */
 const NmId &NmMailboxEntryItem::id() const
 {
+    NM_FUNCTION;
+    
     return mMailboxId;
 }
--- a/emailuis/nmsettingui/src/nmmailboxselectionview.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmsettingui/src/nmmailboxselectionview.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -51,6 +51,8 @@
   mSettingsFactory(settingsFactory),
   mRefreshForm(false)
 {
+    NM_FUNCTION;
+    
     QScopedPointer<QSignalMapper> signalMapper(new QSignalMapper());
 
     // Connect the form's activated signal.
@@ -81,6 +83,8 @@
 */
 NmMailboxSelectionView::~NmMailboxSelectionView()
 {
+    NM_FUNCTION;
+    
     delete mItemDataHelper;
     delete mModel;
     delete mSignalMapper;
@@ -95,7 +99,8 @@
 */
 void NmMailboxSelectionView::buttonClick(QObject *item)
 {
-    NMLOG("NmMailboxSelectionView::buttonClick");
+    NM_FUNCTION;
+    
     NmMailboxEntryItem *entryItem = static_cast<NmMailboxEntryItem *>(item);
     const NmId &id = entryItem->id();
     const QString &name = entryItem->text();
@@ -111,7 +116,7 @@
 */
 void NmMailboxSelectionView::itemActivate(const QModelIndex &index)
 {
-    NMLOG("NmMailboxSelectionView::itemActivate");
+    NM_FUNCTION;
     
     HbDataForm *form = qobject_cast<HbDataForm*>(widget());
     HbDataFormModel *model = static_cast<HbDataFormModel *>(form->model());
@@ -141,7 +146,8 @@
 */
 void NmMailboxSelectionView::populateDataModel(const QList<NmMailbox *> &mailboxList)
 {
-    NMLOG("NmMailboxSelectionView::populateDataModel");
+    NM_FUNCTION;
+    
     mModel->clear();
     foreach (NmMailbox *mailbox, mailboxList) {
         NmId id = mailbox->id();
@@ -164,8 +170,8 @@
 void NmMailboxSelectionView::mailboxListChanged(const NmId &mailboxId,
     NmSettings::MailboxEventType type)
 {
-    NMLOG("NmMailboxSelectionView::mailboxListChanged");
-
+    NM_FUNCTION;
+    
     switch (type) {
         case NmSettings::MailboxDeleted: {
             // Search correct item.
@@ -191,7 +197,6 @@
             break;
         }
     }
-    NMLOG("NmMailboxSelectionView::mailboxListChanged - OK");
 }
 
 /*!
@@ -204,8 +209,8 @@
 void NmMailboxSelectionView::mailboxPropertyChanged(const NmId &mailboxId,
     QVariant property, QVariant value)
 {
-    NMLOG("NmMailboxSelectionView::mailboxPropertyChanged");
-
+    NM_FUNCTION;
+    
     // Search correct item.
     NmMailboxEntryItem *entryItem = 0;
     const int itemCount(mModel->rowCount());
@@ -228,6 +233,4 @@
         default:
             break;
     }
-
-    NMLOG("NmMailboxSelectionView::mailboxPropertyChanged - OK");
 }
--- a/emailuis/nmsettingui/src/nmmailboxsettingsmanager.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmsettingui/src/nmmailboxsettingsmanager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -43,8 +43,8 @@
 */
 QStringList pluginFolders()
 {
-    NMLOG(QString("NmMailboxSettingsManager - HELPER FUNCTIONS - pluginFolders"));
-
+    NM_FUNCTION;
+    
     const QString nmSettingsPluginFolderPath("resource/qt/plugins/nmail/settings");
     QStringList pluginDirectories;
     QFileInfoList driveList = QDir::drives();
@@ -57,8 +57,7 @@
             pluginDirectories.append(pluginDirectory);
         }
     }
-
-    NMLOG(QString("NmMailboxSettingsManager - HELPER FUNCTIONS - pluginFolders - OK"));
+    
     return pluginDirectories;
 }
 
@@ -71,6 +70,8 @@
 NmMailboxSettingsManager::NmMailboxSettingsManager()
 : mDataManager(0)
 {
+    NM_FUNCTION;
+    
     QScopedPointer<NmDataManager> dataManager(new NmDataManager());
     loadPlugins();
     mDataManager = dataManager.take();
@@ -82,6 +83,8 @@
 */
 NmMailboxSettingsManager::~NmMailboxSettingsManager()
 {
+    NM_FUNCTION;
+    
     unloadPlugins();
     qDeleteAll(mPluginLoaders);
     mPluginLoaders.clear();
@@ -98,6 +101,8 @@
 */
 void NmMailboxSettingsManager::listMailboxes(QList<NmMailbox *> &mailboxList)
 {
+    NM_FUNCTION;
+    
     mDataManager->listMailboxes(mailboxList);
 }
 
@@ -110,6 +115,8 @@
 */
 HbIcon &NmMailboxSettingsManager::mailboxIcon(const NmId &mailboxId) const
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(mailboxId);
     // TODO: use some branding feature when it is available.
     return NmIcons::getIcon(NmIcons::NmIconDefaultMailbox);
@@ -128,8 +135,8 @@
 void NmMailboxSettingsManager::populateModel(HbDataFormModel &model,
     HbDataForm &form, const NmId &mailboxId) const
 {
-    NMLOG(QString("NmMailboxSettingsManager::populateModel"));
-
+    NM_FUNCTION;
+    
     NmSettingsPluginInterface *plugin = 0;
 
     foreach (QPluginLoader *loader, mPluginLoaders) {
@@ -145,7 +152,7 @@
             pluginInstance->disconnect(SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
             pluginInstance->disconnect(SIGNAL(goOnline(const NmId &)));
             pluginInstance->disconnect(SIGNAL(goOffline(const NmId &)));
-            pluginInstance->disconnect(SIGNAL(aboutToClose()));
+            pluginInstance->disconnect(this, SIGNAL(aboutToClose()), pluginInstance, SLOT(aboutToClose()));
 
             connect(pluginInstance, SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)),
                 this, SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)));
@@ -165,7 +172,6 @@
             break;
         }
     }
-    NMLOG(QString("NmMailboxSettingsManager::populateModel - OK"));
 }
 
 
@@ -175,8 +181,8 @@
 */
 void NmMailboxSettingsManager::loadPlugins()
 {
-    NMLOG(QString("NmMailboxSettingsManager::loadPlugins"));
-
+    NM_FUNCTION;
+    
     QStringList directories(pluginFolders());
 
     foreach (const QString &directoryPath, directories) {
@@ -190,8 +196,6 @@
             loader.take();
         }
     }
-
-    NMLOG(QString("NmMailboxSettingsManager::loadPlugins - OK"));
 }
 
 
@@ -200,13 +204,11 @@
 */
 void NmMailboxSettingsManager::unloadPlugins()
 {
-    NMLOG(QString("NmMailboxSettingsManager::unloadPlugins"));
-
+    NM_FUNCTION;
+    
     foreach (QPluginLoader *loader, mPluginLoaders) {
         loader->unload();
     }
-
-    NMLOG(QString("NmMailboxSettingsManager::unloadPlugins - OK"));
 }
 
 // End of file.
--- a/emailuis/nmsettingui/src/nmmailboxsettingview.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmsettingui/src/nmmailboxsettingview.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -56,6 +56,8 @@
       mModel(NULL),
       mMailboxId(mailboxId.id())
 {
+    NM_FUNCTION;
+    
     setTitle(mailboxName);
 
     HbDocumentLoader documentLoader;
@@ -74,6 +76,9 @@
     }
 
     if (mForm) {
+        // Fix for dataform item recycling.
+        mForm->setItemRecycling(false);
+
         // Set the form for the view.
         setWidget(mForm);
 
@@ -96,13 +101,9 @@
 */
 NmMailboxSettingView::~NmMailboxSettingView()
 {
-    NMLOG("NmMailboxSettingView::~NmMailboxSettingView()");
-
-    if (mForm) {
-        mForm->removeAllConnection();
-        delete mForm;
-    }
-
+    NM_FUNCTION;
+    
+    delete mForm;
     delete mModel;
 }
 
@@ -116,6 +117,8 @@
 void NmMailboxSettingView::mailboxListChanged(const NmId &mailboxId,
     NmSettings::MailboxEventType type)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(mailboxId);
     Q_UNUSED(type);
 
@@ -137,6 +140,8 @@
                                                   QVariant property,
                                                   QVariant value)
 {
+    NM_FUNCTION;
+    
     Q_UNUSED(mailboxId);
 
     switch (property.toInt()) {
@@ -150,5 +155,12 @@
     }
 }
 
+/*!
+    Returns the mailbox id for this mailbox setting view.    
+*/
+NmId NmMailboxSettingView::mailboxId()
+{
+    return mMailboxId;
+}
 
 // End of file.
--- a/emailuis/nmsettingui/src/nmsettingsformcustomitems.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmsettingui/src/nmsettingsformcustomitems.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,6 +15,8 @@
 *
 */
 
+#include "emailtrace.h"
+
 #include <QModelIndex>
 #include <HbPushButton>
 #include <HbAbstractViewItem>
@@ -37,6 +39,7 @@
 NmSettingsFormCustomItems::NmSettingsFormCustomItems(QGraphicsItem *parent)
 : HbDataFormViewItem(parent)
 {
+    NM_FUNCTION;
 }
 
 
@@ -45,6 +48,7 @@
 */
 NmSettingsFormCustomItems::~NmSettingsFormCustomItems()
 {
+    NM_FUNCTION;
 }
 
 
@@ -53,11 +57,15 @@
 */
 HbAbstractViewItem *NmSettingsFormCustomItems::createItem()
 {
+    NM_FUNCTION;
+    
     return new NmSettingsFormCustomItems(*this);
 }
 
 bool NmSettingsFormCustomItems::canSetModelIndex(const QModelIndex &index) const
 {
+    NM_FUNCTION;
+    
     int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt());
     return type==NmButtonItem;
 }
@@ -67,6 +75,8 @@
 */
 void NmSettingsFormCustomItems::restore()
 {
+    NM_FUNCTION;
+    
     HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>(
         modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
      if (itemType==NmButtonItem) {
@@ -91,6 +101,8 @@
 */
 HbWidget *NmSettingsFormCustomItems::createCustomWidget()
 {
+    NM_FUNCTION;
+    
     HbDataFormModelItem::DataItemType itemType =
         static_cast<HbDataFormModelItem::DataItemType>(
             modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
--- a/emailuis/nmsettingui/src/nmsettingsviewfactory.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmsettingui/src/nmsettingsviewfactory.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -64,6 +64,8 @@
    mSettingsManager(new NmMailboxSettingsManager()), mSettingsViewLauncher(0),mPrevView(0),
    mMessageBox(0)
 {
+    NM_FUNCTION;
+    
     createMessageBox();
 }
 
@@ -90,6 +92,8 @@
      mSettingsManager(new NmMailboxSettingsManager()), mSettingsViewLauncher(viewLauncher),
      mPrevView(0), mMessageBox(0)
 {
+    NM_FUNCTION;
+    
     createMessageBox();
 }
 
@@ -99,6 +103,8 @@
 */
 NmSettingsViewFactory::~NmSettingsViewFactory()
 {
+    NM_FUNCTION;
+    
     delete mSettingsManager;
     delete mMessageBox;
 }
@@ -113,16 +119,15 @@
 */
 CpBaseSettingView *NmSettingsViewFactory::createSettingView() const
 {
-    NMLOG(QString("NmSettingsViewFactory::createSettingView(): Begin."));
-
+    NM_FUNCTION;
+    
     CpBaseSettingView *view = 0;
     QList<NmMailbox *> mailboxList;
     mSettingsManager->listMailboxes(mailboxList);
     const int mailboxCount(mailboxList.count());
 
     // Log the number of mailboxes.
-    NMLOG(QString("NmSettingsViewFactory::createSettingView(): Mailbox count is ") +
-          QString::number(mailboxCount));
+    NM_COMMENT(QString("NmSettingsViewFactory::createSettingView(): mailbox count is %1").arg(mailboxCount));
 
     switch(mailboxCount) {
         case 0: {
@@ -156,8 +161,7 @@
                 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
                 view, SLOT(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
     }
-
-    NMLOG(QString("NmSettingsViewFactory::createSettingView(): End."));
+    
     return view;
 }
 
@@ -171,82 +175,86 @@
 void NmSettingsViewFactory::launchSettingView(const NmId &mailboxId,
                                               const QString &mailboxName) const
 {
-    NMLOG(QString("NmSettingsViewFactory::launchSettingView"));
-
+    NM_FUNCTION;
+    
     // There's always at least one valid main window available.
     HbMainWindow *mainWindow = hbInstance->allMainWindows().takeFirst();
 
-    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 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()));
-    view->setNavigationAction(action);
-    mPrevView = mainWindow->currentView();
-    mainWindow->addView(view);
-    mainWindow->setCurrentView(view);
-
-    NMLOG(QString("NmSettingsViewFactory::launchSettingView - OK"));
+    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 
+    // 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 
+         // 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()));
+         view->setNavigationAction(action);
+         mPrevView = mainWindow->currentView();
+         mainWindow->addView(view);
+         mainWindow->setCurrentView(view);
+    }    
 }
 
-
 /*!
-   Handles back button press.
+   Handels back button press.
    Removes the current view from the main window and activates the previous view.
    Destroys removed view.
 */
 void NmSettingsViewFactory::backPress()
 {
-    NMLOG(QString("NmSettingsViewFactory::backPress"));
-
+    NM_FUNCTION;
+    
     emit aboutToClose();
     HbMainWindow *mainWindow = hbInstance->allMainWindows().takeFirst();
     QList<HbView *> views = mainWindow->views();
@@ -260,8 +268,6 @@
         }
         mPrevView = 0;
     }
-
-    NMLOG(QString("NmSettingsViewFactory::backPress - OK"));
 }
 
 /*!
@@ -271,9 +277,11 @@
 */
 void NmSettingsViewFactory::launchWizard(HbAction *action)
 {
+    NM_FUNCTION;
+    
     if (action == mMessageBox->primaryAction()) {
         // Launch mail wizard.
-        NMLOG(QString("NmSettingsViewFactory::launchWizard(): Launching the mail wizard."));
+        NM_COMMENT(QString("NmSettingsViewFactory::launchWizard(): launching the mail wizard"));
         QStringList args;
         args << mailWizardStartArgs;
         QProcess::startDetached(mailWizardStartExe, args);
@@ -285,6 +293,8 @@
 */
 void NmSettingsViewFactory::createMessageBox()
 {
+    NM_FUNCTION;
+    
     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
     mMessageBox->setText(hbTrId("txt_mail_dialog_no_mailboxes_create_new"));
     mMessageBox->setTimeout(HbMessageBox::NoTimeout);
--- a/emailuis/nmsettingui/src/nmsettingsviewlauncher.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/emailuis/nmsettingui/src/nmsettingsviewlauncher.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -59,11 +59,9 @@
     const NmId &mailboxId,
     const QString &mailboxName)
 {
-    NMLOG(QString("NmSettingsViewLauncher::launchSettingsView"));
-
+    NM_FUNCTION;
+    
     mSettingsViewFactory->launchSettingView(mailboxId, mailboxName);
-
-    NMLOG(QString("NmSettingsViewLauncher::launchSettingsView - OK"));
 }
 
 // End of file.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/cmailboxstateext.h	Thu Jul 22 16:30:28 2010 +0100
@@ -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/emailcommon/inc/cmailboxstateext.h"
\ No newline at end of file
--- a/inc/emailshutdownconst.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/inc/emailshutdownconst.h	Thu Jul 22 16:30:28 2010 +0100
@@ -16,4 +16,64 @@
 *
 */
 
-#include "../emailservices/emailservermonitor/inc/emailshutdownconst.h"
+#ifndef EMAILSHUTDOWNCONST_H
+#define EMAILSHUTDOWNCONST_H
+
+#include <e32cmn.h>                 // TUid
+#include "emailshutdownconst.hrh"   // KEmailShutdownUidAsTInt
+
+
+// Publish & Subscribe category for Email shutdown events
+const TUid KEmailShutdownPsCategory = { KEmailShutdownUidAsTInt };
+
+// Size of one item in platform API UID list (in Publish & Subscribe
+// key EEmailPsKeyPlatformApiAppsToClose)
+const TInt KEmailPlatformApiUidItemSize = sizeof( TInt32 );
+
+// Publish & Subscribe keys used in shutdown process
+enum TEmailShutdownPsKeys
+    {
+    // Publish & Subscribe key used in communication between Shutter
+    // application and installation initiators
+    EEmailPsKeyInstallationStatus = 1,
+    
+    // Publish & Subscribe keys for Email shutdown events
+    EEmailPsKeyShutdownClients,
+    EEmailPsKeyShutdownPlugins,
+    EEmailPsKeyShutdownMsgStore,
+    
+    // Publish & Subscribe keys to register 3rd party applications to be closed
+    EEmailPsKeyPlatformApiAppsToCloseLength,
+    EEmailPsKeyPlatformApiAppsToClose
+    };
+
+// Publish & Subscribe values to be used with key EEmailPsKeyInstallationStatus
+enum TEmailShutdownPsInstallationValues
+    {
+    // Value to be set by installation initiators when installation is starting
+    EEmailPsValueInstallationStarting = 1,
+    // Value to be set by Shutter when all services are shutdown
+    EEmailPsValueInstallationOkToStart,
+    // Value to be set by installation initiators when installation is started
+    // after EEmailPsValueInstallationOkToStart event received
+    EEmailPsValueInstallationStarted,
+    // Value to be set by Starter when installation has finished
+    EEmailPsValueInstallationFinished
+    };
+
+// Executable name of the process that implements the shutdown functionality
+_LIT( KEmailShutdownHandlerExe, "emailservermonitor.exe" );
+
+// Command line arguments that can be given to shutdown handler process when
+// starting it
+
+// KEmailShutdownHandlerArgOnlyShutter should be used when starting the process
+// just before starting installation (if it wasn't already running)
+_LIT( KEmailShutdownHandlerArgOnlyShutter, "OnlyShutter" );
+
+// KEmailShutdownHandlerArgRestart should be given when restarting
+// the process after installation
+_LIT( KEmailShutdownHandlerArgRestart, "RestartAfterInstallation" );
+
+
+#endif // EMAILSHUTDOWNCONST_H
--- a/inc/emailshutdownconst.hrh	Fri Jun 11 16:23:29 2010 +0100
+++ b/inc/emailshutdownconst.hrh	Thu Jul 22 16:30:28 2010 +0100
@@ -16,4 +16,16 @@
 *
 */
 
-#include "../emailservices/emailservermonitor/inc/emailshutdownconst.hrh"
+#ifndef EMAILSHUTDOWNCONST_HRH
+#define EMAILSHUTDOWNCONST_HRH
+
+
+// Publish & Subscribe category for Cmail shutdown events, needs to be the
+// same as UID of the process that implements the shutdown functionality
+#define KEmailShutdownUidAsTInt 0x20025FAD
+
+// Executable name of the process that implements the shutdown functionality
+#define KEmailShutdownProcessExeName emailservermonitor.exe
+
+
+#endif // EMAILSHUTDOWNCONST_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/nmapplicationstateinterface.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,18 @@
+/*
+* 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 "../emailuis/nmailuiengine/inc/nmapplicationstateinterface.h"
--- a/inc/nmmessagesearchlistmodel.h	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +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: 
-*
-*/
-
-#include "../emailuis/nmailuiengine/inc/nmmessagesearchlistmodel.h"
-
-// End of file.
--- a/ipsservices/ipssosaoplugin/inc/IpsSosAOImapPopLogic.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosaoplugin/inc/IpsSosAOImapPopLogic.h	Thu Jul 22 16:30:28 2010 +0100
@@ -134,6 +134,11 @@
      */
     inline TInt GetMailboxLogicIndex( TMsvId aMailboxId );
 
+    /**
+     * Removes orphaned logics. (mailbox has been deleted but logic has not been )
+     */
+    void RemoveOrphanLogicsL();
+    
 private:
     
     CMsvSession&                        iSession;
--- a/ipsservices/ipssosaoplugin/ipssosaoplugin.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosaoplugin/ipssosaoplugin.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -104,7 +104,6 @@
     -lmsgs \
     -letext \
     -limcm \
-    -lgsecomplugin \
     -leikcore \
     -lipssosplugin \
     -lxqsettingsmanager \
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOImapAgent.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOImapAgent.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -33,7 +33,7 @@
 //<QMail>
 #include "IpsSosAOSettingsHandler.h"
 
-const TInt KIpsSetDataHeadersOnly           = -2;
+//<qmail> removed
 //</QMail>
 
 // from ipsplugin
@@ -368,10 +368,16 @@
 void CIpsSosAOImapAgent::CancelAllAndDisconnectL()
     {
     FUNC_LOG;
+    // if we are already idle state, do nothing,
+    // completing in idle state might cause unvanted events to ui
+    if (iState == EStateIdle) 
+        {
+        return;
+        }
+    
     iDoNotDisconnect = EFalse;
     iState = EStateCompleted;
     iFoldersArray.Reset();
-
     if ( IsActive() )
         {
         Cancel();
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOImapPopLogic.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOImapPopLogic.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -23,6 +23,7 @@
 #include <msvids.h>
 #include <msvuids.h>
 
+
 // becuase of RD_IPS_AO_PLUGIN flag, can be removed
 // when flag is removed
 #include "ipsplgsosbaseplugin.hrh"
@@ -31,7 +32,9 @@
 #include "IpsSosAOMboxLogic.h"
 #include "IpsSosAOEMNResolver.h"
 //<QMail>
+
 #include "IpsSosAOSettingsHandler.h"
+#include "IpsSosAoExtendedSettingsManager.h"
 //</QMail>
 
 
@@ -240,7 +243,7 @@
         case MMsvSessionObserver::EMsvEntriesChanged:
             {
             TMsvId parent = (*(TMsvId*) (aArg2));
-            //we check that parent is the root. if not, it cannot be a 
+            //we check that parent is the root. if not, it cannot be an 
             //event from service, thus can't be from connection change..
             if ( parent == KMsvRootIndexEntryId )
                 {
@@ -264,9 +267,16 @@
             }
             break;
         case MMsvSessionObserver::EMsvEntriesDeleted:
-            // NOTE: if mailbox is deleted somewhere else than ips plugin
-            // in here need to put logic for removing corresponding 
-            // mailboxlogic object
+            {
+            TMsvId parent = (*(TMsvId*) (aArg2));
+            //we check that parent is the root. if not, it cannot be an 
+            //event indicating deleted mailbox entry
+            if ( parent == KMsvRootIndexEntryId )
+                {
+                RemoveOrphanLogicsL();
+                }
+            }
+            break;
         case MMsvSessionObserver::EMsvEntriesMoved:
         default:
             break;
@@ -429,6 +439,9 @@
         CleanupStack::PopAndDestroy(settings);
 		//</QMail>
         }
+    
+    //finally, check for orphans ( mailbox has been deleted )
+    RemoveOrphanLogicsL();
     }
 
 // ----------------------------------------------------------------------------
@@ -493,5 +506,33 @@
     return index;
     }
 
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+//
+void CIpsSosAOImapPopLogic::RemoveOrphanLogicsL()
+    {
+    CMsvEntry* cEntry = iSession.GetEntryL( KMsvRootIndexEntryId );
+    CleanupStack::PushL( cEntry );
+    
+    CMsvEntrySelection* popEntries = cEntry->ChildrenWithMtmL( KSenduiMtmPop3Uid );
+    CleanupStack::PushL( popEntries );
+    
+    CMsvEntrySelection* imapEntries = cEntry->ChildrenWithMtmL( KSenduiMtmImap4Uid );
+    CleanupStack::PushL( imapEntries );
+        
+        
+    TInt count = iMailboxLogics.Count();
+    
+    for(TInt i=count-1; i>-1;i--)
+        {
+        if( popEntries->Find(iMailboxLogics[i]->GetMailboxId()) == KErrNotFound &&
+            imapEntries->Find(iMailboxLogics[i]->GetMailboxId()) == KErrNotFound)
+            {
+            StopAndRemoveMailboxL( iMailboxLogics[i]->GetMailboxId() );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( 3, cEntry );
+    }
 // End of file
 
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOMboxLogic.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOMboxLogic.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -221,7 +221,8 @@
     TRAP_IGNORE( settings = 
             CIpsSosAOSettingsHandler::NewL(iSession, iMailboxId));
     
-    if(settings){
+    if( settings )
+        {
         IpsServices::TIpsSetDataEmnStates state = IpsServices::EMailEmnOff;
         state = settings->EmailNotificationState();
         
@@ -250,11 +251,13 @@
     TRAPD( err, settings = CIpsSosAOSettingsHandler::NewL(
             iSession, iMailboxId) );
     
-    if(settings){
+    if( settings )
+        {
         HBufC* addr = NULL;
         TRAP(err, addr = settings->EmailAddressL());
         
-        if(addr){
+        if( addr )
+            {
             __ASSERT_DEBUG( ( 
                     addr->Length() <= KIpsSosAOTextBufferSize ), 
                     User::Panic( KIpsSosAOPanicLit, KErrGeneral) );
@@ -313,7 +316,8 @@
     TInt cycles = 0;
     
     if ( event == EEventStart && iState == EStateError && 
-            CanConnectIfRoamingL() )
+          ( (iIsRoaming && CanConnectIfRoamingL())||
+             !iIsRoaming ) )
         {
         event = EEventNop;
         iAgent->LoadSettingsL();
@@ -853,7 +857,6 @@
     TRAPD(err, mgr.OpenL());
     
     TCmGenConnSettings set;
-    
     if(err==KErrNone){
         TRAP(err, mgr.ReadGenConnSettingsL(set));
         }
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOPopAgent.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOPopAgent.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -302,6 +302,13 @@
 void CIpsSosAOPopAgent::CancelAllAndDisconnectL()
     {
     FUNC_LOG;
+    // if we are already idle state, do nothing
+    // completing in idle state might cause unvanted events to ui
+    if (iState == EStateIdle) 
+        {
+        return;
+        }
+    
     iDoNotDisconnect = EFalse;
     iState = EStateCompleted;
     if ( IsActive() )
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOSettingsHandler.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOSettingsHandler.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -155,9 +155,9 @@
     QVariant state;
     TBool ok = GetSettingValue(IpsServices::ReceptionActiveProfile, state);
     
-    if(ok ){
-        prof = state.toInt();
-        
+    if( ok )
+        {
+        prof = state.toInt();        
         ret = ProfileIntoAOState(prof);
         }   
     
@@ -170,10 +170,12 @@
     const IpsServices::TIpsSetDataAoStates aAlwaysOnlineState )
     {
     //we're allowed to switch ourselves off, not on.
-    if ( aAlwaysOnlineState == IpsServices::EMailAoOff ){
+    if ( aAlwaysOnlineState == IpsServices::EMailAoOff )
+        {
         if(!SetSettingValue(
                 IpsServices::ReceptionActiveProfile, 
-                IpsServices::EmailSyncProfileManualFetch)){
+                IpsServices::EmailSyncProfileManualFetch))
+            {
         
             CreateKeyValuePair(
                     IpsServices::ReceptionActiveProfile, 
@@ -194,7 +196,8 @@
     QVariant state = NULL;
     TBool ok = GetSettingValue(IpsServices::EmailNotificationState, state);
         
-    if(ok){
+    if(ok)
+        {
         ret = static_cast<IpsServices::TIpsSetDataEmnStates>(state.toInt());
         }
     */
@@ -208,7 +211,8 @@
     const IpsServices::TIpsSetDataEmnStates /*aEmnState*/ )
     {
     /* Not supported yet
-    if(!SetSettingValue(IpsServices::EmailNotificationState, aEmnState)){
+    if(!SetSettingValue(IpsServices::EmailNotificationState, aEmnState))
+        {
         CreateKeyValuePair(IpsServices::EmailNotificationState, aEmnState);
         }
     */
@@ -224,7 +228,8 @@
     QVariant state = NULL;
     TBool ok = GetSettingValue(IpsServices::FirstEmnReceived, state);
             
-    if(ok){
+    if(ok)
+        {
         ret = static_cast<TBool>(state.toInt());
         }
     */
@@ -237,7 +242,8 @@
 void CIpsSosAOSettingsHandler::SetFirstEmnReceived( TBool /*aValue*/ )
     {
     /* Not supported yet
-    if(!SetSettingValue( IpsServices::FirstEmnReceived, aValue )){
+    if(!SetSettingValue( IpsServices::FirstEmnReceived, aValue ))
+        {
         CreateKeyValuePair(IpsServices::FirstEmnReceived, aValue);
         }
     */
@@ -254,7 +260,8 @@
     QVariant state = NULL;
     TBool ok = GetSettingValue(IpsServices::EmnReceivedNotSynced, state);
                 
-    if(ok){
+    if(ok)
+        {
         ret = static_cast<TBool>(state.toInt());
         }
     */
@@ -268,7 +275,8 @@
     {
     /* Not supported yet
     
-    if(!SetSettingValue(IpsServices::EmnReceivedNotSynced, aFlag)){
+    if(!SetSettingValue(IpsServices::EmnReceivedNotSynced, aFlag))
+        {
         CreateKeyValuePair(IpsServices::EmnReceivedNotSynced, aFlag);
         }
     */
@@ -283,7 +291,8 @@
     QVariant state = NULL;
     TBool ok = GetSettingValue(IpsServices::ReceptionWeekDays, state);
                     
-    if(ok){
+    if(ok)
+        {
         ret = static_cast<TUint>(state.toUInt());
         }
     
@@ -298,7 +307,8 @@
     TBool ok = GetSettingValue(IpsServices::ReceptionDayStartTime, value);
     TDateTime time;
     
-    if(ok){
+    if(ok)
+        {
         TInt total = value.toInt();
         TInt minutes = total%KAOMinutesInHour;
         TInt hour = total/KAOMinutesInHour;
@@ -318,7 +328,8 @@
     TBool ok = GetSettingValue(IpsServices::ReceptionDayEndTime, value);
     TDateTime time;
     
-    if(ok){
+    if(ok)
+        {
         TInt total = value.toInt();
         TInt minutes = total%KAOMinutesInHour;
         TInt hour = total/KAOMinutesInHour;
@@ -338,24 +349,28 @@
     TInt high = I64HIGH(aLastUpdateInfo.iLastSuccessfulUpdate.Int64());
     TInt low = I64LOW(aLastUpdateInfo.iLastSuccessfulUpdate.Int64());
    
-    if(!SetSettingValue(IpsServices::AoLastSuccessfulUpdateL, low)){
+    if(!SetSettingValue(IpsServices::AoLastSuccessfulUpdateL, low))
+        {
         CreateKeyValuePair(IpsServices::AoLastSuccessfulUpdateL, low);
         }
         
-    if(!SetSettingValue(IpsServices::AoLastSuccessfulUpdateH, high)){
+    if(!SetSettingValue(IpsServices::AoLastSuccessfulUpdateH, high))
+        {
         CreateKeyValuePair(IpsServices::AoLastSuccessfulUpdateH, high);
         }
         
     if(!SetSettingValue(
             IpsServices::AoLastUpdateFailed, 
-            aLastUpdateInfo.iLastUpdateFailed)){
+            aLastUpdateInfo.iLastUpdateFailed))
+        {
         CreateKeyValuePair(IpsServices::AoLastUpdateFailed, 
                 aLastUpdateInfo.iLastUpdateFailed);
         }
         
     if(!SetSettingValue(
             IpsServices::AoUpdateSuccessfulWithCurSettings, 
-            aLastUpdateInfo.iUpdateSuccessfulWithCurSettings)){
+            aLastUpdateInfo.iUpdateSuccessfulWithCurSettings))
+        {
         CreateKeyValuePair(IpsServices::AoUpdateSuccessfulWithCurSettings, 
                 aLastUpdateInfo.iUpdateSuccessfulWithCurSettings);
         }
@@ -376,22 +391,26 @@
     QVariant success=NULL;
         
     TBool ok = GetSettingValue(IpsServices::AoLastSuccessfulUpdateH, high);
-    if(ok){
+    if( ok )
+        {
         ok = GetSettingValue(IpsServices::AoLastSuccessfulUpdateL, low);
         }
-     if(ok){
+     if( ok )
+         {
          info.iLastSuccessfulUpdate = MAKE_TINT64( high.toInt(), low.toInt() );
          }
     
     ok = GetSettingValue(IpsServices::AoLastUpdateFailed, fail);
     
-    if(ok){
+    if( ok )
+        {
         info.iLastUpdateFailed = static_cast<TBool>(fail.toInt());
         }
     
     ok = GetSettingValue(IpsServices::AoUpdateSuccessfulWithCurSettings, success);
     
-    if(ok){
+    if( ok )
+        {
         info.iUpdateSuccessfulWithCurSettings = static_cast<TBool>(success.toInt());
         }
     
@@ -404,15 +423,18 @@
     {
     QVariant value = NULL;
     TBool ok = EFalse;
-    if(IsDaytime()){
+    if( IsDaytime() )
+        {
         ok = GetSettingValue( IpsServices::ReceptionRefreshPeriodDayTime, value);
         }
-    else{
+    else
+        {
         ok = GetSettingValue(IpsServices::ReceptionRefreshPeriodOther, value);
         }    
     
     TInt ret = 0;
-    if(ok){
+    if( ok )
+        {
         ret = value.toInt();
         }
     
@@ -444,7 +466,8 @@
         QVariant& aValue) const
     {
     bool ret = false;
-    if(iExtMgr){
+    if( iExtMgr )
+        {
         ret = iExtMgr->readSetting(aItem, aValue);
         }
     return ret;
@@ -458,7 +481,8 @@
     {
     bool ret = false;
     
-    if(iExtMgr){
+    if( iExtMgr )
+        {
         ret = iExtMgr->writeSetting(aItem, aData);
         }
     return ret;
@@ -510,7 +534,8 @@
     {
     IpsServices::TIpsSetDataAoStates ret = IpsServices::EMailAoOff;
     
-    if ( aProfile != IpsServices::EmailSyncProfileManualFetch ){
+    if ( aProfile != IpsServices::EmailSyncProfileManualFetch )
+        {
         ret = IpsServices::EMailAoAlways;
         }
     
--- a/ipsservices/ipssosplugin/inc/ipsplgcommon.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/inc/ipsplgcommon.h	Thu Jul 22 16:30:28 2010 +0100
@@ -35,7 +35,11 @@
 const TUid KIpsPlgPropertyCatUid  = { IPS_PROPERTY_CAT_UID };
 
 const TInt KIpsPlgMaxPhoneIdLength  = 50;
-
+//<qmail>
+const TInt KIpsSetDataHeadersOnly           = -2;
+const TInt KIpsSetDataFullBodyAndAttas      = -1;
+const TInt KIpsSetDataFullBodyOnly          = -3;
+//</qmail>
 const TInt KContinueInterval = 3000000; // 3 sec
 
 static _LIT_SECURITY_POLICY_PASS( KAllowAllPolicy );
--- a/ipsservices/ipssosplugin/inc/ipsplgdeleteoperation.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/inc/ipsplgdeleteoperation.h	Thu Jul 22 16:30:28 2010 +0100
@@ -52,6 +52,24 @@
             CMsvSession& aMsvSession,
             TRequestStatus& aObserverRequestStatus,
             CMsvEntrySelection* aEntriesToDelete );
+        
+        /**
+        * Two-phased constructor
+        * 
+        * @param aMsvSession                client/server session to MsvServer
+        * @param aObserverRequestStatus     operations observer status
+        * @param aEntriesToDelete           Message entries to be deleted from server and locally
+        * @param aOperationObserver         observes the progress of this operation
+        * @param aRequestId                 identifier for this instance of operation, 
+        *                                   assigned by the client
+        * @return CIpsPlgCreateForwardMessageOperation* self pointer                                  
+        */
+        static CIpsPlgDeleteOperation* NewL(
+            CMsvSession& aMsvSession,
+            TRequestStatus& aObserverRequestStatus,
+            CMsvEntrySelection* aEntriesToDelete,
+            MFSMailRequestObserver& aOperationObserver,
+            const TInt aRequestId);
         // </qmail>    
 //<qmail> class renamed + comments removed
         virtual ~CIpsPlgDeleteOperation();
@@ -59,6 +77,11 @@
         virtual const TDesC8& ProgressL();
 //</qmail> 
 
+// <qmail>
+    protected:        
+        void SignalFSObserver( TInt aStatus );
+// </qmail>
+        
     private:
         // <qmail>   
         enum TIpsPlgDeleteMessagesState 
@@ -76,7 +99,14 @@
         CIpsPlgDeleteOperation(
             CMsvSession& aMsvSession,
             TRequestStatus& aObserverRequestStatus );
-		//</qmail>	
+		//</qmail>
+        //<qmail>
+        CIpsPlgDeleteOperation(
+            CMsvSession& aMsvSession,
+            TRequestStatus& aObserverRequestStatus,
+            MFSMailRequestObserver& aOperationObserver,
+            const TInt aRequestId);
+        //</qmail>
         // <qmail> 
         /**
         * 2nd phase constructor
@@ -128,6 +158,9 @@
         CMsvOperation*              iOperation; // owned
         CMsvEntry*                  iEntry; // owned
         CMsvEntrySelection*         iEntrySelection; // owned
+        MFSMailRequestObserver* iOperationObserver;  // not owned
+        TFSProgress iFSProgress;
+        TInt iFSRequestId;
         // <qmail> removed member iEntryCount
         TInt                        iSetFlagIndex;
         CMsvEntry*                  iSetFlagEntry; // owned
--- a/ipsservices/ipssosplugin/inc/ipsplgheaders.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/inc/ipsplgheaders.h	Thu Jul 22 16:30:28 2010 +0100
@@ -165,7 +165,7 @@
 
 // operations
 #include "ipsplgtimeroperation.h"
-#include "ipsplgoperationwait.h"
+// <qmail> removing #include "ipsplgoperationwait.h"
 #include "ipsplgonlineoperation.h"
 // <qmail>
 #include "ipsplgcreatemessageoperation.h"
--- a/ipsservices/ipssosplugin/inc/ipsplgimap4connectop.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/inc/ipsplgimap4connectop.h	Thu Jul 22 16:30:28 2010 +0100
@@ -91,6 +91,17 @@
      * Returns operation type
      */
     TIpsOpType IpsOpType() const;
+    
+    //<qmail> moved from private to public and changed to static
+    /**
+     * 
+     * @param aInfo is filled correctly in this function
+     * @param aImap4Settings info is filled partly based on settings
+     */
+    static void ConstructImapPartialFetchInfo(
+        TImImap4GetPartialMailInfo& aInfo, 
+        const CImImap4Settings& aImap4Settings );
+    //</qmail>
         
     // <qmail> HandleImapConnectionEvent() not used any more
 
@@ -156,15 +167,7 @@
      */
     void SignalSyncCompleted( TInt aError );
     
-    // <qmail>
-    /**
-     * 
-     * @param aInfo is filled corretcly in this function
-     * @param aImap4Settings info is filled partly based on settings
-     */
-    void ConstructImapPartialFetchInfo(
-        TImImap4GetPartialMailInfo& aInfo, 
-        const CImImap4Settings& aImap4Settings );
+    // <qmail> moved to public
 
     /**
      * GetImapSettingsLC()
--- a/ipsservices/ipssosplugin/inc/ipsplgimap4plugin.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/inc/ipsplgimap4plugin.h	Thu Jul 22 16:30:28 2010 +0100
@@ -44,7 +44,8 @@
     void RefreshNowL(
         const TFSMailMsgId& aMailBoxId,
         MFSMailRequestObserver& aOperationObserver,
-        TInt aRequestId );
+        TInt aRequestId,
+        const TBool aSilentConnection=EFalse );
 
     void ListFoldersL(
         const TFSMailMsgId& aMailBoxId,
--- a/ipsservices/ipssosplugin/inc/ipsplgonlineoperation.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/inc/ipsplgonlineoperation.h	Thu Jul 22 16:30:28 2010 +0100
@@ -57,17 +57,19 @@
      * @param aFSMailBoxId mailbox id
      * @param aFSOperationObserver callback interface to caller for reporting progress (completion) statuses
      * @param aFSRequestId id of the request
+     * @param aSignallingAllowed for asynchronous request response message
      */
     // <qmail> priority parameter has been removed
 	// <qmail> MFSMailRequestObserver& changed to pointer
-	// <qmail> aSignallingAllowed parameter has been removed
+	// <qmail> aSignallingAllowed parameter has been returned
     CIpsPlgOnlineOperation(
         CMsvSession& aMsvSession,
         TRequestStatus& aObserverRequestStatus,
         CIpsPlgTimerOperation& aActivityTimer,
         TFSMailMsgId aFSMailBoxId,
         MFSMailRequestObserver* aFSOperationObserver,
-        TInt aFSRequestId );
+        TInt aFSRequestId,
+        TBool aSignallingAllowed=ETrue );
 
     /**
     * Base constructor
@@ -150,7 +152,9 @@
         // Return this if iSubOperation==NULL.
         TBuf8<1>                iDummyProg;
         
-        // <qmail> removed: TBool           iSignallingAllowed;
+        // <qmail> boolean returned
+        TBool           iSignallingAllowed;
+        // </qmail>
         MFSMailRequestObserver* iFSOperationObserver; //not owned
     };
 
--- a/ipsservices/ipssosplugin/inc/ipsplgoperationwait.h	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
-* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). 
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* 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:  Operation waiter for running asyncronous operations
-*                synchronously
-*
-*/
-
-#ifndef IPSOPERATIONWAIT_H
-#define IPSOPERATIONWAIT_H
-
-
-#include <e32base.h>
-
-NONSHARABLE_CLASS( CIpsPlgOperationWait ) : public CActive
-    {
-    public:
-    
-        /**
-        *
-        */    
-        static CIpsPlgOperationWait* NewL( TInt aPriority = EPriorityStandard );
-        
-        /**
-        *
-        */    
-        static CIpsPlgOperationWait* NewLC( TInt aPriority = EPriorityStandard );
-    
-        /**
-        *
-        */
-        CIpsPlgOperationWait( TInt aPriority );
-
-        /**
-        *
-        */
-        virtual ~CIpsPlgOperationWait();
-
-        /**
-        *
-        */
-        void ConstructL();
-
-        /**
-        *
-        */
-        void Start();
-
-
-    protected:
-
-        /**
-        * From CActive
-        */
-        virtual void DoCancel();
-
-        /**
-        * From CActive
-        */
-        virtual void RunL();
-
-    private:
-        
-        /**
-        *
-        */    
-        void StopScheduler();
-
-    private: // Data
-
-        CActiveSchedulerWait iWait;
-
-    };
-
-
-
-#endif /* IPSOPERATIONWAIT_H */
--- a/ipsservices/ipssosplugin/inc/ipsplgpop3connectop.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/inc/ipsplgpop3connectop.h	Thu Jul 22 16:30:28 2010 +0100
@@ -44,10 +44,13 @@
 	    * @param aFSOperationObserver observer callback pointer
 	    * @param aFSRequestId client assigned identifier for the request instance
 	    * @param aEventHandler event handler for sending sync events
+	    * @param aSignallingAllowed for asynchronous request response message
+	    * @param aFetchWillFollow used when connection must be kept open
 	    * @return new instance of the class
 	    */
 		// <qmail> MFSMailRequestObserver& changed to pointer
-		// <qmail> aSignallingAllowed parameter removed
+		// <qmail> aSignallingAllowed parameter added
+        // <qmail> aFetchWillFollow parameter added
         static CIpsPlgPop3ConnectOp* NewL(
             CMsvSession& aMsvSession,
             TRequestStatus& aObserverRequestStatus,
@@ -57,7 +60,9 @@
             TFSMailMsgId aFSMailBoxId,
             MFSMailRequestObserver* aFSOperationObserver,
             TInt aFSRequestId,
-            CIpsPlgEventHandler* aEventHandler );
+            CIpsPlgEventHandler* aEventHandler,
+            TBool aSignallingAllowed=ETrue,
+            TBool aFetchWillFollow=EFalse );
 
         /**
         *
@@ -91,6 +96,8 @@
         TIpsOpType IpsOpType() const;
 // </qmail>
 
+        TInt GetOperationErrorCodeL( );
+        
     protected:
 
         /**
@@ -109,7 +116,8 @@
         *
         */
 		// <qmail> MFSMailRequestObserver& changed to pointer
-		// <qmail> aSignallingAllowed parameter removed
+		// <qmail> aSignallingAllowed parameter added
+        // <qmail> aFetchWillFollow parameter added
         CIpsPlgPop3ConnectOp(
             CMsvSession& aMsvSession,
             TRequestStatus& aObserverRequestStatus,
@@ -119,7 +127,9 @@
             TFSMailMsgId aFSMailBoxId,
             MFSMailRequestObserver* aFSOperationObserver,
             TInt aFSRequestId,
-            CIpsPlgEventHandler* aEventHandler );
+            CIpsPlgEventHandler* aEventHandler,
+            TBool aSignallingAllowed,
+            TBool aFetchWillFollow );
 
         /**
         *
@@ -134,7 +144,8 @@
         void DoPopulateL();
 	    // <qmail> removed TBool ValidateL() (did nothing)
 	    // <qmail> removed void DoQueryPasswordL() not used any more
-        void DoDisconnect();
+        // <qmail> DoDisconnect -> DoDisconnectL
+        void DoDisconnectL();
 		// </qmail>
         
         // <qmail> removed flag methods as they were not used or even defined anywhere
@@ -165,7 +176,10 @@
 	    TBool                                           iForcePopulate;
 	    // <qmail> removed iSelection;
 	    CIpsPlgEventHandler*                            iEventHandler; // not owned
-        TBool                                           iAlreadyConnected;
+	    // <qmail> iAlreadyConnected removed
+        // <qmail>
+        TBool                                           iFetchWillFollow;
+        // </qmail>
     };
 
 #endif
--- a/ipsservices/ipssosplugin/inc/ipsplgpop3plugin.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/inc/ipsplgpop3plugin.h	Thu Jul 22 16:30:28 2010 +0100
@@ -52,7 +52,8 @@
     void RefreshNowL(
         const TFSMailMsgId& aMailBoxId,
         MFSMailRequestObserver& aOperationObserver,
-        TInt aRequestId );
+        TInt aRequestId,
+        const TBool aSilentConnection=EFalse );
 
     void ListFoldersL(
         const TFSMailMsgId& aMailBoxId,
--- a/ipsservices/ipssosplugin/inc/ipsplgsmtpservice.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/inc/ipsplgsmtpservice.h	Thu Jul 22 16:30:28 2010 +0100
@@ -78,26 +78,12 @@
         TFSMailMsgId aMailBoxId,
         CFSMailMessage& aMessage );
 
-    /**
-     * Creates new email message to message store
-     *
-     * @param aMailBoxId msv entry id to mailbox which setting are used
-     * @param aSession Msv Session
-     * @since FS 1.0
-     * @return pointer created fs message object
-     */
-    CFSMailMessage* CreateNewSmtpMessageL(
-        const TFSMailMsgId& aMailBoxId );
-
-    CFSMailMessage* CreateForwardSmtpMessageL(
-        const TFSMailMsgId& aMailBoxId,
-        const TFSMailMsgId& aOriginalMessageId );
-
-    CFSMailMessage* CreateReplySmtpMessageL(
-        const TFSMailMsgId& aMailBoxId,
-        const TFSMailMsgId& aOriginalMessageId,
-        TBool aReplyToAll );
-
+    // <qmail> removing unused functions
+    // CreateNewSmtpMessageL
+    // CreateForwardSmtpMessageL
+    // CreateReplySmtpMessageL
+    // </qmail>
+            
 // <qmail> moved for public access
     /**
      * Creates proper fs message object and set flags
--- a/ipsservices/ipssosplugin/inc/ipsplgsosbaseplugin.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/inc/ipsplgsosbaseplugin.h	Thu Jul 22 16:30:28 2010 +0100
@@ -19,17 +19,16 @@
 #ifndef IPSPLGSOSBASEPLUGIN_H
 #define IPSPLGSOSBASEPLUGIN_H
 
-//<cmail>
 #include "CFSMailPlugin.h"
 #include "MFSMailRequestObserver.h"
-//</cmail>
 #include <rconnmon.h>
-
 #include "ipsplgsosbaseplugin.hrh"
 #include "ipsplgcommon.h"
 #include "ipsplgsingleopwatcher.h"
 #include "ipsplgtimeroperation.h"
-
+//<Qmail>
+#include "ipsstateextension.h"
+//</Qmail>
 class CMsvSession;
 class CIpsPlgTimerOperation;
 class CIpsPlgMsgMapper;
@@ -51,11 +50,21 @@
  */
 NONSHARABLE_CLASS ( CIpsPlgSosBasePlugin ) :
     public CFSMailPlugin,
-                             public MIpsPlgSingleOpWatcher,
-                             public MFSMailRequestObserver, // a dummy observer
-                             public MIpsPlgTimerOperationCallBack
+    public MIpsPlgSingleOpWatcher,
+    public MFSMailRequestObserver, // a dummy observer
+    public MIpsPlgTimerOperationCallBack,
+    public MStateObserverCallback
     {
+//<Qmail>
+public: //from MStateObserverCallback
+    void ActiveFolderChanged(
+        const TFSMailMsgId& aActiveMailboxId,
+        const TFSMailMsgId& aActiveFolderId);
+    
+public://from CExtendableEmail
 
+    CEmailExtension* ExtensionL( const TUid& aInterfaceUid );
+//</Qmail>    
 public:
 
     /**
@@ -63,7 +72,7 @@
     * Destructor
     */
     IMPORT_C virtual ~CIpsPlgSosBasePlugin();
-
+    
 public: //from MIpsPlgSingleOpWatcher
 
     /**
@@ -176,6 +185,15 @@
         const TFSMailMsgId& aMailBoxId,
         const TFSMailMsgId& aFolderId,
         const RArray<TFSMailMsgId>& aMessages );
+		
+//<qmail>
+    virtual void DeleteMessagesByUidL(
+        const TFSMailMsgId& aMailBoxId,
+        const TFSMailMsgId& aFolderId,
+        const RArray<TFSMailMsgId>& aMessages,
+        MFSMailRequestObserver& aOperationObserver,
+        const TInt aRequestId);
+//</qmail>
 
     // MESSAGE STORE OPERATIONS
 
@@ -648,6 +666,14 @@
         const TFSMailMsgId& aSourceFolderId,
         const TFSMailMsgId& aDestinationFolderId );
 
+    //<Qmail>
+    /**
+     * function to handle active folder changed events
+     */
+    virtual void HandleActiveFolderChangeL(
+            const TFSMailMsgId& aActiveMailboxId,
+            const TFSMailMsgId& aActiveFolderId);
+    //</Qmail>
 private:
 
     /**
@@ -809,6 +835,10 @@
 
     // flag indicates is instance under FSEmail.exe
     TBool iIsUnderUiProcess;
+    
+    //<Qmail>
+    CIpsStateExtension*    iStateExtension;//owned
+    //</Qmail>
 	};
 
 #endif /* IPSPLGSOSBASEPLUGIN_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssosplugin/inc/ipssosextendedsettingsmanager.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,104 @@
+/*
+* 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 NMIPSSOSEXTENDEDSETTINGSMANAGER_H
+#define NMIPSSOSEXTENDEDSETTINGSMANAGER_H
+
+#include <qvariant.h>
+#include "nmipssettingitems.h"
+
+class NmId;
+class XQSettingsManager;
+class XQCentralRepositoryUtils;
+
+/**
+ * class to handle settings stored in central repository
+ */
+NONSHARABLE_CLASS (NmIpsSosExtendedSettingsManager)
+{
+public:
+    /**
+     * constructor
+     * @param mailbox who's settings we are handling
+     */
+    NmIpsSosExtendedSettingsManager(const NmId &mailboxId);
+    
+    /**
+     * destructor
+     */
+    virtual ~NmIpsSosExtendedSettingsManager();
+    
+    /**
+     * reads a setting from cen rep
+     * @param settingItem id of the setting
+     * @param settingValue a return parameter
+     * @return was read a success
+     */
+    bool readSetting(
+            IpsServices::SettingItem settingItem, 
+            QVariant &settingValue) const;
+    
+    /**
+     * writes a setting into cen rep
+     * @param settingItem id of the setting
+     * @param settingValue value of the setting to be stored
+     * @return was write a success
+     */
+    bool writeSetting(
+            IpsServices::SettingItem settingItem, 
+            const QVariant &settingValue);
+    
+	bool writeSetting(
+		int profileMode, 
+		IpsServices::SettingItem settingItem, 
+		const QVariant &settingValue);
+	
+    /**
+     * deletes settings
+     */
+    void deleteSettings();
+    
+    /**
+     * creates a new key-value pair
+     * @param settingItem id of the setting
+     * @param settingValue value of the setting to be stored
+     * @return was creation a success
+     */
+    bool createKeyValuePair(
+            const IpsServices::SettingItem settingItem, 
+            const QVariant &settingValue);
+
+private:
+    bool writeSettingToCenRep(
+	qint32 profileOffset, 
+	IpsServices::SettingItem settingItem, 
+	const QVariant &settingValue);
+	
+    QVariant readFromCenRep(quint32 key) const;
+    bool writeToCenRep(quint32 key, const QVariant &value) const;
+    void calculateMailboxOffset();
+    void calculateActiveProfileOffset();
+    qint32 convertToProfileOffset(int profile);
+
+private: // data
+    const NmId &mMailboxId;
+    qint32 mMailboxOffset;
+    qint32 mActiveProfileOffset;
+    XQSettingsManager* mSettingsManager; // Owned.
+};
+
+#endif // NMIPSSOSEXTENDEDSETTINGSMANAGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssosplugin/inc/ipsstateextension.h	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* 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: This file defines class CIpsPlgSosBasePlugin.
+*
+*/
+#ifndef IPSSTATEEXTENSION_H
+#define IPSSTATEEXTENSION_H
+
+#include <cmailboxstateext.h>
+#include "ipsplgcommon.h"
+
+class MEmailMailboxState;
+
+class MStateObserverCallback
+    {
+public:
+    virtual void ActiveFolderChanged(
+            const TFSMailMsgId& aActiveMailboxId,
+            const TFSMailMsgId& aActiveFolderId)=0;
+    };
+
+NONSHARABLE_CLASS ( CIpsStateExtension ) :
+    public CMailboxStateExtension
+    {
+public: //from CMailboxStateExtension
+
+    static CIpsStateExtension* NewL(MStateObserverCallback& aCallback);
+
+    /**
+     * Sets data provider interface.
+     * @param aDataProvider data provider.
+     */
+    void SetStateDataProvider( MEmailMailboxState* aDataProvider );
+    
+    /**
+    * Notification that folder has changed in email application.
+    * @param aActiveMailboxId id of the mailbox container the folder
+    * @param aActiveFolderId currently active folder id or null id if
+    *        there's currently no active folder (e.g. application is closed)
+    */
+    void NotifyActiveFolderChanged(
+        const TFSMailMsgId& aActiveMailboxId,
+        const TFSMailMsgId& aActiveFolderId);
+    
+    virtual ~CIpsStateExtension();
+private:
+    CIpsStateExtension(MStateObserverCallback& aCallback);
+    void ConstructL();
+    
+private:
+    MEmailMailboxState*         iDataProvider;//not owned    
+    MStateObserverCallback&     iCallback;
+    };
+
+#endif //IPSSTATEEXTENSION_H
--- a/ipsservices/ipssosplugin/ipssosplugin.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/ipssosplugin.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -53,7 +53,7 @@
 inc/ipsplgcreatereplymessageoperation.h \
 inc/ipsplgnewchildpartfromfileoperation.h \
 inc/ipsplgremovechildpartoperation.h \
-inc/ipsplgoperationwait.h \
+# <qmail> inc/ipsplgoperationwait.h \ removed
 inc/ipsplgpop3connectop.h \
 inc/ipsplgpop3fetchoperation.h \
 inc/ipsplgpop3plugin.h \
@@ -73,7 +73,9 @@
 inc/ipsplgsosbaseplugin.hrh \
 inc/ipsplgmailstoreroperation.h \
 inc/mipsplgmailstorerobserver.h \
-inc/ipsplgmessagepartstoreroperation.h
+inc/ipsplgmessagepartstoreroperation.h \
+inc/ipsstateextension.h \
+inc/ipssosextendedsettingsmanager.h
 
     
 SOURCES   += src/ipsplgbaseoperation.cpp \
@@ -98,7 +100,7 @@
 src/ipsplgcreatereplymessageoperation.cpp \
 src/ipsplgnewchildpartfromfileoperation.cpp \
 src/ipsplgremovechildpartoperation.cpp \
-src/ipsplgoperationwait.cpp \
+# <qmail> removed src/ipsplgoperationwait.cpp \
 src/ipsplgpop3connectop.cpp \
 src/ipsplgpop3fetchoperation.cpp \
 src/ipsplgpop3plugin.cpp \
@@ -118,7 +120,9 @@
 inc/ipsplgsearch.inl \
 inc/ipsplgmsgmapper.inl \
 src/ipsplgmailstoreroperation.cpp \
-src/ipsplgmessagepartstoreroperation.cpp
+src/ipsplgmessagepartstoreroperation.cpp \
+src/ipsstateextension.cpp \
+src/ipssosextendedsettingsmanager.cpp
 
 RESOURCES +=
 
@@ -161,8 +165,6 @@
     -lmsgs \
     -letext \
     -limcm \
-    -lgsecomplugin \
-    -lgsframework \
     -lfsmailframework \
     -lfsfwcommonlib \
     -lbafl \
@@ -172,7 +174,8 @@
     -lConnMon \
     -lflogger \
     -lfeatmgr \
-    -lmessagestoreclient
+    -lmessagestoreclient \
+    -lxqsettingsmanager
 
     BLD_INF_RULES.prj_exports += \
       "inc/ipsplgsmtpoperation.h |../inc/ipsplgsmtpoperation.h" \
--- a/ipsservices/ipssosplugin/src/ipsplgdeleteoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgdeleteoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -41,6 +41,8 @@
         aMsvSession, 
         CActive::EPriorityStandard, 
         aObserverRequestStatus),
+    iOperationObserver(NULL),
+    iFSRequestId(KErrNotFound),
     iState( ESetFlags ) // <qmail>
     //</qmail> iBlank removed    
     {
@@ -49,6 +51,30 @@
     }
 //</qmail>
 
+// ----------------------------------------------------------------------------
+// CIpsPlgDeleteOperation::CIpsPlgDeleteOperation
+// ----------------------------------------------------------------------------
+//
+//<qmail>
+CIpsPlgDeleteOperation::CIpsPlgDeleteOperation(
+    CMsvSession& aMsvSession,
+    TRequestStatus& aObserverRequestStatus,
+    MFSMailRequestObserver& aOperationObserver,
+    const TInt aRequestId)
+    :
+    CMsvOperation( 
+        aMsvSession, 
+        CActive::EPriorityStandard, 
+        aObserverRequestStatus),
+    iOperationObserver(&aOperationObserver),
+    iFSRequestId(aRequestId),
+    iState( ESetFlags )
+    {
+    FUNC_LOG;
+    CActiveScheduler::Add(this);
+    }
+//</qmail>
+
 
 // ----------------------------------------------------------------------------
 // CIpsPlgDeleteOperation::ConstructL
@@ -115,6 +141,28 @@
     return self;
     }
 
+// <qmail>
+// ----------------------------------------------------------------------------
+// CIpsPlgDeleteOperation::NewL
+// ----------------------------------------------------------------------------
+//
+CIpsPlgDeleteOperation* CIpsPlgDeleteOperation::NewL(
+    CMsvSession& aMsvSession,
+    TRequestStatus& aObserverRequestStatus,
+    CMsvEntrySelection* aEntriesToDelete,
+    MFSMailRequestObserver& aOperationObserver,
+    const TInt aRequestId)
+    {
+    FUNC_LOG;
+    CIpsPlgDeleteOperation* self=new (ELeave) CIpsPlgDeleteOperation(
+        aMsvSession, aObserverRequestStatus, aOperationObserver, aRequestId );
+    CleanupStack::PushL(self);
+    self->ConstructL( aEntriesToDelete );
+    CleanupStack::Pop( self ); 
+    return self;
+    }
+// </qmail>
+
 // ----------------------------------------------------------------------------
 // CIpsPlgDeleteOperation::~CIpsPlgDeleteOperation
 // ----------------------------------------------------------------------------
@@ -161,6 +209,7 @@
     if ( iStatus.Int() != KErrNone )
         {
         // something failed, just complete
+        SignalFSObserver(iStatus.Int());
         TRequestStatus* status = &iObserverRequestStatus;
         User::RequestComplete(status, iStatus.Int());
         return;
@@ -177,6 +226,7 @@
         
         if ( err != KErrNone )
             {
+            SignalFSObserver(err);
             TRequestStatus* status = &iObserverRequestStatus;
             User::RequestComplete(status, iStatus.Int());
             }
@@ -198,6 +248,8 @@
         }
     else
         {
+        // Inform observer
+        SignalFSObserver(iStatus.Int());
         // nothing left to process, so complete the observer
         TRequestStatus* status = &iObserverRequestStatus;
         User::RequestComplete(status, iStatus.Int());
@@ -244,6 +296,7 @@
     // if error then complete this pass with the error code
     if ( err )
         {
+        SignalFSObserver(err);
         TRequestStatus* status = &iStatus;
         User::RequestComplete(status, err);
         }
@@ -279,6 +332,7 @@
     // if error then complete this pass with the error code
     if ( err )
         {
+        SignalFSObserver(err);
         TRequestStatus* status = &iStatus;
         User::RequestComplete( status, err );
         }
@@ -335,7 +389,25 @@
     
     return ret;
     }
-// </qmail>    
+// </qmail>
+
+//<qmail> 
+// ----------------------------------------------------------------------------
+// CIpsPlgDeleteOperation::SignalFSObserver
+// ----------------------------------------------------------------------------
+//
+void CIpsPlgDeleteOperation::SignalFSObserver(TInt aStatus)
+    {
+    if (iOperationObserver)
+        {
+        iFSProgress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
+        iFSProgress.iError = aStatus;
+        iFSProgress.iParam = NULL;
+    
+        TRAP_IGNORE( iOperationObserver->RequestResponseL( iFSProgress, iFSRequestId ) );
+        }
+    }
+// </qmail>
 
 //  End of File
 
--- a/ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -1033,13 +1033,9 @@
         {
         return;
         }
-    else if ( tChanged.iMtm.iUid == KSenduiMtmSmtpUidValue )
-        {
-        // do not send entry changed events from draft messages
-        // mess up draft email
-        return;
-        }
-
+//<Qmail>
+    
+//</Qmail>
     TFSMailEvent event = static_cast<TFSMailEvent>( KErrNotFound );
 
     RArray<TFSMailMsgId> array(1);
--- a/ipsservices/ipssosplugin/src/ipsplgimap4connectop.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgimap4connectop.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -19,11 +19,7 @@
 #include "emailtrace.h"
 #include "ipsplgheaders.h"
 
-// <qmail>
-const TInt KIpsSetDataHeadersOnly           = -2;
-const TInt KIpsSetDataFullBodyAndAttas      = -1;
-const TInt KIpsSetDataFullBodyOnly          = -3;
-// </qmail>
+// <qmail> removed
 
 // <qmail> KIpsPlgIpsConnPanic removed
 
@@ -488,12 +484,14 @@
         }
     else
         {
+    //<qmail> include html in body
         aInfo.iTotalSizeLimit = sizeLimit*1024; 
         aInfo.iAttachmentSizeLimit = 0;
         aInfo.iMaxEmailSize = sizeLimit*1024;
         aInfo.iBodyTextSizeLimit = sizeLimit*1024;
         aInfo.iPartialMailOptions = EBodyAlternativeText;
         aInfo.iGetMailBodyParts = EGetImap4EmailBodyAlternativeText;
+    // </qmail>    
         }
     }
 
--- a/ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -141,7 +141,8 @@
 void CIpsPlgImap4Plugin::RefreshNowL(
     const TFSMailMsgId& aMailBoxId,
     MFSMailRequestObserver& aOperationObserver,
-    TInt aRequestId )
+    TInt aRequestId,
+    const TBool /*aSilentConnection*/ )
     {
     FUNC_LOG;
     
@@ -165,10 +166,8 @@
     iOperations.AppendL( watcher );
     CleanupStack::Pop( watcher );
     
-	//<qmail>
     // send part of refresh
-    //EmptyOutboxL( aMailBoxId ); // not used in qmail yet
-	//</qmail>
+    EmptyOutboxL( aMailBoxId );
     }
 
 // ---------------------------------------------------------------------------
@@ -579,15 +578,14 @@
     accounts->GetImapAccountL( aMailboxId.Id(), imapAcc );
     accounts->LoadImapSettingsL( imapAcc, *settings );
     TImImap4GetPartialMailInfo info;
-// <qmail>	
-    info.iPartialMailOptions = ENoSizeLimits;
-    //CIpsSetDataApi::ConstructImapPartialFetchInfo( info, *settings );
+// <qmail> Get TImImap4GetPartialMailInfo based on settings
+    CIpsPlgImap4ConnectOp::ConstructImapPartialFetchInfo( info, *settings );
     CleanupStack::PopAndDestroy( 2, settings );
-    /*
+
     if ( info.iTotalSizeLimit == KIpsSetDataHeadersOnly )
         {
         return;
-        }*/
+        }
 // </qmail>
     
     TPckgBuf<TImImap4GetPartialMailInfo> package(info);
--- a/ipsservices/ipssosplugin/src/ipsplgmessagepartstoreroperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgmessagepartstoreroperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -287,9 +287,13 @@
 	RFile file = aPart->GetContentFileL();
 	CleanupClosePushL(file);
 
+    // if we don't do SetSize(0) characters from the original mail are left in the end of the mail
+	// if the modified mail contains less characters.
+	User::LeaveIfError( file.SetSize( 0 ) );
+
 	// Write new content to text/html part file - async function
-	file.Write(0, *iDataBuffer, iDataBuffer->Length(), iStatus);
-
+	file.Write( 0, *iDataBuffer, iDataBuffer->Length(), iStatus );
+	
 	CleanupStack::PopAndDestroy(2, data16);
 	SetActive();
 	}
--- a/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -308,8 +308,8 @@
     TBool unread( aEmlEntry.Unread() );
 
 // <qmail>
-    if ( !LogicalXor( unread, msgFlags & EFSMsgFlag_Read ) ||
-         !LogicalXor( unread, msgFlags & EFSMsgFlag_Read_Locally ))
+    if ( LogicalXor( unread, msgFlags & EFSMsgFlag_Read ) ||
+         LogicalXor( unread, msgFlags & EFSMsgFlag_Read_Locally ))
 // </qmail>
         {
         aEmlEntry.SetUnread( !unread );
@@ -408,15 +408,14 @@
 
     TMsvEmailEntry tEntry( cEntry->Entry() );
     TBool isModified = ChangeTEntryFlagsL( tEntry, aMessage );
-
+    // <qmail>
     if ( isModified )
         {
-// <qmail> Function called sync in Qmail
         cEntry->ChangeL( tEntry );
-// </qmail>
         }
 
     CleanupStack::PopAndDestroy( cEntry );
+    // </qmail>
     }
 
 // ---------------------------------------------------------------------------
@@ -714,8 +713,7 @@
 							{
 							// Only text/calendar part included as attachment
 							aMsg.ResetFlag( EFSMsgFlag_Attachments );
-							//Set Attachment flag for CMsvEntry (needed for sorting)
-							TRAP_IGNORE( SetAttachmentFlagL( aEntry, EFalse ) );
+							// <qmail> remove call to SetAttachmentFlagL(), because shouln't be needed any more
 							}
                 		}
                 	delete cEntry;
@@ -1510,24 +1508,21 @@
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // <cmail>
-void CIpsPlgMsgMapper::SetAttachmentFlagL( const TMsvEmailEntry& aEntry,
-										   TBool aHasAttachment )
+void CIpsPlgMsgMapper::SetAttachmentFlagL( const TMsvEmailEntry& /*aEntry*/,
+										   TBool /*aHasAttachment*/ )
 	{
 	FUNC_LOG;
-	CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() );
+	// <qmail> commented out, causing freeze in message list
+	/*CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() );
 	CleanupStack::PushL( cEntry );
 	// Only text/calendar part included as attachment
 	TMsvEmailEntry entryToBeChanged( aEntry );
 	entryToBeChanged.SetAttachment( aHasAttachment );
 
-// <qmail> Function called sync in Qmail
 	cEntry->ChangeL( entryToBeChanged );
-	CleanupStack::PopAndDestroy( cEntry );
+	CleanupStack::PopAndDestroy( cEntry );*/
 // </qmail>
 	}
-// </cmail>
-
-// <cmail>
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 void CIpsPlgMsgMapper::GetCharsetParameterL(
--- a/ipsservices/ipssosplugin/src/ipsplgonlineoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgonlineoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -36,14 +36,15 @@
 // ----------------------------------------------------------------------------
 // <qmail> priority parameter has been removed
 // <qmail> MFSMailRequestObserver& changed to pointer
-// <qmail> aSignallingAllowed parameter has been removed
+// <qmail> aSignallingAllowed parameter has been returned
 CIpsPlgOnlineOperation::CIpsPlgOnlineOperation(
     CMsvSession& aMsvSession,
     TRequestStatus& aObserverRequestStatus,
     CIpsPlgTimerOperation& aActivityTimer,
     TFSMailMsgId aFSMailBoxId,
     MFSMailRequestObserver* aFSOperationObserver,
-    TInt aFSRequestId )
+    TInt aFSRequestId,
+    TBool aSignallingAllowed )
     :
     CIpsPlgBaseOperation(
         aMsvSession, 
@@ -55,6 +56,7 @@
     iMtmReg( NULL ), 
     iSubOperation( NULL ),
     iError( KErrNone ),
+    iSignallingAllowed( aSignallingAllowed ),
     iFSOperationObserver( aFSOperationObserver )
     {
     FUNC_LOG;
@@ -216,7 +218,9 @@
     {
     FUNC_LOG;
     // <qmail> clean up this function
-    if( iFSOperationObserver )
+    // <qmail>
+    if( iSignallingAllowed )
+    // </qmail>    
         {
         // Initialize the progress data
         TFSProgress prog = { TFSProgress::EFSStatus_RequestComplete, 1, 1, aStatus, NULL };
@@ -226,9 +230,13 @@
             {
             prog.iProgressStatus = TFSProgress::EFSStatus_RequestCancelled;
             }
-        
-        // do the actual signalling
-        TRAP_IGNORE( iFSOperationObserver->RequestResponseL( prog, iFSRequestId ) );
+        // <qmail>
+        if( iFSOperationObserver )
+            {
+            // do the actual signalling
+            TRAP_IGNORE( iFSOperationObserver->RequestResponseL( prog, iFSRequestId ) );
+            }
+        // </qmail>
         }
     }
 
--- a/ipsservices/ipssosplugin/src/ipsplgoperationwait.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*       Simple wait operation for async functions
-*
-*/
-
-
-#include "emailtrace.h"
-#include "ipsplgheaders.h"
-
-
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-CIpsPlgOperationWait* CIpsPlgOperationWait::NewL( 
-    TInt aPriority )
-    {
-    FUNC_LOG;
-    CIpsPlgOperationWait* self = CIpsPlgOperationWait::NewLC( aPriority );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-CIpsPlgOperationWait* CIpsPlgOperationWait::NewLC( 
-    TInt aPriority )
-    {
-    FUNC_LOG;
-    CIpsPlgOperationWait* self = new( ELeave ) CIpsPlgOperationWait( aPriority );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-CIpsPlgOperationWait::CIpsPlgOperationWait( TInt aPriority ) : CActive( aPriority )
-    {
-    FUNC_LOG;
-    }
-    
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-CIpsPlgOperationWait::~CIpsPlgOperationWait()
-    {
-    FUNC_LOG;
-    Cancel();
-    }
-    
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-void CIpsPlgOperationWait::ConstructL()
-    {
-    FUNC_LOG;
-    CActiveScheduler::Add( this );
-    }
-
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-void CIpsPlgOperationWait::Start( )
-    {
-    FUNC_LOG;
-    SetActive();
-    iWait.Start();
-    }
-    
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-void CIpsPlgOperationWait::DoCancel()
-    {
-    FUNC_LOG;
-    if( iStatus == KRequestPending )
-        {
-        TRequestStatus* s=&iStatus;
-        User::RequestComplete( s, KErrCancel );
-        }
-    StopScheduler();
-    }
-    
-// ---------------------------------------------------------------------------
-// ---------------------------------------------------------------------------
-//
-void CIpsPlgOperationWait::RunL()
-    {
-    FUNC_LOG;
-    StopScheduler();
-    }
-
-void CIpsPlgOperationWait::StopScheduler()
-    {
-    FUNC_LOG;
-    if ( iWait.IsStarted() )
-        {
-        /*if (iWait.CanStopNow())
-            {*/
-        iWait.AsyncStop();
-        /*    }
-        else
-            {
-            iWait.AsyncStop(TCallBack(SchedulerStoppedCallBack, env));
-            }*/
-        }
-    }
-
--- a/ipsservices/ipssosplugin/src/ipsplgpop3connectop.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgpop3connectop.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -30,7 +30,8 @@
 // CIpsPlgPop3ConnectOp::NewL()
 // ----------------------------------------------------------------------------
 // <qmail> MFSMailRequestObserver& changed to pointer
-// <qmail> aSignallingAllowed parameter removed
+// <qmail> aSignallingAllowed parameter added
+// <qmail> aFetchWillFollow parameter added
 CIpsPlgPop3ConnectOp* CIpsPlgPop3ConnectOp::NewL(
     CMsvSession& aMsvSession,                           
     TRequestStatus& aObserverRequestStatus,
@@ -40,7 +41,9 @@
     TFSMailMsgId aFSMailBoxId,
     MFSMailRequestObserver* aFSOperationObserver,
     TInt aFSRequestId,
-    CIpsPlgEventHandler* aEventHandler )
+    CIpsPlgEventHandler* aEventHandler,
+    TBool aSignallingAllowed,
+    TBool aFetchWillFollow )
     {
     FUNC_LOG;
     CIpsPlgPop3ConnectOp* op = new(ELeave) CIpsPlgPop3ConnectOp(
@@ -52,7 +55,9 @@
         aFSMailBoxId,
         aFSOperationObserver,
         aFSRequestId,
-        aEventHandler );
+        aEventHandler,
+        aSignallingAllowed,
+        aFetchWillFollow );
 
     CleanupStack::PushL( op );
     op->ConstructL();
@@ -112,7 +117,7 @@
 void CIpsPlgPop3ConnectOp::DoRunL()
     {
     FUNC_LOG;
-    // <qmail> move TInt err declaration later, and narrow the scope
+    TInt err( KErrNone );
 
     // <qmail> remove EQueryingDetails state
     if ( iState == EStartConnect )
@@ -133,35 +138,46 @@
     else if ( iState == EConnected )
         {
         // Connect completed
-// <qmail> Login details checking removed
-        User::LeaveIfError( iStatus.Int() );
+        // <qmail> Login details checking removed
+        err = GetOperationErrorCodeL( );
+        User::LeaveIfError( err );
+
         if ( iForcePopulate && Connected() )
             {
             iState = EPopulate;
             DoPopulateL();
             }
+        // <qmail>
+        else if( iFetchWillFollow && Connected() )
+            {
+            // Leave connection open to make fetch
+            // operation possible
+            iState = EIdle;
+            CompleteObserver( KErrNone );
+            }
+        // </qmail>
         else
             {
             // <qmail>
             // start disconnecting
             iState = EDisconnecting;
-            DoDisconnect();
+            DoDisconnectL();
             // </qmail>
             }
         }
     else if ( iState == EPopulate )
         {
-        // <qmail> suboperation has completed, the result is in 'this->iStatus'
+        err = GetOperationErrorCodeL( );
         if ( iEventHandler )
             {
-            iEventHandler->SetNewPropertyEvent( iService, KIpsSosEmailSyncCompleted, iStatus.Int() );
+            iEventHandler->SetNewPropertyEvent( iService, KIpsSosEmailSyncCompleted, err );
             }
         CIpsPlgSyncStateHandler::SaveSuccessfulSyncTimeL( iMsvSession, iService );
 
         // <qmail>
         // start disconnecting
         iState = EDisconnecting;
-        DoDisconnect();
+        DoDisconnectL();
         // </qmail>
         }
     // <qmail>
@@ -240,7 +256,9 @@
 //
 // <qmail> priority parameter has been removed
 // <qmail> MFSMailRequestObserver& changed to pointer
-// <qmail> aSignallingAllowed parameter removed
+// <qmail> aSignallingAllowed parameter added
+// <qmail> aFetchWillFollow parameter added
+// <qmail> iAlreadyConnected removed
 CIpsPlgPop3ConnectOp::CIpsPlgPop3ConnectOp(
     CMsvSession& aMsvSession,
     TRequestStatus& aObserverRequestStatus,
@@ -250,7 +268,9 @@
     TFSMailMsgId aFSMailBoxId,
     MFSMailRequestObserver* aFSOperationObserver,
     TInt aFSRequestId,
-    CIpsPlgEventHandler* aEventHandler )
+    CIpsPlgEventHandler* aEventHandler,
+    TBool aSignallingAllowed,
+    TBool aFetchWillFollow )
     :
     CIpsPlgOnlineOperation(
         aMsvSession,
@@ -258,11 +278,12 @@
         aActivityTimer, 
         aFSMailBoxId,
         aFSOperationObserver, 
-        aFSRequestId ),
+        aFSRequestId,
+        aSignallingAllowed ),
     iState( EIdle ),
     iForcePopulate( aForcePopulate ),
     iEventHandler( aEventHandler ),
-    iAlreadyConnected( EFalse )
+    iFetchWillFollow( aFetchWillFollow )
     {
     iService = aServiceId; 
     }
@@ -297,7 +318,7 @@
     if ( tentry.Connected() )
         {      
         iState = EConnected;
-		iAlreadyConnected = ETrue;
+        // <qmail> iAlreadyConnected removed
         }
     else
         {
@@ -367,13 +388,35 @@
 
 // <qmail> removed QueryUsrPassL() from here as unneeded
 // <qmail> removed ValidateL() (did nothing)
-// <qmail> removed TInt CIpsPlgPop3ConnectOp::GetOperationErrorCodeL( )
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------    
+// 
+TInt CIpsPlgPop3ConnectOp::GetOperationErrorCodeL( )
+    {
+    FUNC_LOG;
+    if ( !iSubOperation )
+        {
+        return KErrNotFound;
+        }
+    if ( !iSubOperation->IsActive() && iSubOperation->iStatus.Int() != KErrNone )
+        {
+        return iSubOperation->iStatus.Int();
+        }
+    
+    TPckgBuf<TPop3Progress> paramPack;
+    paramPack.Copy( iSubOperation->ProgressL() );
+    const TPop3Progress& progress = paramPack();
+    
+    return progress.iErrorCode;
+    }
+
 // <qmail> removed CIpsPlgImap4ConnectOp::CredientialsSetL
 
 //<qmail> new functions
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
-void CIpsPlgPop3ConnectOp::DoDisconnect()
+void CIpsPlgPop3ConnectOp::DoDisconnectL()
     {
     FUNC_LOG;
     // <qmail> unnecessary: iStatus = KRequestPending;
@@ -398,7 +441,7 @@
     if ( limit > 0 )
         {
         // basically doing a _very_rough_ conversion from kilobyte value to number-of-rows
-    limit = ( limit * KPopulateAlgorithmBytesInKilo ) / KPopulateAlgorithmRowLength;
+        limit = ( limit * KPopulateAlgorithmBytesInKilo ) / KPopulateAlgorithmRowLength;
         }
     CleanupStack::PopAndDestroy( 2, settings );
     return limit;
--- a/ipsservices/ipssosplugin/src/ipsplgpop3fetchoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgpop3fetchoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -145,20 +145,21 @@
 
     iState = EStateConnecting;
     iStatus = KRequestPending;
-    
-    // when connecting for the fetch operation, don't let connect operation to do fetch,
-    // because we do it by ourself. That's why give 0 to connect operation.    
+    // <qmail>
     CIpsPlgPop3ConnectOp* connOp = CIpsPlgPop3ConnectOp::NewL(
         iMsvSession,
         iStatus, 
         iService, 
-        EFalse, 
+        EFalse, // We do fetch by ourselves
         *iActivityTimer,
         iFSMailboxId, 
         iFSOperationObserver, 
         iFSRequestId, 
-        NULL );
+        NULL,
+        EFalse, // Signalling not allowed
+        ETrue ); // Fetch will follow, let connection be open
         
+    // </qmail>    
     delete iSubOperation;
     iSubOperation = connOp;
 
@@ -344,9 +345,8 @@
                 progress.iErrorCode = err;
                 iFetchErrorProgress = paramPack.AllocL();
                 }
+            DoDisconnectL();
             
-            iState = EStateIdle;
-            CompleteObserver( err );
             if ( iEventHandler )
                 {
 				// <qmail>
@@ -355,6 +355,11 @@
                 }
             }
             break;
+        case EStateDisconnecting:
+            {
+            CompleteObserver( iStatus.Int() );
+            }
+            break;
             
         default:
             break;
@@ -409,3 +414,16 @@
     }
 // </qmail>
 
+//<qmail> new function
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsPlgPop3FetchOperation::DoDisconnectL()
+    {
+    FUNC_LOG;
+    iState = EStateDisconnecting;
+    InvokeClientMtmAsyncFunctionL( KPOP3MTMDisconnect, iService ); // <qmail> 1 param removed
+    SetActive();
+    }
+// </qmail>
+
+
--- a/ipsservices/ipssosplugin/src/ipsplgpop3plugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgpop3plugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -19,6 +19,7 @@
 #include "emailtrace.h"
 #include "ipsplgheaders.h"
 
+//<qmail> removed
 
 // ---------------------------------------------------------------------------
 // CIpsPlgPop3Plugin::CIpsPlgPop3Plugin
@@ -138,7 +139,8 @@
 void CIpsPlgPop3Plugin::RefreshNowL(
     const TFSMailMsgId& aMailBoxId,
     MFSMailRequestObserver& aOperationObserver,
-    TInt aRequestId )
+    TInt aRequestId,
+    const TBool /*aSilentConnection*/ )
     {
     FUNC_LOG;
     TMsvId service = aMailBoxId.Id();
@@ -163,12 +165,11 @@
     TInt populationLimit( settings->PopulationLimit() );
     CleanupStack::PopAndDestroy( 2, settings );   // >>> settings, accounts
     TBool forcePopulate( EFalse );
-// <qmail>
-    /*
+// <qmail> back to use
     if( populationLimit != KIpsSetDataHeadersOnly )
         {
         forcePopulate = ETrue;
-        }*/
+        }
 // </qmail>
     
     CIpsPlgBaseOperation* op = CIpsPlgPop3ConnectOp::NewL( 
@@ -188,10 +189,8 @@
     iOperations.AppendL( watcher );
     CleanupStack::Pop( watcher );   // >> watcher
     	
-//<qmail>
     // send part of refresh
-    //EmptyOutboxL( aMailBoxId ); // not used in qmail yet
-//</qmail>
+    EmptyOutboxL( aMailBoxId );
     }
 
 // ---------------------------------------------------------------------------
@@ -273,14 +272,13 @@
  	
  	if( aFolderType==EFSInbox )
         {
-        //in case of pop3, mailbox id == service id == inbox id
-        CMsvEntry* cEntry = iSession->GetEntryL( aMailBoxId.Id() );
-        CleanupStack::PushL( cEntry );
-        if ( cEntry->Count() != 0 )
-            {
-            result.SetId( aMailBoxId.Id() );
-            }
-        CleanupStack::PopAndDestroy( cEntry );
+        //<qmail> removed CMsvEntry conversion 
+ 	
+        // In case of pop3, mailbox id == service id == inbox id,
+        // so no need to create CMsvEntry from mailbox id to
+        // dig if any children exists.
+        result.SetId( aMailBoxId.Id() );
+        //</qmail>
         }
     else if( aFolderType==EFSOutbox )
         {
--- a/ipsservices/ipssosplugin/src/ipsplgsmtpoperation.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgsmtpoperation.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -370,14 +370,14 @@
             // is it safe to change flag from suspended to waiting?
             if ( sendState == KMsvSendStateSuspended )
                 {
+                // <qmail> remove activeschedulerwait
                 CMsvEntry* cEntry = CMsvEntry::NewL(
                     iMsvSession, entry.Id(), TMsvSelectionOrdering() );
                 CleanupStack::PushL( cEntry );
-                CIpsPlgOperationWait* wait = CIpsPlgOperationWait::NewLC( );
                 entry.SetSendingState( KMsvSendStateWaiting );
-                cEntry->ChangeL( entry, wait->iStatus );
-                wait->Start();
-                CleanupStack::PopAndDestroy(2, cEntry ); // wait, cEntry
+                cEntry->ChangeL( entry );
+                CleanupStack::PopAndDestroy( cEntry ); // cEntry
+                // </qmail>
                 }
             // add to send list
             iSelection->AppendL( entry.Id() );
--- a/ipsservices/ipssosplugin/src/ipsplgsmtpservice.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgsmtpservice.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -242,268 +242,11 @@
     CleanupStack::PopAndDestroy( 3, cEntry );   // >>> cEntry, header, store
     }
 
-// ---------------------------------------------------------------------------
-// CIpsPlgSmtpService::CreateNewSmtpMessageL
-// ---------------------------------------------------------------------------
-//
-CFSMailMessage* CIpsPlgSmtpService::CreateNewSmtpMessageL( 
-    const TFSMailMsgId& aMailBoxId )
-    {
-    FUNC_LOG;
-    TMsvPartList partList( KMsvMessagePartBody );
-    
-    CIpsPlgOperationWait* wait = CIpsPlgOperationWait::NewLC( );
-    
-    TMsvEntry mboxEntry;
-    TMsvId service;
-    iSession.GetEntry( aMailBoxId.Id(), service, mboxEntry );
-    
-    // new mail creating operation. Mail is created asynchronously
-    CImEmailOperation* newMailOp = CImEmailOperation::CreateNewL(
-            wait->iStatus, 
-            iSession,
-            KMsvDraftEntryId,
-            mboxEntry.iRelatedId, 
-            partList, 
-            0, 
-            KUidMsgTypeSMTP );
-    
-    CleanupStack::PushL( newMailOp );
-
-    // wait until new mail is created
-    wait->Start();
-   
-    TMsvId msgId = GetIdFromProgressL( newMailOp->FinalProgress() );
-    
-    CleanupStack::PopAndDestroy( 2, wait );
-    
-    return CreateFSMessageAndSetFlagsL( 
-            msgId, KErrNotFound, aMailBoxId.Id() );
-    }
-    
-// ---------------------------------------------------------------------------
-// CIpsPlgSmtpService::CreateForwardSmtpMessageL
-// ---------------------------------------------------------------------------
-//
-CFSMailMessage* CIpsPlgSmtpService::CreateForwardSmtpMessageL( 
-    const TFSMailMsgId& aMailBoxId,
-    const TFSMailMsgId& aOriginalMessageId )
-    {
-    FUNC_LOG;
-    // 1. part of function checs that body text and all
-    // attachments are fetched
-    TMsvEntry orgMsg;
-    TMsvId service;
-    User::LeaveIfError( iSession.GetEntry( 
-            aOriginalMessageId.Id(), service, orgMsg ) );
-    
-    if ( orgMsg.Id() ==  KMsvNullIndexEntryIdValue )
-        {
-        User::Leave(KErrNotFound);
-        }
-    
-    // In case original message is in Sent folder, it's serviceId must be
-    // changed before starting forward/reply msg creation operation
-    // (after forward msg is created, this is changed back)
-    TMsvId orgServiceId( 0 );
-    if ( ( orgMsg.Parent() == KMsvSentEntryIdValue ) && 
-         ( orgMsg.iMtm == KSenduiMtmSmtpUid ) )
-        {
-        orgServiceId = orgMsg.iServiceId;
-        ChangeServiceIdL( orgMsg );
-        }
-
-    TMsvPartList partList( KMsvMessagePartBody | KMsvMessagePartAttachments );
-    
-    CIpsPlgOperationWait* wait = CIpsPlgOperationWait::NewLC( );
-    CImEmailOperation* forwMailOp = CImEmailOperation::CreateForwardL(
-            wait->iStatus, 
-            iSession,
-            orgMsg.Id(),
-            KMsvDraftEntryId, 
-            partList, 
-            0, 
-            KUidMsgTypeSMTP );
-            
-    CleanupStack::PushL( forwMailOp );
-    
-    wait->Start();
-    
-    TMsvId msgId = GetIdFromProgressL( forwMailOp->FinalProgress() );
-    
-    CleanupStack::PopAndDestroy( 2, wait );
-
-    // If original message's serviceId was changed prior to forward/reply msg
-    // creation op, changing it back to the original
-    if ( orgServiceId )
-        {
-        ChangeServiceIdL( orgMsg, orgServiceId );
-        }
-    
-    return CreateFSMessageAndSetFlagsL( msgId, orgMsg.Id(), aMailBoxId.Id() );
-    }
-    
-// ---------------------------------------------------------------------------
-// CIpsPlgSmtpService::CreateReplySmtpMessageL
-// ---------------------------------------------------------------------------
-//
-CFSMailMessage* CIpsPlgSmtpService::CreateReplySmtpMessageL( 
-    const TFSMailMsgId& aMailBoxId,
-    const TFSMailMsgId& aOriginalMessageId,
-    TBool aReplyToAll )
-    {
-    FUNC_LOG;
-    // find orginal message header and check that body is fetched
-    TMsvEntry orgMsg;
-    TMsvId service;
-    User::LeaveIfError( 
-        iSession.GetEntry( aOriginalMessageId.Id(), service, orgMsg ) );
-    
-    if ( orgMsg.Id() ==  KMsvNullIndexEntryIdValue )
-        {
-        User::Leave(KErrNotFound);
-        }
-    
-    // In case original message is in Sent folder, it's serviceId must be
-    // changed before starting forward/reply msg creation operation
-    // (after forward msg is created, this is changed back)
-    TMsvId orgServiceId( 0 );
-    if ( ( orgMsg.Parent() == KMsvSentEntryIdValue ) && 
-         ( orgMsg.iMtm == KSenduiMtmSmtpUid ) )
-        {
-        orgServiceId = orgMsg.iServiceId;
-        ChangeServiceIdL( orgMsg );
-        }
-    
-    // partList flags control e.g. what kind of recipient set is created
-    TMsvPartList partList = KMsvMessagePartBody | KMsvMessagePartDescription
-    | KMsvMessagePartOriginator;        
-    if( aReplyToAll )
-        {
-        partList |= KMsvMessagePartRecipient;
-        }
-    
-    // Ask Symbian messaging fw to create reply message "skeleton"
-    CIpsPlgOperationWait* wait = CIpsPlgOperationWait::NewLC( );
-    CImEmailOperation* replMailOp = CImEmailOperation::CreateReplyL(
-            wait->iStatus, 
-            iSession,
-            orgMsg.Id(),
-            KMsvDraftEntryId, 
-            partList, 
-            0, 
-            KUidMsgTypeSMTP );
-    CleanupStack::PushL( replMailOp );
-    wait->Start();
-    TMsvId msgId = GetIdFromProgressL( replMailOp->FinalProgress() );
-    CleanupStack::PopAndDestroy( 2, wait );
-    
-    // If original message's serviceId was changed prior to forward/reply msg
-    // creation op, changing it back to the original
-    if ( orgServiceId )
-        {
-        ChangeServiceIdL( orgMsg, orgServiceId );
-        }
-
-    // Start finalising new FS style message
-    CFSMailMessage* fsMsg = CreateFSMessageAndSetFlagsL( 
-            msgId, orgMsg.Id(), aMailBoxId.Id() );
-    CleanupStack::PushL( fsMsg ); // ***
-
-    // dig out new reply message's header
-    CMsvEntry* cEntry = iSession.GetEntryL( msgId );
-    CleanupStack::PushL( cEntry ); // ***
-    CMsvStore* store = cEntry->ReadStoreL();
-    CleanupStack::PushL( store ); // ***
-    if( store->IsPresentL( KUidMsgFileIMailHeader ) == EFalse )
-         {
-         User::Leave(KErrCorrupt);
-         }
-    CImHeader* header = CImHeader::NewLC(); // ***
-    header->RestoreL( *store );
-
-    // Start handling recipients
-    HBufC* emailAddr( NULL );
-    CFSMailAddress* fsAddr( NULL );
-    // copy to recipients
-    for( TInt i = 0; i < header->ToRecipients().Count(); i++ )
-        {
-        emailAddr = header->ToRecipients()[i].AllocLC(); // ***
-        fsAddr = CFSMailAddress::NewLC(); // ***
-        fsAddr->SetEmailAddress( *emailAddr ); // Copy created
-        fsMsg->AppendToRecipient( fsAddr ); // No copy
-        CleanupStack::Pop( fsAddr ); // fsAddr belong now to fsMsg
-        CleanupStack::PopAndDestroy( emailAddr ); // emailAddr not used
-        }
-    // copy cc recipients
-    // <cmail>
-    TFSMailMsgId folderId;
-    TFSMailDetails details( EFSMsgDataEnvelope );
-    CFSMailMessage* originalMessage = iPlugin.GetMessageByUidL( aMailBoxId, 
-                                       folderId, aOriginalMessageId, details );
-    CleanupStack::PushL( originalMessage );
-// <qmail> return by value, because Qt types are used for internal CFSMailAddress data storage
-    const RPointerArray<CFSMailAddress>& originalToRecipients = 
-                                            originalMessage->GetToRecipients();
+// <qmail> removing unused functions
+// CreateNewSmtpMessageL
+// CreateForwardSmtpMessageL
+// CreateReplySmtpMessageL
 // </qmail>
-    TInt originalToRecipientsCount = originalToRecipients.Count(); 
-    TBool present = EFalse;
-    // </cmail>
-    for( TInt i = 0; i < header->CcRecipients().Count(); i++ )
-        {
-        emailAddr = header->CcRecipients()[i].AllocLC(); // ***
-        fsAddr = CFSMailAddress::NewLC(); // ***
-        fsAddr->SetEmailAddress( *emailAddr ); // Copy created
-        // <cmail>
-        if( aReplyToAll )
-            {
-            // check if CC recipient read from header was present in To field
-            // of original message. If so, copy it into To recipietns
-            present = EFalse;
-            for( TInt j = 0; j < originalToRecipientsCount; j++ )
-                {
-                if( emailAddr->Find( originalToRecipients[j]->GetEmailAddress())
-                                                              != KErrNotFound )
-                    {
-                    present = ETrue;
-                    break;
-                    }
-                }
-            if( present )
-                {
-                fsMsg->AppendToRecipient( fsAddr ); // No copy
-                }
-            else
-                {
-                fsMsg->AppendCCRecipient( fsAddr ); // No copy
-                }
-            }
-        else
-        {
-            fsMsg->AppendCCRecipient( fsAddr ); // No copy
-        }
-        // </cmail>
-        CleanupStack::Pop( fsAddr ); // fsAddr belong now to fsMsg
-        CleanupStack::PopAndDestroy( emailAddr ); // emailAddr not used
-        }
-    // <cmail>
-    CleanupStack::PopAndDestroy( originalMessage );
-    // </cmail>
-    // copy bcc recipients
-    for( TInt i = 0; i < header->BccRecipients().Count(); i++ )
-        {
-        emailAddr = header->BccRecipients()[i].AllocLC(); // ***
-        fsAddr = CFSMailAddress::NewLC(); // ***
-        fsAddr->SetEmailAddress( *emailAddr ); // Copy created
-        fsMsg->AppendBCCRecipient( fsAddr ); // No copy
-        CleanupStack::Pop( fsAddr ); // fsAddr belong now to fsMsg
-        CleanupStack::PopAndDestroy( emailAddr ); // emailAddr not used
-        }
-
-    CleanupStack::PopAndDestroy( 3, cEntry ); // header, store, cEntry
-    CleanupStack::Pop( fsMsg ); // fsMsg is given to client
-    return fsMsg;
-    }
 
 // ---------------------------------------------------------------------------
 // CIpsPlgSmtpService::ChangeServiceIdL
--- a/ipsservices/ipssosplugin/src/ipsplgsosbaseplugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/ipssosplugin/src/ipsplgsosbaseplugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -25,26 +25,45 @@
 #include "ipsplgmailstoreroperation.h"
 #include "ipsplgmessagepartstoreroperation.h"
 #include "BasePlugin.h" 
+//<Qmail>
+#include "ipssosextendedsettingsmanager.h"
+#include "ipssettingkeys.h"
+//</Qmail>
 //</qmail>
 
-// <cmail> S60 UID update
 #define FREESTYLE_EMAIL_UI_SID 0x200255BA
-// </cmail> S60 UID update
 
 const TInt KOpGranularity = 2;
 
-_LIT( KMimeTextCalRequest,  "text/calendar; method=REQUEST;" );
-_LIT( KMimeTextCalResponse, "text/calendar; method=RESPONSE;" );
-_LIT( KMimeTextCalCancel,   "text/calendar; method=CANCEL;" );
-_LIT8( KMethod, "method" );
-_LIT8( KRequest, "REQUEST" );
-_LIT8( KResponse, "RESPONSE" );
-_LIT8( KCancel, "CANCEL" );
+// <qmail> remove unused literals
 
 #ifdef __WINS__
 _LIT( KEmulatorIMEI, "123456789012345" );
 #endif // __WINS__
 
+//<Qmail>
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsPlgSosBasePlugin::ActiveFolderChanged(
+        const TFSMailMsgId& aActiveMailboxId,
+        const TFSMailMsgId& aActiveFolderId)
+    {
+    TRAP_IGNORE( HandleActiveFolderChangeL(aActiveMailboxId,aActiveFolderId) );
+    }
+
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+CEmailExtension* CIpsPlgSosBasePlugin::ExtensionL( const TUid& aInterfaceUid )
+    {
+    if(aInterfaceUid != KEmailMailboxStateExtensionUid)
+        {
+        User::Leave(KErrNotSupported);
+        }
+    
+    return iStateExtension;
+    }
+//</Qmail>
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // <qmail> iSettingsApi removed
@@ -83,6 +102,7 @@
         {
         iEventHandler->UnRegisterPropertyObserver( iSyncStateHandler );
         }
+    delete iStateExtension;
     delete iEventHandler;
     delete iCachedEntry;
     delete iCachedEmailMessage;
@@ -98,6 +118,7 @@
 void CIpsPlgSosBasePlugin::BaseConstructL()
     {
     FUNC_LOG;
+    iStateExtension = CIpsStateExtension::NewL(*this);
     iEventHandler = CIpsPlgEventHandler::NewL( *this );
     iSession = CMsvSession::OpenAsyncL( *iEventHandler );
     iMsgMapper = CIpsPlgMsgMapper::NewL( *iSession, *this );
@@ -497,16 +518,13 @@
         }
     if( sel->Count() )
         {
-        CIpsPlgOperationWait* wait = CIpsPlgOperationWait::NewLC();
+        // <qmail> remove activeschedulerwait
+        TMsvLocalOperationProgress progress;
         if( !aSourceFolderId.IsNullId() )
             {
             CMsvEntry* cEntry = iSession->GetEntryL( aSourceFolderId.Id() );
             CleanupStack::PushL( cEntry );
-            cEntry->MoveL(
-                *sel,
-                           aDestinationFolderId.Id(),//KMsvDraftEntryIdValue
-                           wait->iStatus );
-
+            cEntry->MoveL( *sel, aDestinationFolderId.Id(), progress );
             CleanupStack::PopAndDestroy( cEntry );
             }
         else
@@ -515,13 +533,10 @@
             // because it's equal to destination.
             TMsvId parent = msgEntry->Entry().Parent();
             msgEntry->SetEntryL( parent );
-            msgEntry->CopyL(
-                *sel,
-                             aDestinationFolderId.Id(),//KMsvDraftEntryIdValue
-                             wait->iStatus );
+            msgEntry->CopyL( *sel, aDestinationFolderId.Id(), progress );
             }
-        wait->Start();
-        CleanupStack::PopAndDestroy( wait ); // wait
+        User::LeaveIfError( progress.iError );
+        // </qmail>
         }
     CleanupStack::PopAndDestroy( 2, sel ); // msgEntry, sel
     }
@@ -810,11 +825,11 @@
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
  CFSMailMessage* CIpsPlgSosBasePlugin::CreateMessageToSendL(
-    const TFSMailMsgId& aMailBoxId )
+    const TFSMailMsgId& /*aMailBoxId*/ )
 	{
-    FUNC_LOG;
-    CFSMailMessage* msg = iSmtpService->CreateNewSmtpMessageL( aMailBoxId );
-	return msg;
+    // <qmail> not used any more
+    User::Leave(KErrFSMailPluginNotSupported);
+    return NULL; // prevents compiler warning
 	}
 
 // <qmail>
@@ -851,26 +866,13 @@
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 CFSMailMessage* CIpsPlgSosBasePlugin::CreateForwardMessageL(
-    const TFSMailMsgId& aMailBoxId,
-    const TFSMailMsgId& aOriginalMessageId,
-    const TDesC& aHeaderDescriptor )
+    const TFSMailMsgId& /*aMailBoxId*/,
+    const TFSMailMsgId& /*aOriginalMessageId*/,
+    const TDesC& /*aHeaderDescriptor*/ )
     {
-    FUNC_LOG;
-    CFSMailMessage* msg = iSmtpService->CreateForwardSmtpMessageL(
-        aMailBoxId, aOriginalMessageId );
-    
-    if ( aHeaderDescriptor != KNullDesC )
-        {
-        // Ignoring trap as it is better to provide something in case of the
-        // below fix method fails than nothing.
-        TRAP_IGNORE( FixReplyForwardHeaderL( 
-                        msg, 
-                        aMailBoxId, 
-                        aOriginalMessageId, 
-                        aHeaderDescriptor ) );
-        }
-  
-    return msg;
+    // <qmail> not used any more
+    User::Leave(KErrFSMailPluginNotSupported);
+    return NULL; // prevents compiler warning
     }
 
 // <qmail>
@@ -929,27 +931,14 @@
 // ----------------------------------------------------------------------------
 // ---------------------------------------------------------------------------- 	
 CFSMailMessage* CIpsPlgSosBasePlugin::CreateReplyMessageL( 
-    const TFSMailMsgId& aMailBoxId,
-    const TFSMailMsgId& aOriginalMessageId,
-    const TBool aReplyToAll,
-    const TDesC& aHeaderDescriptor )
+    const TFSMailMsgId& /*aMailBoxId*/,
+    const TFSMailMsgId& /*aOriginalMessageId*/,
+    const TBool /*aReplyToAll*/,
+    const TDesC& /*aHeaderDescriptor*/ )
     {
-    FUNC_LOG;
-    CFSMailMessage* msg = iSmtpService->CreateReplySmtpMessageL(
-        aMailBoxId, aOriginalMessageId, aReplyToAll );
-
-    if ( aHeaderDescriptor != KNullDesC )
-        {
-        // Ignoring trap as it is better to provide something in case of the
-        // below fix method fails than nothing.
-        TRAP_IGNORE( FixReplyForwardHeaderL( 
-                                msg, 
-                                aMailBoxId, 
-                                aOriginalMessageId, 
-                                aHeaderDescriptor ) );
-        }
-
-    return msg;
+    // <qmail> not used any more
+    User::Leave(KErrFSMailPluginNotSupported);
+    return NULL; // prevents compiler warning
     }
 
 // <qmail>
@@ -1151,147 +1140,20 @@
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 CFSMailMessagePart* CIpsPlgSosBasePlugin::NewChildPartFromFileL(
-    const TFSMailMsgId& aMailBoxId,
-    const TFSMailMsgId& /* aParentFolderId */,
-    const TFSMailMsgId& aMessageId,
-    const TFSMailMsgId& /* aParentPartId */,
-    const TDesC& aContentType,
-    const TDesC& aFilePath )
+    const TFSMailMsgId& /*aMailBoxId*/,
+    const TFSMailMsgId& /*aParentFolderId*/,
+    const TFSMailMsgId& /*aMessageId*/,
+    const TFSMailMsgId& /*aParentPartId*/,
+    const TDesC& /*aContentType*/,
+    const TDesC& /*aFilePath*/ )
     {
-    FUNC_LOG;
-    CFSMailMessagePart* result ( NULL );
-    CMsvEntry* cEntry( NULL );
-    CImEmailMessage* message( NULL );
-    RFile file;
-    TInt fileSize( 0 );
-    TBool parentToMultipartAlternative( EFalse );
-
-    // Read attachment size
-    User::LeaveIfError( file.Open( iSession->FileSession(), aFilePath, EFileShareReadersOnly ) );
-
-    //in rare case that file has disappeared while sending
-    //we just won't get the size for it
-    file.Size( fileSize );
-    file.Close();
-
-  // Take ownership of message entry objects since thanks to
-    // "clever" use of active scheduler waits we can re-enter 
-    // this function leading to crashes if somebody clears the cache
-    // while this iteration still needs them
-    TakeMessageEntryLC( aMessageId.Id(), cEntry, message );
-	
-    // Operation waiter needed to implement synchronous operation
-    // on the top of async API
-    CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewL();
-    CleanupStack::PushL( waiter );
-
-    // Initialize CMsvAttachment instance for the attachment creation
-    CMsvAttachment* info = CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
-    CleanupStack::PushL( info );
-    info->SetAttachmentNameL( aFilePath );
-    info->SetSize( fileSize );
-
-    // Start attachment creation
-    message->AttachmentManager().AddAttachmentL(
-        aFilePath, info, waiter->iStatus );
-    CleanupStack::Pop( info ); // attachment manager takes ownership
-
-    waiter->Start();
-    CleanupStack::PopAndDestroy( waiter );
-    	
-    // Return message entry objects back to cache
-    CleanupStack::Pop( 2 ); // cEntry, message
-    ReturnMessageEntry( cEntry, message );
-
-    // Dig out the entry ID of the new attachment (unbelievable that
-    // there seems to be no better way to do this)
-    message->GetAttachmentsListL( cEntry->Entry().Id( ),
-        CImEmailMessage::EAllAttachments, CImEmailMessage::EThisMessageOnly );
-    TKeyArrayFix key( 0, ECmpTInt32 );
-    CMsvEntrySelection* attachmentIds = message->Selection().CopyLC();
-    attachmentIds->Sort( key );
-    if ( !attachmentIds->Count() )
-        {
-        User::Leave( KErrGeneral );
-        }
-    TMsvId newAttachmentId = (*attachmentIds)[ attachmentIds->Count()-1 ];
-    CleanupStack::PopAndDestroy( attachmentIds );
-
-    CMsvEntry* cAtta = iSession->GetEntryL( newAttachmentId );
-    CleanupStack::PushL( cAtta );
-
-    // Set filename to iDetails
-    TMsvEntry tEntry = cAtta->Entry();
-    tEntry.iDetails.Set( aFilePath );
-    cAtta->ChangeL( tEntry );
-
-    if( cAtta->HasStoreL() )
-        {
-        CMsvStore* store = cAtta->EditStoreL();
-        CleanupStack::PushL( store );
-        CImMimeHeader* mimeHeader = CImMimeHeader::NewLC();
-
-        if( store->IsPresentL( KUidMsgFileMimeHeader ) )
-            {
-            mimeHeader->RestoreL( *store );
-            CDesC8Array& array = mimeHeader->ContentTypeParams();
-            array.AppendL( KMethod );
-            parentToMultipartAlternative = ETrue;
-
-            if( aContentType.Find( KMimeTextCalRequest ) != KErrNotFound )
-                {
-                array.AppendL( KRequest );
-                }
-            else if( aContentType.Find( KMimeTextCalResponse ) != KErrNotFound )
-                {
-                array.AppendL( KResponse );
-                }
-            else if( aContentType.Find( KMimeTextCalCancel ) != KErrNotFound )
-                {
-                array.AppendL( KCancel );
-                }
-            else
-                {
-                parentToMultipartAlternative = EFalse;
-                }
-            mimeHeader->StoreWithoutCommitL( *store );
-            store->CommitL();
-            }
-
-        CleanupStack::PopAndDestroy( 2, store );
-        }
-
-    if( parentToMultipartAlternative &&
-        aFilePath.Find( _L(".ics")) != KErrNotFound )
-        {
-        TMsvEntry tAttaEntry = cAtta->Entry();
-        TMsvId id = tAttaEntry.Parent();
-        CMsvEntry* cParent = iSession->GetEntryL( id );
-        CleanupStack::PushL( cParent );
-
-        TMsvEmailEntry tEntry = cParent->Entry();
-        tEntry.SetMessageFolderType( EFolderTypeAlternative );
-        cParent->ChangeL( tEntry );
-
-        CleanupStack::PopAndDestroy( cParent );
-        }
-    CleanupStack::PopAndDestroy( cAtta );
-
-    // Delete the message entries to get all the changes to disk and
-    // possible store locks released
-    CleanCachedMessageEntries();
-
-    // Create the FS message part object
-    result = iMsgMapper->GetMessagePartL( newAttachmentId, aMailBoxId,
-        aMessageId );
-
-    return result;
+    // <qmail> not used any more
+    User::Leave(KErrFSMailPluginNotSupported);
+    return NULL; // prevents compiler warning
     }
 
 // <qmail>
 // ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------  
 void CIpsPlgSosBasePlugin::NewChildPartFromFileL(
     const TFSMailMsgId& aMailBoxId,
@@ -1321,141 +1183,21 @@
     iOperations.AppendL( watcher ); 
     CleanupStack::Pop( watcher );
     }
-
 // </qmail> 
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------  
 CFSMailMessagePart* CIpsPlgSosBasePlugin::NewChildPartFromFileL(
-    const TFSMailMsgId& aMailBoxId,
-    const TFSMailMsgId& /* aParentFolderId */,
-    const TFSMailMsgId& aMessageId,
-    const TFSMailMsgId& /* aParentPartId */,
-    const TDesC& aContentType,
-    RFile& aFile )
+    const TFSMailMsgId& /*aMailBoxId*/,
+    const TFSMailMsgId& /*aParentFolderId*/,
+    const TFSMailMsgId& /*aMessageId*/,
+    const TFSMailMsgId& /*aParentPartId*/,
+    const TDesC& /*aContentType*/,
+    RFile& /*aFile*/ )
     {
-    FUNC_LOG;
-
-    // Initialize helper variables
-    CFSMailMessagePart* result ( NULL );
-    CMsvEntry* cEntry( NULL );
-    CImEmailMessage* message( NULL );
-    TInt fileSize( 0 );
-    TBuf<KMaxFileName> fileName;
-
- // Take ownership of message entry objects since thanks to
-    // "clever" use of active scheduler waits we can re-enter 
-    // this function leading to crashes if somebody clears the cache
-    // while this iteration still needs them
-    TakeMessageEntryLC( aMessageId.Id(), cEntry, message );
-
-    // Operation waiter needed to implement synchronous operation
-    // on the top of async API
-    CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewL();
-    CleanupStack::PushL( waiter );
-
-    // Initialize CMsvAttachment instance for the attachment creation
-    CMsvAttachment* info = CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
-    CleanupStack::PushL( info );
-
-    // Read attachment size
-    User::LeaveIfError( aFile.Size( fileSize ) );
-    info->SetSize( fileSize );
-
-    // Read attachment filename
-    User::LeaveIfError( aFile.FullName( fileName ) );
-    info->SetAttachmentNameL( fileName );
-
-    message->AttachmentManager().AddAttachmentL( aFile, info, waiter->iStatus );
-    CleanupStack::Pop( info ); // attachment manager takes ownership
-    
-    waiter->Start();
-    CleanupStack::PopAndDestroy( waiter );
-
- 	// Return message entry objects back to cache
- 	CleanupStack::Pop( 2 ); // cEntry, message
- 	ReturnMessageEntry( cEntry, message );
-
-    // Dig out the entry ID of the new attachment
-    message->GetAttachmentsListL( cEntry->Entry().Id( ),
-        CImEmailMessage::EAllAttachments, CImEmailMessage::EThisMessageOnly );
-    TKeyArrayFix key( 0, ECmpTInt32 );
-    CMsvEntrySelection* attachmentIds = message->Selection().CopyLC();
-    attachmentIds->Sort( key );
-    if ( !attachmentIds->Count() )
-        {
-        User::Leave( KErrGeneral );
-        }
-    TMsvId newAttachmentId = (*attachmentIds)[ attachmentIds->Count()-1 ];
-    CleanupStack::PopAndDestroy( attachmentIds );
-
-    // Meeting request related handling
-    TBool parentToMultipartAlternative( EFalse );
-    CMsvEntry* cAtta = iSession->GetEntryL( newAttachmentId );
-    CleanupStack::PushL( cAtta );
-
-    // Set filename to iDetails
-    TMsvEntry tEntry = cAtta->Entry();
-    tEntry.iDetails.Set( fileName );
-    cAtta->ChangeL( tEntry );
-
-    if( cAtta->HasStoreL() )
-        {
-        CMsvStore* store = cAtta->EditStoreL();
-        CleanupStack::PushL( store );
-        CImMimeHeader* mimeHeader = CImMimeHeader::NewLC();
-
-        if( store->IsPresentL( KUidMsgFileMimeHeader ) )
-            {
-            mimeHeader->RestoreL( *store );
-            CDesC8Array& array = mimeHeader->ContentTypeParams();
-            array.AppendL( KMethod );
-            parentToMultipartAlternative = ETrue;
-
-            if( aContentType.Find( KMimeTextCalRequest ) != KErrNotFound )
-                {
-                array.AppendL( KRequest );
-                }
-            else if( aContentType.Find( KMimeTextCalResponse ) != KErrNotFound )
-                {
-                array.AppendL( KResponse );
-                }
-            else if( aContentType.Find( KMimeTextCalCancel ) != KErrNotFound )
-                {
-                array.AppendL( KCancel );
-                }
-            else
-                {
-                parentToMultipartAlternative = EFalse;
-                }
-            mimeHeader->StoreWithoutCommitL( *store );
-            store->CommitL();
-            }
-        CleanupStack::PopAndDestroy( 2, store );
-        }
-    if( parentToMultipartAlternative && fileName.Find( _L(".ics")) != KErrNotFound )
-        {
-        TMsvEntry tAttaEntry = cAtta->Entry();
-        TMsvId id = tAttaEntry.Parent();
-        CMsvEntry* cParent = iSession->GetEntryL( id );
-        CleanupStack::PushL( cParent );
-
-        TMsvEmailEntry tEntry = cParent->Entry();
-        tEntry.SetMessageFolderType( EFolderTypeAlternative );
-        cParent->ChangeL( tEntry );
-
-        CleanupStack::PopAndDestroy( cParent );
-        }
-    CleanupStack::PopAndDestroy( cAtta );
-
-    // Delete the message entries to get all the changes to disk and
-    // possible store locks released
-    CleanCachedMessageEntries();
-
-    // Create the FS message part object and return it
-    result = iMsgMapper->GetMessagePartL( newAttachmentId, aMailBoxId,
-        aMessageId );
-    return result;
+    // <qmail> not used any more
+    User::Leave(KErrFSMailPluginNotSupported);
+    return NULL; // prevents compiler warning
     }
 
 // ----------------------------------------------------------------------------
@@ -1477,55 +1219,14 @@
 // ----------------------------------------------------------------------------
 //
 void CIpsPlgSosBasePlugin::RemoveChildPartL(
-    const TFSMailMsgId& /* aMailBoxId */,
-    const TFSMailMsgId& /* aParentFolderId */,
-    const TFSMailMsgId& aMessageId,
-    const TFSMailMsgId& /* aParentPartId */,
-    const TFSMailMsgId& aPartId)
+    const TFSMailMsgId& /*aMailBoxId*/,
+    const TFSMailMsgId& /*aParentFolderId*/,
+    const TFSMailMsgId& /*aMessageId*/,
+    const TFSMailMsgId& /*aParentPartId*/,
+    const TFSMailMsgId& /*aPartId*/)
 	{
-    FUNC_LOG;
-    TInt status( KErrNone );
-    CMsvEntry* cEntry( NULL );
-    TMsvEntry tEntry;
-    TMsvId serviceId;
-    status = iSession->GetEntry( aPartId.Id(), serviceId, tEntry );
-
-    if ( ( status == KErrNone ) &&
-         ( tEntry.iType == KUidMsvAttachmentEntry ) )
-        {
-        CImEmailMessage* message( NULL );
-  
-        // We trust that the message ID really refers to a message
-        
-        // Take ownership of message entry objects since thanks to
-        // "clever" use of active scheduler waits we can re-enter 
-        // this function leading to crashes if somebody clears the cache
-        // while this iteration still needs them
-        TakeMessageEntryLC( aMessageId.Id(), cEntry, message );
-
-        MMsvAttachmentManager& attachmentMgr( message->AttachmentManager() );
-
-        CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewL();
-        CleanupStack::PushL( waiter );
-
-        attachmentMgr.RemoveAttachmentL(
-            (TMsvAttachmentId) aPartId.Id(), waiter->iStatus );
-
-        waiter->Start();
-        CleanupStack::PopAndDestroy( waiter );
-        	
-        // Return message entry objects to cache
-        CleanupStack::Pop( 2 ); // cEntry, message
-        ReturnMessageEntry( cEntry, message );
-        }
-    else if ( ( status == KErrNone ) &&
-              ( tEntry.iType == KUidMsvFolderEntry ) )
-        {
-        cEntry = iSession->GetEntryL( tEntry.Parent() );
-        CleanupStack::PushL( cEntry );
-        cEntry->DeleteL( tEntry.Id() );
-        CleanupStack::PopAndDestroy( cEntry );
-        }
+    // <qmail> not used any more
+    User::Leave(KErrFSMailPluginNotSupported);
 	}
 
 // <qmail>
@@ -1773,58 +1474,14 @@
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 void CIpsPlgSosBasePlugin::RemovePartContentL(
-    const TFSMailMsgId& /* aMailBoxId */,
-    const TFSMailMsgId& /* aParentFolderId */,
-    const TFSMailMsgId& /* aMessageId */,
-    const RArray<TFSMailMsgId>& aPartIds )
+    const TFSMailMsgId& /*aMailBoxId*/,
+    const TFSMailMsgId& /*aParentFolderId*/,
+    const TFSMailMsgId& /*aMessageId*/,
+    const RArray<TFSMailMsgId>& /*aPartIds*/ )
     {
-    TInt count( aPartIds.Count() );
-
-    for( TInt i(0); i < count; i++ )
-        {
-        CMsvEntry* cEntry = iSession->GetEntryL( aPartIds[i].Id() );
-        CleanupStack::PushL( cEntry );
-        CMsvStore* store = NULL;
-        TBool hasStore = cEntry->HasStoreL();
-        if ( hasStore )
-            {
-            store = cEntry->EditStoreL();
-            }
-
-        if ( !store || !hasStore )
-            {
-            User::Leave( KErrNotFound );
-            }
-        CleanupStack::PushL( store );
-        MMsvAttachmentManager& attachmentMgr = store->AttachmentManagerL();
-
-        // It is assumed that the attachment file is always in the index 0
-        if ( attachmentMgr.AttachmentCount() )
-            {
-            // delete attachment file
-            CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewLC();
-            attachmentMgr.RemoveAttachmentL( 0, waiter->iStatus );
-            waiter->Start();
-            CleanupStack::PopAndDestroy( waiter );
-            store->CommitL();
-
-            // clear complete flag
-            TMsvEntry tEntry( cEntry->Entry() );
-            tEntry.SetComplete( EFalse );
-
-            waiter = CIpsPlgOperationWait::NewLC();
-            CMsvOperation* ops = cEntry->ChangeL( tEntry, waiter->iStatus );
-            CleanupStack::PushL( ops );
-            waiter->Start();
-            CleanupStack::PopAndDestroy( 2, waiter );
-            }
-        else
-            {
-            User::Leave( KErrNotFound );
-            }
-        CleanupStack::PopAndDestroy( store );
-        CleanupStack::PopAndDestroy( cEntry );
-        }
+    // <qmail>
+    User::Leave( KErrFSMailPluginNotSupported );
+    // </qmail>
     }
 
 // ----------------------------------------------------------------------------
@@ -2072,6 +1729,45 @@
     //</qmail>
     }
 
+// <qmail>
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsPlgSosBasePlugin::DeleteMessagesByUidL(
+    const TFSMailMsgId& /*aMailBoxId*/,
+    const TFSMailMsgId& /*aFolderId*/,
+	const RArray<TFSMailMsgId>& aMessages,
+    MFSMailRequestObserver& aOperationObserver,
+    const TInt aRequestId)
+    {
+    FUNC_LOG;
+    CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection;
+    CleanupStack::PushL(sel);
+
+    TInt count = aMessages.Count();
+    TMsvEntry tEntry;
+    TMsvId service;
+    
+    for(TInt i=0; i<count; i++)
+        {
+        iSession->GetEntry( aMessages[i].Id(), service, tEntry );
+        //make sure that only messages get deleted.
+        if( tEntry.iType == KUidMsvMessageEntry )
+            {            
+            sel->AppendL( tEntry.Id() );
+            }
+        }
+        
+    CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL( *this );
+    CleanupStack::PushL( watcher );
+    CMsvOperation* op = CIpsPlgDeleteOperation::NewL( *iSession,
+        watcher->iStatus, sel, aOperationObserver, aRequestId );
+    watcher->SetOperation( op );
+    iOperations.AppendL( watcher );
+    CleanupStack::Pop( watcher );
+    CleanupStack::Pop( sel );
+    }
+// </qmail>
+
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 void CIpsPlgSosBasePlugin::SubscribeMailboxEventsL(
@@ -2779,11 +2475,58 @@
     TBool ret( EFalse );
     for ( TInt i = 0; i < iOperations.Count(); i++ )
         {
-        if( iOperations[i]->BaseOperation()->FSMailboxId() == aMailboxId )
+        if( iOperations[i]->BaseOperation() && 
+            iOperations[i]->BaseOperation()->FSMailboxId() == aMailboxId )
             {
             ret = ETrue;
             }
         }
     return ret;
     }
+//</Qmail>
+//<Qmail>
+// ---------------------------------------------------------------------------
+// CIpsPlgImap4Plugin::HandleActiveFolderChangeL
+// ---------------------------------------------------------------------------
+//
+void CIpsPlgSosBasePlugin::HandleActiveFolderChangeL(
+        const TFSMailMsgId& aActiveMailboxId,
+        const TFSMailMsgId& aActiveFolderId)
+    {
+    TMsvId service;
+    TMsvEntry folder;
+    iSession->GetEntry( aActiveFolderId.Id(), service, folder );
+    
+    
+    //currently, no actions unless this is inbox
+    //also, if id is '0', it means inbox before first sync...it doesn't really exist yet
+    if( folder.iDetails.CompareF( KIpsPlgInbox ) == 0 || folder.Id() == 0 )
+        {
+        //folder is inbox
+        if ( iSyncStateHandler->GetMailboxIpsState( aActiveMailboxId.Id() )
+                    == KIpsSosEmailSyncStarted )
+            {
+            //we won't do anything if sync is already started
+            return;
+            }
+        
+        //check are we in polling mode
+        NmIpsSosExtendedSettingsManager* eMgr= 
+                new NmIpsSosExtendedSettingsManager(aActiveMailboxId.Id());
+        
+        QVariant value;
+        bool ok = eMgr->readSetting(IpsServices::ReceptionActiveProfile, value);
+        delete eMgr;
+        
+        if ( ok )
+            {
+            TInt profile = value.toInt();
+            if ( profile != IpsServices::EmailSyncProfileManualFetch )
+                {
+                // let's sync
+                GoOnlineL(aActiveMailboxId);
+                }
+            }        
+        }        
+    }
 // </qmail>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssosplugin/src/ipssosextendedsettingsmanager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,411 @@
+/*
+* 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 <xqsettingsmanager.h>
+#include <xqcentralrepositoryutils.h>
+#include <xqcentralrepositorysearchcriteria.h>
+#include <qlist.h>
+
+#include "ipssosextendedsettingsmanager.h"
+#include "nmipssettingitems.h"
+#include "ipssettingkeys.h"
+#include "nmcommon.h"
+
+/*!
+    \class NmIpsSosExtendedSettingsManager
+    \brief The class is used for manipulating extended POP3 and IMAP4 account settings stored
+    in the Central Repository.
+*/
+
+// ======== MEMBER FUNCTIONS ========
+
+/*!
+    Constructor    
+    Creates the NmIpsSosExtendedSettingsManagerfor loading and saving extended mailbox settings.
+    \param mailboxId Mailbox identifier.
+*/
+NmIpsSosExtendedSettingsManager::NmIpsSosExtendedSettingsManager(const NmId &mailboxId)
+    : mMailboxId(mailboxId), mMailboxOffset(-1), mActiveProfileOffset(-1)
+{
+    mSettingsManager = new XQSettingsManager();
+
+    calculateMailboxOffset();
+}
+
+/*!
+    Destructor
+*/
+NmIpsSosExtendedSettingsManager::~NmIpsSosExtendedSettingsManager()
+{
+    delete mSettingsManager;
+}
+
+/*!     
+    Reads extended mailbox 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 read, otherwise <false>.
+*/
+bool NmIpsSosExtendedSettingsManager::readSetting(IpsServices::SettingItem settingItem,
+                                               QVariant &settingValue) const
+{
+    bool ret(mMailboxOffset>=0);
+    if(ret) {
+        switch(settingItem) {
+            case IpsServices::DownloadPictures:
+                settingValue = readFromCenRep(IpsServices::EmailKeyPreferenceDownloadPictures);
+                break;
+            case IpsServices::MessageDivider:
+                settingValue = readFromCenRep(IpsServices::EmailKeyPreferenceMessageDivider);
+                break;
+            case IpsServices::ReceptionActiveProfile:
+                settingValue = readFromCenRep(IpsServices::EmailKeyReceptionActiveProfile);
+                break;
+            case IpsServices::ReceptionUserDefinedProfile:
+                settingValue = readFromCenRep(IpsServices::EmailKeyReceptionUserDefinedProfile);
+                break;
+            case IpsServices::ReceptionInboxSyncWindow:
+                settingValue = readFromCenRep(mActiveProfileOffset +
+                                              IpsServices::EmailKeyReceptionInboxSyncWindow);
+                break;
+            case IpsServices::ReceptionGenericSyncWindowInMessages:
+                settingValue = readFromCenRep(mActiveProfileOffset +
+                                      IpsServices::EmailKeyReceptionGenericSyncWindowInMessages);
+                break;
+            case IpsServices::ReceptionWeekDays:
+                settingValue = readFromCenRep(mActiveProfileOffset +
+                                              IpsServices::EmailKeyReceptionWeekDays);
+                break;
+            case IpsServices::ReceptionDayStartTime:
+                settingValue = readFromCenRep(mActiveProfileOffset +
+                                              IpsServices::EmailKeyReceptionDayStartTime);
+                break;
+            case IpsServices::ReceptionDayEndTime:
+                settingValue = readFromCenRep(mActiveProfileOffset +
+                                              IpsServices::EmailKeyReceptionDayEndTime);
+                break;
+            case IpsServices::ReceptionRefreshPeriodDayTime:
+                settingValue = readFromCenRep(mActiveProfileOffset +
+                                              IpsServices::EmailKeyReceptionRefreshPeriodDayTime);
+                break;
+            case IpsServices::ReceptionRefreshPeriodOther:
+                settingValue = readFromCenRep(mActiveProfileOffset +
+                                              IpsServices::EmailKeyReceptionRefreshPeriodOther);
+                break;
+            case IpsServices::UserNameHidden:
+                settingValue = readFromCenRep(IpsServices::EmailKeyUserNameHidden);
+                break;
+            case IpsServices::EmailNotificationState:
+                settingValue = readFromCenRep(IpsServices::EmailKeyEMNState);
+                break;
+            case IpsServices::FirstEmnReceived:
+                settingValue = readFromCenRep(IpsServices::EmailKeyFirstEmnReceived);
+                break;
+            case IpsServices::EmnReceivedNotSynced:
+                settingValue = readFromCenRep(IpsServices::EmailKeyEmnReceivedNotSynced);
+                break;
+            case IpsServices::AoLastSuccessfulUpdateL:
+                settingValue = readFromCenRep(IpsServices::EmailKeyAoLastSuccessfulUpdateL);
+                break;
+            case IpsServices::AoLastSuccessfulUpdateH:
+                settingValue = readFromCenRep(IpsServices::EmailKeyAoLastSuccessfulUpdateH);
+                break;
+            case IpsServices::AoLastUpdateFailed:
+                settingValue = readFromCenRep(IpsServices::EmailKeyAoLastUpdateFailed);
+                break;
+            case IpsServices::AoUpdateSuccessfulWithCurSettings:
+                settingValue = readFromCenRep(IpsServices::EmailKeyAoUpdateSuccessfulWithCurSettings);
+                break;
+            default:
+                ret = false;
+                break;
+            }
+    }
+    if(!settingValue.isValid()){
+        ret = false;
+        }
+    
+    return ret;
+}
+   
+/*!     
+    Writes extended mailbox setting.
+    \param settingItem SettingItem enum of the setting to replace.
+    \param settingValue QVariant of the new setting value.
+    \return bool <true> when the setting item was written, otherwise <false>.
+*/
+bool NmIpsSosExtendedSettingsManager::writeSetting(IpsServices::SettingItem settingItem,
+                                                const QVariant &settingValue)
+{
+    return writeSettingToCenRep(mActiveProfileOffset, settingItem, settingValue);
+}
+
+/*!     
+
+*/
+bool NmIpsSosExtendedSettingsManager::writeSetting(int profileMode,
+    IpsServices::SettingItem settingItem, const QVariant &settingValue)
+{
+    quint32 profileOffset = convertToProfileOffset(profileMode);
+    return writeSettingToCenRep(profileOffset, settingItem, settingValue);
+}
+
+/*!     
+    Deletes all the extended settings of the mailbox.
+*/
+void NmIpsSosExtendedSettingsManager::deleteSettings()
+{
+    if(mMailboxOffset>=0) {
+
+        // Find all the keys that match the criteria 0xXXXXXZZZ, where X=part of mailbox offset
+        // and Z=don't care. This will give us all the keys for the particular mailbox.
+        quint32 partialKey(mMailboxOffset);
+        quint32 bitMask(0xFFFFF000);
+        XQCentralRepositorySearchCriteria criteria(IpsServices::EmailMailboxSettingRepository,
+                                                   partialKey, bitMask);
+        // Find the keys.
+        XQCentralRepositoryUtils utils(*mSettingsManager);
+        QList<XQCentralRepositorySettingsKey> foundKeys = utils.findKeys(criteria);
+
+        // Delete the keys.
+        foreach(XQCentralRepositorySettingsKey key, foundKeys) {
+            utils.deleteKey(key);
+            }
+    }
+}
+
+/*!
+
+*/
+bool NmIpsSosExtendedSettingsManager::writeSettingToCenRep(qint32 profileOffset,
+    IpsServices::SettingItem settingItem, const QVariant &settingValue)
+{
+    bool ret(profileOffset >= 0);
+    if(ret) {
+        switch(settingItem) {
+            case IpsServices::DownloadPictures:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyPreferenceDownloadPictures, 
+                        settingValue);
+                break;
+            case IpsServices::MessageDivider:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyPreferenceMessageDivider, 
+                        settingValue);
+                break;
+            case IpsServices::ReceptionActiveProfile:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyReceptionActiveProfile, 
+                        settingValue);
+                calculateActiveProfileOffset();
+                break;
+            case IpsServices::ReceptionUserDefinedProfile:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyReceptionUserDefinedProfile, 
+                        settingValue);
+                break;
+            case IpsServices::ReceptionInboxSyncWindow:
+                ret = writeToCenRep(
+                        profileOffset + 
+                        IpsServices::EmailKeyReceptionInboxSyncWindow,
+                        settingValue);
+                break;
+            case IpsServices::ReceptionGenericSyncWindowInMessages:
+                ret = writeToCenRep(
+                        profileOffset + 
+                        IpsServices::EmailKeyReceptionGenericSyncWindowInMessages,
+                        settingValue);
+                break;
+            case IpsServices::ReceptionWeekDays:
+                ret = writeToCenRep(
+                        profileOffset + 
+                        IpsServices::EmailKeyReceptionWeekDays,
+                        settingValue);
+                break;
+            case IpsServices::ReceptionDayStartTime:
+                ret = writeToCenRep(
+                        profileOffset + 
+                        IpsServices::EmailKeyReceptionDayStartTime,
+                        settingValue);
+                break;
+            case IpsServices::ReceptionDayEndTime:
+                ret = writeToCenRep(
+                        profileOffset + 
+                        IpsServices::EmailKeyReceptionDayEndTime,
+                        settingValue);
+                break;
+            case IpsServices::ReceptionRefreshPeriodDayTime:
+                ret = writeToCenRep(
+                        profileOffset + 
+                        IpsServices::EmailKeyReceptionRefreshPeriodDayTime,
+                        settingValue);
+                break;
+            case IpsServices::ReceptionRefreshPeriodOther:
+                ret = writeToCenRep(
+                        profileOffset + 
+                        IpsServices::EmailKeyReceptionRefreshPeriodOther,
+                        settingValue);
+                break;
+            case IpsServices::UserNameHidden:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyUserNameHidden, settingValue);
+                break;
+            case IpsServices::EmailNotificationState:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyEMNState, settingValue);
+                break;
+            case IpsServices::FirstEmnReceived:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyFirstEmnReceived, settingValue);
+                break;
+            case IpsServices::EmnReceivedNotSynced:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyEmnReceivedNotSynced,
+                        settingValue);
+                break;
+            case IpsServices::AoLastSuccessfulUpdateL:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyAoLastSuccessfulUpdateL,
+                        settingValue);
+                break;
+            case IpsServices::AoLastSuccessfulUpdateH:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyAoLastSuccessfulUpdateH,
+                        settingValue);
+                break;
+            case IpsServices::AoLastUpdateFailed:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyAoLastUpdateFailed,
+                        settingValue);
+                break;
+            case IpsServices::AoUpdateSuccessfulWithCurSettings:
+                ret = writeToCenRep(
+                        IpsServices::EmailKeyAoUpdateSuccessfulWithCurSettings,
+                        settingValue);
+                break;
+            default:
+                ret = false;
+                break;
+            }
+    }
+    return ret;
+}
+
+/*!
+    Creates a new key-value pair into cenrep
+ */
+bool NmIpsSosExtendedSettingsManager::createKeyValuePair(
+            const IpsServices::SettingItem settingItem, 
+            const QVariant &settingValue)
+    {
+    
+    XQCentralRepositoryUtils* utils =
+            new XQCentralRepositoryUtils(*mSettingsManager);
+    
+    XQCentralRepositorySettingsKey settingKey(
+                  IpsServices::EmailMailboxSettingRepository,
+                  mMailboxOffset + settingItem);
+          
+    bool ret = utils->createKey(settingKey, settingValue);
+          
+    
+    delete utils;
+    
+    return ret;    
+    }
+
+/*!
+    Reads a key value from the Central Repository.
+    \param key Key identifier.
+    \return The settings value for the given key.
+*/
+QVariant NmIpsSosExtendedSettingsManager::readFromCenRep(quint32 key) const
+{
+    XQCentralRepositorySettingsKey settingKey(IpsServices::EmailMailboxSettingRepository,
+                                              mMailboxOffset + key);
+    return mSettingsManager->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 NmIpsSosExtendedSettingsManager::writeToCenRep(quint32 key, const QVariant &value) const
+{
+    XQCentralRepositorySettingsKey settingKey(IpsServices::EmailMailboxSettingRepository,
+                                              mMailboxOffset + key);
+    return mSettingsManager->writeItemValue(settingKey, value);
+}
+
+void NmIpsSosExtendedSettingsManager::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.id32());
+
+    // Find the keys.
+    XQCentralRepositoryUtils utils(*mSettingsManager);
+    QList<XQCentralRepositorySettingsKey> foundKeys = utils.findKeys(criteria);
+
+    // We should only get one key as a result.
+    if (foundKeys.count() == 1) {
+        mMailboxOffset = foundKeys[0].key();
+        calculateActiveProfileOffset();
+    }
+}
+
+/*!
+    Calculates the active reception schedule profile offset.
+*/
+void NmIpsSosExtendedSettingsManager::calculateActiveProfileOffset()
+{
+    QVariant activeProfile = readFromCenRep(IpsServices::EmailKeyReceptionActiveProfile);
+    mActiveProfileOffset = convertToProfileOffset(activeProfile.toInt());
+}
+
+/*!
+
+*/
+qint32 NmIpsSosExtendedSettingsManager::convertToProfileOffset(int profile)
+{
+    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;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssosplugin/src/ipsstateextension.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*       Extension to monitor Activer folder change events
+*
+*/
+#include "ipsstateextension.h"
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+CIpsStateExtension* CIpsStateExtension::NewL(MStateObserverCallback& aCallback)
+    {
+    CIpsStateExtension* self = new(ELeave) CIpsStateExtension(aCallback);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsStateExtension::SetStateDataProvider( MEmailMailboxState* aDataProvider )
+    {
+    iDataProvider = aDataProvider;
+    }
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsStateExtension::NotifyActiveFolderChanged(
+        const TFSMailMsgId& aActiveMailboxId,
+        const TFSMailMsgId& aActiveFolderId)
+    {
+    iCallback.ActiveFolderChanged( aActiveMailboxId, aActiveFolderId );
+    }
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+CIpsStateExtension::CIpsStateExtension(MStateObserverCallback& aCallback):
+        iCallback(aCallback)
+    {
+    
+    }
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+CIpsStateExtension::~CIpsStateExtension()
+    {
+    
+    }
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+void CIpsStateExtension::ConstructL()
+    {
+    
+    }
+//EOF
--- a/ipsservices/nmimapclientplugin/src/nmimapclientplugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmimapclientplugin/src/nmimapclientplugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -176,7 +176,7 @@
                 SIGNAL(goOffline(const NmId &)),
                 this, SLOT(goOffline(const NmId &)));
         }
-
+        handleRequest(NmActionResponseCommandSettings, mMenuRequest);
         mSettingsViewLauncher->launchSettingsView(id, mailbox->name());
     }
 
--- a/ipsservices/nmipssettings/inc/nmipsimap4settingsmanager.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/inc/nmipsimap4settingsmanager.h	Thu Jul 22 16:30:28 2010 +0100
@@ -32,24 +32,23 @@
 
 public:
         
-    NmIpsImap4SettingsManager(const NmId &mailboxId, CEmailAccounts *account, TImapAccount imapAccount);
-
+    NmIpsImap4SettingsManager(const NmId &mailboxId,
+                              CEmailAccounts *account,
+                              TImapAccount imapAccount);
     virtual ~NmIpsImap4SettingsManager();
-    
     bool readSetting(IpsServices::SettingItem settingItem, QVariant &settingValue);
     bool writeSetting(IpsServices::SettingItem settingItem, const QVariant &settingValue);
-    
     int deleteMailbox();    
     int determineDefaultIncomingPort();
 
 private:    
 
     bool saveSettings();
+    bool saveIAPSettings(uint snapId);
     
 private: // data
 
     CImImap4Settings *mImap4Settings;   // Owned.
-
     TImapAccount mImap4Account;
 };
 
--- a/ipsservices/nmipssettings/inc/nmipspop3settingsmanager.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/inc/nmipspop3settingsmanager.h	Thu Jul 22 16:30:28 2010 +0100
@@ -31,24 +31,23 @@
 {
 public:
         
-    NmIpsPop3SettingsManager(const NmId &mailboxId, CEmailAccounts *account, TPopAccount popAccount);
-
+    NmIpsPop3SettingsManager(const NmId &mailboxId,
+                             CEmailAccounts *account,
+                             TPopAccount popAccount);
     virtual ~NmIpsPop3SettingsManager();
-    
-    bool readSetting(IpsServices::SettingItem settingItem, QVariant &value);
+    bool readSetting(IpsServices::SettingItem settingItem, QVariant &settingValue);
     bool writeSetting(IpsServices::SettingItem settingItem, const QVariant &settingValue);
-    
     int deleteMailbox();
     int determineDefaultIncomingPort();
 
 private:
 
     bool saveSettings();
+    bool saveIAPSettings(uint snapId);
     
-private:
+private: // data
 
     CImPop3Settings *mPop3Settings;   // Owned.
-
     TPopAccount mPop3Account;
 };
 
--- a/ipsservices/nmipssettings/inc/nmipssettingitems.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/inc/nmipssettingitems.h	Thu Jul 22 16:30:28 2010 +0100
@@ -47,7 +47,7 @@
         OutgoingMailServer,                     // String
         IncomingPort,                           // Integer
         OutgoingPort,                           // Integer
-        FolderPath,                              // String: Empty string means 'Default'
+        FolderPath,                             // String: Empty string means 'Default'
         AlwaysOnlineState,                      // Integer: 0=always,1=homeonly,2=off
         EmailNotificationState,                 // Integer: 0=automatic,1=homeonly,2=off
         FirstEmnReceived,                       // Integer: 0=false,1=true
@@ -62,7 +62,8 @@
         OutgoingPassword,                       // String
         SMTPAuthentication,                     // Boolean
         OutgoingSecureSockets,                  // Boolean
-        OutgoingSSLWrapper                      // Boolean
+        OutgoingSSLWrapper,                     // Boolean
+        Connection                              // Unsigned integer, Network Destination ID (SNAP)
     }; 
     
     /**
--- a/ipsservices/nmipssettings/inc/nmipssettingshelper.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/inc/nmipssettingshelper.h	Thu Jul 22 16:30:28 2010 +0100
@@ -22,6 +22,7 @@
 #include <QMap>
 #include <QVariant>
 #include <QDateTime>
+#include <QPersistentModelIndex>
 
 #include "nmsettingscommon.h"
 #include "nmipssettingitems.h"
@@ -37,11 +38,12 @@
 class CpSettingFormItemData;
 class NmIpsSettingsManagerBase;
 class NmId;
+class CmApplSettingsUi;
 
 
 // Constant for User Defined sync profile (EmailProfileOffsetUD)
 // \sa ipssettingkeys.h - Currently used sync profile
-const int NmIpsSettingsReceivingScheduleUserDefinedProfile = 3;
+const int NmIpsSettingsReceivingScheduleUserDefinedProfile(3);
 
 class NmIpsSettingsHelper : public QObject
 {
@@ -61,15 +63,17 @@
     void setReceivingScheduleGroupItem(HbDataFormModelItem *item);
     void setServerInfoGroupItem(HbDataFormModelItem *item);
     void createOrUpdateReceivingScheduleGroupDynamicItem(IpsServices::SettingItem item);
-    void createServerInfoGroupDynamicItems();
+    void createServerInfoGroupDynamicItems(bool hiddenItem);
     
-    int getCorrectPortRadioButtonIndex(int currentPort);
-    int getCorrectSecureRadioButtonIndex(QVariant secureSockets, QVariant secureSSLWrapper);
-    int getCorrectInboxPathRadioButtonIndex(QVariant folderPath);
-    int getCorrectOutgoingPortRadioButtonIndex(int currentPort);
+    int getCorrectIncomingPortRadioButtonIndex();
+    int getCorrectIncomingSecureRadioButtonIndex();
+    int getCorrectOutgoingSecureRadioButtonIndex();
+    int getCorrectFolderPathRadioButtonIndex();
+    int getCorrectOutgoingPortRadioButtonIndex();
     int getCorrectOutgoingAuthenticationRadioButtonIndex();
     void handleReceivingScheduleSettingChange(IpsServices::SettingItem settingItem,
         const QVariant &settingValue);
+    QString destinationNameFromIdentifier(uint identifier);
     
 signals:
 
@@ -101,32 +105,34 @@
     void saveOutgoingMailServer();
     void outgoingMailServerTextChange(const QString &text);
     void incomingPortChange(int index);
-    void incomingPortPress(const QModelIndex &index);
     void incomingSecureConnectionItemChange(int index);
-    void incomingSecureConnectionPress(const QModelIndex &index);
     void folderPathChange(int index);
-    void folderPathPress(const QModelIndex &index);
     void outgoingPortChange(int index);
-    void outgoingPortPress(const QModelIndex &index);
     void outgoingSecureConnectionItemChange(int index);
-    void outgoingSecureConnectionPress(const QModelIndex &index);
     void outgoingAuthenticationChange(int index);
-    void outgoingAuthenticationPress(const QModelIndex &index);
+    void connectionButtonPress();
 
 private slots:
 
     void receivingWeekdaysModified();
     void startTimeModified(QTime time);
     void endTimeModified(QTime time);
-    void refreshPeriodModified(int index);
+    void refreshPeriodModified(QPersistentModelIndex, QVariant);
     void handleMailboxDelete(HbAction *action);
     void handleMailboxDeleteUpdate(HbAction *action);
     void handleUserDefinedIncomingPortInput(HbAction *action);
     void handleUserDefinedFolderPathInput(HbAction *action);
     void handleUserDefinedOutgoingPortInput(HbAction *action);
+    void handleConnectionSelected(uint status);
     
 private:
 
+    enum AppLibUpdateOperation
+    {
+        UnregisterMailbox,
+        UpdateMailboxName
+    };
+
     void updateShowMailInMailbox();
     void deleteReceivingScheduleGroupDynamicItem(IpsServices::SettingItem item);
     void deleteServerInfoGroupDynamicItems();
@@ -134,6 +140,8 @@
     void showFolderPathInputDialog();
     void showOutgoingPortInputDialog();
     void copyReceivingScheduleSettingsFromActiveProfile(int profileMode);
+    void updateAppLib(AppLibUpdateOperation op, QString mailboxName = QString());
+    void noReceptionWeekdaysSelected();
 
     Q_DISABLE_COPY(NmIpsSettingsHelper)
 
@@ -147,15 +155,16 @@
     HbDataFormModelItem *mServerInfoGroupItem;	// Not owned.
 	HbDataForm &mDataForm;
 	HbDataFormModel &mDataFormModel;
-	HbMessageBox *mDeleteConfirmationDialog; // Owned;
-	HbMessageBox *mDeleteInformationDialog; // Owned;
-	HbInputDialog *mIncomingPortInputDialog; // Owned;
-	HbValidator *mIncomingPortInputValidator; // Owned;
-    HbInputDialog *mFolderPathInputDialog; // Owned;
-    HbInputDialog *mOutgoingPortInputDialog; // Owned;
-    HbValidator *mOutgoingPortInputValidator; // Owned;    
+	HbMessageBox *mDeleteConfirmationDialog; // Owned.
+	HbMessageBox *mDeleteInformationDialog; // Owned.
+	HbInputDialog *mIncomingPortInputDialog; // Owned.
+	HbValidator *mIncomingPortInputValidator; // Owned.
+    HbInputDialog *mFolderPathInputDialog; // Owned.
+    HbInputDialog *mOutgoingPortInputDialog; // Owned.
+    HbValidator *mOutgoingPortInputValidator; // Owned.
+    CmApplSettingsUi *mDestinationDialog; // Owned.
     bool mServerInfoDynamicItemsVisible;
-    int mRadioButtonPreviousIndex;
+    bool mAbortDynamicRSItemHandling;
 };
 
 #endif // NMIPSSETTINGSHELPER_H
--- a/ipsservices/nmipssettings/inc/nmipssettingslabeledcombobox.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/inc/nmipssettingslabeledcombobox.h	Thu Jul 22 16:30:28 2010 +0100
@@ -52,6 +52,7 @@
 signals:
 
     void currentIndexChanged(int index);
+    void propertyChanged(QMap<QString, QVariant> properties);
 
 private slots:
 
--- a/ipsservices/nmipssettings/inc/nmipssettingsmanagerbase.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/inc/nmipssettingsmanagerbase.h	Thu Jul 22 16:30:28 2010 +0100
@@ -24,9 +24,7 @@
 #include "nmipssettingitems.h"
 
 class QVariant;
-class CEmailAccounts;
 class CImSmtpSettings;
-class TSmtpAccount;
 class NmIpsExtendedSettingsManager;
 class NmId;
 
@@ -34,7 +32,9 @@
 {
 public:
 
-    NmIpsSettingsManagerBase(const NmId &mailboxId, CEmailAccounts *account, IpsServices::TIpsSetAccountTypes);
+    NmIpsSettingsManagerBase(const NmId &mailboxId,
+                             CEmailAccounts *account,
+                             IpsServices::TIpsSetAccountTypes);
     virtual ~NmIpsSettingsManagerBase();
     virtual bool readSetting(IpsServices::SettingItem settingItem, QVariant &settingValue);
     virtual bool writeSetting(IpsServices::SettingItem settingItem, const QVariant &settingValue);
@@ -48,8 +48,9 @@
 private:
 
     bool saveSettings();
+    bool saveIAPSettings(uint snapId);
     
-protected: // data.
+protected: // data
 
     CEmailAccounts *mAccount;   // Owned.
     CImSmtpSettings *mSmtpSettings; // Owned.
--- a/ipsservices/nmipssettings/inc/nmipssettingsplugin.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/inc/nmipssettingsplugin.h	Thu Jul 22 16:30:28 2010 +0100
@@ -20,18 +20,20 @@
 
 #include <QObject>
 #include <QVariant>
+#include <QPersistentModelIndex>
+#include <AlwaysOnlineManagerClient.h>
 
 #include "nmsettingsplugininterface.h"
 #include "nmsettingscommon.h"
 
+class QTranslator;
+class QModelIndex;
 class HbDataForm;
 class HbDataFormModel;
 class HbDataFormModelItem;
 class NmId;
 class NmIpsSettingsHelper;
 class NmIpsSettingsManagerBase;
-class QTranslator;
-class QModelIndex;
 
 class NmIpsSettingsPlugin : public QObject, public NmSettingsPluginInterface
 {
@@ -59,7 +61,7 @@
 private slots:
 
     void createUserDefinedMode();
-    void showMailInInboxModified(int index);
+    void showMailInInboxModified(QPersistentModelIndex, QVariant value);
 
 private:
 
@@ -68,19 +70,17 @@
     void initReceivingScheduleItems(HbDataFormModelItem &item);
     void initUserInfoItems(HbDataFormModelItem &item) const;
     void initServerInfoItems(HbDataFormModelItem &item) const;
+    void setAlwaysOnlineState(TAlwaysOnlineServerAPICommands command, NmId mailboxId) const;
 
     Q_DISABLE_COPY(NmIpsSettingsPlugin)
 
-private:
+private: // data.
 
-    // Owned.
-    NmIpsSettingsHelper *mSettingsHelper;
-    // Owned.
-    NmIpsSettingsManagerBase *mSettingsManager;
-    // Not owned.
-    HbDataFormModel *mModel;
-    // Not owned.
-    HbDataForm *mForm;
+    NmIpsSettingsHelper *mSettingsHelper;  // Owned.
+    NmIpsSettingsManagerBase *mSettingsManager; // Owned.
+    HbDataFormModel *mModel; // Not owned.
+    HbDataForm *mForm; // Not owned.
+    bool mHiddenItem;
 };
 
 #endif // NMIPSSETTINGS_H
--- a/ipsservices/nmipssettings/inc/nmipssettingstimeeditor.h	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/inc/nmipssettingstimeeditor.h	Thu Jul 22 16:30:28 2010 +0100
@@ -63,10 +63,14 @@
     // Now owned.
     HbPushButton *mButton;
 
+    // Owned.
     HbDialog *mTimePickerDialog;
 
     QTime mTime;
     QString mLabel;
+    
+    // Not owned.
+    HbAction *mPrimaryAction;
 };
 
 #endif // NMIPSSETTINGSTIMEEDITOR_H
--- a/ipsservices/nmipssettings/nmipssettings.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/nmipssettings.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -74,6 +74,11 @@
     LIBS += -lxqsettingsmanager
     LIBS += -leuser
     LIBS += -llibc
+    LIBS += -lcmapplsettingsui
+    LIBS += -lAlwaysOnlineManagerClient
+    
+    CONFIG += mobility
+    MOBILITY += bearer serviceframework
 }
 
 symbian: plugin { # copy qtstub and manifest
--- a/ipsservices/nmipssettings/src/nmipsimap4settingsmanager.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/src/nmipsimap4settingsmanager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -17,6 +17,7 @@
 
 #include <QVariant>
 #include <imapset.h>
+#include <iapprefs.h>
 #include <cemailaccounts.h>
 #include <xqconversions.h>
 
@@ -32,7 +33,7 @@
 // ======== MEMBER FUNCTIONS ========
 
 /*!
-    Constructor
+    Constructor.
     Creates the CImImap4Settings instance for loading and saving the IMAP4 settings.
     Finds and loads the SMTP account and settings linked to the IMAP4 account.
     \param mailboxId Mailbox identifier.
@@ -53,7 +54,7 @@
 }
 
 /*!
-    Destructor
+    Destructor.
 */
 NmIpsImap4SettingsManager::~NmIpsImap4SettingsManager()
 {
@@ -66,7 +67,8 @@
     \param QVariant SettingValue of the found setting value.
     \return <true> when the setting item was found otherwise <false>.
 */
-bool NmIpsImap4SettingsManager::readSetting(IpsServices::SettingItem settingItem, QVariant &settingValue)
+bool NmIpsImap4SettingsManager::readSetting(IpsServices::SettingItem settingItem,
+                                            QVariant &settingValue)
 {
     bool found(false);
     switch (settingItem) {
@@ -101,7 +103,7 @@
         case IpsServices::IncomingSSLWrapper:
         	settingValue = mImap4Settings->SSLWrapper();
             found = true;
-            break;  
+            break;
         default:
             found = NmIpsSettingsManagerBase::readSetting(settingItem, settingValue);
             break;
@@ -115,7 +117,8 @@
     \param settingValue QVariant of the new setting value.
     \return bool <true> when the setting item was succesfully written, otherwise <false>.
 */
-bool NmIpsImap4SettingsManager::writeSetting(IpsServices::SettingItem settingItem, const QVariant &settingValue)
+bool NmIpsImap4SettingsManager::writeSetting(IpsServices::SettingItem settingItem,
+                                             const QVariant &settingValue)
 {
     HBufC *tmp = 0;
     HBufC8 *tmp8 = 0;
@@ -174,6 +177,9 @@
             mImap4Settings->SetSSLWrapper(settingValue.toBool());
             ret = saveSettings();
             break;  
+        case IpsServices::Connection:
+            ret = saveIAPSettings(settingValue.toUInt());
+            // Fallthrough so SMTP IAP settings are also updated accordingly.
         default:
             ret = NmIpsSettingsManagerBase::writeSetting(settingItem, settingValue);
             break;
@@ -183,7 +189,6 @@
 
 /*!
     Deletes the IMAP4 mailbox.
-
     \return Error code <code>0</code> if mailbox deletion was successful, otherwise error
             code is returned.
 */
@@ -198,6 +203,20 @@
     return error;
 }
 
+
+/*!
+     Determines the default port for the incoming mail server based on the security settings.
+     \return The port number to use.
+ */
+int NmIpsImap4SettingsManager::determineDefaultIncomingPort()
+{
+    int port(IpsServices::standardImap4Port);
+    if (mImap4Settings->SSLWrapper()) {
+        port = IpsServices::imap4OverSslPort;
+    }        
+    return port;
+}
+
 /*!
     Stores the IMAP4 specific settings.
     \return bool <true> when the IMAP4 settings were succesfully written, otherwise <false>.
@@ -210,18 +229,17 @@
 }
 
 /*!
-     Determine the default port for the incoming mail server based on the security settings
-     
-     \return int the port number to use
- */
-int NmIpsImap4SettingsManager::determineDefaultIncomingPort()
+    Stores the IMAP4 specific IAP settings.
+    \return bool <true> when the IMAP4 IAP settings were succesfully written, otherwise <false>.
+*/
+bool NmIpsImap4SettingsManager::saveIAPSettings(uint snapId)
 {
-    int port = 0;    
-    bool sslTls = mImap4Settings->SSLWrapper();    
-    if (sslTls) {
-        port = IpsServices::imap4OverSslPort;
-    } else {
-        port = IpsServices::standardImap4Port;
-    }        
-    return port;
+    TRAPD(err,
+        CImIAPPreferences *prefs = CImIAPPreferences::NewLC();
+        mAccount->LoadImapIapSettingsL(mImap4Account, *prefs);
+        prefs->SetSNAPL(snapId);
+        mAccount->SaveImapIapSettingsL(mImap4Account, *prefs);
+        CleanupStack::PopAndDestroy(prefs);
+    );
+    return (err==KErrNone);
 }
--- a/ipsservices/nmipssettings/src/nmipspop3settingsmanager.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/src/nmipspop3settingsmanager.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -17,6 +17,7 @@
 
 #include <QVariant>
 #include <pop3set.h>
+#include <iapprefs.h>
 #include <cemailaccounts.h>
 #include <xqconversions.h>
 
@@ -32,7 +33,7 @@
 // ======== MEMBER FUNCTIONS ========
 
 /*!
-    Constructor
+    Constructor.
     Creates the CImPop4Settings instance for loading and saving the POP3 settings.
     Finds and loads the SMTP account and settings linked to the POP3 account.
     \param mailboxId Mailbox identifier.
@@ -52,7 +53,7 @@
 }
 
 /*!
-    Destructor
+    Destructor.
 */
 NmIpsPop3SettingsManager::~NmIpsPop3SettingsManager()
 {
@@ -65,40 +66,41 @@
     \param QVariant SettingValue of the found setting value.
     \return <true> when the setting item was found otherwise <false>.
 */
-bool NmIpsPop3SettingsManager::readSetting(IpsServices::SettingItem settingItem, QVariant &value)
+bool NmIpsPop3SettingsManager::readSetting(IpsServices::SettingItem settingItem,
+                                           QVariant &settingValue)
 {
 	bool found(false);
 	switch (settingItem) {
         case IpsServices::IncomingLoginName:
-            value = XQConversions::s60Desc8ToQString(mPop3Settings->LoginName());
+            settingValue = XQConversions::s60Desc8ToQString(mPop3Settings->LoginName());
             found = true;
             break;
         case IpsServices::IncomingPassword:
-            value = XQConversions::s60Desc8ToQString(mPop3Settings->Password());
+            settingValue = XQConversions::s60Desc8ToQString(mPop3Settings->Password());
             found = true;
             break;
         case IpsServices::MailboxName:
-            value = XQConversions::s60DescToQString(mPop3Account.iPopAccountName);
+            settingValue = XQConversions::s60DescToQString(mPop3Account.iPopAccountName);
             found = true;
             break;
         case IpsServices::IncomingMailServer:
-            value = XQConversions::s60DescToQString(mPop3Settings->ServerAddress());
+            settingValue = XQConversions::s60DescToQString(mPop3Settings->ServerAddress());
             found = true;
             break;   
         case IpsServices::IncomingPort:
-            value = mPop3Settings->Port();
+            settingValue = mPop3Settings->Port();
             found = true;
             break;  
         case IpsServices::IncomingSecureSockets:
-            value = mPop3Settings->SecureSockets();
+            settingValue = mPop3Settings->SecureSockets();
             found = true;
             break;  
         case IpsServices::IncomingSSLWrapper:
-            value = mPop3Settings->SSLWrapper();
+            settingValue = mPop3Settings->SSLWrapper();
             found = true;
-            break;  
+            break;
         default:
-            found = NmIpsSettingsManagerBase::readSetting(settingItem, value);
+            found = NmIpsSettingsManagerBase::readSetting(settingItem, settingValue);
             break;
     }
 	return found;
@@ -109,7 +111,8 @@
     \param settingItem SettingItem enum of the setting to replace.
     \param settingValue QVariant of the new setting value.
 */
-bool NmIpsPop3SettingsManager::writeSetting(IpsServices::SettingItem settingItem, const QVariant &settingValue)
+bool NmIpsPop3SettingsManager::writeSetting(IpsServices::SettingItem settingItem,
+                                            const QVariant &settingValue)
 {
     HBufC *tmp = 0;
     HBufC8 *tmp8 = 0;
@@ -159,7 +162,10 @@
         case IpsServices::IncomingSSLWrapper:
             mPop3Settings->SetSSLWrapper(settingValue.toBool());
             ret = saveSettings();
-            break;  
+            break;
+        case IpsServices::Connection:
+            ret = saveIAPSettings(settingValue.toUInt());
+            // Fallthrough so SMTP IAP settings are also updated accordingly.
         default:
             ret = NmIpsSettingsManagerBase::writeSetting(settingItem, settingValue);
             break;
@@ -169,7 +175,6 @@
 
 /*!
     Deletes the POP3 mailbox.
-
     \return Error code <code>0</code> if mailbox deletion was successful, otherwise error
             code is returned.
 */
@@ -185,6 +190,19 @@
 }
 
 /*!
+     Determines the default port for the incoming mail server based on the security settings.
+     \return The port number to use.
+ */
+int NmIpsPop3SettingsManager::determineDefaultIncomingPort()
+{
+    int port(IpsServices::standardPop3Port);
+    if (mPop3Settings->SSLWrapper()) {
+        port = IpsServices::securePop3Port;
+    }        
+    return port;
+}
+
+/*!
     Stores the POP3 specific settings.
     \return bool <true> when the POP3 settings were succesfully written, otherwise <false>.
 */
@@ -196,18 +214,17 @@
 }
 
 /*!
-     Determine the default port for the incoming mail server based on the security settings
-     
-     \return int the port number to use
- */
-int NmIpsPop3SettingsManager::determineDefaultIncomingPort()
+    Stores the POP3 specific IAP settings.
+    \return bool <true> when the POP3 IAP settings were succesfully written, otherwise <false>.
+*/
+bool NmIpsPop3SettingsManager::saveIAPSettings(uint snapId)
 {
-    int port = 0;    
-    bool sslTls = mPop3Settings->SSLWrapper();    
-    if (sslTls) {
-        port = IpsServices::securePop3Port;
-    } else {
-        port = IpsServices::standardPop3Port;
-    }        
-    return port;
+    TRAPD(err,
+        CImIAPPreferences *prefs = CImIAPPreferences::NewLC();
+        mAccount->LoadPopIapSettingsL(mPop3Account, *prefs);
+        prefs->SetSNAPL(snapId);
+        mAccount->SavePopIapSettingsL(mPop3Account, *prefs);
+        CleanupStack::PopAndDestroy(prefs);
+    );
+    return (err==KErrNone);
 }
--- a/ipsservices/nmipssettings/src/nmipssettingscustomitem.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/src/nmipssettingscustomitem.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -78,6 +78,8 @@
     switch (type) {
         case LabeledComboBox: {
             widget = new NmIpsSettingsLabeledComboBox();
+            connect(widget, SIGNAL(propertyChanged(QMap<QString, QVariant>)),
+                    this, SLOT(propertyChanged(QMap<QString, QVariant>)));
             break;
             }
         case TimeEditor: {
--- a/ipsservices/nmipssettings/src/nmipssettingshelper.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/src/nmipssettingshelper.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -16,21 +16,29 @@
 */
 
 #include <QVariant>
+#include <QIntValidator>
+#include <QStringList>
+
 #include <HbAction>
 #include <HbGlobal>
 #include <HbMessageBox>
 #include <HbProgressDialog>
 #include <HbInputDialog>
-#include <cpsettingformitemdata.h>
-#include <hbdataformmodel.h>
-#include <qstringlist.h>
-#include <hbextendedlocale.h>
-#include <hblineedit.h>
+#include <HbDataFormModel>
+#include <HbExtendedLocale>
+#include <HbLineEdit>
 #include <HbValidator>
-#include <QIntValidator>
 #include <HbStringUtil>
 #include <HbDataForm>
 
+#include <cpsettingformitemdata.h>
+
+#include <cmapplsettingsui.h>
+#include <cmmanagerdefines_shim.h>
+#include <qnetworkconfigmanager.h>
+#include <qnetworkconfiguration.h>
+#include <qservicemanager.h>
+
 #include "nmipssettingshelper.h"
 #include "nmipssettingsmanagerbase.h"
 #include "nmipssettingscustomitem.h"
@@ -38,14 +46,32 @@
 
 // CONSTANTS
 
-// Dynamic receiving schedule group items
-const IpsServices::SettingItem NmIpsSettingsReceivingSchedule[] = {
+// Dynamic receiving schedule items.
+const IpsServices::SettingItem NmIpsSettingsReceivingScheduleItems[] = {
         IpsServices::ReceptionInboxSyncWindow,
         IpsServices::ReceptionWeekDays,
         IpsServices::ReceptionDayStartTime,
         IpsServices::ReceptionDayEndTime,
         IpsServices::ReceptionRefreshPeriodDayTime};
 
+// Dynamic receiving schedule item count.
+const int NmIpsSettingsReceivingScheduleItemCount(
+    sizeof(NmIpsSettingsReceivingScheduleItems) / sizeof(NmIpsSettingsReceivingScheduleItems[0]));
+
+// Index of ReceptionDayStartTime in NmIpsSettingsReceivingScheduleItems array.
+const int NmIpsSettingsIndexOfReceptionDayStartTime(2);
+
+// Index of user defined mode.
+const int NmIpsSettingsIndexOfUserDefinedMode(3);
+
+// Receving schedule item not found value.
+const int NmIpsSettingsRecevingScheduleItemNotFound(-1);
+
+
+
+QTM_USE_NAMESPACE
+
+
 /*!
     \class NmIpsSettingsHelper
     \brief Helper class to save data into database when user has made changes.
@@ -72,8 +98,9 @@
   mFolderPathInputDialog(0),
   mOutgoingPortInputDialog(0),
   mOutgoingPortInputValidator(0),
+  mDestinationDialog(0),
   mServerInfoDynamicItemsVisible(false),
-  mRadioButtonPreviousIndex(0)
+  mAbortDynamicRSItemHandling(false)
 {
 }
 
@@ -175,10 +202,10 @@
                     formItemData->setData(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1,
                         weekdayItemValues);
 
-                    formItemData->setContentWidgetData(QString("heading"),
+                    formItemData->setContentWidgetData("heading",
                         hbTrId("txt_mailips_dialog_heading_receiving_weekdays"));
 
-                    formItemData->setContentWidgetData(QString("items"), weekdayItems);
+                    formItemData->setContentWidgetData("items", weekdayItems);
 
                     mDataForm.addConnection(formItemData, SIGNAL(editingFinished()),
                         this, SLOT(receivingWeekdaysModified()));
@@ -198,14 +225,21 @@
                    }
                 }
 
-                formItemData->setContentWidgetData(QString("selectedItems"), selectedDays);
+                formItemData->setContentWidgetData("selectedItems", selectedDays);
 
-                // Every weekday selected
-                if (days == 0x7f) {
-                    formItemData->setContentWidgetData(QString("text"),
+                if (days == 0) {
+                    // Abort receiving schedule handling and delete unecessary settings items.
+                    mAbortDynamicRSItemHandling = true;
+                    noReceptionWeekdaysSelected();
+                    // Update button text nothing selected.
+                    formItemData->setContentWidgetData("text",
+                        hbTrId("txt_mailips_setlabel_download_images_val_none"));
+
+                } else if (days == 0x7f) {
+                    // Update button text every day selected.
+                    formItemData->setContentWidgetData("text",
                         hbTrId("txt_mailips_setlabel_download_images_val_every_day"));
                 }
-
                 break;
             }
 
@@ -219,7 +253,7 @@
                             hbTrId("txt_mailips_setlabel_day_start_time"));
 
                     insertContentItem(IpsServices::ReceptionDayStartTime, formItemData);
-                    formItemData->setContentWidgetData(QString("heading"),
+                    formItemData->setContentWidgetData("heading",
                         hbTrId("txt_mailips_dialog_heading_start_time"));
                     mReceivingScheduleGroupItem->appendChild(formItemData);
                     mDataForm.addConnection(formItemData, SIGNAL(timeChanged(QTime)),
@@ -242,11 +276,11 @@
                 // If not exist, create one
                 if (!formItemData) {
                     formItemData = new CpSettingFormItemData(
-                        static_cast<HbDataFormModelItem::DataItemType> (NmIpsSettingsCustomItem::TimeEditor),
+                        static_cast<HbDataFormModelItem::DataItemType>(NmIpsSettingsCustomItem::TimeEditor),
                             hbTrId("txt_mailips_setlabel_day_end_time"));
 
                     insertContentItem(IpsServices::ReceptionDayEndTime, formItemData);
-                    formItemData->setContentWidgetData(QString("heading"),
+                    formItemData->setContentWidgetData("heading",
                         hbTrId("txt_mailips_dialog_heading_end_time"));
                     mReceivingScheduleGroupItem->appendChild(formItemData);
                 }
@@ -273,23 +307,18 @@
 
                     mReceivingScheduleGroupItem->appendChild(formItemData);
                     insertContentItem(IpsServices::ReceptionRefreshPeriodDayTime, formItemData);
+
+                    // If changes are made to refreshMailItems, conversion table in
+                    // refreshPeriodModified method needs to be updated also.
                     QStringList refreshMailItems;
                     refreshMailItems << hbTrId("txt_mailips_setlabel_val_keep_uptodate")
-                                     << hbTrId("txt_mailips_setlabel_val_every_15_minutes")
-                                     << hbTrId("txt_mailips_setlabel_val_every_1_hour")
-                                     << hbTrId("txt_mailips_setlabel_val_every_4_hours");
-                    formItemData->setContentWidgetData(QString("items"), refreshMailItems);
-
-                    QList<QVariant> refreshMailItemValues;
-                    refreshMailItemValues << 5
-                                          << 15
-                                          << 60
-                                          << 240;
-                    QVariant value(refreshMailItemValues);
-                    formItemData->setData(HbDataFormModelItem::DescriptionRole + 1, value);
-
-                    mDataForm.addConnection(formItemData, SIGNAL(itemSelected(int)),
-                        this, SLOT(refreshPeriodModified(int)));
+                                     << HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_15_minutes"))
+                                     << HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_1_hour"))
+                                     << HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_4_hours"));
+                    formItemData->setContentWidgetData("items", refreshMailItems);
+                    mDataForm.addConnection(
+                        formItemData, SIGNAL(valueChanged(QPersistentModelIndex, QVariant)),
+                        this, SLOT(refreshPeriodModified(QPersistentModelIndex, QVariant)));
                 }
 
                 // Update data
@@ -300,7 +329,7 @@
                 refreshPeriod[15] = 1;
                 refreshPeriod[60] = 2;
                 refreshPeriod[240] = 3;
-                formItemData->setContentWidgetData(QString("selected"),
+                formItemData->setContentWidgetData("selected",
                     refreshPeriod.value(interval.toInt()));
                 break;
             }
@@ -316,7 +345,7 @@
 /*!
     Creates the setting items under the Serverinfo group items user authentication.
 */
-void NmIpsSettingsHelper::createServerInfoGroupDynamicItems()
+void NmIpsSettingsHelper::createServerInfoGroupDynamicItems(bool hiddenItem)
 {   
     HbDataFormModelItem *item = mContentItems.value(IpsServices::SMTPAuthentication);
     int insertIndex = mServerInfoGroupItem->indexOf(item) + 1;
@@ -327,11 +356,15 @@
     CpSettingFormItemData *usernameItem = new CpSettingFormItemData(
         HbDataFormModelItem::TextItem, hbTrId("txt_mailips_setlabel_username"));
     insertContentItem(IpsServices::OutgoingLoginName, usernameItem);
-    usernameItem->setContentWidgetData(QString("text"), username);
+    usernameItem->setContentWidgetData("text", username);
     mDataForm.addConnection(usernameItem, SIGNAL(editingFinished()),
                             this, SLOT(saveOutgoingUserName()));
     mDataForm.addConnection(usernameItem, SIGNAL(textChanged(QString)),
                             this, SLOT(outgoingUserNameTextChange(QString)));
+    if (hiddenItem) { // Starred and dimmed.
+        usernameItem->setContentWidgetData("echoMode", HbLineEdit::Password);
+        usernameItem->setEnabled(false);
+    }
     mServerInfoGroupItem->insertChild(insertIndex, usernameItem);
 
     // Password
@@ -340,8 +373,8 @@
     CpSettingFormItemData *passwordItem = new CpSettingFormItemData(
         HbDataFormModelItem::TextItem, hbTrId("txt_mailips_setlabel_password"));
     insertContentItem(IpsServices::OutgoingPassword, passwordItem);
-    passwordItem->setContentWidgetData(QString("text"), password);
-    passwordItem->setContentWidgetData(QString("echoMode"), HbLineEdit::PasswordEchoOnEdit);
+    passwordItem->setContentWidgetData("text", password);
+    passwordItem->setContentWidgetData("echoMode", HbLineEdit::PasswordEchoOnEdit);
     mDataForm.addConnection(passwordItem, SIGNAL(editingFinished()),
                             this, SLOT(saveOutgoingPassword()));
     mServerInfoGroupItem->insertChild(insertIndex + 1, passwordItem);
@@ -356,7 +389,7 @@
 {
     if (mCurrentLineEditChanged) {
         HbDataFormModelItem *item = mContentItems.value(IpsServices::EmailAlias);
-        QVariant data = item->contentWidgetData(QString("text"));
+        QVariant data = item->contentWidgetData("text");
         mSettingsManager.writeSetting(IpsServices::EmailAlias, data);
     }
     mCurrentLineEditChanged = false;
@@ -364,7 +397,6 @@
 
 /*!
     Sets the edit changed flag to indicate that user has edited the field
-
     \param text Reference to the text value in the line edit box.
 */
 void NmIpsSettingsHelper::myNameTextChange(const QString &text)
@@ -381,7 +413,7 @@
 	bool ok = true;
     if (mCurrentLineEditChanged) {
         HbDataFormModelItem *item = mContentItems.value(IpsServices::MailboxName);
-        QVariant data = item->contentWidgetData(QString("text"));
+        QVariant data = item->contentWidgetData("text");
         // Only save mailbox name if it's length is greater than zero. CEmailAccounts does not
         // allow zero-length mailbox names.
         if (data.toString().length() > 0) {
@@ -395,22 +427,23 @@
 				ok = mSettingsManager.writeSetting(IpsServices::MailboxName, data);
 			}
 
+            // Update the mailbox's name to AppLib.
+            updateAppLib(UpdateMailboxName, data.toString());
+
             QVariant property(NmSettings::MailboxName);
             emit mailboxPropertyChanged(mSettingsManager.mailboxId(), property, data);
         }
         else {
             if (mSettingsManager.readSetting(IpsServices::MailboxName, data)) {
-                item->setContentWidgetData(QString("text"), data);
+                item->setContentWidgetData("text", data);
             }
         }
-
     }
     mCurrentLineEditChanged = false;
 }
 
 /*!
     Sets the edit changed flag to indicate that user has edited the field
-
     \param text Reference to the text value in the line edit box.
 */
 void NmIpsSettingsHelper::mailboxNameTextChange(const QString &text)
@@ -428,8 +461,10 @@
 		emit goOffline(mSettingsManager.mailboxId());
 		mEmitOnline = true;
 		HbDataFormModelItem *item = mContentItems.value(IpsServices::EmailAddress);
-        QVariant data = item->contentWidgetData(QString("text"));
+        QVariant data = item->contentWidgetData("text");
         mSettingsManager.writeSetting(IpsServices::EmailAddress, data);
+        QVariant property(NmSettings::MailboxName);
+        emit mailboxPropertyChanged(mSettingsManager.mailboxId(), property, data);
     }
     mCurrentLineEditChanged = false;
 }
@@ -454,11 +489,11 @@
 		emit goOffline(mSettingsManager.mailboxId());
 		mEmitOnline = true;
 		HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingLoginName);
-        QVariant username = item->contentWidgetData(QString("text"));
+        QVariant username = item->contentWidgetData("text");
         mSettingsManager.writeSetting(IpsServices::IncomingLoginName, username);
         // Outgoing username needs to be updated if it is set as Same as Incoming.
         item = mContentItems.value(IpsServices::SMTPAuthentication);
-        QVariant selected = item->contentWidgetData(QString("selected"));
+        QVariant selected = item->contentWidgetData("selected");
         if (selected.toInt() == IpsServices::EMailAuthSameAsIncoming) {
             mSettingsManager.writeSetting(IpsServices::OutgoingLoginName, username);
         }
@@ -475,7 +510,7 @@
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
         HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingLoginName);
-        QVariant data = item->contentWidgetData(QString("text"));
+        QVariant data = item->contentWidgetData("text");
         mSettingsManager.writeSetting(IpsServices::OutgoingLoginName, data);
     }
     mCurrentLineEditChanged = false;
@@ -512,11 +547,11 @@
 	emit goOffline(mSettingsManager.mailboxId());
 	mEmitOnline = true;
 	HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingPassword);
-    QVariant password = item->contentWidgetData(QString("text"));
+    QVariant password = item->contentWidgetData("text");
     mSettingsManager.writeSetting(IpsServices::IncomingPassword, password);
     // Outgoing password needs to be updated if it is set as Same as Incoming.
     item = mContentItems.value(IpsServices::SMTPAuthentication);
-    QVariant selected = item->contentWidgetData(QString("selected"));
+    QVariant selected = item->contentWidgetData("selected");
     if (selected.toInt() == IpsServices::EMailAuthSameAsIncoming) {
         mSettingsManager.writeSetting(IpsServices::OutgoingPassword, password);
     }
@@ -530,7 +565,7 @@
     emit goOffline(mSettingsManager.mailboxId());
     mEmitOnline = true;
     HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingPassword);
-    QVariant data = item->contentWidgetData(QString("text"));
+    QVariant data = item->contentWidgetData("text");
     mSettingsManager.writeSetting(IpsServices::OutgoingPassword, data);
 }
 /*!
@@ -540,7 +575,7 @@
 {
     if (mCurrentLineEditChanged) {
         HbDataFormModelItem *item = mContentItems.value(IpsServices::ReplyAddress);
-        QVariant data = item->contentWidgetData(QString("text"));
+        QVariant data = item->contentWidgetData("text");
         mSettingsManager.writeSetting(IpsServices::ReplyAddress, data);
     }
     mCurrentLineEditChanged = false;
@@ -548,7 +583,6 @@
 
 /*!
     Sets the edit changed flag to indicate that user has edited the field
-
     \param text Reference to the text value in the line edit box.
 */
 void NmIpsSettingsHelper::replyToTextChange(const QString &text)
@@ -577,8 +611,7 @@
 */
 void NmIpsSettingsHelper::handleMailboxDelete(HbAction *action)
 {
-    if (action == mDeleteConfirmationDialog->primaryAction()) {
-        
+    if (action == mDeleteConfirmationDialog->actions().at(0)) {        
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = false;
     
@@ -589,13 +622,16 @@
         // button.
         HbProgressDialog progressNote(HbProgressDialog::WaitDialog);
         progressNote.setText(hbTrId("txt_common_info_deleting"));
-        action = progressNote.primaryAction();
-        progressNote.removeAction(action);
+        progressNote.removeAction(progressNote.actions().at(0));
         progressNote.delayedShow();
     
         if (!mSettingsManager.deleteMailbox()) {
-            // The mailbox was deleted successfully. Hide the progress note and
-            // display the "mailbox deleted" dialog.
+            // The mailbox was deleted successfully.
+
+            // Delete the mailbox also from AppLib.
+            updateAppLib(UnregisterMailbox);
+
+            // Hide the progress note and display the "mailbox deleted" dialog.
             progressNote.close();
             
             if (!mDeleteInformationDialog) {
@@ -615,7 +651,7 @@
 }
 
 /*!
-    Handels the event after the mailbox delete information dialog has been dismissed.
+    Handles the event after the mailbox delete information dialog has been dismissed.
 */
 void NmIpsSettingsHelper::handleMailboxDeleteUpdate(HbAction *action)
 {
@@ -641,26 +677,24 @@
         item->setData(HbDataFormModelItem::PropertyRole, data);
     }
 
-    // Read receiving schedule dynamic group item values and
+    // Read receiving schedule item values and
     // make a decision based on those if item should be visible or not.
-    const int dynamicGroupItemsCount(
-        sizeof(NmIpsSettingsReceivingSchedule) / sizeof(NmIpsSettingsReceivingSchedule[0]));
+    mAbortDynamicRSItemHandling = false;
+    for (int index(0); (index < NmIpsSettingsReceivingScheduleItemCount) &&
+             !mAbortDynamicRSItemHandling; ++index) {
 
-    for (int itemIndex(0); itemIndex < dynamicGroupItemsCount; ++itemIndex) {
+        // Read setting value from active profile
         QVariant setting;
-        // Read setting value from active profile
-        IpsServices::SettingItem item(NmIpsSettingsReceivingSchedule[itemIndex]);
+        IpsServices::SettingItem item(NmIpsSettingsReceivingScheduleItems[index]);
         mSettingsManager.readSetting(item, setting);
 
         // If setting value is not valid (-1=N/A) then remove setting item.
-        int value = setting.toInt();
-        if (value != -1) {
+        if (setting.toInt() != NmIpsSettingsRecevingScheduleItemNotFound) {
             createOrUpdateReceivingScheduleGroupDynamicItem(item);
         } else {
             deleteReceivingScheduleGroupDynamicItem(item);
         }
     }
-
     updateShowMailInMailbox();
 }
 
@@ -688,7 +722,7 @@
 
     HbDataFormModelItem *item = mContentItems.value(IpsServices::ReceptionInboxSyncWindow);
     if (item) {
-        item->setContentWidgetData(QString("selected"), syncWindows.value(value.toInt()));
+        item->setContentWidgetData("selected", syncWindows.value(value.toInt()));
     }
 }
 
@@ -742,7 +776,7 @@
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
         HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingMailServer);
-        QVariant data = item->contentWidgetData(QString("text"));
+        QVariant data = item->contentWidgetData("text");
         mSettingsManager.writeSetting(IpsServices::IncomingMailServer, data);
     }
     mCurrentLineEditChanged = false;
@@ -750,7 +784,6 @@
 
 /*!
     Sets the edit changed flag to indicate that user has edited the field
-
     \param text Reference to the text value in the line edit box.
 */
 void NmIpsSettingsHelper::incomingMailServerTextChange(const QString &text)
@@ -767,7 +800,7 @@
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
         HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingMailServer);
-        QVariant data = item->contentWidgetData(QString("text"));
+        QVariant data = item->contentWidgetData("text");
         mSettingsManager.writeSetting(IpsServices::OutgoingMailServer, data);
     }
     mCurrentLineEditChanged = false;
@@ -775,7 +808,6 @@
 
 /*!
     Sets the edit changed flag to indicate that user has edited the field
-
     \param text Reference to the text value in the line edit box.
 */
 void NmIpsSettingsHelper::outgoingMailServerTextChange(const QString &text)
@@ -787,23 +819,26 @@
 /*!
     Saves the incoming port value into database if user has changed the value. If the user wish to
     define the port, a input dialog is shown.
-    
     \param index Used to determine if the default value or a user defined value should be written
 */
 void NmIpsSettingsHelper::incomingPortChange(int index)
 {
-    if (mRadioButtonPreviousIndex != index && index == IpsServices::NmIpsSettingsDefault) {
-        emit goOffline(mSettingsManager.mailboxId());
-        mEmitOnline = true;
-        int port = mSettingsManager.determineDefaultIncomingPort();
-        mSettingsManager.writeSetting(IpsServices::IncomingPort, port);
+    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);    
+        }
     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
         showIncomingPortInputDialog();
     }
 }
 
 /*!
-    Show a input dialog for allowing the user to specify a incoming port.
+    Shows an input dialog for allowing the user to specify a incoming port.
 */
 void NmIpsSettingsHelper::showIncomingPortInputDialog()
 {    
@@ -828,11 +863,13 @@
 }
 
 /*!
-   Handels the saving of the port new value.
+   Handles the saving of the port new value.
 */
 void NmIpsSettingsHelper::handleUserDefinedIncomingPortInput(HbAction *action)
 {
-    if (action == mIncomingPortInputDialog->primaryAction()) {
+    int previousindex = getCorrectIncomingPortRadioButtonIndex();
+    
+    if (action == mIncomingPortInputDialog->actions().at(0)) {
         QVariant newPort = mIncomingPortInputDialog->value();
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
@@ -840,20 +877,21 @@
     } else {
         //set selected value back if user canceled.
         HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingPort);
-        item->setContentWidgetData(QString("selected"), mRadioButtonPreviousIndex);
+        item->setContentWidgetData("selected", previousindex);
     }
 }
 
 /*!
     Used for getting the index to display in the port radio button list 
-    
     \return index Used to set the selected value
 */
-int NmIpsSettingsHelper::getCorrectPortRadioButtonIndex(int currentPort)
+int NmIpsSettingsHelper::getCorrectIncomingPortRadioButtonIndex()
 {
+    QVariant incomingPort;
+        mSettingsManager.readSetting(IpsServices::IncomingPort, incomingPort);
     int index = 0;
     int port = mSettingsManager.determineDefaultIncomingPort();
-    if (port == currentPort) {
+    if (port == incomingPort.toInt()) {
         index = IpsServices::NmIpsSettingsDefault;
     } else {
         index = IpsServices::NmIpsSettingsUserDefined;
@@ -862,24 +900,13 @@
 }
 
 /*!
-    Sets the previous index value to indicate that user has edited the field
-
-    \param text Reference to the item in the radio button list.
-*/
-void NmIpsSettingsHelper::incomingPortPress(const QModelIndex &index)
-{
-    Q_UNUSED(index);
-    HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingPort);
-    QVariant data = item->contentWidgetData(QString("selected"));
-    mRadioButtonPreviousIndex = data.toInt();
-}
-
-/*!
     Saves the incoming secure connection value into database if user has changed the value.
 */
 void NmIpsSettingsHelper::incomingSecureConnectionItemChange(int index)
-{
-    if (mRadioButtonPreviousIndex != index) {
+{  
+    int previousindex = getCorrectIncomingSecureRadioButtonIndex();
+    
+    if (previousindex != index) {
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
         switch (index) {
@@ -887,52 +914,69 @@
                 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:
+    
+             default:
                 break;
         }
         // Update incoming port value only if default incoming port used
         HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingPort);
-        QVariant data = item->contentWidgetData(QString("selected"));
+        QVariant data = item->contentWidgetData("selected");
         // Default incoming port selected
         if (data.toInt() == IpsServices::NmIpsSettingsDefault) {
-			int port = mSettingsManager.determineDefaultIncomingPort();
-			mSettingsManager.writeSetting(IpsServices::IncomingPort, port);
+            int port = mSettingsManager.determineDefaultIncomingPort();
+            mSettingsManager.writeSetting(IpsServices::IncomingPort, port);
         }
     }
 }
 
 /*!
-    Sets the previous index value to indicate that user has edited the field
-
-    \param text Reference to the item in the radio button list.
+    Used for getting the index to display in the secure connection radio button list.
+    \return index Used to set the selected value
 */
-void NmIpsSettingsHelper::incomingSecureConnectionPress(const QModelIndex &index)
+int NmIpsSettingsHelper::getCorrectIncomingSecureRadioButtonIndex()
 {
-	Q_UNUSED(index);
-	HbDataFormModelItem *item = mContentItems.value(IpsServices::IncomingSecureSockets);
-    QVariant data = item->contentWidgetData(QString("selected"));
-    mRadioButtonPreviousIndex = data.toInt();
+    QVariant secureSockets;
+    QVariant secureSSLWrapper;
+    mSettingsManager.readSetting(IpsServices::IncomingSecureSockets, secureSockets);
+    mSettingsManager.readSetting(IpsServices::IncomingSSLWrapper, secureSSLWrapper);
+    
+    IpsServices::TIpsSetDataSecurityTypes securityType = IpsServices::EMailStartTls;
+    // secureSockets == True
+    if (secureSockets.toBool()) { 
+        securityType = IpsServices::EMailStartTls;
+    }
+    // secureSockets == False & secureSSLWrapper == True
+    else if (secureSSLWrapper.toBool()) {
+        securityType = IpsServices::EMailSslTls;
+    }
+    // secureSockets == False & secureSSLWrapper == False
+    else {
+        securityType = IpsServices::EMailSecurityOff;
+    }
+    return securityType;
 }
 
 /*!
-    Used for getting the index to display in the secure connection radio button list 
-    
+    Used for getting the index to display in the secure connection radio button list.
     \return index Used to set the selected value
 */
-int NmIpsSettingsHelper::getCorrectSecureRadioButtonIndex(QVariant secureSockets, 
-                                                          QVariant secureSSLWrapper)
+int NmIpsSettingsHelper::getCorrectOutgoingSecureRadioButtonIndex()
 {
+    QVariant secureSockets;
+    QVariant secureSSLWrapper;
+    mSettingsManager.readSetting(IpsServices::OutgoingSecureSockets, secureSockets);
+    mSettingsManager.readSetting(IpsServices::OutgoingSSLWrapper, secureSSLWrapper);
+    
     IpsServices::TIpsSetDataSecurityTypes securityType = IpsServices::EMailStartTls;
     // secureSockets == True
     if (secureSockets.toBool()) { 
@@ -954,9 +998,13 @@
 */
 void NmIpsSettingsHelper::folderPathChange(int index)
 {
-    if (mRadioButtonPreviousIndex != index && index == IpsServices::NmIpsSettingsDefault) {
-        // Empty string sets the folder path to default.
-        mSettingsManager.writeSetting(IpsServices::FolderPath, QString(""));
+    int previousindex = getCorrectFolderPathRadioButtonIndex();
+        
+    if (index == IpsServices::NmIpsSettingsDefault) {
+        if (index != previousindex ) {
+            // Empty string sets the folder path to default.
+            mSettingsManager.writeSetting(IpsServices::FolderPath, "");    
+        }
     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
         showFolderPathInputDialog();       
     }
@@ -987,43 +1035,32 @@
 */
 void NmIpsSettingsHelper::handleUserDefinedFolderPathInput(HbAction *action)
 {
+    int previousindex = getCorrectFolderPathRadioButtonIndex();
+    
     HbDataFormModelItem *item = mContentItems.value(IpsServices::FolderPath);
     
-    if (action == mFolderPathInputDialog->primaryAction()) { 
+    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.
         if (newFolderPath.toString().isEmpty()) {
-            item->setContentWidgetData(QString("selected"), IpsServices::NmIpsSettingsDefault);
+            item->setContentWidgetData("selected", IpsServices::NmIpsSettingsDefault);
         }
     } else {
         //set selected value back if user canceled.
-        item->setContentWidgetData(QString("selected"), mRadioButtonPreviousIndex);
+        item->setContentWidgetData("selected", previousindex);
     }
 }
 
 /*!
-    Sets the previous index value to indicate that user has edited the field.
-
-    \param text Reference to the item in the radio button list.
-*/
-void NmIpsSettingsHelper::folderPathPress(const QModelIndex &index)
-{
-    Q_UNUSED(index);
-    HbDataFormModelItem *item = mContentItems.value(IpsServices::FolderPath);
-    QVariant data = item->contentWidgetData(QString("selected"));
-    mRadioButtonPreviousIndex = data.toInt();
-}
-
-/*!
     Handles weekdays modifications.
 */
 void NmIpsSettingsHelper::receivingWeekdaysModified()
 {
     HbDataFormModelItem *item = mContentItems.value(IpsServices::ReceptionWeekDays);
-    QVariant widgetData = item->contentWidgetData(QString("selectedItems"));
+    QVariant widgetData = item->contentWidgetData("selectedItems");
     QList<QVariant> selectedIndexes = widgetData.value< QList<QVariant> >();
-    QVariant itemData = item->data(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1);
+    QVariant itemData = item->data(HbDataFormModelItem::DescriptionRole + 1);
     QList<QVariant> itemValues = itemData.value< QList<QVariant> >();
 
     int days(0);
@@ -1031,57 +1068,81 @@
         days |= itemValues.at(selectedIndex.toInt()).toInt();
     }
 
-    handleReceivingScheduleSettingChange(IpsServices::ReceptionWeekDays, days);
+    QVariant previouslySelectedValue;
+    mSettingsManager.readSetting(IpsServices::ReceptionWeekDays, previouslySelectedValue);
+    if (days != previouslySelectedValue.toInt()) {
+        handleReceivingScheduleSettingChange(IpsServices::ReceptionWeekDays, days);
+    }
 
-    // Every weekday selected.
-    if (days == 0x7f) {
-        item->setContentWidgetData(QString("text"),
+    // Although the mode might not be changed we need to still update the button text.
+    if (days == 0) {
+        noReceptionWeekdaysSelected();
+        item->setContentWidgetData("text", hbTrId("txt_mailips_setlabel_download_images_val_none"));
+    } else if (days == 0x7f) {
+        item->setContentWidgetData("text",
             hbTrId("txt_mailips_setlabel_download_images_val_every_day"));
     }
 }
 
 /*!
     Handles start time modifications.
-	
     \param time Modified start time.
 */
 void NmIpsSettingsHelper::startTimeModified(QTime time)
 {
     int startTime(time.hour()*60 + time.minute());
-    handleReceivingScheduleSettingChange(IpsServices::ReceptionDayStartTime, startTime);
+    QVariant previouslySelectedStartTime;
+    mSettingsManager.readSetting(IpsServices::ReceptionDayStartTime, previouslySelectedStartTime);
+    if (startTime != previouslySelectedStartTime.toInt()) {
+        handleReceivingScheduleSettingChange(IpsServices::ReceptionDayStartTime, startTime);
+    }
 }
 
 /*!
     Handles refresh period modifications.
-
-    \param index selected item index.
+    \param value Selected value as a text.
 */
-void NmIpsSettingsHelper::refreshPeriodModified(int index)
+void NmIpsSettingsHelper::refreshPeriodModified(QPersistentModelIndex, QVariant value)
 {
-    HbDataFormModelItem* item = mContentItems.value(IpsServices::ReceptionRefreshPeriodDayTime);
-    QVariant itemData = item->data(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1);
-    int selectedValue = itemData.value< QList< QVariant > >().at(index).toInt();
-    handleReceivingScheduleSettingChange(IpsServices::ReceptionRefreshPeriodDayTime, selectedValue);
+    QMap<QString, int> conversionTable;
+    conversionTable[HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_keep_uptodate"))] = 5;
+    conversionTable[HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_15_minutes"))] = 15;
+    conversionTable[HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_1_hour"))] = 60;
+    conversionTable[HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_4_hours"))] = 240;
+
+    int selectedValue(conversionTable.value(value.toString()));
+    QVariant previouslySelectedValue;
+    mSettingsManager.readSetting(IpsServices::ReceptionRefreshPeriodDayTime,
+        previouslySelectedValue);
+    if (selectedValue != previouslySelectedValue.toInt()) {
+        handleReceivingScheduleSettingChange(IpsServices::ReceptionRefreshPeriodDayTime,
+            selectedValue);
+    }
 }
 
 /*!
     Handles end time modifications.
-
     \param time Modified start time.
 */
 void NmIpsSettingsHelper::endTimeModified(QTime time)
 {
     int endTime(time.hour()*60 + time.minute());
-    handleReceivingScheduleSettingChange(IpsServices::ReceptionDayEndTime, endTime);
+    QVariant previouslySelectedEndTime;
+    mSettingsManager.readSetting(IpsServices::ReceptionDayEndTime, previouslySelectedEndTime);
+    if (endTime != previouslySelectedEndTime) {
+        handleReceivingScheduleSettingChange(IpsServices::ReceptionDayEndTime, endTime);
+    }
 }
 
 /*!
     Used for getting the index to display in the inbox path radio button list 
-    
     \return index Used to set the selected value
 */
-int NmIpsSettingsHelper::getCorrectInboxPathRadioButtonIndex(QVariant folderPath)
+int NmIpsSettingsHelper::getCorrectFolderPathRadioButtonIndex()
 {
+    QVariant folderPath;
+    mSettingsManager.readSetting(IpsServices::FolderPath, folderPath);
+    
     int index(0);
     if (folderPath.toString().isEmpty()) {
         index = IpsServices::NmIpsSettingsDefault;
@@ -1095,7 +1156,6 @@
     Handles receiving schedule item value modifications.
     Takes care of creating 'user defined' mode, coping values from active profile to
     user defined mode, storing changed value and selecting 'user defined' mode.
-
     \param settingItem Changed setting item.
     \param settingValue Setting item's value.
 */
@@ -1124,55 +1184,119 @@
 
     // update selection
     HbDataFormModelItem *syncProfile = contentItem(IpsServices::ReceptionActiveProfile);
-    syncProfile->setContentWidgetData(QString("currentIndex"), 3);
+    syncProfile->setContentWidgetData("currentIndex", NmIpsSettingsIndexOfUserDefinedMode);
+}
+
+/*!
+     Return the localized name for network destination with id of \a identifier.
+     \param identifier Network destination identifier.
+     \return Name of the network destination.
+ */
+QString NmIpsSettingsHelper::destinationNameFromIdentifier(uint identifier)
+{
+    const QString snapPrefix("S_");
+
+    QNetworkConfigurationManager netMan;
+    QNetworkConfiguration conf =
+        netMan.configurationFromIdentifier(snapPrefix + QString::number(identifier));
+    return conf.name();
 }
 
 /*!
     Copies receiving schedule settings from currently active profile to given profile.
-
     \param profileMode Mode where receiving schedule settings from active profile are copied to.
 */
 void NmIpsSettingsHelper::copyReceivingScheduleSettingsFromActiveProfile(int profileMode)
 {
     // Read receiving schedule dynamic group item values and
     // make a decision based on those if item should be visible or not.
-    const int dynamicGroupItemsCount(
-        sizeof(NmIpsSettingsReceivingSchedule) / sizeof(NmIpsSettingsReceivingSchedule[0]));
-
     NmIpsExtendedSettingsManager &extendedSettingsManager =
         mSettingsManager.extendedSettingsManager();
 
-    for (int itemIndex(0); itemIndex < dynamicGroupItemsCount; ++itemIndex) {
+    for (int index(0); index < NmIpsSettingsReceivingScheduleItemCount; ++index) {
         QVariant setting;
         // Read setting value from active profile
-        IpsServices::SettingItem item(NmIpsSettingsReceivingSchedule[itemIndex]);
+        IpsServices::SettingItem item(NmIpsSettingsReceivingScheduleItems[index]);
         mSettingsManager.readSetting(item, setting);
 
         // write settings to user defined profile.
         extendedSettingsManager.writeSetting(profileMode, item, setting);
     }
 }
+
+/*!
+    Updates the mailbox entry in AppLib.
+    \param op App Library operation.
+    \param mailboxName Mailbox name.
+*/
+void NmIpsSettingsHelper::updateAppLib(AppLibUpdateOperation op, QString mailboxName)
+{
+    // Find and load the interface.
+    QServiceManager manager;
+    QServiceFilter filter("com.nokia.symbian.IEmailRegisterAccount");
+    QList<QServiceInterfaceDescriptor> interfaces = manager.findInterfaces(filter);
+    QObject *registerInterface = 0;
+    if (!interfaces.isEmpty()) {
+        registerInterface = manager.loadInterface(interfaces.first());
+    }
+
+    if (registerInterface) {
+        quint64 mailboxId(mSettingsManager.mailboxId().id());
+        switch(op) {
+            case UnregisterMailbox:
+                // Try to remove the mailbox from the App Library.
+                (void)QMetaObject::invokeMethod(registerInterface,
+                    "unregisterMailbox",
+                    Q_ARG(quint64, mailboxId));
+                break;
+            case UpdateMailboxName:
+                // Update the mailbox's name in the App Library.
+                (void)QMetaObject::invokeMethod(registerInterface,
+                    "updateMailboxName",
+                    Q_ARG(quint64, mailboxId),
+                    Q_ARG(QString, mailboxName));
+                break;
+            default:
+                break;
+        }
+    }
+}
+
+/*!
+    Deletes ReceptionDayStartTime, ReceptionDayEndTime and ReceptionRefreshPeriodDayTime
+    setting items.
+*/
+void NmIpsSettingsHelper::noReceptionWeekdaysSelected()
+{
+    for (int index(NmIpsSettingsIndexOfReceptionDayStartTime);
+            index < NmIpsSettingsReceivingScheduleItemCount; ++index) {
+        deleteReceivingScheduleGroupDynamicItem(NmIpsSettingsReceivingScheduleItems[index]);
+    }
+}
+
 /*!
     Saves the outgoing port value into database if user has changed the value. If the user wish to
     define the port, a input dialog is shown.
-
     \param index Used to determine if the default value or a user defined value should be written
 */
 void NmIpsSettingsHelper::outgoingPortChange(int index)
 {
-    if (mRadioButtonPreviousIndex != index && index == IpsServices::NmIpsSettingsDefault) {
-        emit goOffline(mSettingsManager.mailboxId());
-        mEmitOnline = true;
-        int port = mSettingsManager.determineDefaultOutgoingPort();
-        mSettingsManager.writeSetting(IpsServices::OutgoingPort, port);
+    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);    
+        }
     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
         showOutgoingPortInputDialog();
     }
 }
 
 /*!
-    Show a input dialog for allowing the user to specify a outgoing port.
-
+    Shows an input dialog for allowing the user to specify a outgoing port.
 */
 void NmIpsSettingsHelper::showOutgoingPortInputDialog()
 {
@@ -1197,11 +1321,14 @@
 }
 
 /*!
-    Handels the saving of the port new value.
+    Handles the saving of the port new value.
+    \action Selected action.
 */
 void NmIpsSettingsHelper::handleUserDefinedOutgoingPortInput(HbAction *action)
 {
-    if (action == mOutgoingPortInputDialog->primaryAction()) {
+    int previousindex = getCorrectOutgoingPortRadioButtonIndex();
+    
+    if (action == mOutgoingPortInputDialog->actions().at(0)) {
         QVariant newPort = mOutgoingPortInputDialog->value();
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
@@ -1209,33 +1336,39 @@
     } else {
         //set selected value back if user canceled.
         HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingPort);
-        item->setContentWidgetData(QString("selected"), mRadioButtonPreviousIndex);
+        item->setContentWidgetData("selected", previousindex);
     }
 }
 
 /*!
-    Sets the previous index value to indicate that user has edited the field
-
-    \param index Reference to the item in the radio button list.
+    Handles the saving of the selected network connection.
+    \param status Dialog exit status \sa CmApplSettingsUi::ApplSettingsError.
 */
-void NmIpsSettingsHelper::outgoingPortPress(const QModelIndex &index)
+void NmIpsSettingsHelper::handleConnectionSelected(uint status)
 {
-    Q_UNUSED(index);
-    HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingPort);
-    QVariant data = item->contentWidgetData(QString("selected"));
-    mRadioButtonPreviousIndex = data.toInt();
+    if (status == CmApplSettingsUi::ApplSettingsErrorNone) {
+        CmApplSettingsUi::SettingSelection selection = mDestinationDialog->selection();
+        uint destId(selection.id);
+        if (mSettingsManager.writeSetting(IpsServices::Connection, QVariant(destId))) {
+            QString destName(destinationNameFromIdentifier(destId));
+            HbDataFormModelItem *item = mContentItems.value(IpsServices::Connection);
+            item->setContentWidgetData("text", destName);
+        }
+    }
 }
 
 /*!
-    Used for getting the index to display in the outgoing port radio button list
-
-    \return index Used to set the selected value
+    Used for getting the index to display in the outgoing port radio button list.
+    \return index Used to set the selected value.
 */
-int NmIpsSettingsHelper::getCorrectOutgoingPortRadioButtonIndex(int currentPort)
+int NmIpsSettingsHelper::getCorrectOutgoingPortRadioButtonIndex()
 {
+    QVariant outgoingPort;
+    mSettingsManager.readSetting(IpsServices::OutgoingPort, outgoingPort);
+    
     int index = 0;
     int port = mSettingsManager.determineDefaultOutgoingPort();
-    if (port == currentPort) {
+    if (port == outgoingPort.toInt()) {
         index = IpsServices::NmIpsSettingsDefault;
     } else {
         index = IpsServices::NmIpsSettingsUserDefined;
@@ -1244,9 +1377,8 @@
 }
 
 /*!
-    Used for getting the index to display in the outgoing authentication radio button list 
-    
-    \return index Used to set the selected value
+    Used for getting the index to display in the outgoing authentication radio button list.
+    \return index Used to set the selected value.
 */
 int NmIpsSettingsHelper::getCorrectOutgoingAuthenticationRadioButtonIndex()
 {
@@ -1270,7 +1402,11 @@
     
     if (outgoingAuthentication) {
         if (outgoingLoginName == incomingLoginName && outgoingPassword == incomingPassword) {
-            index = IpsServices::EMailAuthSameAsIncoming;    
+            index = IpsServices::EMailAuthSameAsIncoming;
+            HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingLoginName);
+            if (item) {
+                index = IpsServices::EMailAuthUserAuthentication;
+            }
         } else {
             index = IpsServices::EMailAuthUserAuthentication;
         }
@@ -1280,10 +1416,13 @@
 
 /*!
     Saves the outgoing secure connection value into database if user has changed the value.
+    \param index Selected radio button index.
 */
 void NmIpsSettingsHelper::outgoingSecureConnectionItemChange(int index)
-{
-    if (mRadioButtonPreviousIndex != index) {
+{      
+    int previousindex = getCorrectOutgoingSecureRadioButtonIndex();
+    
+    if (previousindex != index) {
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
         switch (index) {
@@ -1307,7 +1446,7 @@
         }
         // Update outgoing port value only if default outgoing port used
         HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingPort);
-        QVariant data = item->contentWidgetData(QString("selected"));
+        QVariant data = item->contentWidgetData("selected");
         // Default outgoing port selected
         if (data.toInt() == IpsServices::NmIpsSettingsDefault) {
 			int port = mSettingsManager.determineDefaultOutgoingPort();
@@ -1317,25 +1456,15 @@
 }
 
 /*!
-    Sets the previous index value to indicate that user has edited the field
-
-    \param text Reference to the item in the radio button list.
-*/
-void NmIpsSettingsHelper::outgoingSecureConnectionPress(const QModelIndex &index)
-{
-	Q_UNUSED(index);
-	HbDataFormModelItem *item = mContentItems.value(IpsServices::OutgoingSecureSockets);
-    QVariant data = item->contentWidgetData(QString("selected"));
-    mRadioButtonPreviousIndex = data.toInt();
-}
-
-/*!
     Saves the outgoing authetication value into database if user has changed the value and
     updates dynamic group items.
+    \param index Selected radio button index.
 */
 void NmIpsSettingsHelper::outgoingAuthenticationChange(int index)
 {
-    if (mRadioButtonPreviousIndex != index) {
+    int previousindex = getCorrectOutgoingAuthenticationRadioButtonIndex();
+    
+    if (previousindex != index) {
         QVariant loginName;
         QVariant loginPassword;
         emit goOffline(mSettingsManager.mailboxId());
@@ -1359,7 +1488,7 @@
 
             case IpsServices::EMailAuthUserAuthentication: // User authentication
                 mSettingsManager.writeSetting(IpsServices::SMTPAuthentication, true);
-                createServerInfoGroupDynamicItems();
+                createServerInfoGroupDynamicItems(false);
                 break;
                 
              default:
@@ -1369,15 +1498,30 @@
 }
 
 /*!
-    Sets the previous index value to indicate that user has edited the field
-
-    \param text Reference to the item in the radio button list.
+    Launches the connection selection dialog.
 */
-void NmIpsSettingsHelper::outgoingAuthenticationPress(const QModelIndex &index)
+void NmIpsSettingsHelper::connectionButtonPress()
 {
-    Q_UNUSED(index);
-    HbDataFormModelItem *item = mContentItems.value(IpsServices::SMTPAuthentication);
-    QVariant data = item->contentWidgetData(QString("selected"));
-    mRadioButtonPreviousIndex = data.toInt();
+    if (!mDestinationDialog) {
+        // Create the dialog and configure it.
+        mDestinationDialog = new CmApplSettingsUi(this);
+
+        mDestinationDialog->setOptions(
+            QFlags<CmApplSettingsUi::SelectionDialogItems>(CmApplSettingsUi::ShowDestinations),
+            QSet<CmApplSettingsUi::BearerTypeFilter>());
+        connect(mDestinationDialog, SIGNAL(finished(uint)),
+                this, SLOT(handleConnectionSelected(uint)));
+    }
+
+    // Set currently active destination as selected.
+    QVariant destId;
+    if (mSettingsManager.readSetting(IpsServices::Connection, destId)) {
+        CmApplSettingsUi::SettingSelection selection;
+        selection.result = CmApplSettingsUi::SelectionTypeDestination;
+        selection.id = destId.toUInt();
+        mDestinationDialog->setSelection(selection);
+    }
+
+    // Open the dialog.
+    mDestinationDialog->open();
 }
-
--- a/ipsservices/nmipssettings/src/nmipssettingslabeledcombobox.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/src/nmipssettingslabeledcombobox.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -56,9 +56,6 @@
     // Connect signals and slots.
     connect(mComboBox, SIGNAL(currentIndexChanged(int)),
         this, SLOT(comboBoxIndexChanged(int)), Qt::UniqueConnection);
-
-    connect(mComboBox, SIGNAL(currentIndexChanged(int)),
-        this, SIGNAL(currentIndexChanged(int)), Qt::UniqueConnection);
 }
 
 /*!
@@ -134,4 +131,8 @@
 {
     QString label(mLabelTexts.value(index));
     mLabel->setPlainText(label);
+    QMap<QString, QVariant> properties;
+    properties.insert("currentIndex", index);
+    emit propertyChanged(properties);
+    emit currentIndexChanged(index);
 }
--- a/ipsservices/nmipssettings/src/nmipssettingsmanagerbase.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/src/nmipssettingsmanagerbase.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -44,10 +44,11 @@
 */
 NmIpsSettingsManagerBase::NmIpsSettingsManagerBase(const NmId &mailboxId, CEmailAccounts *account, 
     IpsServices::TIpsSetAccountTypes accountType)
-: mAccountType(accountType),
-  mMailboxId(mailboxId.id())
+    : mAccountType(accountType),
+      mMailboxId(mailboxId.id())
 {
-    QScopedPointer<NmIpsExtendedSettingsManager> extendedSettings(new NmIpsExtendedSettingsManager(mailboxId));
+    QScopedPointer<NmIpsExtendedSettingsManager> extendedSettings(
+        new NmIpsExtendedSettingsManager(mailboxId));
 
     QT_TRAP_THROWING(mSmtpSettings = new(ELeave) CImSmtpSettings());
 
@@ -57,7 +58,7 @@
 }
 
 /*!
-    Destructor
+    Destructor.
 */
 NmIpsSettingsManagerBase::~NmIpsSettingsManagerBase()
 {
@@ -73,7 +74,8 @@
     \param QVariant SettingValue of the found setting value.
     \return bool <true> when the setting item was found otherwise <false>.
 */
-bool NmIpsSettingsManagerBase::readSetting(IpsServices::SettingItem settingItem, QVariant &settingValue)
+bool NmIpsSettingsManagerBase::readSetting(IpsServices::SettingItem settingItem,
+                                           QVariant &settingValue)
 {
     bool found(false);
     
@@ -117,7 +119,17 @@
         case IpsServices::OutgoingSSLWrapper:
         	settingValue = mSmtpSettings->SSLWrapper();
             found = true;
-            break;  
+            break;
+        case IpsServices::Connection:
+            settingValue = 0;
+            TRAP_IGNORE(
+                CImIAPPreferences *prefs = CImIAPPreferences::NewLC();
+                mAccount->LoadSmtpIapSettingsL(mSmtpAccount, *prefs);
+                settingValue = (uint)prefs->SNAPPreference();
+                CleanupStack::PopAndDestroy(prefs);
+                found = true;
+            );
+            break;
         default:
             found = mExtendedSettingsManager->readSetting(settingItem, settingValue);
             break;
@@ -131,7 +143,8 @@
     \param settingValue QVariant of the new setting value.
     \return bool <true> when the setting item was succesfully written, otherwise <false>.
 */
-bool NmIpsSettingsManagerBase::writeSetting(IpsServices::SettingItem settingItem, const QVariant &settingValue)
+bool NmIpsSettingsManagerBase::writeSetting(IpsServices::SettingItem settingItem,
+                                            const QVariant &settingValue)
 {
     HBufC *tmp = 0;
     HBufC8 *tmp8 = 0;
@@ -203,7 +216,10 @@
         case IpsServices::OutgoingSSLWrapper:
             mSmtpSettings->SetSSLWrapper(settingValue.toBool());
             ret = saveSettings();
-            break;  
+            break;
+        case IpsServices::Connection:
+            ret = saveIAPSettings(settingValue.toUInt());
+            break;
         default:
             ret = mExtendedSettingsManager->writeSetting(settingItem, settingValue);
             break;    
@@ -212,8 +228,7 @@
 }
 
 /*!     
-    Delete mailbox.
-
+    Deletes the mailbox.
     \return Error code <code>0</code> if mailbox deletion was successful, otherwise error
             code is returned.
 */
@@ -227,6 +242,46 @@
 }
 
 /*!     
+    Returns the NmId of the mailbox.
+    \return Mailbox id.
+*/
+NmId NmIpsSettingsManagerBase::mailboxId() const
+{
+    return mMailboxId;
+}
+
+/*!     
+    Returns the mailbox account type.
+    \return Account type.
+*/
+IpsServices::TIpsSetAccountTypes NmIpsSettingsManagerBase::accountType() const
+{
+    return mAccountType;
+}
+
+/*!
+     Determines the default port for the outgoing mail server based on the security settings.
+     \return The port number to use.
+ */
+int NmIpsSettingsManagerBase::determineDefaultOutgoingPort()
+{
+    int port(IpsServices::standardSmtpPort);
+    if (mSmtpSettings->SSLWrapper()) {
+        port = IpsServices::secureSmtpPort;
+    }        
+    return port;
+}
+
+/*!
+    Returns reference to the Extended Settings Manager.
+    \return Extended Settings Manager reference.
+*/
+NmIpsExtendedSettingsManager &NmIpsSettingsManagerBase::extendedSettingsManager() const
+{
+    return *mExtendedSettingsManager;
+}
+
+/*!
     Stores the SMTP specific settings.
     \return bool <true> when the SMTP settings were succesfully written, otherwise <false>.
 */
@@ -236,44 +291,18 @@
     return (err == KErrNone);
 }
 
-/*!     
-    NmId for the mailbox. 
+/*!
+    Stores the SMTP specific IAP settings.
+    \return bool <true> when the SMTP IAP settings were succesfully written, otherwise <false>.
 */
-NmId NmIpsSettingsManagerBase::mailboxId() const
+bool NmIpsSettingsManagerBase::saveIAPSettings(uint snapId)
 {
-    return mMailboxId;
-}
-
-/*!     
-    Mailbox account type. 
-*/
-IpsServices::TIpsSetAccountTypes NmIpsSettingsManagerBase::accountType() const
-{
-    return mAccountType;
+    TRAPD(err,
+        CImIAPPreferences *prefs = CImIAPPreferences::NewLC();
+        mAccount->LoadSmtpIapSettingsL(mSmtpAccount, *prefs);
+        prefs->SetSNAPL(snapId);
+        mAccount->SaveSmtpIapSettingsL(mSmtpAccount, *prefs);
+        CleanupStack::PopAndDestroy(prefs);
+    );
+    return (err == KErrNone);
 }
-
-/*!
-     Determine the default port for the outgoing mail server based on the security settings
-     
-     \return int the port number to use
- */
-int NmIpsSettingsManagerBase::determineDefaultOutgoingPort()
-{
-    int port = 0;    
-    bool sslTls = mSmtpSettings->SSLWrapper();    
-    if (sslTls) {
-        port = IpsServices::secureSmtpPort;
-    } else {
-        port = IpsServices::standardSmtpPort;
-    }        
-    return port;
-}
-
-/*!
-
-*/
-NmIpsExtendedSettingsManager &NmIpsSettingsManagerBase::extendedSettingsManager() const
-{
-    return *mExtendedSettingsManager;
-}
-
--- a/ipsservices/nmipssettings/src/nmipssettingsmultiselectionitem.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/src/nmipssettingsmultiselectionitem.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -21,9 +21,13 @@
 #include <HbSelectionDialog>
 #include <HbLabel>
 #include <HbExtendedLocale>
+#include <HbAction>
 
 #include "nmipssettingsmultiselectionitem.h"
 
+// CONSTANTS
+const QChar NmIpsSettingsMultiSelectionItemSpace(' ');
+
 /*!
     \class NmIpsSettingsMultiSelectionItem
     \brief The class implements a custom HbDataFormViewItem for showing multi selection dialog.
@@ -35,8 +39,6 @@
 /*!
     Constructor of NmIpsSettingsMultiSelectionItem.
 */
-
-
 NmIpsSettingsMultiSelectionItem::NmIpsSettingsMultiSelectionItem(
     QGraphicsItem *parent, Qt::WindowFlags wFlags)
  : HbWidget(parent, wFlags),
@@ -175,7 +177,12 @@
 */
 void NmIpsSettingsMultiSelectionItem::selectionDialogClosed(HbAction *action)
 {
-    if (action == mSelectionDialog->primaryAction()) {
+    // TODO: Needs to be properly fixed when ever orbit supports
+    // e.g. <code>void finished(int result)</code> type of signaling.
+    // This is kind of hack but we do not want to compare button text to some string to
+    // be certain which button was pressed (NOTE: Buttons are created and placed
+    // by HbSelectionDialog).
+    if (action == mSelectionDialog->actions().at(0)) {
         // Get selected items.
         mSelectedItems = mSelectionDialog->selectedItems();
 
@@ -201,10 +208,11 @@
     const int itemCount(mItems.count());
     if (mItems.count() >= mSelectedItems.count()) {
         // Construct separator for button text.
-        QChar groupSeparator = HbExtendedLocale::system().groupSeparator();
-        QString separator(" ");
-        separator.insert(0, groupSeparator);
-
+        QChar groupSeparator(HbExtendedLocale::system().groupSeparator());
+        QString separator(groupSeparator);
+        if (!groupSeparator.isSpace()) {
+            separator.append(NmIpsSettingsMultiSelectionItemSpace);
+        }
         QString buttonText;
         QListIterator<QVariant> itemIterator(mSelectedItems);
         while (itemIterator.hasNext()) {
@@ -220,6 +228,13 @@
                 }
             }
         }
+        // If empty text is set to the button, next time when some "real" text is set to the button
+        // the text is drawn from left to the center of button. Text is drawn multiple times to
+        // wrong place while it travelling from left side to the center of button.
+        // To prevent this feature, one space is set to button instead of real empty string.
+        if (buttonText.isEmpty()) {
+            buttonText = " ";
+        }
         mButton->setText(buttonText);
     }
 }
--- a/ipsservices/nmipssettings/src/nmipssettingsplugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/src/nmipssettingsplugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -15,17 +15,19 @@
 *
 */
 
-#include <hbdataform.h>
-#include <hbdataformmodel.h>
-#include <hbdataformmodelitem.h>
-#include <hblineedit.h>
-#include <cpsettingformitemdata.h>
 #include <qplugin.h>
 #include <QCoreApplication>
 #include <QTranslator>
 #include <QScopedPointer>
 #include <QLocale>
+
 #include <HbStringUtil>
+#include <HbDataForm>
+#include <HbDataFormModel>
+#include <HbDataFormModelItem>
+#include <HbLineEdit>
+
+#include <cpsettingformitemdata.h>
 
 #include "nmipssettingsplugin.h"
 #include "nmipssettingshelper.h"
@@ -41,6 +43,7 @@
 const QString NmIpsSettingsComboItems("comboItems");
 const QString NmIpsSettingsLabelTexts("labelTexts");
 const QString NmIpsSettingsItems("items");
+const int NmIpsSettingsReceptionUserDefinedProfileEnabled(1);
 
 /*!
     \class NmIpsSettingsPlugin
@@ -56,14 +59,14 @@
 */
 NmIpsSettingsPlugin::NmIpsSettingsPlugin()
 : mSettingsHelper(0),
-  mSettingsManager(0)
+  mSettingsManager(0),
+  mHiddenItem(false)
 {
     QString lang = QLocale::system().name();
     QString path = "Z:/resource/qt/translations/";
     QString appName = "mailips_";
     QString commonName = "common_";
     
-
     // Load common strings
 	QScopedPointer<QTranslator> commonTranslator(new QTranslator(this));
     commonTranslator->load(commonName + lang, path);
@@ -96,10 +99,6 @@
 bool NmIpsSettingsPlugin::populateModel(HbDataFormModel &model,
     HbDataForm &form, const NmId &mailboxId)
 {
-    // Store model and form pointers.
-    mModel = &model;
-    mForm = &form;
-
     // populateModel is called each time when a new settings view is created and this
     // plugin is destructed only after the mail settings is exited, so
     // SettingsManager and SettingsHelper needs to be deleted.
@@ -113,6 +112,13 @@
     // This plugin is only used when the mailbox is a IMAP or POP3 account.
     // Settings manager object is valid if the mailboxId is IMAP or POP3 account.
     if (mSettingsManager) {
+        // Turns AlwaysOnline OFF
+        setAlwaysOnlineState(EServerAPIEmailTurnOff, mailboxId);
+        
+        // Store model and form pointers.
+        mModel = &model;
+        mForm = &form;
+        
         // Create settings helper.
         mSettingsHelper = new NmIpsSettingsHelper(*mSettingsManager, form, model);
 
@@ -128,12 +134,15 @@
 
         connect(mSettingsHelper, SIGNAL(createUserDefinedMode()),
                 this, SLOT(createUserDefinedMode()));
-
+        
+        // Get the value if some ui items need to be hidden.
+        QVariant data;
+        mSettingsManager->readSetting(IpsServices::UserNameHidden, data);
+        mHiddenItem = data.toBool();
         // Add items to the model.
         initGroupItems();
         result = true;
     }
-    
     return result;
 }
 
@@ -143,10 +152,15 @@
 void NmIpsSettingsPlugin::aboutToClose()
 {
     QVariant profileIndex;
+    const NmId mailboxId = mSettingsManager->mailboxId();
+    
 	mSettingsManager->readSetting(IpsServices::ReceptionActiveProfile, profileIndex);
 	if ((mSettingsHelper->isOffline()) && (profileIndex.toInt() != IpsServices::EmailSyncProfileManualFetch)) {
-		emit goOnline(mSettingsManager->mailboxId());
+		emit goOnline(mailboxId);
 	}
+	
+	// Turns AlwaysOnline ON
+	setAlwaysOnlineState(EServerAPIEmailTurnOn, mailboxId);
 }
 
 /*!
@@ -203,7 +217,22 @@
 */
 void NmIpsSettingsPlugin::initPreferenceItems(HbDataFormModelItem &item) const
 {
-    // 1. My Name
+    // 1. Connection
+    QVariant destId;
+    mSettingsManager->readSetting(IpsServices::Connection, destId);
+    QString destName(mSettingsHelper->destinationNameFromIdentifier(destId.toUInt()));
+    HbDataFormModelItem::DataItemType buttonItem =
+        static_cast<HbDataFormModelItem::DataItemType>(
+            HbDataFormModelItem::CustomItemBase + 2);
+    CpSettingFormItemData *connectionButtonItem = new CpSettingFormItemData(buttonItem,
+        hbTrId("txt_mailips_setlabel_connection"));
+    connectionButtonItem->setContentWidgetData(QString("text"), destName);
+    mSettingsHelper->insertContentItem(IpsServices::Connection, connectionButtonItem);
+    mForm->addConnection(connectionButtonItem, SIGNAL(clicked()),
+                         mSettingsHelper, SLOT(connectionButtonPress()));
+    item.appendChild(connectionButtonItem);
+
+    // 2. My Name
     QVariant myName;
     mSettingsManager->readSetting(IpsServices::EmailAlias, myName);
     CpSettingFormItemData *myNameItem = new CpSettingFormItemData(
@@ -216,7 +245,7 @@
                          mSettingsHelper, SLOT(myNameTextChange(QString)));
     item.appendChild(myNameItem);
 
-    // 2. Mailbox Name
+    // 3. Mailbox Name
     QVariant mailboxName;
     mSettingsManager->readSetting(IpsServices::MailboxName, mailboxName);
     CpSettingFormItemData *mailboxNameItem = new CpSettingFormItemData(
@@ -292,21 +321,14 @@
 
     mSettingsHelper->insertContentItem(IpsServices::ReceptionInboxSyncWindow, showMailInInboxItem);
 
+    // If changes are made to showMailItems, conversion table in
+    // showMailInInboxModified method needs to be updated also.
     QStringList showMailItems;
     showMailItems << HbStringUtil::convertDigits("50")
                   << HbStringUtil::convertDigits("100")
                   << HbStringUtil::convertDigits("500")
                   << hbTrId("txt_mailips_setlabel_val_all");
     
-
-    QList<QVariant> showMailItemValues;
-    showMailItemValues << 50
-                       << 100
-                       << 500
-                       << 0;
-    
-    QVariant value(showMailItemValues);
-    showMailInInboxItem->setData(HbDataFormModelItem::DescriptionRole + 1, value);
     showMailInInboxItem->setContentWidgetData(NmIpsSettingsItems, showMailItems);
     showMailInInboxItem->setEnabled(true);
     item.appendChild(showMailInInboxItem);
@@ -315,8 +337,8 @@
     mForm->addConnection(infoItem, SIGNAL(currentIndexChanged(int)),
         mSettingsHelper, SLOT(receivingScheduleChange(int)));
 
-    mForm->addConnection(showMailInInboxItem, SIGNAL(itemSelected(int)),
-        this, SLOT(showMailInInboxModified(int)));
+    mForm->addConnection(showMailInInboxItem, SIGNAL(valueChanged(QPersistentModelIndex, QVariant)),
+        this, SLOT(showMailInInboxModified(QPersistentModelIndex, QVariant)));
 
     // Must be called manually here, because the signal->slot connection set above using
     // HbDataForm::addConnection() is actually established AFTER the properties have first been
@@ -357,8 +379,13 @@
                          mSettingsHelper, SLOT(saveIncomingUserName()));
     mForm->addConnection(usernameItem, SIGNAL(textChanged(QString)),
                          mSettingsHelper, SLOT(incomingUserNameTextChange(QString)));
+    if (mHiddenItem) { // Starred and dimmed.
+        usernameItem->setContentWidgetData(QString("echoMode"), HbLineEdit::Password);
+        usernameItem->setEnabled(false);
+    }
     item.appendChild(usernameItem);
-
+    
+    
     // 3. Password
     QVariant password;
     mSettingsManager->readSetting(IpsServices::IncomingPassword, password);
@@ -371,7 +398,7 @@
                          mSettingsHelper, SLOT(saveIncomingPassword()));
     item.appendChild(passwordItem);
 
-    // Reply to address
+    // 4. Reply to address
     QVariant replyToAddress;
     mSettingsManager->readSetting(IpsServices::ReplyAddress, replyToAddress);
     CpSettingFormItemData *replyToItem = new CpSettingFormItemData(
@@ -402,13 +429,13 @@
                          mSettingsHelper, SLOT(saveIncomingMailServer()));
     mForm->addConnection(incomingMailServerItem, SIGNAL(textChanged(QString)),
                          mSettingsHelper, SLOT(incomingMailServerTextChange(QString)));
+    if (mHiddenItem) { // Starred and dimmed.
+        incomingMailServerItem->setContentWidgetData(QString("echoMode"), HbLineEdit::Password);
+        incomingMailServerItem->setEnabled(false);
+    }
     item.appendChild(incomingMailServerItem);
     
     // 2. Incoming Secure connection
-    QVariant secureSockets;
-    QVariant secureSSLWrapper;
-    mSettingsManager->readSetting(IpsServices::IncomingSecureSockets, secureSockets);
-    mSettingsManager->readSetting(IpsServices::IncomingSSLWrapper, secureSSLWrapper);
     CpSettingFormItemData *incomingSecureConnectionItem =
         new CpSettingFormItemData(HbDataFormModelItem::RadioButtonListItem, hbTrId(
             "txt_mailips_setlabel_incoming_security"));
@@ -417,37 +444,35 @@
     showSCItems << hbTrId("txt_mailips_setlabel_security_val_on_starttls")
                 << hbTrId("txt_mailips_setlabel_security_val_on_ssltls")
                 << hbTrId("txt_mailips_setlabel_security_val_off");
-
     incomingSecureConnectionItem->setContentWidgetData(QString("items"), showSCItems);
     int incomingSecureConnectionItemIndex = 
-        mSettingsHelper->getCorrectSecureRadioButtonIndex(secureSockets, secureSSLWrapper);
+        mSettingsHelper->getCorrectIncomingSecureRadioButtonIndex();
     incomingSecureConnectionItem->setContentWidgetData(QString("selected"), 
                                                        incomingSecureConnectionItemIndex);
-    mForm->addConnection(incomingSecureConnectionItem, SIGNAL(itemSelected(int)),    		  
-    		mSettingsHelper, SLOT(incomingSecureConnectionItemChange(int)));
-    mForm->addConnection(incomingSecureConnectionItem, SIGNAL(pressed(const QModelIndex &)),    		  
-    		mSettingsHelper, SLOT(incomingSecureConnectionPress(const QModelIndex &)));
+    mForm->addConnection(incomingSecureConnectionItem, SIGNAL(itemSelected(int)),             
+            mSettingsHelper, SLOT(incomingSecureConnectionItemChange(int)));
+    if (mHiddenItem) {
+        incomingSecureConnectionItem->setEnabled(false);
+    }
     item.appendChild(incomingSecureConnectionItem);
     
     // 3. Incoming mail server port
-    QVariant incomingPort;
-    mSettingsManager->readSetting(IpsServices::IncomingPort, incomingPort);
     CpSettingFormItemData *incomingPortItem =
         new CpSettingFormItemData(HbDataFormModelItem::RadioButtonListItem, hbTrId(
             "txt_mailips_setlabel_incoming_port"));
-    mSettingsHelper->insertContentItem(IpsServices::IncomingPort, incomingPortItem);    
-    mForm->addConnection(incomingPortItem, SIGNAL(itemSelected(int)),
-                         mSettingsHelper, SLOT(incomingPortChange(int)));
-    mForm->addConnection(incomingPortItem, SIGNAL(pressed(const QModelIndex &)),              
-                         mSettingsHelper, SLOT(incomingPortPress(const QModelIndex &)));
+    mSettingsHelper->insertContentItem(IpsServices::IncomingPort, incomingPortItem);
     QStringList incomingPortItems;
     incomingPortItems << hbTrId("txt_mailips_setlabel_incoming_port_default")
                       << hbTrId("txt_mailips_setlabel_incoming_port_user_defined");
     incomingPortItem->setContentWidgetData(QString("items"), incomingPortItems);
-    int incomingPortItemIndex = 
-        mSettingsHelper->getCorrectPortRadioButtonIndex(incomingPort.toInt()); 
+    int incomingPortItemIndex = mSettingsHelper->getCorrectIncomingPortRadioButtonIndex(); 
     incomingPortItem->setContentWidgetData(QString("selected"), incomingPortItemIndex);
-    item.appendChild(incomingPortItem);    
+    mForm->addConnection(incomingPortItem, SIGNAL(itemSelected(int)),
+        mSettingsHelper, SLOT(incomingPortChange(int)));
+    if (mHiddenItem) {
+        incomingPortItem->setEnabled(false);
+    }
+    item.appendChild(incomingPortItem);
     
     // 4. Outgoing mail server address
     QVariant outgoingMailServer;
@@ -460,52 +485,49 @@
                          mSettingsHelper, SLOT(saveOutgoingMailServer()));
     mForm->addConnection(outgoingMailServerItem, SIGNAL(textChanged(QString)),
                          mSettingsHelper, SLOT(outgoingMailServerTextChange(QString)));
+    if (mHiddenItem) {// Starred and dimmed.
+        outgoingMailServerItem->setContentWidgetData(QString("echoMode"), HbLineEdit::Password);
+        outgoingMailServerItem->setEnabled(false);
+    }
     item.appendChild(outgoingMailServerItem);
     
     // 5. Outgoing secure connection
-    QVariant outgoingSecureSockets;
-    QVariant outgoingSSLWrapper;
-    mSettingsManager->readSetting(IpsServices::OutgoingSecureSockets, outgoingSecureSockets);
-    mSettingsManager->readSetting(IpsServices::OutgoingSSLWrapper, outgoingSSLWrapper);
     CpSettingFormItemData *outgoingSecureConnectionItem =
         new CpSettingFormItemData(HbDataFormModelItem::RadioButtonListItem, hbTrId(
             "txt_mailips_setlabel_outgoing_security"));
     mSettingsHelper->insertContentItem(IpsServices::OutgoingSecureSockets, outgoingSecureConnectionItem);
     QStringList outgoingShowSCItems;
     outgoingShowSCItems << hbTrId("txt_mailips_setlabel_security_val_on_starttls")
-                << hbTrId("txt_mailips_setlabel_security_val_on_ssltls")
-                << hbTrId("txt_mailips_setlabel_security_val_off");
-
+                        << hbTrId("txt_mailips_setlabel_security_val_on_ssltls")
+                        << hbTrId("txt_mailips_setlabel_security_val_off");
     outgoingSecureConnectionItem->setContentWidgetData(QString("items"), outgoingShowSCItems);
     int outgoingSecureConnectionItemIndex = 
-        mSettingsHelper->getCorrectSecureRadioButtonIndex(outgoingSecureSockets, 
-														  outgoingSSLWrapper);
+        mSettingsHelper->getCorrectOutgoingSecureRadioButtonIndex();
     outgoingSecureConnectionItem->setContentWidgetData(QString("selected"), 
                                                        outgoingSecureConnectionItemIndex);
-    mForm->addConnection(outgoingSecureConnectionItem, SIGNAL(itemSelected(int)),    		  
-    		mSettingsHelper, SLOT(outgoingSecureConnectionItemChange(int)));
-    mForm->addConnection(outgoingSecureConnectionItem, SIGNAL(pressed(const QModelIndex &)),    		  
-    		mSettingsHelper, SLOT(outgoingSecureConnectionPress(const QModelIndex &)));
+    mForm->addConnection(outgoingSecureConnectionItem, SIGNAL(itemSelected(int)),             
+            mSettingsHelper, SLOT(outgoingSecureConnectionItemChange(int)));
+    if (mHiddenItem) {
+        outgoingSecureConnectionItem->setEnabled(false);
+    }
     item.appendChild(outgoingSecureConnectionItem);
 
     // 6. Outgoing mail server port
-    QVariant outgoingPort;
-    mSettingsManager->readSetting(IpsServices::OutgoingPort, outgoingPort);
     CpSettingFormItemData *outgoingPortItem =
         new CpSettingFormItemData(HbDataFormModelItem::RadioButtonListItem, hbTrId(
             "txt_mailips_setlabel_outgoing_port"));
-    mSettingsHelper->insertContentItem(IpsServices::OutgoingPort, outgoingPortItem);    
-    mForm->addConnection(outgoingPortItem, SIGNAL(itemSelected(int)),
-                         mSettingsHelper, SLOT(outgoingPortChange(int)));
-    mForm->addConnection(outgoingPortItem, SIGNAL(pressed(const QModelIndex &)),              
-                         mSettingsHelper, SLOT(outgoingPortPress(const QModelIndex &)));
+    mSettingsHelper->insertContentItem(IpsServices::OutgoingPort, outgoingPortItem);
     QStringList outgoingPortItems;
     outgoingPortItems << hbTrId("txt_mailips_setlabel_incoming_port_default")
                       << hbTrId("txt_mailips_setlabel_incoming_port_user_defined");
     outgoingPortItem->setContentWidgetData(QString("items"), outgoingPortItems);
-    int outgoingPortItemIndex = 
-        mSettingsHelper->getCorrectOutgoingPortRadioButtonIndex(outgoingPort.toInt()); 
+    int outgoingPortItemIndex = mSettingsHelper->getCorrectOutgoingPortRadioButtonIndex(); 
     outgoingPortItem->setContentWidgetData(QString("selected"), outgoingPortItemIndex);
+    mForm->addConnection(outgoingPortItem, SIGNAL(itemSelected(int)),
+        mSettingsHelper, SLOT(outgoingPortChange(int)));
+    if (mHiddenItem) {
+        outgoingPortItem->setEnabled(false);
+    }
     item.appendChild(outgoingPortItem);
     
     // 7. Outgoing authentication.
@@ -513,10 +535,6 @@
         new CpSettingFormItemData(HbDataFormModelItem::RadioButtonListItem, hbTrId(
             "txt_mailips_setlabel_outgoing_mail_authentication"));
     mSettingsHelper->insertContentItem(IpsServices::SMTPAuthentication, outgoingAuthenticationItem);
-    mForm->addConnection(outgoingAuthenticationItem, SIGNAL(itemSelected(int)),
-                         mSettingsHelper, SLOT(outgoingAuthenticationChange(int)));
-    mForm->addConnection(outgoingAuthenticationItem, SIGNAL(pressed(const QModelIndex &)),              
-                         mSettingsHelper, SLOT(outgoingAuthenticationPress(const QModelIndex &)));
     QStringList outgoingAuthenticationItems;
     outgoingAuthenticationItems << hbTrId("txt_mailips_setlabel_outgoing_authentication_none")
                                 << hbTrId("txt_mailips_setlabel_outgoing_authentication_same")
@@ -525,35 +543,56 @@
     int outgoingAuthenticationIndex = 
         mSettingsHelper->getCorrectOutgoingAuthenticationRadioButtonIndex(); 
     outgoingAuthenticationItem->setContentWidgetData(QString("selected"), outgoingAuthenticationIndex);
+    mForm->addConnection(outgoingAuthenticationItem, SIGNAL(itemSelected(int)),
+        mSettingsHelper, SLOT(outgoingAuthenticationChange(int)));
     item.appendChild(outgoingAuthenticationItem);
+    if (mHiddenItem) {
+        outgoingAuthenticationItem->setEnabled(false);
+    }
     if (outgoingAuthenticationIndex == IpsServices::EMailAuthUserAuthentication) {
-        mSettingsHelper->createServerInfoGroupDynamicItems();
+        mSettingsHelper->createServerInfoGroupDynamicItems(mHiddenItem);
     }
     
     // 8. Folder path
     // This item is only shown for IMAP4 account.
     if (mSettingsManager->accountType() == IpsServices::EMailImap) {
-        QVariant folderPath;
-        mSettingsManager->readSetting(IpsServices::FolderPath, folderPath);
         CpSettingFormItemData *folderPathItem =
             new CpSettingFormItemData(HbDataFormModelItem::RadioButtonListItem, hbTrId(
                 "txt_mailips_setlabel_folder_path"));
         mSettingsHelper->insertContentItem(IpsServices::FolderPath, folderPathItem);    
-        mForm->addConnection(folderPathItem, SIGNAL(itemSelected(int)),
-                             mSettingsHelper, SLOT(folderPathChange(int)));
-        mForm->addConnection(folderPathItem, SIGNAL(pressed(const QModelIndex &)),              
-                             mSettingsHelper, SLOT(folderPathPress(const QModelIndex &)));
         QStringList folderPathItems;
         folderPathItems << hbTrId("txt_mailips_setlabel_folder_path_val_default")
-                       << hbTrId("txt_mailips_setlabel_folder_path_user_defined");
+                        << hbTrId("txt_mailips_setlabel_folder_path_user_defined");
         folderPathItem->setContentWidgetData(QString("items"), folderPathItems);
-        int folderPathItemIndex = mSettingsHelper->getCorrectInboxPathRadioButtonIndex(folderPath);
+        int folderPathItemIndex = mSettingsHelper->getCorrectFolderPathRadioButtonIndex();
         folderPathItem->setContentWidgetData(QString("selected"), folderPathItemIndex);
+        mForm->addConnection(folderPathItem, SIGNAL(itemSelected(int)),
+            mSettingsHelper, SLOT(folderPathChange(int)));
         item.appendChild(folderPathItem);
     }
 }
 
 /*!
+    Sets the state of the AlwaysOnline.
+    \param command Command for the state of the AlwaysOnline.
+    \param mailboxId Mailbox id.
+*/
+void NmIpsSettingsPlugin::setAlwaysOnlineState(TAlwaysOnlineServerAPICommands command,
+                                               NmId mailboxId) const
+{
+    RAlwaysOnlineClientSession aosession;
+    TInt err(aosession.Connect());
+    
+    if (err == KErrNone) {
+        TPckgBuf<TMsvId> mboxBuf(mailboxId.id32());
+        
+        TRAP_IGNORE(aosession.RelayCommandL(command, mboxBuf));
+    }
+    
+    aosession.Close();
+}
+
+/*!
     Creates user defined mode if not already exist.
 */
 void NmIpsSettingsPlugin::createUserDefinedMode()
@@ -588,8 +627,8 @@
         mForm->addConnection(syncProfile, SIGNAL(currentIndexChanged(int)),
             mSettingsHelper, SLOT(receivingScheduleChange(int)));
 
-        // Mark that user defined mode exists.
-        userDefineMode.setValue(1);
+        // Set reception user defined profile enabled.
+        userDefineMode.setValue(NmIpsSettingsReceptionUserDefinedProfileEnabled);
         mSettingsManager->writeSetting(IpsServices::ReceptionUserDefinedProfile, userDefineMode);
     }
 }
@@ -597,15 +636,23 @@
 /*!
     Handles mail in inbox modifications.
 
-    \param index Selected value index.
+    \param value Selected value as a text.
 */
-void NmIpsSettingsPlugin::showMailInInboxModified(int index)
+void NmIpsSettingsPlugin::showMailInInboxModified(QPersistentModelIndex, QVariant value)
 {
-    HbDataFormModelItem* item = mSettingsHelper->contentItem(IpsServices::ReceptionInboxSyncWindow);
-    QVariant itemData = item->data(HbDataFormModelItem::HbDataFormModelItem::DescriptionRole + 1);
-    int selectedValue = itemData.value< QList< QVariant > >().at(index).toInt();
-    mSettingsHelper->handleReceivingScheduleSettingChange(
-        IpsServices::ReceptionInboxSyncWindow, selectedValue);
+    QMap<QString, int> conversionTable;
+    conversionTable[HbStringUtil::convertDigits("50")] = 50;
+    conversionTable[HbStringUtil::convertDigits("100")] = 100;
+    conversionTable[HbStringUtil::convertDigits("500")] = 500;
+    conversionTable[hbTrId("txt_mailips_setlabel_val_all")] = 0;
+
+    int selectedValue(conversionTable.value(value.toString()));
+    QVariant previouslySelectedValue;
+    mSettingsManager->readSetting(IpsServices::ReceptionInboxSyncWindow, previouslySelectedValue);
+    if (previouslySelectedValue.toInt() != selectedValue) {
+        mSettingsHelper->handleReceivingScheduleSettingChange(
+            IpsServices::ReceptionInboxSyncWindow, selectedValue);
+    }
 }
 
 Q_EXPORT_PLUGIN2(nmipssettings, NmIpsSettingsPlugin);
--- a/ipsservices/nmipssettings/src/nmipssettingstimeeditor.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/src/nmipssettingstimeeditor.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -39,7 +39,8 @@
 NmIpsSettingsTimeEditor::NmIpsSettingsTimeEditor(QGraphicsItem *parent, Qt::WindowFlags wFlags)
     : HbWidget(parent, wFlags),
       mButton(0),
-      mTimePickerDialog(0)
+      mTimePickerDialog(0),
+      mPrimaryAction(0)
 {
     // Create widget layout.
     QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
@@ -130,11 +131,12 @@
 
     // Set dialog actions.
     HbAction *okAction = new HbAction(QString(hbTrId("txt_common_button_ok")), mTimePickerDialog);
-    mTimePickerDialog->setPrimaryAction(okAction);
-
-    HbAction *cancelAction = new HbAction(QString(hbTrId("txt_common_button_cancel")),
-        mTimePickerDialog);
-    mTimePickerDialog->setSecondaryAction( cancelAction );
+    mTimePickerDialog->addAction(okAction);
+    mPrimaryAction = okAction;
+    
+    HbAction *cancelAction = new HbAction(QString(hbTrId("txt_common_button_cancel")), 
+                                          mTimePickerDialog);
+    mTimePickerDialog->addAction(cancelAction);
 
     // Show the dialog.
     mTimePickerDialog->open(this, SLOT(handleTimeAction(HbAction *)));
@@ -145,7 +147,7 @@
  */
 void NmIpsSettingsTimeEditor::handleTimeAction(HbAction *action)
 {
-    if (action == mTimePickerDialog->primaryAction()) {
+    if (action==mPrimaryAction) {
         // Get the time from the picker.
         QTime newTime = static_cast<HbDateTimePicker *> (mTimePickerDialog->contentWidget())->time();
 
Binary file ipsservices/nmipssettings/translations/mailips.qm has changed
--- a/ipsservices/nmipssettings/translations/mailips.ts	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmipssettings/translations/mailips.ts	Thu Jul 22 16:30:28 2010 +0100
@@ -7,17 +7,37 @@
     <source>On (StartTLS)</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
     <extra-loc-positionid>setlabel_11_12_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mailips_list_popup_sec_off">
+    <comment>Option item for txt_mailips_dialog_heading_incoming_connection and txt_mailips_dialog_heading_outgoing_connection. For defining that the setting for securing incoming/outgoing mail is off. Example flow in settings.ppt, slide 18</comment>        
+    <source>Off</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_a, mail_006_d_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_dialog_heading_refresh_mail">
+    <comment>Option item in txt_mailips_dialog_heading_refresh_mail setting dialog. Option for defining that the mailbox gets refreshed from server according to a default refreshing schedule.</comment>        
+    <source>Refresh mail</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mailips_setlabel_outgoing_mail_authentication">
     <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the type of authentication for outgoing mail. Setting item in server info: what is used for outgoing mail authetication</comment>        
     <source>Outgoing mail authentication</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_d_c</extra-loc-viewid>
     <extra-loc-positionid>setlabel_10</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -27,11 +47,411 @@
     <source>Reply to address</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_c</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_c</extra-loc-viewid>
     <extra-loc-positionid>setlabel_4</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mailips_setlabel_folder_path_val_default">
+    <comment>Value for txt_mailips_setlabel_folder_path. Default folder path will be used. Refers to all folders. </comment>        
+    <source>Default</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_d</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_9_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_dialog_heading_connection">
+    <comment>Title text in setting radio button dialog opened from txt_mailips_setlabel_connection. Example of the dialog can be found from settings.ppt, slide 18</comment>        
+    <source>Connection</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_a_a</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_dialog_heading_show_in_inbox">
+    <comment>Title text in setting dialog opened from txt_mailips_setlabel_show_mail_in_inbox. Example flow can be found from 10.2settings.ptt, slide 16</comment>        
+    <source>Show mail in inbox</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_a</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_download_images_val_every_day">
+    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. The value text for Receiving weekdays if all seven days are selected. </comment>        
+    <source>Every day</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_download_images_val_tue">
+    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Tuesdays setting item</comment>        
+    <source>Tue</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_outgoing_port">
+    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the outgoing port for mail connection.</comment>        
+    <source>Outgoing port</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_14</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_val_every_1_hour">
+    <comment>Value for txt_mailips_setlabel_refresh_mail. The mailbox is refreshed every hour</comment>        
+    <source>Every 1 hour</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_6_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_thursday">
+    <comment>Option item in txt_mailips_dialog_heading_receiving_weekdays setting dialog.</comment>        
+    <source>Thu</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_outgoing_mail_server">
+    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the outgoing mail server. Setting item in server info</comment>        
+    <source>Outgoing mail server</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_3</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_the_mailbox_is_refreshed_as_defin">
+    <comment>info text to explain the profile (txt_mailmfe_setlabel_selected_mode_val_user_defined)</comment>        
+    <source>The mailbox is refreshed as defined by the user</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_description_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_on_ssltls">
+    <comment>Option item for txt_mailips_dialog_heading_incoming_connection and txt_mailips_dialog_heading_outgoing_connection. For defining that the setting for securing incoming/outgoing mail is on with SSL/TLS protocol. Example flow in settings.ppt, slide 18</comment>        
+    <source>On (SSL/TLS)</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_a, mail_006_d_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_the_mailbox_is_refreshed_every_hour">
+    <comment>info text to explain the profile (txt_mailmfe_setlabel_selected_mode_val_save_energy)</comment>        
+    <source>The mailbox is refreshed every hour during daytime</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_description_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_download_images_val_sun">
+    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Sunday setting item</comment>        
+    <source>Sun</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_folder_path_user_defined">
+    <comment>Value for txt_mailips_setlabel_folder_path. User is able to define the folder path.</comment>        
+    <source>User defined</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_d</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_9_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_folder_path">
+    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the folder path. Setting item in server info</comment>        
+    <source>Folder path</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_d</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_9</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_every_4_hours">
+    <comment>Option item in txt_mailips_dialog_heading_refresh_mail setting dialog. Option for defining that the mailbox gets refreshed from server every 4 hours.</comment>        
+    <source>Every 4 hours</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_username">
+    <comment>Setting label under User info for defining the user´s username related to the mailbox. Setting item in user info</comment>        
+    <source>Username</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_c</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_2</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_receiving_weekdays">
+    <comment>Setting label under Receiving schedule &gt; Selected mode &gt; Save energy  (txt_mailips_setlabel_selected_mode_val_save_energy). Label for selecting the busy days when the mail is received frequently</comment>        
+    <source>Receiving days</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_3</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_mailbox_name">
+    <comment>Setting item in Prefences: Defines the mailbox name</comment>        
+    <source>Mailbox name</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_a_e</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_2</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_every_15_minutes">
+    <comment>Option item in txt_mailips_dialog_heading_refresh_mail setting dialog. Option for defining that the mailbox gets refreshed from server every 15 minutes.</comment>        
+    <source>Every 15 minutes</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_wednesday">
+    <comment>Option item in txt_mailips_dialog_heading_receiving_weekdays setting dialog.</comment>        
+    <source>Wed</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_download_images_val_mon">
+    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Monday setting item</comment>        
+    <source>Mon</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_outgoing_authentication_same">
+    <comment>Value for txt_mailips_setlabel_outgoing_mail_authentication. Same authentication as for incoming mail</comment>        
+    <source>Same as for incoming</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_10_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_incoming_security">
+    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the secure connection usage for incoming mail. </comment>        
+    <source>Incoming secure connection</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_a</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_11</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_the_mailbox_is_refreshed_every_15">
+    <comment>info text to explain the profile (txt_mailmfe_setlabel_selected_mode_val_save_energy)</comment>        
+    <source>The mailbox is refreshed every 15 minutes during daytime</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_description_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_all">
+    <comment>One of the values for txt_mailips_setlabel_show_mail_in_inbox and txt_mailips_setlabel_show_mail_in_other_folders. The user can select that all the mail messages in the mailbox are synced to phone..</comment>        
+    <source>All</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_saturday">
+    <comment>Option item in txt_mailips_dialog_heading_receiving_weekdays setting dialog.</comment>        
+    <source>Sat</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_val_keep_uptodate">
+    <comment>Value for txt_mailips_setlabel_refresh_mail. The mailbox is kept up-to-date</comment>        
+    <source>Keep up-to-date</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_6_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_the_mailbox_is_uptodate_during">
+    <comment>info text to explain the profile (txt_mailmfe_setlabel_selected_mode_val_keep_uptoda)</comment>        
+    <source>The mailbox is up-to-date during daytime</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_description_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_dialog_heading_outgoing_authentication">
+    <comment>Title text in setting dialog opened from txt_mailips_setlabel_refresh_mail. For defining the settings for outgoing mail authentication. Radio button list. Example flow in settings.ppt, slide 18</comment>        
+    <source>Outgoing mail authentication</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_c</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_security_val_on_ssltls">
+    <comment>Value for txt_mailips_setlabel_secure_connection. Secure connection on with SLL/TLS (name of the secure connection protocol )</comment>        
+    <source>On (SLL/TLS)</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_11_12_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_outgoing_security">
+    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the secure connection usage for outgoing mail.</comment>        
+    <source>Outgoing secure connection</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_b</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_12</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_selected_mode_val_fetch_manua">
+    <comment>Under Receiving schedule &gt; Selected mode. Mode drop down: fetch manually mode. The mailbox is refreshed only by user request. Example flow in settings.ppt, slide 14.</comment>        
+    <source>Fetch manually</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_combobox_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_20_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_no_authentication">
+    <comment>Option item in txt_mailips_dialog_heading_refresh_mail setting dialog. Radio button list. Example flow in settings.ppt, slide 18</comment>        
+    <source>No authentication</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_c</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_day_start_time">
+    <comment>Setting label under Receiving schedule &gt; Selected mode &gt; Save energy  (txt_mailips_setlabel_selected_mode_val_save_energy).  Label for selecting the start time of the day</comment>        
+    <source>Day start time</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_d</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_4</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_keep_up_to_date">
+    <comment>Option item in txt_mailips_dialog_heading_refresh_mail setting dialog. Option for defining that the mailbox gets refreshed from server according to a default refreshing schedule.</comment>        
+    <source>Keep up-to-date</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_val_all">
+    <comment>One of the values for txt_mailips_setlabel_show_mail_in_inbox and txt_mailips_setlabel_show_mail_in_other_folders. The user can select that all the mail messages in the mailbox are synced to phone..</comment>        
+    <source>All</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_1_2_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_version_l1">
+    <comment>Version number of the mail client. Maximum number of digits replacing the parameter is 7.</comment>        
+    <source>Version: %[]1</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_user_authentication">
+    <comment>Option item in txt_mailips_dialog_heading_refresh_mail setting dialog. Radio button list. Example flow in settings.ppt, slide 18</comment>        
+    <source>User authentication</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_c</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_setlabel_outgoing_authentication_none">
+    <comment>Value for txt_mailips_setlabel_outgoing_mail_authentication. No authetication</comment>        
+    <source>None</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_10_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_long_caption_mailips">
     <comment>Name of the mail application.</comment>        
     <source>Mail</source>
@@ -42,52 +462,92 @@
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_folder_path_val_default">
-    <comment>Value for txt_mailips_setlabel_folder_path. Default folder path will be used.</comment>        
-    <source>Default</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_9_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mailips_setlabel_incoming_port">
     <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the incoming port for mail connection.</comment>        
     <source>Incoming port</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
     <extra-loc-positionid>setlabel_13</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mailips_dialog_heading_end_time">
+    <comment>Title text in setting dialog opened from txt_mailips_setlabel_day_end_time. Day here refers to the peak time for synchronization within one day ie. during which hours wihtin one day the user wants the mailbox refreshed from the server most often. Typically for example during business hours but not in the evening in which case the day start time could be 9 am when the user comes to office and the day end time could be 5 pm when the user leaves office. Example flow can be found from 10.2settings.ptt, slide 17</comment>        
+    <source>Day end time</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_e</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mailips_setlabel_incoming_port_default">
     <comment>Value for txt_mailips_setlabel_incoming_port</comment>        
     <source>Default</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
     <extra-loc-positionid>setlabel_13_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mailips_dialog_heading_outgoing_connection">
+    <comment>Title text in setting dialog opened from txt_mailips_setlabel_outgoing_security. Radio button list. Example flow in settings.ppt, slide 18</comment>        
+    <source>Outgoing secure connection</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_b</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_every_hour">
+    <comment>Option item in txt_mailips_dialog_heading_refresh_mail setting dialog. Option for defining that the mailbox gets refreshed from server every hour.</comment>        
+    <source>Every hour</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_friday">
+    <comment>Option item in txt_mailips_dialog_heading_receiving_weekdays setting dialog.</comment>        
+    <source>Fri</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mailips_setlabel_incoming_mail_server">
     <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the incoming mail server. Setting item in server info</comment>        
     <source>Incoming mail server</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
     <extra-loc-positionid>setlabel_2</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mailips_list_popup_sec_on_starttls">
+    <comment>Option item for txt_mailips_dialog_heading_incoming_connection and txt_mailips_dialog_heading_outgoing_connection. For defining that the setting for securing incoming/outgoing mail is on with StartTLS protocol. Example flow in settings.ppt, slide 18</comment>        
+    <source>On (StartTLS)</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_a, mail_006_d_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mailips_setlabel_my_name">
     <comment>Setting item in Prefences: defines user&apos;s own name</comment>        
     <source>My name</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_a</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_a_d</extra-loc-viewid>
     <extra-loc-positionid>setlabel_1</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -97,88 +557,48 @@
     <source>Preferences</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_group_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_a</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_a</extra-loc-viewid>
     <extra-loc-positionid>subhead</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mailips_setlabel_day_end_time">
-    <comment>Setting label under Receiving schedule &gt; Selected mode &gt; Save energy  (txt_mailips_setlabel_selected_mode_val_save_energy). Label for selecting the end time of of the day</comment>        
+    <comment>Setting label under Receiving schedule &gt; Selected mode &gt; Save energy  (txt_mailips_setlabel_selected_mode_val_save_energy). Label for selecting the end time of of the day. Day here refers to the peak time for synchronization within one day ie. during which hours wihtin one day the user wants the mailbox refreshed from the server most often. Typically for example during business hours but not in the evening in which case the day start time could be 9 am when the user comes to office and the day end time could be 5 pm when the user leaves office.</comment>        
     <source>Day end time</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b_e</extra-loc-viewid>
     <extra-loc-positionid>setlabel_5</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_download_images_val_every_day">
-    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. The value text for Receiving weekdays if all seven days are selected. </comment>        
-    <source>Every day</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_setlabel_download_images_val_tue">
-    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Tuesdays setting item</comment>        
-    <source>Tue</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_setlabel_outgoing_port">
-    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the outgoing port for mail connection.</comment>        
-    <source>Outgoing port</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_14</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_setlabel_val_every_1_hour">
-    <comment>Value for txt_mailips_setlabel_refresh_mail. The mailbox is refreshed every hour</comment>        
-    <source>Every 1 hour</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_6_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_setlabel_outgoing_mail_server">
-    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the outgoing mail server. Setting item in server info</comment>        
-    <source>Outgoing mail server</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_3</extra-loc-positionid>
+<message numerus="no" id="txt_mailips_list_popup_sec_folder_path_val_default">
+    <comment>Option item in txt_mailips_setlabel_folder_path. Default folder path will be used. See example image from settings.ppt, slide 19</comment>        
+    <source>Default</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_d</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mailips_setlabel_selected_mode_val_save_energy">
-    <comment>Under Receiving schedule &gt; Selected mode. Mode drop down:Save energy mode. The mailbox is refreshed every 15 minutes during daytime</comment>        
+    <comment>Under Receiving schedule &gt; Selected mode. Mode drop down:Save energy mode. The mailbox is refreshed every 15 minutes during daytime. Example flow in settings.ppt, slide 14.</comment>        
     <source>Save energy</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_combobox_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
     <extra-loc-positionid>setlabel_20_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_list_the_mailbox_is_refreshed_as_defin">
-    <comment>info text to explain the profile (txt_mailmfe_setlabel_selected_mode_val_user_defined)</comment>        
-    <source>The mailbox is refreshed as defined by the user</source>
+<message numerus="no" id="txt_mailips_setlabel_download_images_val_wed">
+    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Wednesday setting item</comment>        
+    <source>Wed</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_description_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -187,48 +607,18 @@
     <source>Sat</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_setlabel_download_images_val_wed">
-    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Wednesday setting item</comment>        
-    <source>Wed</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
     <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_download_images_val_sun">
-    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Sunday setting item</comment>        
+<message numerus="no" id="txt_mailips_list_popup_sec_sunday">
+    <comment>Option item in txt_mailips_dialog_heading_receiving_weekdays setting dialog.</comment>        
     <source>Sun</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_setlabel_folder_path_user_defined">
-    <comment>Value for txt_mailips_setlabel_folder_path. User is able to define the folder path.</comment>        
-    <source>User defined</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_9_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_setlabel_folder_path">
-    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the folder path. Setting item in server info</comment>        
-    <source>Folder path</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_9</extra-loc-positionid>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -237,7 +627,7 @@
     <source>Off</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
     <extra-loc-positionid>setlabel_11_12_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -247,28 +637,38 @@
     <source>Show mail in other folders</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b_b</extra-loc-viewid>
     <extra-loc-positionid>setlabel_2</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_username">
-    <comment>Setting label under User info for defining the user´s username related to the mailbox. Setting item in user info</comment>        
-    <source>Username</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_c</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_2</extra-loc-positionid>
+<message numerus="no" id="txt_mailips_list_popup_sec_folder_path_user_defined">
+    <comment>Option item in txt_mailips_setlabel_folder_path. User is able to define the folder path. See example image from settings.ppt, slide 19</comment>        
+    <source>User defined</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_d</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_receiving_weekdays">
-    <comment>Setting label under Receiving schedule &gt; Selected mode &gt; Save energy  (txt_mailips_setlabel_selected_mode_val_save_energy). Label for selecting the busy days when the mail is received frequently</comment>        
-    <source>Receiving days</source>
+<message numerus="no" id="txt_mailips_setlabel_download_images_val_none">
+    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Shown if none of the days are selected.</comment>        
+    <source>None</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_3</extra-loc-positionid>
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_list_popup_sec_tuesday">
+    <comment>Option item in txt_mailips_dialog_heading_receiving_weekdays setting dialog.</comment>        
+    <source>Tue</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -277,7 +677,7 @@
     <source>Refresh mail</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
     <extra-loc-positionid>setlabel_6</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -287,58 +687,38 @@
     <source>Mail address</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_c</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_c</extra-loc-viewid>
     <extra-loc-positionid>setlabel_1</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_mailbox_name">
-    <comment>Setting item in Prefences: Defines the mailbox name</comment>        
-    <source>Mailbox name</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_a</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_2</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mailips_setlabel_connection">
-    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the type of connection used for fetching mail. Setting item in server info</comment>        
+    <comment>Setting label under Preferences for defining the type of connection used for fetching mail. Opens a radio button dialog, see example from settings.ppt, slide 18</comment>        
     <source>Connection</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_a_a</extra-loc-viewid>
     <extra-loc-positionid>setlabel_8</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_download_images_val_mon">
-    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Monday setting item</comment>        
-    <source>Mon</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
+<message numerus="no" id="txt_mailips_list_popup_sec_same_as_for_incoming">
+    <comment>Option item in txt_mailips_dialog_heading_refresh_mail setting dialog. Radio button list. Example flow in settings.ppt, slide 18</comment>        
+    <source>Same as for incoming</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_c</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_outgoing_authentication_same">
-    <comment>Value for txt_mailips_setlabel_outgoing_mail_authentication. Same authentication as for incoming mail</comment>        
-    <source>Same as for incoming</source>
+<message numerus="no" id="txt_mailips_setlabel_download_images_val_thu">
+    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Thursday setting item</comment>        
+    <source>Thu</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_10_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_setlabel_incoming_security">
-    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the secure connection usage for incoming mail. </comment>        
-    <source>Incoming secure connection</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_11</extra-loc-positionid>
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -347,58 +727,68 @@
     <source>Receiving Schedule</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_group_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
     <extra-loc-positionid>subhead</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_download_images_val_thu">
-    <comment>One of the values for txt_mailips_setlabel_receiving_weekdays. Thursday setting item</comment>        
-    <source>Thu</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mailips_subhead_server_info">
     <comment>Subheading. Group box for expanding/ collapsing Server settings in settings view. Opens list of settings related to Server settings (server name, domain name, secure connection on/off). </comment>        
     <source>Server info</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_group_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
     <extra-loc-positionid>subhead</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
+<message numerus="no" id="txt_mailips_list_popup_sec_monday">
+    <comment>Option item in txt_mailips_dialog_heading_receiving_weekdays setting dialog.</comment>        
+    <source>Mon</source>
+    <translation variants="yes" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_list_popup_sec_add</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
+<message numerus="no" id="txt_mailips_dialog_heading_folder_path">
+    <comment>Title text in setting dialog opened from Server info txt_mailips_subhead_server_info for defining the folder path. See example image from settings.ppt, slide 19</comment>        
+    <source>Folder path</source>
+    <translation variants="no" type="unfinished"></translation>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_d</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
+    <extra-loc-feature>mail</extra-loc-feature>
+    <extra-loc-blank>False</extra-loc-blank>
+</message>
 <message numerus="no" id="txt_mailips_setlabel_val_when_i_open_mailbox">
     <comment>Value for txt_mailips_setlabel_refresh_mail. The mailbox is refreshed only and always when the user opens the mailbox</comment>        
     <source>When I open mailbox</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
     <extra-loc-positionid>setlabel_6_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_list_the_mailbox_is_refreshed_every_15">
-    <comment>info text to explain the profile (txt_mailmfe_setlabel_selected_mode_val_save_energy)</comment>        
-    <source>The mailbox is refreshed every 15 minutes during daytime</source>
+<message numerus="no" id="txt_mailips_setlabel_selected_mode_val_user_define">
+    <comment>Under Receiving schedule &gt; Selected mode. Mode drop down:User defined mode. The mailbox is refreshed as defined by the user. Example flow in settings.ppt, slide 14.</comment>        
+    <source>User defined</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_description_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-layout_id>qtl_dataform_combobox_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_20_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_selected_mode_val_user_define">
-    <comment>Under Receiving schedule &gt; Selected mode. Mode drop down:User defined mode. The mailbox is refreshed as defined by the user.</comment>        
-    <source>User defined</source>
+<message numerus="no" id="txt_mailips_dialog_heading_show_in_folders">
+    <comment>Title text in setting dialog opened from txt_mailips_setlabel_show_mail_in_other_folders. Example flow can be found from 10.2settings.ptt, slide 16</comment>        
+    <source>Show mail in other folders</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_combobox_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_20_val</extra-loc-positionid>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_b</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -407,58 +797,48 @@
     <source>Fri</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
     <extra-loc-positionid>setlabel_3_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_incoming_port_user_defined">
-    <comment>Value for txt_mailips_setlabel_incoming_port</comment>        
-    <source>User defined</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_13_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mailips_setlabel_val_every_4_hours">
     <comment>Value for txt_mailips_setlabel_refresh_mail. The mailbox is refreshed every four hours</comment>        
     <source>Every 4 hours</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
     <extra-loc-positionid>setlabel_6_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_val_keep_uptodate">
-    <comment>Value for txt_mailips_setlabel_refresh_mail. The mailbox is kept up-to-date</comment>        
-    <source>Keep up-to-date</source>
+<message numerus="no" id="txt_mailips_setlabel_incoming_port_user_defined">
+    <comment>Value for txt_mailips_setlabel_incoming_port</comment>        
+    <source>User defined</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_6_val</extra-loc-positionid>
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
+    <extra-loc-positionid>setlabel_13_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mailips_setlabel_selected_mode_val_keep_upto">
-    <comment>Under Receiving schedule &gt; Selected mode. Mode drop down: keep up to date mode. The mailbox is up-to-date during daytime</comment>        
+    <comment>Under Receiving schedule &gt; Selected mode. Mode drop down: keep up to date mode. The mailbox is up-to-date during daytime. Example flow in settings.ppt, slide 14.</comment>        
     <source>Keep up-to-date</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_combobox_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
     <extra-loc-positionid>setlabel_20_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_list_the_mailbox_is_uptodate_during">
-    <comment>info text to explain the profile (txt_mailmfe_setlabel_selected_mode_val_keep_uptoda)</comment>        
-    <source>The mailbox is up-to-date during daytime</source>
+<message numerus="no" id="txt_mailips_dialog_heading_incoming_connection">
+    <comment>Title text in setting dialog opened from txt_mailips_setlabel_incoming_security for defining the secure connection usage for incoming mail. Radio button list. Example flow in settings.ppt, slide 18</comment>        
+    <source>Incoming secure connection</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_description_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>list</extra-loc-positionid>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_d_a</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -467,28 +847,18 @@
     <source>User authentication</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_d</extra-loc-viewid>
     <extra-loc-positionid>setlabel_10_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_security_val_on_ssltls">
-    <comment>Value for txt_mailips_setlabel_secure_connection. Secure connection on with SLL/TLS (name of the secure connection protocol )</comment>        
-    <source>On (SLL/TLS)</source>
+<message numerus="no" id="txt_mailips_dialog_heading_receiving_days">
+    <comment>Title text in setting dialog opened from txt_mailips_setlabel_receiving_weekdays. Allows the user to define the weekdays when mail is refreshed to mailbox from server. Example flow can be found from 10.2settings.ptt, slide 19</comment>        
+    <source>Receiving days</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_11_12_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_setlabel_outgoing_security">
-    <comment>Setting label under Server info txt_mailips_subhead_server_info for defining the secure connection usage for outgoing mail.</comment>        
-    <source>Outgoing secure connection</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_12</extra-loc-positionid>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_c</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -497,48 +867,28 @@
     <source>Password</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_c</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_c</extra-loc-viewid>
     <extra-loc-positionid>setlabel_3</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_selected_mode_val_fetch_manua">
-    <comment>Under Receiving schedule &gt; Selected mode. Mode drop down: fetch manually mode. The mailbox is refreshed only by user request.</comment>        
-    <source>Fetch manually</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_combobox_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_20_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_list_the_mailbox_is_refreshed_only_by">
-    <comment>info text to explain the profile (txt_mailmfe_setlabel_selected_mode_val_fetch_manually)</comment>        
-    <source>The mailbox is refreshed only by user request</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_description_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>list</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 <message numerus="no" id="txt_mailips_setlabel_val_every_15_minutes">
     <comment>Value for txt_mailips_setlabel_refresh_mail. The mailbox is refreshed every 15 minutes</comment>        
     <source>Every 15 minutes</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b_f</extra-loc-viewid>
     <extra-loc-positionid>setlabel_6_val</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_day_start_time">
-    <comment>Setting label under Receiving schedule &gt; Selected mode &gt; Save energy  (txt_mailips_setlabel_selected_mode_val_save_energy).  Label for selecting the start time of the day</comment>        
-    <source>Day start time</source>
+<message numerus="no" id="txt_mailips_list_the_mailbox_is_refreshed_only_by">
+    <comment>info text to explain the profile (txt_mailmfe_setlabel_selected_mode_val_fetch_manually)</comment>        
+    <source>The mailbox is refreshed only by user request</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_4</extra-loc-positionid>
+    <extra-loc-layout_id>qtl_dataform_description_sec</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
+    <extra-loc-positionid>list</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -547,38 +897,18 @@
     <source>User info</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_group_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_c</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_c</extra-loc-viewid>
     <extra-loc-positionid>subhead</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_val_all">
-    <comment>One of the values for txt_mailips_setlabel_show_mail_in_inbox and txt_mailips_setlabel_show_mail_in_other_folders. The user can select that all the mail messages in the mailbox are synced to phone..</comment>        
-    <source>All</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_1_2_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailips_list_version_l1">
-    <comment>Version number of the mail client. Maximum number of digits replacing the parameter is 7.</comment>        
-    <source>Version: %[]1</source>
+<message numerus="no" id="txt_mailips_dialog_heading_start_time">
+    <comment>Title text in setting dialog opened from txt_mailips_setlabel_day_start_time. Day here refers to the peak time for synchronization within one day ie. during which hours wihtin one day the user wants the mailbox refreshed from the server most often. Typically for example during business hours but not in the evening in which case the day start time could be 9 am when the user comes to office and the day end time could be 5 pm when the user leaves office. Example flow can be found from 10.2settings.ptt, slide 17</comment>        
+    <source>Day start time</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06</extra-loc-viewid>
-    <extra-loc-positionid>list</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
-<message numerus="no" id="txt_mailnips_setlabel_signature">
-    <comment>Setting item in preferences.</comment>        
-    <source>Signature</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_a</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_10</extra-loc-positionid>
+    <extra-loc-layout_id>qtl_dialog_pri_heading</extra-loc-layout_id>    
+    <extra-loc-viewid>mail_006_b_d</extra-loc-viewid>
+    <extra-loc-positionid>title</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
@@ -587,7 +917,7 @@
     <source>Selected mode</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b</extra-loc-viewid>
     <extra-loc-positionid>setlabel_20</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -597,7 +927,7 @@
     <source>Show mail in inbox</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_pri</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_b</extra-loc-viewid>
+    <extra-loc-viewid>mail_006_b_a</extra-loc-viewid>
     <extra-loc-positionid>setlabel_1</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
@@ -607,20 +937,10 @@
     <source>Delete mailbox</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06</extra-loc-viewid>
+    <extra-loc-viewid>mail_006</extra-loc-viewid>
     <extra-loc-positionid>Button</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
     <extra-loc-blank>False</extra-loc-blank>
 </message>
-<message numerus="no" id="txt_mailips_setlabel_outgoing_authentication_none">
-    <comment>Value for txt_mailips_setlabel_outgoing_mail_authentication. No authetication</comment>        
-    <source>None</source>
-    <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
-    <extra-loc-viewid>mail_06_d</extra-loc-viewid>
-    <extra-loc-positionid>setlabel_10_val</extra-loc-positionid>
-    <extra-loc-feature>mail</extra-loc-feature>
-    <extra-loc-blank>False</extra-loc-blank>
-</message>
 </context>
 </TS>
--- a/ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp	Thu Jul 22 16:30:28 2010 +0100
@@ -33,8 +33,8 @@
     Constructs a new NmPopClientPlugin.
  */
 NmPopClientPlugin::NmPopClientPlugin()
-: mSettingsViewLauncher(NULL),
-mListOptionsMenuRequest(NULL)
+: mListOptionsMenuRequest(NULL),
+mSettingsViewLauncher(NULL)
 {
     NMLOG("NmPopClientPlugin::NmPopClientPlugin()-->");
     NMLOG("<--NmPopClientPlugin::NmPopClientPlugin()");
@@ -182,6 +182,7 @@
                 this, SLOT(goOffline(const NmId &)));
         }
 
+        handleRequest(NmActionResponseCommandSettings, mMenuRequest);
         mSettingsViewLauncher->launchSettingsView(id, mailbox->name());
     }
 
--- a/ipsservices/rom/FreestyleIpsServices.iby	Fri Jun 11 16:23:29 2010 +0100
+++ b/ipsservices/rom/FreestyleIpsServices.iby	Thu Jul 22 16:30:28 2010 +0100
@@ -23,7 +23,7 @@
 #ifdef FF_EMAIL_FRAMEWORK
 
 ECOM_PLUGIN( ipssosplugin.dll, ipssosplugin.rsc )
-//ECOM_PLUGIN( IPSSosAOPlugin.dll, IPSSosAOPlugin.rsc )
+ECOM_PLUGIN( IPSSosAOPlugin.dll, IPSSosAOPlugin.rsc )
 
 file=ABI_DIR\BUILD_DIR\nmipsmtms.dll		SHARED_LIB_DIR\nmipsmtms.dll        PAGED
 data=DATAZ_\MTM_INFO_FILE_DIR\smtp.rsc           MTM_INFO_FILE_DIR\smtp.rsc
--- a/nmail.pro	Fri Jun 11 16:23:29 2010 +0100
+++ b/nmail.pro	Thu Jul 22 16:30:28 2010 +0100
@@ -17,19 +17,9 @@
 
 TEMPLATE = subdirs
 
-win32: { 
-    SUBDIRS = \
-        emailservices/nmailbase \
-        emailuis/nmailuiengine  \
-        emailuis/nmailuiwidgets \
-        emailuis/nmailuiwidgetsplugin \
-        emailuis/nmailuiengine/tsrc/nmtestplugin \
-        emailuis/nmailuiengine/tsrc/nmtestpluginextension \
-        emailuis/nmailui
-}
-
 symbian*: { 
     SUBDIRS = \
+        email_plat \
         emailservices/nmailbase \
         emailuis/nmailuiengine \
         emailuis/nmailuiwidgets \
@@ -41,11 +31,11 @@
         emailservices/emailcommon \
         emailservices/emailframework \
         emailservices/emailstore \
+        emailservices/emailclientapi \
         ipsservices \
         emailuis/nmframeworkadapter \
         emailservices/nmclientapi \
         emailservices/nmailagent \
-        email_plat \
         emailservices/nmregister \
         emailuis/nmhswidget \
         emailuis/nmhswidget/tsrc/nmhswidgettestapp \