201027
authorhgs
Fri, 09 Jul 2010 12:17:13 +0300
changeset 51 d845db10c0d4
parent 49 00c7ae862740
child 56 15bc1d5d6267
201027
email_plat/email_services_api/email_services_api.h
emailservices/emailcommon/src/CFSMailBox.cpp
emailservices/emailcommon/src/CFSMailFolder.cpp
emailservices/emailcommon/src/CFSMailMessagePart.cpp
emailservices/emailcommon/src/CFSMailRequestHandler.cpp
emailservices/emailframework/src/CFSMailClient.cpp
emailservices/emailstore/base_plugin/src/MailIterator.cpp
emailservices/emailstore/base_plugin/src/baseplugintranslator.cpp
emailservices/emailstore/message_store/client/src/MsgStore.cpp
emailservices/emailstore/message_store/client/src/MsgStoreMessagePart.cpp
emailservices/emailstore/message_store/client/src/RMessageStoreSession.cpp
emailservices/emailstore/message_store/common/src/AccountsSerializer.cpp
emailservices/emailstore/message_store/debuglog/src/DebugLog.cpp
emailservices/emailstore/message_store/server/inc/ContainerStore.h
emailservices/emailstore/message_store/server/inc/ContainerStoreContainersTable.h
emailservices/emailstore/message_store/server/inc/ContainerStoreDefs.h
emailservices/emailstore/message_store/server/inc/ContainerStoreDeleteHandler.h
emailservices/emailstore/message_store/server/inc/ContainerStoreSortingTable.h
emailservices/emailstore/message_store/server/inc/MessageStoreServer.h
emailservices/emailstore/message_store/server/src/ContainerStore.cpp
emailservices/emailstore/message_store/server/src/ContainerStoreContainersTable.cpp
emailservices/emailstore/message_store/server/src/ContainerStoreDeleteHandler.cpp
emailservices/emailstore/message_store/server/src/ContainerStoreMRUAddressTable.cpp
emailservices/emailstore/message_store/server/src/ContainerStoreSearchHandler.cpp
emailservices/emailstore/message_store/server/src/ContainerStoreSortingTable.cpp
emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp
emailservices/emailstore/message_store/server/src/MessageStoreSession.cpp
emailservices/emailstore/message_store/server/src/MsgStoreSortResultRowSet.cpp
emailservices/emailstore/message_store/server/src/MsgStoreStringSortResultRowSet.cpp
emailservices/nmailagent/inc/nmmailagent.h
emailservices/nmailagent/src/nmmailagent.cpp
emailuis/nmailui/inc/nmapplication.h
emailuis/nmailui/inc/nmeditorcontent.h
emailuis/nmailui/inc/nmeditorheader.h
emailuis/nmailui/src/nmapplication.cpp
emailuis/nmailui/src/nmeditorcontent.cpp
emailuis/nmailui/src/nmeditorheader.cpp
emailuis/nmailui/src/nmeditorview.cpp
emailuis/nmailui/src/nmmessagelistview.cpp
emailuis/nmailui/src/nmutilities.cpp
emailuis/nmailui/src/nmviewerserviceinterface.cpp
emailuis/nmailui/src/nmviewerview.cpp
emailuis/nmailui/translations/mail.qm
emailuis/nmailui/translations/mail.ts
emailuis/nmailuiengine/bwins/nmailuiengineu.def
emailuis/nmailuiengine/eabi/nmailuiengineu.def
emailuis/nmailuiengine/inc/nmuiengine.h
emailuis/nmailuiengine/src/nmuiengine.cpp
emailuis/nmailuiwidgets/nmailuiwidgets.qrc
emailuis/nmailuiwidgets/src/nmeditortextedit.cpp
emailuis/nmframeworkadapter/src/nmframeworkadapter.cpp
emailuis/nmframeworkadapter/src/nmfwamessagepartsfetchingoperation.cpp
emailuis/nmsettingui/src/nmsettingsviewfactory.cpp
ipsservices/ipssosplugin/inc/ipsplgeventhandler.h
ipsservices/ipssosplugin/inc/ipsplgmsgiterator.h
ipsservices/ipssosplugin/inc/ipsplgmsgkey.h
ipsservices/ipssosplugin/inc/ipsplgsearch.h
ipsservices/ipssosplugin/inc/ipsplgsearch.inl
ipsservices/ipssosplugin/inc/ipsplgsyncstatehandler.h
ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp
ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp
ipsservices/ipssosplugin/src/ipsplgmsgiterator.cpp
ipsservices/ipssosplugin/src/ipsplgmsgkey.cpp
ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp
ipsservices/ipssosplugin/src/ipsplgsearch.cpp
ipsservices/ipssosplugin/src/ipsplgsyncstatehandler.cpp
ipsservices/nmimapclientplugin/src/nmimapclientplugin.cpp
ipsservices/nmipssettings/inc/nmipssettingsplugin.h
ipsservices/nmipssettings/src/nmipssettingshelper.cpp
ipsservices/nmipssettings/src/nmipssettingsplugin.cpp
ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp
--- a/email_plat/email_services_api/email_services_api.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/email_plat/email_services_api/email_services_api.h	Fri Jul 09 12:17:13 2010 +0300
@@ -25,6 +25,8 @@
 static const QString emailSendToKey = "to";
 static const QString emailSendCcKey = "cc";
 static const QString emailSendBccKey = "bcc";
+static const QString emailSendBodyTextKey = "body";
+static const QString emailSendAttachmentKey = "attachment";
 
 /*!
     Mail service name
--- a/emailservices/emailcommon/src/CFSMailBox.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailcommon/src/CFSMailBox.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -654,7 +654,7 @@
             TFSMailMsgId id = iFolders[i]->GetFolderId();
             if( id != draftsFolderId && id != outboxId )
             {
-                folderIds.Append(id);
+                folderIds.AppendL(id);
             }
         }
         
--- a/emailservices/emailcommon/src/CFSMailFolder.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailcommon/src/CFSMailFolder.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -176,7 +176,7 @@
 		{
 		RArray<TFSMailMsgId> messages;
 		messages.Reset();
-		messages.Append(aMessage);
+		messages.AppendL(aMessage);
 		plugin->DeleteMessagesByUidL(GetMailBoxId(),GetFolderId(),messages);
 		messages.Close();
 		}
@@ -204,7 +204,7 @@
         
         RArray<TFSMailMsgId> messages;
         messages.Reset();
-        messages.Append(aMessage);
+        messages.AppendL(aMessage);
         
         TRAP(err,plugin->DeleteMessagesByUidL(
             GetMailBoxId(),
--- a/emailservices/emailcommon/src/CFSMailMessagePart.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailcommon/src/CFSMailMessagePart.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -570,7 +570,7 @@
         CleanupClosePushL( ids ); 
         for(TInt i=0;i<attachments.Count();i++)
             {
-            ids.Append(attachments[i]->GetPartId());
+            ids.AppendL(attachments[i]->GetPartId());
             }
         
         // remove attachment fetched contents 
@@ -1382,9 +1382,8 @@
 	TInt requestId(0);
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
 		{
-		
 	    RArray<TFSMailMsgId> messageList;
-    	messageList.Append(GetPartId());
+    	messageList.AppendL(GetPartId());
 		
 	    // init async request
 	    TFSPendingRequest request = iRequestHandler->InitAsyncRequestL(	GetPartId().PluginId(),
--- a/emailservices/emailcommon/src/CFSMailRequestHandler.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailcommon/src/CFSMailRequestHandler.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -154,7 +154,7 @@
         CFSMailRequestObserver* observer = 
             CFSMailRequestObserver::NewL(*this, aOperationObserver);
         newRequest.iObserver = observer;
-        iPendingRequests.Append(newRequest);
+        iPendingRequests.AppendL(newRequest);
         
         return newRequest;
     }
@@ -231,8 +231,7 @@
     CFSMailPluginData* pluginData = new (ELeave) CFSMailPluginData;
     pluginData->iPluginId = aPluginId;
     pluginData->iPlugin = aPlugin;
-    iPluginList.Append(pluginData);             
-
+    iPluginList.AppendL(pluginData);             
     }
 
 // -----------------------------------------------------------------------------
--- a/emailservices/emailframework/src/CFSMailClient.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailframework/src/CFSMailClient.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -254,7 +254,7 @@
                         mailBox = plugin->GetMailBoxByUidL(mailBoxList[ii]) );
 				    if ( mailBox )
     				    {
-                        aMailBoxes.Append( mailBox );
+                        err = aMailBoxes.Append( mailBox );
                         }
 				// </cmail>
 					if(err != KErrNone)
@@ -294,7 +294,7 @@
                         mailBox = plugin->GetMailBoxByUidL(mailBoxList[i]) );
                     if ( mailBox )
                         {
-                        aMailBoxes.Append( mailBox );
+                        err = aMailBoxes.Append( mailBox );
                         }
                 // </cmail>				
 				if(err != KErrNone)
--- a/emailservices/emailstore/base_plugin/src/MailIterator.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/MailIterator.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -134,7 +134,7 @@
         
         iPlugin.TranslateMsgStorePropsL( iMailBox, *msMsgs[i], *fsMsg );
 
-        aMessages.Append( fsMsg );
+        aMessages.AppendL( fsMsg );
         CleanupStack::Pop( fsMsg );
         }
 
@@ -184,7 +184,7 @@
 
         iPlugin.TranslateMsgStorePropsL( iMailBox, *msMsgs[i], *fsMsg );
 
-        aMessages.Append( fsMsg );
+        aMessages.AppendL( fsMsg );
         CleanupStack::Pop( fsMsg );
         }
 
--- a/emailservices/emailstore/base_plugin/src/baseplugintranslator.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/baseplugintranslator.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -613,7 +613,7 @@
         if ( aCalendar.FindProperty( KMsgStorePropertyMrMonthDay, idx ) )
             {
             TUint32 monthDayNo = aCalendar.PropertyValueUint32L( idx );
-            days.Append(monthDayNo);
+            days.AppendL(monthDayNo);
             /**@ double check that when testing starts.*/
             }
             
--- a/emailservices/emailstore/message_store/client/src/MsgStore.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/client/src/MsgStore.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -282,7 +282,7 @@
     for ( TInt i = 0 ; i < accounts.Count() && defaultMailboxId == KMsgStoreInvalidId ; i++ )
         {
         CMsgStoreMailBox* mb = OpenAccountL( *accounts[i] );
-        mailBoxes.Append( mb );
+        mailBoxes.AppendL( mb );
         if ( mb->IsDefaultMailbox() )
             {
             defaultMailboxId = mb->Id();
--- a/emailservices/emailstore/message_store/client/src/MsgStoreMessagePart.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/client/src/MsgStoreMessagePart.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -269,7 +269,7 @@
 							{
 							//body is not the first child, move it to the first place
 							aParts.Remove(i);
-							aParts.Insert( part, 0 );
+							aParts.InsertL( part, 0 );
 							}
 						break;
 					}
--- a/emailservices/emailstore/message_store/client/src/RMessageStoreSession.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/client/src/RMessageStoreSession.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -442,7 +442,7 @@
 	for ( int i = 0 ; i < count ; i++ )
 		{
 		CMsgStoreAccount* account = CMsgStoreAccount::NewL( ownerIds[i], *(names[i]) );
-		aAccounts.Append( account );
+		aAccounts.AppendL( account );
 		}
 	CleanupStack::PopAndDestroy( serializer );
 	CleanupStack::PopAndDestroy( &resultBuf );
@@ -525,7 +525,7 @@
         User::LeaveIfError( fs.Connect() );
         fs.ShareProtected();        
         
-        User::LeaveIfError( file.Open( fs, aContentFilename, EFileRead | EFileShareAny ) );
+        User::LeaveIfError( file.Open( fs, aContentFilename, EFileShareReadersOnly ) );
         User::LeaveIfError( file.TransferToServer( ipcArgs, KIpcArgsIndex2, KIpcArgsIndex3 ) );	    	    
 	    } // end if
 
@@ -776,7 +776,7 @@
 	const TUint KDivider = 4;
 	for( TInt count = 0; count < childrenBuf.Length() / KDivider; count++ )
 		{
-		aChildrenIds.Append( readStream.ReadUint32L() );
+		aChildrenIds.AppendL( readStream.ReadUint32L() );
 		} // end for
 		
 	CleanupStack::PopAndDestroy( &readStream );
@@ -1287,7 +1287,7 @@
             countPckg.Copy( pointer, countPckg.Length() );
             pointer += countPckg.Length();
             
-            aItemsInGroup.Append( count );        
+            aItemsInGroup.AppendL( count );        
             }
         }
     
@@ -1332,7 +1332,7 @@
             flagPckg.Copy( pointer, flagPckg.Length() );
             pointer += flagPckg.Length();
             
-            aIdsAndFlags.Append( TMsgStoreIdAndFlag( id, flag ) );        
+            aIdsAndFlags.AppendL( TMsgStoreIdAndFlag( id, flag ) );        
             }
         }
     
@@ -1387,7 +1387,7 @@
             idPckg.Copy( pointer, idPckg.Length() );
             pointer += idPckg.Length();
             
-            aMessageIds.Append( id );        
+            aMessageIds.AppendL( id );        
             }
         }
     
@@ -1425,7 +1425,7 @@
         idPckg.Copy( pointer, idPckg.Length() );
         pointer += idPckg.Length();
         
-        aMessageIds.Append( id );
+        aMessageIds.AppendL( id );
         --idCount;
         }
     
@@ -1437,7 +1437,7 @@
         countPckg.Copy( pointer, countPckg.Length() );
         pointer += countPckg.Length();
         
-        aItemsInGroup.Append( count ); 
+        aItemsInGroup.AppendL( count ); 
         --groupCount;
         }
     
@@ -1710,7 +1710,7 @@
     
         //create the address object and add it to the output array
         CMsgStoreAddress *address = CMsgStoreAddress::NewL( addrDes16, nameDes16 );
-        aAddressArray.Append( address );            
+        aAddressArray.AppendL( address );            
         } // end while          
     
     CleanupStack::PopAndDestroy( &serializedBuf );
--- a/emailservices/emailstore/message_store/common/src/AccountsSerializer.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/common/src/AccountsSerializer.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -46,8 +46,8 @@
 void CAccountsSerializer::AddAccountL( TInt32 aOwnerId, const TDesC& aName )
 	{
 	HBufC* nameCopy = aName.AllocL();
-	iNameBufArray.Append( nameCopy );
-	iOwnerIdArray.Append( aOwnerId );
+	iNameBufArray.AppendL( nameCopy );
+	iOwnerIdArray.AppendL( aOwnerId );
 	iCount++;
 	}
         
--- a/emailservices/emailstore/message_store/debuglog/src/DebugLog.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/debuglog/src/DebugLog.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -1162,7 +1162,7 @@
     CLogFileHandler* handler = NULL;
     
     // Look for the log file handler for the given directory.
-    TInt  index = 0;
+    TInt index = 0;
     while( index < iFiles.Count() && ( !handler ) )
         {
         CLogFileHandler* currentHandler = iFiles[index];
@@ -1182,7 +1182,7 @@
 
         if( handler )
             {            
-            iFiles.Append( handler );
+            iFiles.AppendL( handler );
             } // end if
         }
     
@@ -1194,11 +1194,11 @@
 		if ( copyOfName )
 		    {       
             copyOfName->Des().Copy( aObject->ClassName8() );
-            handler->iObjectNames.Append( copyOfName );
+            handler->iObjectNames.AppendL( copyOfName );
 			}
 //#endif        
 
-        handler->iObjects.Append( aObject );
+        handler->iObjects.AppendL( aObject );
 	    } // end if
 	    
 	return handler;       
@@ -1212,7 +1212,7 @@
 // ==========================================================================
 void CDebugLogTlsData::DoReleaseLogFileHandler( CLogFileHandler* aHandler, RDebugLog* aObject )
     {
-    TInt index = aHandler->iObjects.Find( aObject );
+    TInt index = aHandler->iObjects.FindL( aObject );
     
     if( index >= 0 )
         {
@@ -1224,9 +1224,8 @@
         
         if( aHandler->iObjects.Count() == 0 )
             {
+            iFiles.Remove( iFiles.Find(aHandler) );
             delete aHandler;
-            
-            iFiles.Remove( iFiles.Find(aHandler) );                        
             } // end if
         }
     else
--- a/emailservices/emailstore/message_store/server/inc/ContainerStore.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/ContainerStore.h	Fri Jul 09 12:17:13 2010 +0300
@@ -428,6 +428,7 @@
         void CommitDatabaseTransactionL();
         
         const TDesC& PrivatePath();
+        TBool DeleteFromSortingTable();
         
 #ifdef _DEBUG                      
         
--- a/emailservices/emailstore/message_store/server/inc/ContainerStoreContainersTable.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/ContainerStoreContainersTable.h	Fri Jul 09 12:17:13 2010 +0300
@@ -157,6 +157,8 @@
         
         TBool IsEncrypted();
         
+        TContainerId FirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark );
+        
 	private:
 	
 	    // ===============
@@ -189,7 +191,7 @@
         void WriteUnencryptedPropertiesColumnL( const TDesC8& aProperties );
         
         void SetEncryptedL( TBool aIsEncrypted );
-
+        TContainerId GetFirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark );
 	    // ==================
 	    // PRIVATE ATTRIBUTES
 	    // ==================
--- a/emailservices/emailstore/message_store/server/inc/ContainerStoreDefs.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/ContainerStoreDefs.h	Fri Jul 09 12:17:13 2010 +0300
@@ -65,6 +65,7 @@
 _LIT( KContainersTableCountsCol,		  "C008" );
 _LIT( KContainersTableIsRowEncryptedCol,  "C009" );
 _LIT( KContainersTableIdIndex,            "C00A" );
+_LIT( KContainersTableParentIdIndex,      "C00B" );
 
 // Sorting table
 _LIT( KSortingTableName,                  "D001" );
@@ -113,6 +114,10 @@
 _LIT( KMruAddressTableMruNumIndex,        "F007" );
 _LIT( KMruAddressTableMailboxIdIndex,     "F008" );
 
+_LIT(KMarkedForDeleteTableName,                 "H001");
+_LIT(KMarkedForDeleteTableIDCol,                "H002");
+
+
 
 /** Defines the states of encryption/decryption operation 
  *  This state needs to be persisted in the db, so that if
--- a/emailservices/emailstore/message_store/server/inc/ContainerStoreDeleteHandler.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/ContainerStoreDeleteHandler.h	Fri Jul 09 12:17:13 2010 +0300
@@ -46,7 +46,8 @@
         enum TState
             {
             ERetryDelete,
-            EDelete
+            EDelete,
+            EDeleteFromSortingTable
             };
         // ==============
         // PUBLIC METHODS
--- a/emailservices/emailstore/message_store/server/inc/ContainerStoreSortingTable.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/ContainerStoreSortingTable.h	Fri Jul 09 12:17:13 2010 +0300
@@ -113,6 +113,7 @@
         
         TBool DecryptFirstL( TDbBookmark& aNextRow );
         TBool DecryptNextL( TDbBookmark& aNextRow );
+        TBool DeleteNextContainerMarkedForDeletionL();
         
 	private:
 
@@ -159,8 +160,11 @@
         
         TBool IsEncrypted( RDbRowSet& aRowSet );
         void SetEncryptedL( TBool aIsEncrypted );
-        
-
+        void CreateMarkedForDeletionTableL();
+        void CreateOrOpenMarkedForDeletionTableL();
+        void MarkIdForDeletionL( TContainerId aId);
+        TBool DeleteNextMessageL( TContainerId aId );
+        TBool DeleteFromMarkedForDeletionTableL();
     private:
     
         // ==================
@@ -186,7 +190,8 @@
         TInt                  iIsEncryptedColNum;
         
         TUint                 iFieldsChanged;
-	    
+        RDbTable              iMarkedForDeleteTable;
+        TInt                  iMarkedForDeleteIdColNum;
 	    __LOG_DECLARATION
     		
 	}; // end class CContainerStoreSortingTable
--- a/emailservices/emailstore/message_store/server/inc/MessageStoreServer.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/MessageStoreServer.h	Fri Jul 09 12:17:13 2010 +0300
@@ -125,7 +125,7 @@
 
         static CMessageStoreServer* NewLC();
 
-        void AddSession( CMessageStoreSession* aSession );
+        void AddSessionL( CMessageStoreSession* aSession );
 
         void DropSession( CMessageStoreSession* aSession );
 
--- a/emailservices/emailstore/message_store/server/src/ContainerStore.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStore.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -1735,15 +1735,10 @@
 // ==========================================================================
 void CContainerStore::FirstChildL( TContainerId aId, TContainerId& aFirstChildId, TDbBookmark& aBookmark )
     {
-    aFirstChildId = FirstChildL( aId );
-    
-    if( aFirstChildId != KContainerInvalidId )
-        {
-        aBookmark = iContainersTable->Bookmark();
-        } // end if
-        
-     } // end FirstChildL
-		
+    //Used to by the deletehandler to traverse the table for the lowest level child
+    aFirstChildId = iContainersTable->FirstChildForDeleteL( aId, aBookmark );       
+    } 
+
 // ==========================================================================
 // FUNCTION: SearchL
 // ==========================================================================
@@ -1773,6 +1768,7 @@
 
 // ==========================================================================
 // FUNCTION: StartSortingL
+// Will leave with KErrNotFound if the container is marked for deletion.
 // ==========================================================================
 TContainerId CContainerStore::StartSortingL( TMsgStoreSortCriteria& aSortCriteria, 
                                              RPointerArray<HBufC8>& aPropertyNames,
@@ -1781,6 +1777,13 @@
     __LOG_ENTER_SUPPRESS( "StartSortingL" )
     __LOG_WRITE_FORMAT4_INFO( "folder=%x sortField=%d order=%d, aInMemorySort=%d", aSortCriteria.iFolderId, aSortCriteria.iSortBy, aSortCriteria.iSortOrder, aInMemorySort )
 
+    //Seek to make sure the container is not markd for deletion, if the container is marked for deletion
+    //this will leave with KerrNotFound
+    TRAPD(err, iContainersTable->SeekL( aSortCriteria.iFolderId, iHierarchy )); 
+    if (err != KErrNone)
+        {
+        User::LeaveIfError(KErrNotFound);
+        }
     CMsgStoreSortResultRowSet* resultRowSet = iSortingTable->SortL( aSortCriteria, aInMemorySort );
     CleanupStack::PushL( resultRowSet );
     
@@ -1797,7 +1800,7 @@
     session.iSessionId = iNextSortSessionId++;
     session.iResultRowSet = resultRowSet ;
     
-    iSortSessions.Append( session );
+    iSortSessions.AppendL( session );
     
     CleanupStack::Pop( resultRowSet );
     
@@ -2488,6 +2491,15 @@
     iUtils->CommitDatabaseTransactionL();
     }
 
+/*
+ * Check to see there are mailboxes/folder IDs marked for deletion.
+ */
+TBool CContainerStore::DeleteFromSortingTable()
+    {
+    TBool moreToDelete = EFalse;
+    TRAP_IGNORE(moreToDelete = iSortingTable->DeleteNextContainerMarkedForDeletionL());
+    return moreToDelete;   
+    }
 /**
  * 
  */
--- a/emailservices/emailstore/message_store/server/src/ContainerStoreContainersTable.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStoreContainersTable.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -297,9 +297,22 @@
     iIsRowEncryptedColNum  = colSet->ColNo( KContainersTableIsRowEncryptedCol );
 
 	CleanupStack::PopAndDestroy( colSet );
-	
-	// Set the table's index to the ID index.
-	User::LeaveIfError( iTable.SetIndex( KContainersTableIdIndex ) );
+
+    // make sure KContainersTableParentIdIndex exists
+    TInt err = iTable.SetIndex( KContainersTableParentIdIndex );
+    if ( err == KErrNotFound )
+        {
+        iUtils.CloseTable( iTable );
+        CreateIndexL( KContainersTableName, KContainersTableParentIdIndex, KContainersTableParentIdCol );
+        iUtils.OpenTableL( iTable, KContainersTableName );
+        }
+    else
+        {
+        User::LeaveIfError( err );
+        }
+
+    // Set the table's index to the ID index.
+    User::LeaveIfError( iTable.SetIndex( KContainersTableIdIndex ) );
 	
 	__LOG_EXIT
 	} // end OpenTableL
@@ -347,8 +360,9 @@
 	
 	// Create table index.
     CreateIndexL( KContainersTableName, KContainersTableIdIndex, KContainersTableIdCol );
-	
-	OpenTableL();
+    CreateIndexL( KContainersTableName, KContainersTableParentIdIndex, KContainersTableParentIdCol );
+
+    OpenTableL();
 	
 	__LOG_EXIT	
 	} // end CreateTableL
@@ -932,7 +946,9 @@
 	    queryString.AppendNum( toBeSearched[0] );    	    
         toBeSearched.Remove( 0 );
         
-        if ( aType == EMsgStorePartBits )
+        if ( aType == EMsgStorePartBits || 
+           ( ( aId & KContainerTypeMask ) == EMsgStoreMessageBits ) ||
+           ( ( aId & KContainerTypeMask ) == EMsgStorePartBits ) )
         	{
         	//must sort the message parts by containerId in ascending order
         	// to preserve the same order as they are created
@@ -1208,4 +1224,47 @@
     iTable.SetColL( iIsRowEncryptedColNum, static_cast<TUint8>(aIsEncrypted) );
     }
 
+/*
+ * Search based on the parent ID. This will set the index if one exists and use the find if the index does not
+ * exists which could happen for a existing DB(IAD case)
+ */
+TContainerId CContainerStoreContainersTable::FirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark )
+    {
+    __LOG_ENTER( "FirstChildForDeleteL" )
+    __LOG_WRITE8_FORMAT1_INFO( "id=%x", aId )
 
+    TContainerId returnValue = KContainerInvalidId;
+    User::LeaveIfError( iTable.SetIndex( KContainersTableParentIdIndex ) );
+    TRAP_IGNORE( returnValue = GetFirstChildForDeleteL( aId, aBookmark ) );
+    //remember to set the index back
+    iTable.SetIndex( KContainersTableIdIndex );
+
+    __LOG_EXIT
+    return returnValue;   
+    }
+
+/*
+ * Search based on the parent ID. 
+ */
+TContainerId CContainerStoreContainersTable::GetFirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark )
+    {
+    __LOG_ENTER( "FirstChildForDeleteL" )
+    __LOG_WRITE8_FORMAT1_INFO( "id=%x", aId )
+    
+    TContainerId returnValue = KContainerInvalidId;
+    //Index on parent id, so we can Seek, faster than Find
+    if ( !iTable.SeekL( aId ) )
+        {
+        __LOG_WRITE_INFO( "No match found" )
+        returnValue = KContainerInvalidId;
+        }
+    else
+        {
+        iTable.GetL();
+        returnValue = iTable.ColUint32( iIdColNum );
+        aBookmark = Bookmark();
+        __LOG_WRITE8_FORMAT1_INFO( "found id=%x", returnValue )
+        }
+    __LOG_EXIT
+    return returnValue;   
+    }
--- a/emailservices/emailstore/message_store/server/src/ContainerStoreDeleteHandler.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStoreDeleteHandler.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -115,7 +115,7 @@
 // ==========================================================================
 void CDeleteHandler::FindContainerToDeleteL()
     {
-    TBool done = EFalse;
+    TBool done(EFalse);
     
     TContainerId containerId = KToBeDeletedContainers;
     if ( iState == ERetryDelete )
@@ -163,7 +163,7 @@
     // Delete the lowest node in the hierarchy.        
     TRAPD( result, FindContainerToDeleteL() );
 
-    TBool more = EFalse;    
+    TBool more ( EFalse );    
         
     if( result == KErrNone )
         {        
@@ -201,7 +201,18 @@
         {   
         if ( iState == ERetryDelete )
             {
-            iState = EDelete;
+            //next state
+            iState = EDeleteFromSortingTable;
+            more = ETrue;
+            }
+        else if(iState == EDeleteFromSortingTable)
+            {
+            //check sorting table for containers that have been marked for deletion
+            if(!iContainerStore.DeleteFromSortingTable())
+                {
+                //if nor more then set to next state
+                iState = EDelete;
+                }
             more = ETrue;
             }
         else
@@ -214,21 +225,3 @@
     return more;
     
     } // end DoNextDelete
-
-// ==========================================================================
-// FUNCTION: FinishDeletes
-// ==========================================================================
-void CDeleteHandler::FinishDeletes()
-    {
-    if( IsActive() )
-        {
-        Cancel();
-        
-        // Loop until all deletes are done.
-        while( DoNextDelete() )
-            {
-            }        
-        
-        } // end if
-    
-    } // end FinishDeletes
--- a/emailservices/emailstore/message_store/server/src/ContainerStoreMRUAddressTable.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStoreMRUAddressTable.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -461,7 +461,7 @@
         }
     
     CMruAddressList* list = new(ELeave) CMruAddressList( aMailboxId );
-    iAddressLists.Append( list );
+    iAddressLists.AppendL( list );
     
     __LOG_EXIT
     }
@@ -619,7 +619,7 @@
         {
         TContainerId mailboxId = aMailboxIds[i];
         CMruAddressList* list = new(ELeave) CMruAddressList( mailboxId );
-        iAddressLists.Append( list );
+        iAddressLists.AppendL( list );
         
         const TUint bufSize = 100;
         TBuf<bufSize> sqlString;
--- a/emailservices/emailstore/message_store/server/src/ContainerStoreSearchHandler.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStoreSearchHandler.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -274,13 +274,13 @@
     iFolderIds.Reset();
     for( TInt i = 0 ; i < aFolderIds.Count() ; i++ )
         {
-        iFolderIds.Append( aFolderIds[i] );
+        iFolderIds.AppendL( aFolderIds[i] );
         }
 
     iPropertyNames.ResetAndDestroy();
     for ( TInt i = 0 ; i < aPropertyNames.Count() ; i++ )
         {
-        iPropertyNames.Append( aPropertyNames[i] );
+        iPropertyNames.AppendL( aPropertyNames[i] );
         }
     aPropertyNames.Reset();
     
@@ -466,7 +466,7 @@
         __LOG_WRITE_FORMAT1_INFO( "search string =%S", &searchStringPtr );
         
         HBufC* pattern = HBufC::NewL( searchString->Length() + 2 );
-        aSearchPatterns.Append( pattern );
+        aSearchPatterns.AppendL( pattern );
         TPtr seartStringPrt( pattern->Des() );
         
         //we are using MatchC(), so we need to add * to the start and end of the search pattern
--- a/emailservices/emailstore/message_store/server/src/ContainerStoreSortingTable.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStoreSortingTable.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -28,7 +28,6 @@
 #include "MsgStoreInMemorySortRowSet.h"
 	
 _LIT( KSelect,  "SELECT "   );
-_LIT( KDelete,  "DELETE "   );
 _LIT( KFrom,    " FROM "    );
 _LIT( KWhere,   " WHERE "   );
 _LIT( KEquals,  " = "       );
@@ -113,6 +112,7 @@
 CContainerStoreSortingTable::~CContainerStoreSortingTable()
 	{
 	iUtils.CloseTable( iTable );
+    iUtils.CloseTable (iMarkedForDeleteTable);
     iEncryptedBuffer.Close();
 	__LOG_DESTRUCT	
 	} // end destructor
@@ -148,7 +148,7 @@
 	
 	// Set the table's index to the ID index.
 	User::LeaveIfError( iTable.SetIndex( KSortingTableMessageIdIndex ) );
-
+	CreateOrOpenMarkedForDeletionTableL();
 	__LOG_EXIT	
 	}
 		
@@ -206,7 +206,6 @@
 	
 	CleanupStack::PopAndDestroy( colSet );
 	
-	// Create index for every column except for mailBoxId
 	CreateIndexL( KSortingTableName, KSortingTableMessageIdIndex,      KSortingTableMessageIdCol    );
 	CreateIndexL( KSortingTableName, KSortingTableFolderIdIndex,       KSortingTableFolderIdCol     );
     CreateIndexL( KSortingTableName, KSortingTableMailBoxIdIndex,      KSortingTableMailBoxIdCol    );
@@ -284,21 +283,9 @@
 void CContainerStoreSortingTable::DeleteMessagesByFolderIdL( TContainerId aFolderId )
 	{
 	__LOG_ENTER_SUPPRESS( "DeleteMessagesByFolderIdL" )
-	__LOG_WRITE8_FORMAT1_DEBUG3( "aFolderId=%x", aFolderId )
-	
-	TBuf<KQuerryBufSize> queryString;
-	queryString.Copy( KDelete );
-	queryString.Append( KFrom );
-	queryString.Append( KSortingTableName );
-	queryString.Append( KWhere );
-	queryString.Append( KSortingTableFolderIdCol );
-	queryString.Append( KEquals );
-	queryString.AppendNum( aFolderId );
-	
-	iUtils.Execute( queryString );
-    
-    //Notify the observer
-    iObserver.FolderDeleted( aFolderId );
+	__LOG_WRITE8_FORMAT1_DEBUG3( "aFolderId=%x", aFolderId )	
+	//Add the folder ID into the MarkedForDeleteTable to be processed in the background.
+	MarkIdForDeletionL(aFolderId);
 	}
 
 // ==========================================================================
@@ -308,20 +295,8 @@
     {
     __LOG_ENTER_SUPPRESS( "DeleteMessagesByMailBoxIdL" )
     __LOG_WRITE8_FORMAT1_DEBUG3( "aMailBoxId=%x", aMailBoxId )
-    
-    TBuf<KQuerryBufSize> queryString;
-    queryString.Copy( KDelete );
-    queryString.Append( KFrom );
-    queryString.Append( KSortingTableName );
-    queryString.Append( KWhere );
-    queryString.Append( KSortingTableMailBoxIdCol );
-    queryString.Append( KEquals );
-    queryString.AppendNum( aMailBoxId );
-    
-    iUtils.Execute( queryString );
-    
-    //Notify the observer
-    iObserver.MailBoxDeleted( aMailBoxId );
+     //Add the mailbox ID into the MarkedForDeleteTable to be processed in the background. 
+    MarkIdForDeletionL( aMailBoxId);   
     }
 
 // ==========================================================================
@@ -1245,3 +1220,142 @@
     iTable.SetColL( iIsEncryptedColNum, static_cast<TUint8>(aIsEncrypted) );
     }
 
+// ==========================================================================
+// FUNCTION: CreateMarkedForDeletionTableL
+// ==========================================================================
+void CContainerStoreSortingTable::CreateMarkedForDeletionTableL()
+    {
+    __LOG_ENTER( "CreateMarkedForDeletionTableL" )
+    
+    // Create table columns
+    CDbColSet* colSet = CDbColSet::NewLC();
+    TDbCol mailboxIdCol( KMarkedForDeleteTableIDCol, EDbColUint32 );
+    colSet->AddL( mailboxIdCol );      
+    // Create table.
+    iUtils.CreateTableL( KMarkedForDeleteTableName, *colSet );   
+    CleanupStack::PopAndDestroy( colSet );             
+    __LOG_EXIT
+    }
+
+// ==========================================================================
+// FUNCTION: CreateOrOpenMarkedForDeletionTableL
+// try to open the Table - create if not found (IAD case) and then open
+// ==========================================================================
+void CContainerStoreSortingTable::CreateOrOpenMarkedForDeletionTableL()
+    {
+    __LOG_ENTER( "OpenMarkedForDeletionTableL" )
+            
+    TRAPD(err, iUtils.OpenTableL( iMarkedForDeleteTable, KMarkedForDeleteTableName ));
+    if(err != KErrNone)
+        {
+        CreateMarkedForDeletionTableL();
+        iUtils.OpenTableL( iMarkedForDeleteTable, KMarkedForDeleteTableName );
+        }
+    CDbColSet* colSet = iMarkedForDeleteTable.ColSetL();
+    CleanupStack::PushL( colSet );
+    //Get the column number
+    iMarkedForDeleteIdColNum = colSet->ColNo( KMarkedForDeleteTableIDCol ); 
+    CleanupStack::PopAndDestroy( colSet );
+    __LOG_EXIT  
+    }
+
+// ==========================================================================
+// FUNCTION: MarkIdForDeletionL
+// Add the ID into the marked for DeletionTable.
+// ==========================================================================
+void CContainerStoreSortingTable::MarkIdForDeletionL( TContainerId aId)
+    {
+    __LOG_ENTER( "MarkIdForDeletionL" )
+    
+    __LOG_WRITE8_FORMAT1_DEBUG3( "Id=%x",aId )
+    iMarkedForDeleteTable.LastL();
+    iMarkedForDeleteTable.InsertL();   
+    iMarkedForDeleteTable.SetColL( iMarkedForDeleteIdColNum, aId );   
+    iMarkedForDeleteTable.PutL();
+    __LOG_EXIT 
+    }
+
+// ==========================================================================
+// FUNCTION: DeleteNextContainerMarkedForDeletionL
+// Use the ID in the MarkedForDeletionTable to delete items from the sorting table .
+// ==========================================================================
+TBool CContainerStoreSortingTable::DeleteNextContainerMarkedForDeletionL()
+    {
+    __LOG_ENTER( " DeleteNextContainerMarkedForDeletionL" )
+    TBool more = EFalse;
+    //set the index to mailboxID to help with seek
+    // Set the table's index to the ID index.
+    if(!iMarkedForDeleteTable.IsEmptyL())
+        {
+        iMarkedForDeleteTable.FirstL();
+        iMarkedForDeleteTable.GetL();
+        TInt deletionID =  iMarkedForDeleteTable.ColUint32(iMarkedForDeleteIdColNum);
+        //check if the ID refers to a folder or is a mailbox and set the index for the table accordingly.
+        if ( ( deletionID & EMsgStoreContainerMask ) == EMsgStoreMailBoxBits)
+            {
+            iTable.SetIndex( KSortingTableMailBoxIdIndex );
+            }
+        else if ( ( deletionID & EMsgStoreContainerMask ) == EMsgStoreFolderBits)
+            {
+            iTable.SetIndex( KSortingTableFolderIdIndex );
+            }
+        //Delete next message from the mailbox/folder
+        TRAPD(err, more = DeleteNextMessageL(deletionID));
+        if (err == KErrNone)
+            {
+            if (!more)
+                {
+                TRAP_IGNORE(more = DeleteFromMarkedForDeletionTableL());
+                }
+            }
+        //reset to the original index 
+        iTable.SetIndex( KSortingTableMessageIdIndex );
+        }
+    __LOG_EXIT
+    return more;
+    }
+
+// ==========================================================================
+// FUNCTION: DeleteNextContainerMarkedForDeletionL
+// Use the ID in the MarkedForDeletionTable to delete items from the sorting table .
+// ==========================================================================
+TBool CContainerStoreSortingTable::DeleteFromMarkedForDeletionTableL()
+    {
+    __LOG_ENTER( " DeleteFromMarkedForDeletionTableL" )
+    TBool more(EFalse);
+    // removed the row once all the messages for that ID have been deleted.
+    iMarkedForDeleteTable.DeleteL();
+    //check if there is another entry
+    if(iMarkedForDeleteTable.NextL())
+        {
+        more = ETrue;
+        }
+    __LOG_EXIT
+    return more;
+    }
+
+// ==========================================================================
+// FUNCTION: DeleteNextMessageL
+// Deletes one row where ID = aId. 
+// @ return Etrue if seek successful
+//          EFalse if seek failed which mean no more messages for the 
+//          given container ID
+// ==========================================================================
+TBool CContainerStoreSortingTable::DeleteNextMessageL( TContainerId aId )
+    {
+    __LOG_ENTER( "DeleteNextMessageL" )
+    __LOG_WRITE8_FORMAT1_DEBUG3( "aId=%x", aId )
+       
+    //Find first matching row
+    TRAPD(err, SeekL( aId ));
+    TBool more(EFalse);
+    if (err ==KErrNone)
+        {
+        iTable.GetL();   
+        iTable.DeleteL();
+        more =  ETrue;
+        }
+    __LOG_EXIT
+    return more;
+    }
+
--- a/emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -369,10 +369,10 @@
 // A new session is being created
 // Cancel the shutdown timer if it was running
 // ==========================================================================
-void CMessageStoreServer::AddSession( CMessageStoreSession* aSession )
+void CMessageStoreServer::AddSessionL( CMessageStoreSession* aSession )
     {
     __LOG_ENTER( "AddSession" )
-    iSessions.Append( aSession );
+    iSessions.AppendL( aSession );
 
     // notify new session of current state
     TMsgStoreEvent event;
--- a/emailservices/emailstore/message_store/server/src/MessageStoreSession.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/MessageStoreSession.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -112,10 +112,16 @@
     {
     __LOG_ENTER( "CreateL" )
     
-    iServer.AddSession( this );
+    iServer.AddSessionL( this );
 
     // This could leave if a session is created while the store is unavailable.
-    TRAP_IGNORE( iServer.MessageStoreL().ObserveL( this ) );
+    TRAPD( err, iServer.MessageStoreL().ObserveL( this ) );
+    
+    if( err != KErrNone )
+    {
+        iServer.DropSession( this );
+        User::Leave( err );
+    }
     
     __LOG_EXIT
     } // end CreateL
@@ -694,12 +700,16 @@
         	event.iOtherId     = KMsgStoreInvalidId;
         	event.iFlags       = KMsgStoreFlagsNotFound;
 
-    		iEventQueue.Append( event );		
+        	// return value can be ignored because queueing is very rare
+        	// case anyway and appending T-class into RArray should succeed
+    		TInt ignore = iEventQueue.Append( event );
 		    }
 		else
 		    {
     		__LOG_WRITE_INFO( "event queued" )
-    		iEventQueue.Append( aEvent );		
+            // return value can be ignored because queueing is very rare
+            // case anyway and appending T-class into RArray should succeed
+            TInt ignore = iEventQueue.Append( aEvent );
 		    } // end if		
 		}
 	else
@@ -1064,7 +1074,7 @@
 void CMessageStoreSession::DoMatchFoundL( TContainerId aMessageId, TContainerId aFolderId, const TDesC8& aPropertyBuf )
     {
     CSearchResult* result = CSearchResult::NewL( aMessageId, aFolderId, aPropertyBuf );
-    iMatchMessages.Append( result );
+    iMatchMessages.AppendL( result );
 
     SendMatchesToClient();
     } // end MatchFound
@@ -2185,7 +2195,7 @@
     TBool inMemorySort = aMessage.Int3();
 
     TContainerId sessionId = iServer.MessageStoreL().StartSortingL( sortCriteria, iPropertyNames, inMemorySort );
-    iSortSessionIds.Append( sessionId );
+    iSortSessionIds.AppendL( sessionId );
     
     TPckg<TContainerId> sessionIdPckg( sessionId );
     aMessage.WriteL( 0, sessionIdPckg );
@@ -2582,7 +2592,7 @@
         
         CMruAddress* mruAddress = CMruAddress::NewL(0, addressDes, dispNameDes );
         
-        iMruAddressArray.Append( mruAddress );
+        iMruAddressArray.AppendL( mruAddress );
         
         } // end while
     
@@ -2724,11 +2734,12 @@
         aMessage.ReadL( aIndex, length16Pckg, position );        
         position += length16Pckg.Length();
         
-        HBufC8* buf8 = HBufC8::NewL( length16 );            
-        aArray.Append( buf8 );
+        HBufC8* buf8 = HBufC8::NewLC( length16 );            
         TPtr8 buf8Ptr( buf8->Des() );
         aMessage.ReadL( aIndex, buf8Ptr, position );
         buf8->Des().SetLength( length16 ); 
+        aArray.AppendL( buf8 );
+        CleanupStack::Pop(buf8);
         position += length16;
         } // end while
     }
@@ -2755,7 +2766,7 @@
         
         if ( readBuf.MaxLength() < length16 )
             {
-            readBuf.ReAlloc( length16 );
+            readBuf.ReAllocL( length16 );
             }
         aMessage.ReadL( aIndex, readBuf, position );
         
@@ -2763,7 +2774,9 @@
         const TUint16* valuePtr = reinterpret_cast<const TUint16*>( readBuf.Ptr() );
         TPtrC valueDes( valuePtr, length16 / 2 );  
         
-        aArray.Append( valueDes.AllocL() );
+        HBufC *p = valueDes.AllocLC();
+        aArray.AppendL( p );
+        CleanupStack::Pop( p );
         
         position += length16;
         } // end while
@@ -2784,7 +2797,7 @@
     for( position = 0; position < aMessage.GetDesLengthL( aIndex ); position += idPckg.Length() )
         {
         aMessage.ReadL( aIndex, idPckg, position );      
-        aArray.Append( id );
+        aArray.AppendL( id );
         } // end for
     }
 
--- a/emailservices/emailstore/message_store/server/src/MsgStoreSortResultRowSet.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/MsgStoreSortResultRowSet.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -396,7 +396,7 @@
             {
             ++count;
             curTotal += itemsInPreviousGroup;
-            aItemsInGroup.Append( itemsInPreviousGroup );
+            aItemsInGroup.AppendL( itemsInPreviousGroup );
             }
         } while ( hasMore );        
     
@@ -406,7 +406,7 @@
     if ( lastGroupCount > 0 )
         {
         ++count;
-        aItemsInGroup.Append( lastGroupCount );
+        aItemsInGroup.AppendL( lastGroupCount );
         }
     
     return count;
@@ -424,7 +424,7 @@
 	for ( TInt i = 0 ; i < count ; i++  )
 		{
 		iDbView.NextL();
-		aIdArray.Append( GetRowL() );
+		aIdArray.AppendL( GetRowL() );
 		}
 	}
 
@@ -462,7 +462,7 @@
     iPropertyNames.ResetAndDestroy();
     for ( int i = 0 ; i < aPropertyNames.Count() ; i++ )
         {
-        iPropertyNames.Append( aPropertyNames[i]->Des().AllocL() );
+        iPropertyNames.AppendL( aPropertyNames[i]->Des().AllocL() );
         }
     }
 
--- a/emailservices/emailstore/message_store/server/src/MsgStoreStringSortResultRowSet.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/MsgStoreStringSortResultRowSet.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -581,13 +581,13 @@
 	        if ( nextGroupId != curGroupId )
 	        	{
 	        	//found a new group
-	            aItemsInGroup.Append( i - curPos );
+	            aItemsInGroup.AppendL( i - curPos );
 	            curPos = i;
 	            curGroupId = nextGroupId; 
 	        	}	        
 	        }
 	    //last group
-        aItemsInGroup.Append( i - curPos );
+        aItemsInGroup.AppendL( i - curPos );
     	}    
     
     return aItemsInGroup.Count();
@@ -611,7 +611,7 @@
         TRAP( err, msgId = NextL() );
 		if ( err == KErrNone )
 			{
-			aIdArray.Append( msgId );
+			aIdArray.AppendL( msgId );
 			}
 		else if ( err == KErrOverflow )
 			{
@@ -1126,8 +1126,8 @@
     
     //now we can reset to initial state
     InitState();
-    iSortedResultArray.Append( iCenterRow );
-    iSortedIdArray.Append( iCenterRow );
+    iSortedResultArray.AppendL( iCenterRow );
+    iSortedIdArray.AppendL( iCenterRow );
     
     iState = EStateSliding;
     
--- a/emailservices/nmailagent/inc/nmmailagent.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/nmailagent/inc/nmmailagent.h	Fri Jul 09 12:17:13 2010 +0300
@@ -87,15 +87,17 @@
 
     void indicatorActivated(const QString &type, const QVariantMap &data);
 
-    void valueChanged(const XQSettingsKey& key, const QVariant& value);
+    void valueChanged(const XQSettingsKey &key, const QVariant &value);
 
+    void delayedMailboxCreated(const NmId mailboxId);
+    
 private:
 
     void initMailboxStatus();
 
     bool updateUnreadCount(const NmId &mailboxId, NmMailboxInfo &mailboxInfo);
 
-    int getOutboxCount(const NmId &mailboxId);
+    int getOutboxCount(const NmId &mailboxId, const NmId &outboxId);
 
     NmMailboxInfo *getMailboxByType(const QString &type);
 
@@ -139,17 +141,26 @@
 
     bool launchMailbox(quint64 mailboxId);
 
+    void handleMessageCreatedEvent(const NmId &folderId, const QList<NmId> &messageIds,
+        const NmId &mailboxId, bool &updateNeeded, bool &activate);
+
+    void handleMessageChangedEvent(const NmId &folderId, const NmId &mailboxId,
+        bool &updateNeeded, bool &activate);
+
+    void handleMessageDeletedEvent(const NmId &folderId, const QList<NmId> &messageIds,
+        const NmId &mailboxId, bool &updateNeeded, bool &activate);
+
 private: // data
 
-    HbIndicator *mIndicator;
-    XQSystemToneService *mSystemTone;
-    NmDataPluginFactory *mPluginFactory;
+    HbIndicator *mIndicator; // Owned;
+    XQSystemToneService *mSystemTone; // Owned.
+    NmDataPluginFactory *mPluginFactory; // Not owned (singleton).
     QList<NmMailboxInfo*> mMailboxes;
-    CHWRMVibra *mVibra; // Owned
+    CHWRMVibra *mVibra; // Owned.
     bool mAlertToneAllowed;
     int mLastOutboxCount;
     bool mUnreadIndicatorActive;
-    XQSettingsManager *mSettingManager;
+    XQSettingsManager *mSettingManager; // Owned.
     int mSilenceMode;
 };
 
--- a/emailservices/nmailagent/src/nmmailagent.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailservices/nmailagent/src/nmmailagent.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -1,19 +1,22 @@
 /*
-* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Mail agent is responsible of monitoring mail accounts. It activates
+ *              and deactivates indicator depending on received events. Mail agent is
+ *              also responsible of monitoring silence mode, playing alert tone and vibrating
+ *              phone when new mail is received.
+ *
+ */
 
 #include "emailtrace.h"
 #include "nmmailagentheaders.h"
@@ -29,7 +32,7 @@
 #include <xqsettingskey.h>
 #include <ProfileEngineInternalCRKeys.h>
 
-// CONSTS
+// CONSTANTS
 const int NmAgentIndicatorNotSet = -1;
 const int NmAgentAlertToneTimer = 60000; // 60s
 const int NmAgentDefaultVibraDuration = 1000; // 1 second
@@ -44,72 +47,78 @@
     Helper method for finding out if XQSettingsKey and XQCentralRepositorySettingsKey points to
     same key.
 
-    @param settingKey XQSettingsKey
-    @param cenrepSettingKey XQCentralRepositorySettingsKey
-    @return <code>true</code> if target, uid and key matches otherwise returns <code>false</code>
-*/
+    \param settingKey XQSettingsKey
+    \param cenrepSettingKey XQCentralRepositorySettingsKey
+    \return <code>true</code> if target, uid and key matches otherwise returns <code>false</code>
+ */
 bool keysEqual(const XQSettingsKey& settingKey, const XQCentralRepositorySettingsKey& cenrepSettingKey)
 {
     return ((settingKey.target() == cenrepSettingKey.target()) &&
-            (settingKey.uid() == cenrepSettingKey.uid()) &&
-            (settingKey.key() == cenrepSettingKey.key()));
+        (settingKey.uid() == cenrepSettingKey.uid()) &&
+        (settingKey.key() == cenrepSettingKey.key()));
 }
 
 
+
+/*!
+    \class NmMailboxInfo
+
+    \brief Main class for storing mailbox data.
+ */
+NmMailboxInfo::NmMailboxInfo()
+: mId(0),
+  mIndicatorIndex(NmAgentIndicatorNotSet),
+  mInboxFolderId(0),
+  mOutboxFolderId(0),
+  mSyncState(SyncComplete),
+  mConnectState(Disconnected),
+  mInboxCreatedMessages(0),
+  mInboxChangedMessages(0),
+  mInboxDeletedMessages(0),
+  mOutboxMails(0),
+  mActive(false),
+  mInboxActive(false)
+  {
+    NM_FUNCTION;
+  }
+
 /*!
     \class NmMailAgent
 
-    \brief Main class for receiving email events and passing them to the HbIndicator
-*/
-
-NmMailboxInfo::NmMailboxInfo()
-{
+    \brief Main class for receiving email events. Activates and deactivates indicator.
+ */
+NmMailAgent::NmMailAgent() :
+     mIndicator(NULL),
+     mSystemTone(NULL),
+     mPluginFactory(NULL),
+     mVibra(NULL),
+     mAlertToneAllowed(true),
+     mLastOutboxCount(0),
+     mUnreadIndicatorActive(false),
+     mSettingManager(NULL),
+     mSilenceMode(NmSilenceModeOn)  // by default silent mode is on
+     {
     NM_FUNCTION;
-
-    mId = 0;
-    mIndicatorIndex = NmAgentIndicatorNotSet;
-    mSyncState = SyncComplete;
-    mConnectState = Disconnected;
-    mOutboxMails = 0;
-    mInboxFolderId = 0;
-    mOutboxFolderId = 0;
-    mInboxCreatedMessages = 0;
-    mInboxChangedMessages = 0;
-    mInboxDeletedMessages = 0;
-    mActive = false;
-    mInboxActive = false;
-}
-
-NmMailAgent::NmMailAgent() :
- mIndicator(NULL),
- mSystemTone(NULL),
- mPluginFactory(NULL),
- mVibra(NULL),
- mAlertToneAllowed(true),
- mLastOutboxCount(0),
- mUnreadIndicatorActive(false),
- mSettingManager(NULL),
- mSilenceMode(NmSilenceModeOn)  // by default silent mode is on
-{
-    NM_FUNCTION;
-}
+     }
 
 /*!
-    Delayed start
-*/
+    Delayed start.
+ */
 void NmMailAgent::delayedStart()
 {
     NM_FUNCTION;
 
-	if (!init()) {
-		// Initialisation failed. Quit the agent.
-		QCoreApplication::exit(1);
-	}
+    if (!init()) {
+        // Initialisation failed. Quit the agent.
+        QCoreApplication::exit(1);
+    }
 }
 
 /*!
-    Initialise the agent. \return true if succesfully started.
-*/
+    Initialise the agent.
+
+    \return true if succesfully started.
+ */
 bool NmMailAgent::init()
 {
     NM_FUNCTION;
@@ -131,9 +140,9 @@
     // Start monitoring silence mode key.
     bool monitoring(mSettingManager->startMonitoring(NmSilenceModeKey, XQSettingsManager::TypeInt));
     monitoring &= connect(mSettingManager,
-                          SIGNAL(valueChanged(const XQSettingsKey&, const QVariant&)),
+                          SIGNAL(valueChanged(const XQSettingsKey &, const QVariant &)),
                           this,
-                          SLOT(valueChanged(const XQSettingsKey&, const QVariant&)),
+                          SLOT(valueChanged(const XQSettingsKey &, const QVariant &)),
                           Qt::UniqueConnection);
 
     // If silence mode monitoring can't be started, then change silence mode on to be sure
@@ -149,32 +158,32 @@
     delete mIndicator;
     mIndicator = NULL;
     mIndicator = new HbIndicator();
-    connect(mIndicator,SIGNAL(userActivated(const QString &, const QVariantMap&)),
-        this, SLOT(indicatorActivated(const QString&, const QVariantMap&)));
+    connect(mIndicator,SIGNAL(userActivated(const QString &, const QVariantMap &)),
+        this, SLOT(indicatorActivated(const QString &, const QVariantMap &)));
 
     QList<QObject*> *plugins = mPluginFactory->pluginInstances();
 
     foreach (QObject *plugin, *plugins) {
-    	if (plugin) {
-			// Start listening events
-			connect(plugin, SIGNAL(mailboxEvent(NmMailboxEvent, const QList<NmId>&)),
-				this, SLOT(handleMailboxEvent(NmMailboxEvent, const QList<NmId> &)),
-				Qt::UniqueConnection);
+        if (plugin) {
+            // Start listening events
+            connect(plugin, SIGNAL(mailboxEvent(NmMailboxEvent, const QList<NmId> &)),
+                    this, SLOT(handleMailboxEvent(NmMailboxEvent, const QList<NmId> &)),
+                    Qt::UniqueConnection);
 
-			connect(plugin, SIGNAL(messageEvent(
-					NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)),
-				this, SLOT(handleMessageEvent(
-					NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)),
-				Qt::UniqueConnection);
+            connect(plugin, SIGNAL(messageEvent(
+                        NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)),
+                    this, SLOT(handleMessageEvent(
+                        NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)),
+                    Qt::UniqueConnection);
 
-			connect(plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent&)),
-				this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent&)),
-				Qt::UniqueConnection);
+            connect(plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent &)),
+                    this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent &)),
+                Qt::UniqueConnection);
 
-			connect(plugin, SIGNAL(connectionEvent(NmConnectState, const NmId, int)),
-				this, SLOT(handleConnectionEvent(NmConnectState, const NmId, int)),
-				Qt::UniqueConnection);
-    	}
+            connect(plugin, SIGNAL(connectionEvent(NmConnectState, const NmId, int)),
+                    this, SLOT(handleConnectionEvent(NmConnectState, const NmId, int)),
+                    Qt::UniqueConnection);
+        }
     }
 
     // Construct the vibra interface instance.
@@ -188,10 +197,14 @@
     return true;
 }
 
+/*!
+    Destructor of NmMailAgent.
+ */
 NmMailAgent::~NmMailAgent()
 {
     NM_FUNCTION;
 
+    delete mIndicator;
     delete mVibra;
     delete mSystemTone;
     if (mSettingManager) {
@@ -204,8 +217,8 @@
 }
 
 /*!
-    Initialize the mailbox list with the current state
-*/
+    Initialize the mailbox list with the current state.
+ */
 void NmMailAgent::initMailboxStatus()
 {
     NM_FUNCTION;
@@ -228,12 +241,12 @@
         while (i.hasPrevious()) {
             const NmMailbox *mailbox = i.previous();
             if (mailbox) {
-                NmMailboxInfo *mailboxInfo = createMailboxInfo(*mailbox,plugin);
+                NmMailboxInfo *mailboxInfo = createMailboxInfo(*mailbox, plugin);
                 if (mailboxInfo) {
                     bool activate = updateUnreadCount(mailbox->id(), *mailboxInfo);
                     bool wasActive = isMailboxActive(mailbox->id());
                     if (activate) {
-                        if(!wasActive) {
+                        if (!wasActive) {
                             // do not activate the mailbox if it was left as hidden last time
                             activate = false;
                         }
@@ -243,13 +256,14 @@
                         }
                     }
 
-                    mailboxInfo->mOutboxMails = getOutboxCount(mailbox->id());
+                    mailboxInfo->mOutboxMails = getOutboxCount(mailbox->id(),
+                        mailboxInfo->mOutboxFolderId);
                     if (mailboxInfo->mOutboxMails > 0 && wasActive) {
                         activate = true;
                     }
 
-	                // Create indicator for visible mailboxes
-    	            updateMailboxState(mailbox->id(), activate, false);
+                    // Create indicator for visible mailboxes
+                    updateMailboxState(mailbox->id(), activate, false);
                 }
             }
         }
@@ -260,51 +274,55 @@
 }
 
 /*!
-    Get mailbox unread count in inbox folder
+    Get mailbox unread count in inbox folder.
+
     \param mailboxId id of the mailbox
     \param mailboxInfo contains the list of unread messages
     \return true if new unread mails was found
-*/
+ */
 bool NmMailAgent::updateUnreadCount(const NmId &mailboxId, NmMailboxInfo &mailboxInfo)
 {
     NM_FUNCTION;
 
     int newUnreadMessages(0);
-
     NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
 
     if (plugin) {
-		// get inbox folder ID
-		NmId inboxId = plugin->getStandardFolderId(
-				mailboxId, NmFolderInbox );
+        NmId inboxId = mailboxInfo.mInboxFolderId.id();
 
-		// get list of messages in inbox
-		QList<NmMessageEnvelope*> messageList;
-		plugin->listMessages(mailboxId, inboxId, messageList);
+        // Inbox folder ID may be still unknown
+        if (inboxId == 0) {
+            mailboxInfo.mInboxFolderId = plugin->getStandardFolderId(mailboxId, NmFolderInbox);
+            inboxId = mailboxInfo.mInboxFolderId.id();
+        }
+
+        // get list of messages in inbox
+        QList<NmMessageEnvelope*> messageList;
+        plugin->listMessages(mailboxId, inboxId, messageList);
 
-		QList<NmId> newUnreadMessageIdList;
-		foreach (const NmMessageEnvelope* envelope, messageList) {
-		    // if the message is not read, it is "unread"
-			if (!envelope->isRead()) {
-		        quint64 messageId = envelope->messageId().id();
-			    newUnreadMessageIdList.append(envelope->messageId());
-			    bool found(false);
-			    // Iterate through all known ids. If the id can't be found the mail is new.
-			    foreach (const NmId id, mailboxInfo.mUnreadMailIdList) {
-			        if (id.id() == messageId) {
-			            found = true;
-			            break;
-			        }
-			    }
+        QList<NmId> newUnreadMessageIdList;
+        foreach (const NmMessageEnvelope* envelope, messageList) {
+            // if the message is not read, it is "unread"
+            if (!envelope->isRead()) {
+                quint64 messageId = envelope->messageId().id();
+                newUnreadMessageIdList.append(envelope->messageId());
+                bool found(false);
+                // Iterate through all known ids. If the id can't be found the mail is new.
+                foreach (const NmId id, mailboxInfo.mUnreadMailIdList) {
+                    if (id.id() == messageId) {
+                        found = true;
+                        break;
+                    }
+                }
 
-			    if (!found) {
-			        newUnreadMessages++;
-			    }
-			}
-		}
-		qDeleteAll(messageList);
+                if (!found) {
+                    newUnreadMessages++;
+                }
+            }
+        }
+        qDeleteAll(messageList);
 
-		// Save updated list of unread message IDs
+        // Save updated list of unread message IDs
         mailboxInfo.mUnreadMailIdList = newUnreadMessageIdList;
     }
     NM_COMMENT(QString("NmMailAgent::getUnreadCount(): count=%1, new=%2").
@@ -314,28 +332,25 @@
 }
 
 /*!
-    Get mailbox count in outbox folder
+    Get mailbox count in outbox folder.
+
     \param mailboxId id of the mailbox
-    \param maxCount max number of outbox mails that is needed
+    \param outboxId Outbox folder Id
     \return number of mails in the outbox
-*/
-int NmMailAgent::getOutboxCount(const NmId &mailboxId)
+ */
+int NmMailAgent::getOutboxCount(const NmId &mailboxId, const NmId &outboxId)
 {
     NM_FUNCTION;
 
     int count(0);
-
     NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
 
     if (plugin) {
-		// get outbox folder ID
-		NmId outboxId = plugin->getStandardFolderId( mailboxId, NmFolderOutbox );
-
-		// get list of messages in outbox
-		QList<NmMessageEnvelope*> messageList;
-		plugin->listMessages(mailboxId, outboxId, messageList);
-		count = messageList.count();
-		qDeleteAll(messageList);
+        // get list of messages in outbox
+        QList<NmMessageEnvelope*> messageList;
+        plugin->listMessages(mailboxId, outboxId, messageList);
+        count = messageList.count();
+        qDeleteAll(messageList);
     }
     NM_COMMENT(QString("NmMailAgent::getOutboxCount(): count=%1").arg(count));
 
@@ -343,9 +358,10 @@
 }
 
 /*!
-    Get list of unread counts in active mailboxes
+    Get list of unread counts in active mailboxes.
+
 	\returns total number of unread mails
-*/
+ */
 int NmMailAgent::getTotalUnreadCount() const
 {
     NM_FUNCTION;
@@ -360,9 +376,10 @@
 }
 
 /*!
-    Update the "@" indicator state according to unread state
+    Update the "@" indicator state according to unread state.
+
     \return true if the indicator was activated
-*/
+ */
 bool NmMailAgent::updateUnreadIndicator()
 {
     NM_FUNCTION;
@@ -372,12 +389,13 @@
 }
 
 /*!
-    Update the mailbox visibility and status
+    Update the mailbox visibility and status.
+
     \param mailboxId id of the mailbox
     \param active visibility state of the mailbox
     \param refreshAlways true when the indicator should be always updated
     \return true if the mailbox state was changed
-*/
+ */
 bool NmMailAgent::updateMailboxState(const NmId &mailboxId,
     bool active, bool refreshAlways)
 {
@@ -388,7 +406,7 @@
     if (mailboxInfo->mActive != active ||
         refreshAlways) {
 
-		// store the new state to permanent storage
+        // store the new state to permanent storage
         storeMailboxActive(mailboxId, active);
 
         mailboxInfo->mActive = active;
@@ -413,12 +431,13 @@
 }
 
 /*!
-    Updates indicator status
+    Updates indicator status.
+
     \param mailboxIndex index of the item shown in indicator menu
     \param active indicator visibility state
     \param mailboxInfo information of the mailbox
     \return true if indicator was updated with no errors
-*/
+ */
 bool NmMailAgent::updateIndicator(bool active,
     const NmMailboxInfo& mailboxInfo)
 {
@@ -453,9 +472,11 @@
 }
 
 /*!
-    update the unread indicator state
+    Update the unread indicator state.
+
+    \param active if true unread indicator is activated otherwise deactivated
     \return true if the indicator was activated
-*/
+ */
 bool NmMailAgent::updateUnreadIndicator(bool active)
 {
     NM_FUNCTION;
@@ -476,9 +497,11 @@
 }
 
 /*!
-    Opens inbox view to specific mailbox
+    Opens inbox view to specific mailbox.
+
+    \param mailboxId Id of mailbox
     \return true if inbox is succesfully opened
-*/
+ */
 bool NmMailAgent::launchMailbox(quint64 mailboxId)
 {
     NM_FUNCTION;
@@ -492,7 +515,6 @@
         QList<QVariant> list;
         list.append(QVariant(mailboxId));
         request->setArguments(list);
-
         ok = request->send();
         NM_COMMENT(QString("Launch ok=%1 error=%2").arg(ok).arg(request->lastError()));
         delete request;
@@ -501,8 +523,163 @@
 }
 
 /*!
-    Get next free indicator index, starting from 0
-    @return index of the indicator that is available
+    Handles message created event.
+
+    \param folderId Id of the folder that includes the message
+    \param messageIds Message ids that are checked
+    \param mailboxId Id of the mailbox that includes the message
+    \param updateNeeded Set to <code>true</code> if update needed otherwise not touched
+    \param activate Set to <code>true</code> if activation needed otherwise not touched
+ */
+void NmMailAgent::handleMessageCreatedEvent(const NmId &folderId, const QList<NmId> &messageIds,
+    const NmId &mailboxId, bool &updateNeeded, bool &activate)
+{
+    NM_FUNCTION;
+
+    // Check the new messages to make the indicator appear earlier
+    NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
+
+    // Inbox folder ID may be still unknown
+    if (mailboxInfo->mInboxFolderId.id() == 0) {
+        NmDataPluginInterface *plugin =
+            mPluginFactory->interfaceInstance(mailboxId);
+
+        if (plugin) {
+            mailboxInfo->mInboxFolderId =
+                plugin->getStandardFolderId(mailboxId, NmFolderInbox);
+        }
+    }
+
+    if (folderId == mailboxInfo->mInboxFolderId) {
+        foreach (NmId messageId, messageIds) {
+            bool messageUnread = false;
+
+            // Check the message if we can either play a tone or if the "@" is
+            // not visible at the moment
+            if (mAlertToneAllowed || !mUnreadIndicatorActive) {
+                if (getMessageUnreadInfo(folderId, messageId, mailboxId, messageUnread)) {
+                    if (messageUnread) {
+                        mailboxInfo->mUnreadMailIdList.append(messageId);
+                        mailboxInfo->mInboxActive = true;
+                        updateMailboxState(mailboxId, true, false);
+
+                        // make the "@" appear immediatelly
+                        updateUnreadIndicator(true);
+
+                        // Play the tone as well
+                        playAlertTone();
+                    }
+                }
+            }
+        }
+    }
+
+    if (folderId==mailboxInfo->mInboxFolderId) {
+        mailboxInfo->mInboxCreatedMessages += messageIds.count();
+    }
+
+    // When created a new mail in the outbox, we are in sending state
+    if (mailboxInfo->mOutboxFolderId == folderId) {
+        // The first mail created in the outbox
+        if (mailboxInfo->mOutboxMails <= 0) {
+            NM_COMMENT("NmMailAgent: first mail in outbox");
+        }
+        // Always activate the indicator
+        activate = true;
+        updateNeeded = true;
+
+        mailboxInfo->mOutboxMails += messageIds.count();
+        updateSendIndicator();
+    }
+}
+
+
+/*!
+    Handles message changed event.
+    \sa updateUnreadCount
+
+    \param folderId Id of the folder that includes the message
+    \param mailboxId Id of the mailbox that includes the message
+    \param updateNeeded Set to <code>true</code> if update needed otherwise not touched
+    \param activate Set result value of updateUnreadCount method
+ */
+void NmMailAgent::handleMessageChangedEvent(const NmId &folderId, const NmId &mailboxId,
+    bool &updateNeeded, bool &activate)
+{
+    NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
+
+    if (folderId == mailboxInfo->mInboxFolderId) {
+        mailboxInfo->mInboxChangedMessages++;
+    }
+
+    // If not currently syncronizing the mailbox, this may mean
+    // that a message was read/unread
+    if (mailboxInfo && mailboxInfo->mSyncState == SyncComplete) {
+
+        // check the unread status again
+        int oldCount(mailboxInfo->mUnreadMailIdList.count());
+        activate = updateUnreadCount(mailboxId, *mailboxInfo);
+
+        // new unread mails found or no more unread mails in the inbox
+        if (oldCount>0 && mailboxInfo->mUnreadMailIdList.count()==0) {
+            updateNeeded = true;
+        }
+    }
+}
+
+/*!
+    Handles message deleted event.
+
+    \param folderId Id of the folder that includes the message
+    \param messageIds Message ids that are checked
+    \param mailboxId Id of the mailbox that includes the message
+    \param updateNeeded Set to <code>true</code> if update needed otherwise not touched
+    \param activate Set to <code>true</code> if activation needed otherwise not touched
+ */
+void NmMailAgent::handleMessageDeletedEvent(const NmId &folderId, const QList<NmId> &messageIds,
+    const NmId &mailboxId, bool &updateNeeded, bool &activate)
+{
+    NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
+
+    if (folderId == mailboxInfo->mInboxFolderId) {
+        mailboxInfo->mInboxDeletedMessages++;
+    }
+
+    // Deleted mails from the outbox
+    if (mailboxInfo->mOutboxFolderId == folderId) {
+        mailboxInfo->mOutboxMails -= messageIds.count();
+
+        // Sanity check for the outbox count
+        if (mailboxInfo->mOutboxMails < 0) {
+            mailboxInfo->mOutboxMails = 0;
+        }
+
+        // The last mail was now deleted
+        if (mailboxInfo->mOutboxMails == 0) {
+            NM_COMMENT("NmMailAgent: last mail deleted from outbox");
+            updateNeeded = true;
+
+            // Keep it active if there is unread mails and inbox is still active
+            if (mailboxInfo->mInboxActive &&
+                mailboxInfo->mUnreadMailIdList.count() > 0) {
+                activate = true;
+            }
+        }
+        else {
+            // Also update the indicator status if it is already shown
+            if (mailboxInfo->mActive) {
+                activate = true;
+                updateNeeded = true;
+            }
+        }
+        updateSendIndicator();
+    }
+}
+
+/*!
+    Get next free indicator index, starting from 0.
+
+    \return index of the indicator that is available
  */
 int NmMailAgent::getFreeIndicatorIndex()
 {
@@ -527,7 +704,10 @@
 /*!
     Received from NmFrameworkAdapter mailboxEvent signal
     \sa NmFrameworkAdapter
-*/
+
+    \param event Mailbox event type
+    \param mailboxIds Mailbox ids that are checked
+ */
 void NmMailAgent::handleMailboxEvent(NmMailboxEvent event, const QList<NmId> &mailboxIds)
 {
     NM_FUNCTION;
@@ -536,7 +716,15 @@
     switch(event) {
         case NmMailboxCreated:
             foreach (NmId mailboxId, mailboxIds) {
-                getMailboxInfo(mailboxId); // create a new mailbox if needed
+                NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); // create a new mailbox if needed
+                if (!mailboxInfo) {
+                    // Unable to initialise the mailbox. Try again later.
+                    NM_COMMENT("Cannot initialise mailbox");
+                    
+                    qRegisterMetaType<NmId>("NmId");
+                    QMetaObject::invokeMethod(this, "delayedMailboxCreated",
+                        Qt::QueuedConnection, Q_ARG(NmId,mailboxId));
+                }
 
                 // make sure the mailbox activity data is reseted
                 deleteStoredMailboxActivity(mailboxId);
@@ -550,7 +738,7 @@
                 NmMailbox *mailbox(NULL);
                 NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
                 if (plugin) {
-					plugin->getMailboxById(mailboxId,mailbox);
+                    plugin->getMailboxById(mailboxId,mailbox);
                 }
                 if (mailbox && mailboxInfo) {
                     if(mailbox->name() != mailboxInfo->mName) {
@@ -581,32 +769,53 @@
 }
 
 /*!
-   Map the type name to mailbox info
-    \return NULL if no mailbox match the type
+    Called when mailbox is initialised with a delay. This may happen at least when 
+    NmMailboxCreated event is received.
+    
+    \param mailboxId id of the mailbox
 */
+void NmMailAgent::delayedMailboxCreated(const NmId mailboxId)
+{
+    NM_FUNCTION;
+
+    // create and subscribe to the mailbox, if not done earlier
+    getMailboxInfo(mailboxId);
+}
+
+/*!
+   Map the type name to mailbox info.
+
+   \param type Indicator type name
+   \return NULL if no mailbox match the type
+ */
 NmMailboxInfo *NmMailAgent::getMailboxByType(const QString &type)
 {
     NM_FUNCTION;
 
+    NmMailboxInfo *foundMailbox = NULL;
     foreach (NmMailboxInfo *mailbox, mMailboxes) {
         // mailbox is shown in indicators
         if (mailbox->mIndicatorIndex >= 0 && mailbox->mActive) {
             QString typeName = QString(NmMailboxIndicatorType).arg(mailbox->mIndicatorIndex);
 
             // type names match(!)
-            if(type==typeName) {
-                return mailbox;
+            if (type == typeName) {
+                foundMailbox = mailbox;
+                break;
             }
         }
     }
-    return NULL;
+    return foundMailbox;
 }
 
 /*!
     Called when indicator is clicked from the indicator menu
     - indicator will be hide from the menu
     - mailbox will be launched
-*/
+
+    \param type Indicator type name
+    \param data Data sent by indicator
+ */
 void NmMailAgent::indicatorActivated(const QString &type, const QVariantMap &data)
 {
     NM_FUNCTION;
@@ -628,10 +837,10 @@
     Called when cenrep key value has been changed.
     - only silence mode key handled
 
-    @param key changed key
-    @param value value for a key.
-*/
-void NmMailAgent::valueChanged(const XQSettingsKey& key, const QVariant& value)
+    \param key changed key
+    \param value value for a key
+ */
+void NmMailAgent::valueChanged(const XQSettingsKey &key, const QVariant &value)
 {
     NM_FUNCTION;
 
@@ -643,15 +852,19 @@
 /*!
     Received from NmFrameworkAdapter messageEvent signal
     \sa NmFrameworkAdapter
-*/
+
+    \param event Message event
+    \param folderId Folder Id
+    \param messageIds List of message Ids
+    \param mailboxId Id of the mailbox
+ */
 void NmMailAgent::handleMessageEvent(
-            NmMessageEvent event,
-            const NmId &folderId,
-            const QList<NmId> &messageIds,
-            const NmId& mailboxId)
+    NmMessageEvent event,
+    const NmId &folderId,
+    const QList<NmId> &messageIds,
+    const NmId &mailboxId)
 {
     NM_FUNCTION;
-
     NM_COMMENT(QString("NmMailAgent::handleMessageEvent(): event=%1, id=%2").
         arg(event).arg(mailboxId.id()));
 
@@ -660,120 +873,15 @@
 
     switch (event) {
         case NmMessageCreated: {
-            // Check the new messages to make the indicator appear earlier
-            NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
-            
-            // Inbox folder ID may be still unknown
-            if (mailboxInfo->mInboxFolderId.id() == 0) {
-                NmDataPluginInterface *plugin =
-                    mPluginFactory->interfaceInstance(mailboxId);
-
-                if (plugin) {
-                    mailboxInfo->mInboxFolderId =
-                        plugin->getStandardFolderId(mailboxId, NmFolderInbox);
-                }
-            }
-
-            if (folderId == mailboxInfo->mInboxFolderId) {
-                foreach (NmId messageId, messageIds) {
-                    bool messageUnread = false;
-
-                    // Check the message if we can either play a tone or if the "@" is
-                    // not visible at the moment
-                    if (mAlertToneAllowed || !mUnreadIndicatorActive) {
-                        if (getMessageUnreadInfo(folderId, messageId, mailboxId, messageUnread)) {
-                            if (messageUnread) {
-                                mailboxInfo->mUnreadMailIdList.append(messageId);
-                                mailboxInfo->mInboxActive = true;
-                                updateMailboxState(mailboxId, true, false);
-
-                                // make the "@" appear immediatelly
-                                updateUnreadIndicator(true);
-
-                                // Play the tone as well
-                                playAlertTone();
-                            }
-                        }
-                    }
-                }
-            }
-
-            if (folderId==mailboxInfo->mInboxFolderId) {
-                mailboxInfo->mInboxCreatedMessages += messageIds.count();
-            }
-
-            // When created a new mail in the outbox, we are in sending state
-            if (mailboxInfo->mOutboxFolderId == folderId) {
-                // The first mail created in the outbox
-                if (mailboxInfo->mOutboxMails <= 0) {
-					NM_COMMENT("NmMailAgent: first mail in outbox");
-                }
-                // Always activate the indicator
-                activate = true;
-                updateNeeded = true;
-
-                mailboxInfo->mOutboxMails += messageIds.count();
-				updateSendIndicator();
-            }
+            handleMessageCreatedEvent(folderId, messageIds, mailboxId, updateNeeded, activate);
             break;
         }
         case NmMessageChanged: {
-            NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
-
-            if (folderId==mailboxInfo->mInboxFolderId) {
-                mailboxInfo->mInboxChangedMessages++;
-            }
-
-            // If not currently syncronizing the mailbox, this may mean
-            // that a message was read/unread
-            if (mailboxInfo && mailboxInfo->mSyncState==SyncComplete) {
-                // check the unread status again
-                int oldCount = mailboxInfo->mUnreadMailIdList.count();
-                activate = updateUnreadCount(mailboxId, *mailboxInfo);
-
-                // new unread mails found or no more unread mails in the inbox
-                if (oldCount>0 && mailboxInfo->mUnreadMailIdList.count()==0) {
-                    updateNeeded = true;
-                }
-            }
-			break;
-		}
+            handleMessageChangedEvent(folderId, mailboxId, updateNeeded, activate);
+            break;
+        }
         case NmMessageDeleted: {
-            NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
-
-            if (folderId==mailboxInfo->mInboxFolderId) {
-                mailboxInfo->mInboxDeletedMessages++;
-            }
-
-            // Deleted mails from the outbox
-            if (mailboxInfo->mOutboxFolderId == folderId) {
-                mailboxInfo->mOutboxMails -= messageIds.count();
-
-                // Sanity check for the outbox count
-                if (mailboxInfo->mOutboxMails < 0) {
-                    mailboxInfo->mOutboxMails = 0;
-                }
-
-                // The last mail was now deleted
-                if (mailboxInfo->mOutboxMails == 0) {
-					NM_COMMENT("NmMailAgent: last mail deleted from outbox");
-					updateNeeded = true;
-
-	                // Keep it active if there is unread mails and inbox is still active
- 				    if (mailboxInfo->mInboxActive &&
-					    mailboxInfo->mUnreadMailIdList.count() > 0) {
-					    activate = true;
-	                }
-				}
-				else {
-	                // Also update the indicator status if it is already shown
-    	            if (mailboxInfo->mActive) {
-						activate = true;
-            	        updateNeeded = true;
-					}
-				}
-				updateSendIndicator();
-            }
+            handleMessageDeletedEvent(folderId, messageIds, mailboxId, updateNeeded, activate);
             break;
         }
         default:
@@ -790,12 +898,14 @@
 }
 
 /*!
-    Received from NmFrameworkAdapter syncStateEvent signal
+    Received from NmFrameworkAdapter syncStateEvent signal.
     \sa NmFrameworkAdapter
-*/
-void NmMailAgent::handleSyncStateEvent(
-            NmSyncState state,
-            const NmOperationCompletionEvent &event)
+
+    \param state state of synchronization
+    \param event Information related to asynchronous operation
+
+ */
+void NmMailAgent::handleSyncStateEvent(NmSyncState state, const NmOperationCompletionEvent &event)
 {
     NM_FUNCTION;
     NM_COMMENT(QString("NmMailAgent::handleSyncStateEvent(): state=%1, id=%2").
@@ -813,15 +923,15 @@
         }
         else if (state==SyncComplete) {
             // Check the unread status here again
-            bool activate = updateUnreadCount(event.mMailboxId, *info);
+            bool updateMailbox = updateUnreadCount(event.mMailboxId, *info);
             int oldOutboxCount = info->mOutboxMails;
-            info->mOutboxMails = getOutboxCount(event.mMailboxId);
-            if (info->mOutboxMails > oldOutboxCount) {
+            info->mOutboxMails = getOutboxCount(event.mMailboxId, info->mOutboxFolderId);
+            int unreadMailCount(info->mUnreadMailIdList.count());
+            if (info->mOutboxMails > oldOutboxCount || unreadMailCount == 0) {
                 // new mails in outbox
-                activate = true;
+                updateMailbox = true;
             }
-            bool active = info->mUnreadMailIdList.count() ||
-                info->mOutboxMails;
+            bool active = unreadMailCount || info->mOutboxMails;
 
             // Refresh the indicator if messages created or changed
             NM_COMMENT(QString("NmMailAgent::handleSyncStateEvent(): "
@@ -833,7 +943,7 @@
 
             updateUnreadIndicator();
 
-            if (activate) {
+            if (updateMailbox) {
                 updateMailboxState(event.mMailboxId, active, refresh);
             }
         }
@@ -841,9 +951,13 @@
 }
 
 /*!
-    Received from NmFrameworkAdapter connectionState signal
+    Received from NmFrameworkAdapter connectionState signal.
     \sa NmFrameworkAdapter
-*/
+
+    \param state Connection state
+    \param mailboxId Id of the mailbox
+    \parma errorcode Error code
+ */
 void NmMailAgent::handleConnectionEvent(NmConnectState state, const NmId mailboxId, int errorcode)
 {
     NM_FUNCTION;
@@ -859,9 +973,11 @@
 }
 
 /*!
-    Remove a mailbox info entry
-    \return true if mailbox info was found
-*/
+    Remove a mailbox info entry.
+
+    \param id Id of the mailbox
+    \return true if mailbox info was found.
+ */
 bool NmMailAgent::removeMailboxInfo(const NmId &id)
 {
     NM_FUNCTION;
@@ -882,9 +998,11 @@
 }
 
 /*!
-    Create a new mailbox info entry
+    Create a new mailbox info entry.
+
+    \param id Id of the mailbox
     \return new mailbox info object
-*/
+ */
 NmMailboxInfo *NmMailAgent::createMailboxInfo(const NmId &id)
 {
     NM_FUNCTION;
@@ -905,8 +1023,11 @@
 
 /*!
     Create a new mailbox info with given parameters
+
+    \param mailbox Mailbox which mailbox info will be created
+    \param plugin Interface to access email data
     \return new mailbox info object
-*/
+ */
 NmMailboxInfo *NmMailAgent::createMailboxInfo(const NmMailbox &mailbox, NmDataPluginInterface *plugin)
 {
     NM_FUNCTION;
@@ -939,9 +1060,12 @@
 }
 
 /*!
-    Return mailbox info class with mailbox id. If no class is found, create a new instance with given id.
+    Return mailbox info class with mailbox id. If no class is found,
+    create a new instance with given id.
+
+    \param id Id of the mailbox
     \return mailbox info object
-*/
+ */
 NmMailboxInfo *NmMailAgent::getMailboxInfo(const NmId &id)
 {
     NM_FUNCTION;
@@ -958,19 +1082,20 @@
 
 /*!
     Finds out if the message is unread.
+
     \param folderId the id of the folder that includes the message
     \param messageIds the message ids that are checked
     \param mailboxId the id of the mailbox that includes the message
     \param unreadMessage true if there was unread messages
     \return true if info fetching was successful
-*/
+ */
 bool NmMailAgent::getMessageUnreadInfo(const NmId &folderId,
     const NmId &messageId, const NmId &mailboxId, bool &unreadMessage)
 {
     NM_FUNCTION;
 
     NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
-    bool ok = false;
+    bool ok(false);
 
     if (plugin) {
         NmMessage *message=NULL;
@@ -988,13 +1113,14 @@
 }
 
 /*!
-    Plays email alert tone when new messages arrive
+    Plays email alert tone when new messages arrive.
+
 	\returns true if the tone was played
-*/
+ */
 bool NmMailAgent::playAlertTone()
 {
     NM_FUNCTION;
-	bool played(false);
+    bool played(false);
 
     if (mAlertToneAllowed) {
         // Play tone only if system tone service is available and
@@ -1011,15 +1137,15 @@
         // play alert only once per minute
         mAlertToneAllowed = false;
         QTimer::singleShot(NmAgentAlertToneTimer, this, SLOT(enableAlertTone()));
-		played = true;
+        played = true;
     }
 
-	return played;
+    return played;
 }
 
 /*!
-    Allows alert tune to be played again
-*/
+    Allows alert tune to be played again.
+ */
 void NmMailAgent::enableAlertTone()
 {
     NM_FUNCTION;
@@ -1028,14 +1154,14 @@
 }
 
 /*!
-    update send indicator according to outbox state
-*/
+    Update send indicator according to outbox state.
+ */
 void NmMailAgent::updateSendIndicator()
 {
     NM_FUNCTION;
 
     // Get number of mails in outboxes
-    int outboxMails = 0;
+    int outboxMails(0);
     foreach (NmMailboxInfo *mailboxInfo, mMailboxes) {
         outboxMails += mailboxInfo->mOutboxMails;
     }
@@ -1046,18 +1172,19 @@
     else if (outboxMails > mLastOutboxCount) {
         // New mails detected in outbox
 
-    	// indicator will disappear automatically after a delay
+        // indicator will disappear automatically after a delay
         mIndicator->activate(NmSendIndicatorName);
-	}
+    }
 
-	mLastOutboxCount = outboxMails;
+    mLastOutboxCount = outboxMails;
 }
 
 /*!
-    Store the mailbox active information to permanent storage
-    \param mailboxId id of the mailbox
+    Store the mailbox active information to permanent storage.
+
+    \param mailboxId Id of the mailbox
     \param active true if the mailbox is active
-*/
+ */
 void NmMailAgent::storeMailboxActive(const NmId &mailboxId, bool active)
 {
     NM_FUNCTION;
@@ -1078,9 +1205,10 @@
 
 /*!
     Get the mailbox activity state.
+
     \param mailboxId id of the mailbox
     \return true if the mailbox is active or no information was stored earlier
-*/
+ */
 bool NmMailAgent::isMailboxActive(const NmId &mailboxId)
 {
     NM_FUNCTION;
@@ -1098,15 +1226,16 @@
 }
 
 /*!
-    Delete all stored activity information for the mailbox id
+    Delete all stored activity information for the mailbox id.
+
     \param mailboxId id of the mailbox
-*/
+ */
 void NmMailAgent::deleteStoredMailboxActivity(const NmId &mailboxId)
 {
     NM_FUNCTION;
 
     // deactivation delete the key too
-    storeMailboxActive(mailboxId,false);
+    storeMailboxActive(mailboxId, false);
 }
 
 // End of file
--- a/emailuis/nmailui/inc/nmapplication.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/inc/nmapplication.h	Fri Jul 09 12:17:13 2010 +0300
@@ -67,7 +67,11 @@
     void createMainWindow();
     void pushView(NmBaseView *view);
     void resetViewStack();
+    void hideApplication();
 
+signals:
+	void applicationReady();
+    
 private:
     HbMainWindow *mMainWindow;              // Owned
     QStack<NmBaseView*> *mViewStack;        // Owned
--- a/emailuis/nmailui/inc/nmeditorcontent.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/inc/nmeditorcontent.h	Fri Jul 09 12:17:13 2010 +0300
@@ -62,6 +62,7 @@
 
 public slots:
     void setEditorContentHeight();
+    void setEditorContentWidth();
     void ensureCursorVisibility();
 
 private:
@@ -75,6 +76,7 @@
     HbWidget *mScrollAreaContents; // Not owned
     QPointF mScrollPosition;
     NmApplication &mApplication;
+    bool mNeedForWidthAdjustment;
 };
 
 #endif /* NMEDITORCONTENT_H_ */
--- a/emailuis/nmailui/inc/nmeditorheader.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/inc/nmeditorheader.h	Fri Jul 09 12:17:13 2010 +0300
@@ -29,13 +29,15 @@
 class QGraphicsLinearLayout;
 class NmRecipientField;
 class NmAttachmentList; 
+class NmAttachmentListWidget;
+class NmApplication;
 
 class NmEditorHeader : public QObject
 {
 Q_OBJECT
 
 public:
-    NmEditorHeader(QObject *parent, HbDocumentLoader *documentLoader);
+    NmEditorHeader(QObject *parent, NmApplication &application, HbDocumentLoader *documentLoader);
     virtual ~NmEditorHeader();
     qreal headerHeight() const;
     NmHtmlLineEdit *subjectEdit() const;
@@ -53,6 +55,7 @@
         const QString &fileSize,
         int result);
     void setFieldVisibility(bool isVisible);
+    void adjustHeaderWidth();
 
 private:
     void loadWidgets();
@@ -70,26 +73,30 @@
     void editorContentChanged();
     void attachmentActivated(int arrayIndex);
     void attachmentLongPressed(int arrayIndex, QPointF point);
+    void repositHeader(const QPointF &scrollPosition);
 
 private:
+    NmApplication &mApplication;
     HbDocumentLoader* mDocumentLoader;  // Not owned
     qreal mHeaderHeight;
     HbLabel *mPriorityIcon; // Not owned
     HbLabel *mFollowUpIcon; // Not owned
     bool mIconVisible;
-    NmRecipientLineEdit *mToEdit; // Not owned
-    NmRecipientLineEdit *mCcEdit; // Not owned
-    NmRecipientLineEdit *mBccEdit; // Not owned
-    NmHtmlLineEdit *mSubjectEdit; // Not owned
+    NmRecipientLineEdit *mToEdit;      // Not owned
+    NmRecipientLineEdit *mCcEdit;      // Not owned
+    NmRecipientLineEdit *mBccEdit;     // Not owned
+    NmHtmlLineEdit *mSubjectEdit;      // Not owned
     bool mRecipientFieldsEmpty;
-    QGraphicsLinearLayout *mLayout; // Not owned
+    QGraphicsLinearLayout *mLayout;    // Not owned
     NmAttachmentList *mAttachmentList; // Not owned
+    NmAttachmentListWidget *mAttachmentListWidget; // Not owned
     NmRecipientField *mToField;    // Not owned
+    HbWidget *mToWidget;           // Not owned
     NmRecipientField *mCcField;    // Not owned
-    HbWidget *mCcWidget;    // Not owned
+    HbWidget *mCcWidget;           // Not owned
     NmRecipientField *mBccField;   // Not owned
-    HbWidget *mBccWidget;    // Not owned
-    HbWidget *mSubjectWidget;    // Not owned
+    HbWidget *mBccWidget;          // Not owned
+    HbWidget *mSubjectWidget;      // Not owned
     QGraphicsLinearLayout *mSubjectLayout; // Not owned
     bool mCcBccFieldVisible;
 };
--- a/emailuis/nmailui/src/nmapplication.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/src/nmapplication.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -221,6 +221,7 @@
     	NmBaseView *currentView = mViewStack->top();
         if (currentView) {
             currentView->viewReady();
+            emit applicationReady();
         }
     }
 }
@@ -320,6 +321,18 @@
 }
 
 /*!
+     Hide the application
+*/
+void NmApplication::hideApplication()
+{
+    // Hide the application
+    XQServiceUtil::toBackground(true);
+
+    // hide the sync indicator as well
+    mUiEngine->enableSyncIndicator(false);
+}
+
+/*!
     Pop view from view stack. View object is deleted.
 */
 void NmApplication::popView()
@@ -340,6 +353,13 @@
 				}
 	        }
             mBackButtonPressed = false;
+
+            // Move the application to background if closing the message list view
+            if (topViewId == NmUiViewMessageList && mViewStack->size() == 1) {
+                hideApplication();
+                return;
+            }
+
             mViewStack->pop();
             // Call custom exit function.
             view->aboutToExitView();
--- a/emailuis/nmailui/src/nmeditorcontent.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/src/nmeditorcontent.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -39,16 +39,20 @@
     mEditorWidget(NULL),
     mScrollArea(NULL),
     mScrollAreaContents(NULL),
-    mApplication(application)
+    mApplication(application),
+    mNeedForWidthAdjustment(false)
 {
     NM_FUNCTION;
 
     // Construct container for the header widgets
-    mHeader = new NmEditorHeader(this, documentLoader);
+    mHeader = new NmEditorHeader(this, application, documentLoader);
 
     // Get pointer to body text area handling widget
     mEditorWidget = qobject_cast<NmEditorTextEdit *>(documentLoader->findWidget(NMUI_EDITOR_BODY));
-    
+
+    // Enable the emoticons.
+    mEditorWidget->setSmileysEnabled(true);
+
     // Set body editor to use NmEditorTextDocument
     NmEditorTextDocument *textDocument = new NmEditorTextDocument(manager);
     mEditorWidget->setDocument(textDocument); 
@@ -56,8 +60,10 @@
 
     mScrollArea = qobject_cast<NmBaseViewScrollArea *>
         (documentLoader->findWidget(NMUI_EDITOR_SCROLL_AREA));
+    
     mScrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal);
-    
+    mScrollArea->setClampingStyle(HbScrollArea::BounceBackClamping);
+        
     // Enable style picker menu item.
     mEditorWidget->setFormatDialog(new HbFormatDialog());
 
@@ -66,6 +72,12 @@
     
     // Create signal slot connections
     createConnections();
+
+    // The following line is necessary in terms of being able to add emoticons
+    // (smileys) to an empty document (mail content). Otherwise the private
+    // pointer of the QTextDocument which the smiley engine has is NULL and
+    // inserting a smiley will lead to an error.
+    mEditorWidget->setPlainText("");
 }
 
 /*!
@@ -87,10 +99,12 @@
     NM_FUNCTION;
     
     QString bodyContent;
+	QTextCursor cursor(mEditorWidget->document());
     
     // Create the "reply" header (also for forward message)
     if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll || 
         editorStartMode==NmUiEditorForward) {
+		bodyContent.append(QString("<style type=\"text/css\">* { color: black; }</style>"));
         bodyContent.append(NmUtilities::createReplyHeader(originalMessage.envelope()));
     }
     
@@ -103,15 +117,27 @@
         if(editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll ) {
             removeEmbeddedImages(bodyContent);
         }
-        emit setHtml(bodyContent);
+        cursor.insertHtml(bodyContent);
         mMessageBodyType = NmHTMLText;
     }
     else if (plainPart) {
         // Plain text part was present, set it to HbTextEdit
         bodyContent.append(plainPart->textContent());
-        emit setPlainText(bodyContent);
+        cursor.insertText(bodyContent);
         mMessageBodyType = NmPlainText;
+        
+		// Next we set text color for black for all current content
+        QTextCharFormat blackForeground;
+    	blackForeground = cursor.charFormat();
+    	blackForeground.setForeground(Qt::black);
+    	cursor.select(QTextCursor::Document);
+    	cursor.mergeCharFormat(blackForeground);
     }
+    // Update of the body width is done when next contentChanged signal comes from the body.
+    mNeedForWidthAdjustment = true;
+	cursor.clearSelection();
+	cursor.setPosition(0);
+	cursor.insertHtml(QString("<html><body><br><br></body></html>"));
 }  
 
 /*!
@@ -152,6 +178,14 @@
     // listen to the parent's (NmEditorView) size changes which happen eg. when VKB is opened/closed
     connect(parent(), SIGNAL(sizeChanged()), this, SLOT(ensureCursorVisibility()),
         Qt::QueuedConnection);
+
+    // Listen scroll posion change signals for header reposition.
+    connect(mScrollArea, SIGNAL(scrollPositionChanged(QPointF)),
+    		mHeader, SLOT(repositHeader(QPointF)));
+
+    // Listen content change signal for body widget width adjustment.
+    connect(mEditorWidget->document(), SIGNAL(contentsChanged()), this, 
+        SLOT(setEditorContentWidth()), Qt::QueuedConnection);
 }
 
 /*!
@@ -209,6 +243,21 @@
 }
 
 /*!
+    This slot is used to set width for the body field.
+    For some reason HbTextEdit does not set it's width, so we need to se it here.
+    This slot can be removed if HbTextEdit is fixed.
+ */
+void NmEditorContent::setEditorContentWidth()
+{
+    NM_FUNCTION;
+    
+    if (mNeedForWidthAdjustment) {
+        mNeedForWidthAdjustment = false;
+        mScrollAreaContents->setPreferredWidth(mEditorWidget->document()->idealWidth());
+    }
+}
+
+/*!
     This slot is called when the cursor visibility has to be ensured ie. the scroll position is 
     adjusted so that the cursor can be seen.
 */
--- a/emailuis/nmailui/src/nmeditorheader.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/src/nmeditorheader.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -22,6 +22,7 @@
 static const char *NMUI_EDITOR_CONTAINER = "scrollAreaContents";
 static const char *NMUI_EDITOR_SUBJECT_FIELD = "editorSubjectField";
 static const char *NMUI_EDITOR_SUBJECT_EDIT = "editorSubjectEdit";
+static const char *NMUI_EDITOR_TO_FIELD = "editorToField";
 static const char *NMUI_EDITOR_CC_FIELD = "editorCcField";
 static const char *NMUI_EDITOR_BCC_FIELD = "editorBccField";
 static const char *NMUI_EDITOR_PRIORITY_ICON = "editPriorityIcon";
@@ -39,8 +40,10 @@
 /*!
     Constructor
 */
-NmEditorHeader::NmEditorHeader(QObject *parent, HbDocumentLoader *documentLoader) :
+NmEditorHeader::NmEditorHeader(
+    QObject *parent, NmApplication &application, HbDocumentLoader *documentLoader) :
     QObject(parent),
+    mApplication(application),
     mDocumentLoader(documentLoader),
     mHeaderHeight(0),
     mIconVisible(false),
@@ -93,6 +96,8 @@
         ccEditorInterface.setUpAsLatinAlphabetOnlyEditor();
         bccEditorInterface.setUpAsLatinAlphabetOnlyEditor();
 
+        mToWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_TO_FIELD));
+        
         // Cc field is not shown by default. It needs to be both hidden and removed from the layout.
         mCcWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD));
         mCcWidget->hide();
@@ -113,13 +118,12 @@
         mSubjectEdit->setMaxRows(NmMaxRows);
     
         // Add attachment list
-        NmAttachmentListWidget *attachmentList = qobject_cast<NmAttachmentListWidget *>
+        mAttachmentListWidget = qobject_cast<NmAttachmentListWidget *>
             (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST));
         // Create attachment list handling object
-        mAttachmentList = new NmAttachmentList(*attachmentList);
+        mAttachmentList = new NmAttachmentList(*mAttachmentListWidget);
         mAttachmentList->setParent(this); // ownership changes
-        attachmentList->hide();
-        mLayout->removeItem(attachmentList);
+        mAttachmentListWidget->hide();
     
         // Add priority icon
         mPriorityIcon = qobject_cast<HbLabel *>
@@ -253,6 +257,23 @@
 }
 
 /*!
+    Because header filds have fixed size policy. This function must be called to set
+    new width for every header field when orintation has been changed.
+ */
+void NmEditorHeader::adjustHeaderWidth()
+{
+    NM_FUNCTION;
+    
+    int newWidth = mApplication.screenSize().width();
+    mToWidget->setPreferredWidth(newWidth);
+    mCcWidget->setPreferredWidth(newWidth);
+    mBccWidget->setPreferredWidth(newWidth);
+    mSubjectWidget->setPreferredWidth(newWidth);
+    mAttachmentListWidget->setPreferredWidth(newWidth);
+    mSubjectWidget->setPreferredWidth(newWidth);
+}
+
+/*!
     Return pointer to to edit
  */
 NmRecipientLineEdit* NmEditorHeader::toEdit() const
@@ -385,12 +406,11 @@
 {
     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();
     }
+
+    mAttachmentList->insertAttachment(fileName, fileSize, nmid);
     sendHeaderHeightChanged();
 }
 
@@ -464,4 +484,22 @@
     // Remove selected attachment
     emit attachmentLongPressed(mAttachmentList->nmIdByIndex(arrayIndex), point);
 }
+
+/*!
+    This slot is called when scroll position has been changed.
+    Function set new positions for header fields so that header stays visible
+    when body is scrolled horizontally.
+ */
+void NmEditorHeader::repositHeader(const QPointF &scrollPosition)
+{
+    NM_FUNCTION;
     
+    QTransform tr;
+    tr.translate(scrollPosition.x(),0);
+    mToWidget->setTransform(tr);
+    mCcWidget->setTransform(tr);
+    mBccWidget->setTransform(tr);
+    mSubjectWidget->setTransform(tr);
+    mAttachmentListWidget->setTransform(tr);
+}
+
--- a/emailuis/nmailui/src/nmeditorview.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/src/nmeditorview.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -193,6 +193,7 @@
     // content widget height needs to be set according to the new orientation to get the scroll
 	// area work correctly
 	mHeaderWidget->sendDelayedHeaderHeightChanged();
+	mHeaderWidget->adjustHeaderWidth();
 }
 
 /*!
--- a/emailuis/nmailui/src/nmmessagelistview.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/src/nmmessagelistview.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -23,9 +23,7 @@
 
 #include "nmuiheaders.h"
 
-const QString syncIndicatorName = "com.nokia.nmail.indicatorplugin.sync/1.0";
-
-/*! 
+/*!
 	\class NmMessageListView
 	\brief Message list view
 */
@@ -204,7 +202,7 @@
 */
 void NmMessageListView::initTreeView()
 {
-    NM_FUNCTION; 
+    NM_FUNCTION;
 
     // Get mailbox widget pointer and set parameters
     if (mMessageListWidget){
@@ -237,7 +235,14 @@
         mStartParam=NULL;
         // Store new start parameter data
         mStartParam=startParam;
-        // Update the model with new parameters
+        // Disconnect signals from previous model
+        QObject::disconnect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
+                this, SLOT(itemsAdded(const QModelIndex&,int,int)));
+        QObject::disconnect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
+                this, SLOT(itemsRemoved()));
+        QObject::disconnect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)),
+                this, SLOT(reloadViewContents(NmUiStartParam*)));
+        // Update model pointer and refresh mailbox with new model
         mMessageListModel = &mUiEngine.messageListModel(startParam->mailboxId(), startParam->folderId());
         refreshList();
         // Refresh the mailboxname
@@ -250,7 +255,7 @@
     }
 }
 
- 
+
 /*!
     Return view id
 */
@@ -269,16 +274,16 @@
     NM_FUNCTION;
 
     if (mMessageListModel) {
-        NmId mailboxId = mMessageListModel->currentMailboxId();    
+        NmId mailboxId = mMessageListModel->currentMailboxId();
         // In each refresh, e.g. in folder change the UI signals
         // lower layer about the folder that has been opened.
         if (mStartParam){
             mUiEngine.updateActiveFolder(mailboxId, mStartParam->folderId());
-            
+
             NmFolderType folderType = mUiEngine.folderTypeById(mStartParam->mailboxId(),
                                               mStartParam->folderId());
             if (folderType == NmFolderInbox) { // If the new folder is an inbox, first automatic sync should be shown
-                mIsFirstSyncInMessageList = true; 
+                mIsFirstSyncInMessageList = true;
             }
         }
 
@@ -286,11 +291,11 @@
         if (mMessageListWidget) {
             mMessageListWidget->setModel(static_cast<QStandardItemModel*>(mMessageListModel));
             QObject::connect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
-                    this, SLOT(itemsAdded(const QModelIndex&,int,int)));
+                    this, SLOT(itemsAdded(const QModelIndex&,int,int)),Qt::UniqueConnection);
             QObject::connect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
-                    this, SLOT(itemsRemoved()));
+                    this, SLOT(itemsRemoved()),Qt::UniqueConnection);
             QObject::connect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)),
-                    this, SLOT(reloadViewContents(NmUiStartParam*)));
+                    this, SLOT(reloadViewContents(NmUiStartParam*)),Qt::UniqueConnection);
 
             mPreviousModelCount=mMessageListModel->rowCount();
             if (mPreviousModelCount==0){
@@ -299,14 +304,14 @@
             else{
                 hideNoMessagesText();
             }
-        }    
+        }
     }
 }
 
 /*!
     Sync state event handling
 */
-void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId & mailboxId)
+void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId &mailboxId)
 {
     NM_FUNCTION;
     if (mMessageListModel && mailboxId == mMessageListModel->currentMailboxId()) {
@@ -322,15 +327,14 @@
             // Show sync icon only for the first automatic sync after opening message list.
             // Sync icon for manual sync is shown in NmUiEngine::refreshMailbox, not here.
             if (mIsFirstSyncInMessageList) {
-                HbIndicator indicator;
-                indicator.activate(syncIndicatorName, QVariant());
+				mUiEngine.enableSyncIndicator(true);
                 mIsFirstSyncInMessageList = false;
             }
         }
     }
 }
 
-/*! 
+/*!
     folder selection handling within current mailbox
 */
 void NmMessageListView::folderSelected()
@@ -357,17 +361,17 @@
 
 
 /*!
-    Long keypress handling 
+    Long keypress handling
 */
 void NmMessageListView::showItemContextMenu(HbAbstractViewItem *listViewItem, const QPointF &coords)
 {
     NM_FUNCTION;
-   
+
     if (listViewItem) {
         // Recreate item context menu each time it is called
         if (mItemContextMenu){
             mItemContextMenu->clearActions();
-            delete mItemContextMenu;    
+            delete mItemContextMenu;
             mItemContextMenu=NULL;
         }
         mItemContextMenu = new HbMenu();
@@ -650,7 +654,7 @@
     visible and keeps the scroll position on the top of the list.
 
     \param parent Not used.
-    \param start 
+    \param start
     \param end Not used.
 */
 void NmMessageListView::itemsAdded(const QModelIndex &parent, int start, int end)
@@ -688,7 +692,7 @@
     }
     // Store model count
     if (mMessageListModel){
-        mPreviousModelCount=mMessageListModel->rowCount();    
+        mPreviousModelCount=mMessageListModel->rowCount();
     }
 }
 
@@ -701,7 +705,7 @@
     NM_FUNCTION;
     // Store model count
     if (mMessageListModel){
-        mPreviousModelCount=mMessageListModel->rowCount();    
+        mPreviousModelCount=mMessageListModel->rowCount();
     }
     if (mPreviousModelCount == 0){
         showNoMessagesText();
--- a/emailuis/nmailui/src/nmutilities.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/src/nmutilities.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -264,6 +264,7 @@
     NM_FUNCTION;
 
     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+    messageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);  
     messageBox->setText(noteText);
     messageBox->setTimeout(HbMessageBox::NoTimeout); // Note has to be dismissed manually
     messageBox->open(receiver, member);
@@ -292,7 +293,7 @@
 {
     NM_FUNCTION;
 
-    QString ret = "<html><body><br><br>";
+    QString ret = "<html><body>";
     // Append "----- Original message ----" text
     ret+=hbTrId("txt_mail_editor_reply_original_msg");
     // Append sender
--- a/emailuis/nmailui/src/nmviewerserviceinterface.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/src/nmviewerserviceinterface.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -57,10 +57,12 @@
     NM_FUNCTION;
 
     mAsyncReqId = setCurrentRequestAsync();
-
-    NmId mailboxNmId(mailboxId.toULongLong());
-    NmId messageNmId(messageId.toULongLong());
-    NmId folderNmId(folderId.toULongLong());
+    NmId mailboxNmId(0);
+    mailboxNmId = mailboxId.toULongLong();   
+    NmId messageNmId(0);
+    messageNmId = messageId.toULongLong(); 
+    NmId folderNmId(0);
+    folderNmId = folderId.toULongLong();
 
 	// Make sure the app stays background if user presses back in viewer view
 	bool visible = mApplication->updateVisibilityState();
--- a/emailuis/nmailui/src/nmviewerview.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/src/nmviewerview.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -182,7 +182,8 @@
                 mHeaderWidget->setView(this);
                 mHeaderWidget->rescaleHeader(mScreenSize);
                 mHeaderWidget->setMessage(mMessage);
-                mHeaderStartScenePos = mHeaderWidget->scenePos();
+                QPointF headerStartPos = mHeaderWidget->scenePos();
+                mHeaderStartScenePos = QPointF(0,headerStartPos.y());
             }
 
             // Load webview
Binary file emailuis/nmailui/translations/mail.qm has changed
--- a/emailuis/nmailui/translations/mail.ts	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailui/translations/mail.ts	Fri Jul 09 12:17:13 2010 +0300
@@ -453,8 +453,8 @@
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_status_menu_new_mail">
-    <comment>Secondary text for status menu item: indicates the there are new mail messages</comment>        
-    <source>New Mail</source>
+    <comment>Secondary text for status menu item: indicates the there are new mail messages. We are not going to show the number of messages here. </comment>        
+    <source>New mail</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_notifdialog_sec_medium_graphic</extra-loc-layout_id>    
     <extra-loc-viewid>mail_001_d</extra-loc-viewid>
@@ -493,7 +493,7 @@
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_status_menu_unset">
-    <comment>Primary text for status menu item: indicates that there are unsent messages in outbox. %[]1 is account name.</comment>        
+    <comment>Primary text for status menu item: indicates that there are unsent messages in outbox. %[]1 is account name. The number of unsent mails is not going to be shown here.</comment>        
     <source>%[]1: Unsent</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_notifdialog_pri_medium_graphic</extra-loc-layout_id>    
@@ -513,7 +513,7 @@
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_short_caption_mail">
-    <comment>Short caption text for Mail application. Name of the mail application.</comment>        
+    <comment>Short caption text for Mail application. Name of the mail application. Not in the UI, needed for B&amp;I purposes</comment>        
     <source>Mail</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_grid_applications_sec</extra-loc-layout_id>    
@@ -896,7 +896,7 @@
     <comment>Button that is shown if all the message content is not downloaded while message is opened.</comment>        
     <source>Download rest</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
     <extra-loc-viewid>mail_002_b</extra-loc-viewid>
     <extra-loc-positionid>button</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
@@ -923,7 +923,7 @@
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_long_caption_mail">
-    <comment>Long caption text for Mail application. Name of the mail application.</comment>        
+    <comment>Long caption text for Mail application. Name of the mail application. Not in the UI, needed for B&amp;I purposes</comment>        
     <source>Mail</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_list_pri_large_graphic</extra-loc-layout_id>    
--- a/emailuis/nmailuiengine/bwins/nmailuiengineu.def	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailuiengine/bwins/nmailuiengineu.def	Fri Jul 09 12:17:13 2010 +0300
@@ -312,4 +312,5 @@
 	?qt_metacall@NmUiEngine@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 311 NONAME ; int NmUiEngine::qt_metacall(enum QMetaObject::Call, int, void * *)
 	?message@NmDataManager@@QAEPAVNmMessage@@ABVNmId@@00@Z @ 312 NONAME ; class NmMessage * NmDataManager::message(class NmId const &, class NmId const &, class NmId const &)
 	?metaObject@NmOperation@@UBEPBUQMetaObject@@XZ @ 313 NONAME ; struct QMetaObject const * NmOperation::metaObject(void) const
+	?enableSyncIndicator@NmUiEngine@@QAEX_N@Z @ 314 NONAME ; void NmUiEngine::enableSyncIndicator(bool)
 
--- a/emailuis/nmailuiengine/eabi/nmailuiengineu.def	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailuiengine/eabi/nmailuiengineu.def	Fri Jul 09 12:17:13 2010 +0300
@@ -319,4 +319,5 @@
 	_ZThn8_N18NmBaseClientPlugin10getActionsERK15NmActionRequestR5QListIP8NmActionE @ 318 NONAME
 	_ZThn8_N18NmBaseClientPluginD0Ev @ 319 NONAME
 	_ZThn8_N18NmBaseClientPluginD1Ev @ 320 NONAME
+	_ZN10NmUiEngine19enableSyncIndicatorEb @ 321 NONAME
 
--- a/emailuis/nmailuiengine/inc/nmuiengine.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailuiengine/inc/nmuiengine.h	Fri Jul 09 12:17:13 2010 +0300
@@ -56,7 +56,7 @@
     void refreshMailboxListModel();
 
     NmId getPluginIdByMailboxId(quint32 accountId);
-    
+
     NmMessageListModel &messageListModel(const NmId &mailboxId,
                                          const NmId &folderId);
 
@@ -74,24 +74,24 @@
         const NmId &folderId,
         const NmId &messageId);
 
-    QPointer<NmOperation> fetchMessagePart( 
+    QPointer<NmOperation> fetchMessagePart(
         const NmId &mailboxId,
         const NmId &folderId,
         const NmId &messageId,
         const NmId &messagePartId);
-    
-    QPointer<NmOperation> fetchMessageParts( 
+
+    QPointer<NmOperation> fetchMessageParts(
         const NmId &mailboxId,
         const NmId &folderId,
         const NmId &messageId,
         const QList<NmId> &messagePartIds);
-    
+
     XQSharableFile messagePartFile(
        const NmId &mailboxId,
        const NmId &folderId,
        const NmId &messageId,
        const NmId &messagePartId);
-    
+
     NmMailboxMetaData *mailboxById(const NmId &mailboxId);
 
     int contentToMessagePart(
@@ -131,31 +131,31 @@
     int refreshMailbox(const NmId &mailboxId);
 
     int goOnline(const NmId &mailboxId);
-    
+
     int goOffline(const NmId &mailboxId);
-    
+
     int removeMessage(const NmId &mailboxId,
                       const NmId &folderId,
                       const NmId &messageId);
-    
+
     void removeDraftMessage(NmMessage *message);
-    
+
     void saveDraftMessage(NmMessage *message,
                           const QList<NmOperation*> &preliminaryOperations);
-    
+
     void sendMessage(NmMessage *message,
                      const QList<NmOperation*> &preliminaryOperations);
 
     bool isSendingMessage() const;
 
     const NmMessage *messageBeingSent() const;
-    
+
     QPointer<NmAddAttachmentsOperation> addAttachments(
         const NmMessage &message,
         const QList<QString> &fileList);
-    
+
     QPointer<NmOperation> removeAttachment(
-        const NmMessage &message, 
+        const NmMessage &message,
         const NmId &attachmentPartId);
 
     NmSyncState syncState(const NmId& mailboxId);
@@ -166,11 +166,13 @@
                const QStringList &searchStrings);
 
     int cancelSearch(const NmId &mailboxId);
-    
+
     NmFolderType folderTypeById(NmId mailboxId, NmId folderId);
 
     void updateActiveFolder(const NmId &mailboxId, const NmId &folderId);
-    
+
+    void enableSyncIndicator(bool enabled);
+
 public slots:
 
     void handleCompletedSendOperation();
@@ -189,17 +191,17 @@
 
     void handleMessageEvent(NmMessageEvent event,
                             const NmId &folderId,
-                            const QList<NmId> &messageIds, 
+                            const QList<NmId> &messageIds,
                             const NmId& mailboxId);
-    
+
     void handleMailboxEvent(NmMailboxEvent event,
                             const QList<NmId> &mailboxIds);
 
     void handleMatchFound(const NmId &messageId, const NmId &folderId);
-    
+
     void messageEventForListModel(NmMessageEvent event,
                             const NmId &folderId,
-                            const QList<NmId> &messageIds, 
+                            const QList<NmId> &messageIds,
                             const NmId& mailboxId);
 
 
--- a/emailuis/nmailuiengine/src/nmuiengine.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailuiengine/src/nmuiengine.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -32,7 +32,7 @@
 /*!
     Constructor
 */
-NmUiEngine::NmUiEngine() 
+NmUiEngine::NmUiEngine()
 : mMailboxListModel(NULL),
   mInboxListModel(NULL),
   mMessageListModel(NULL),
@@ -43,7 +43,7 @@
   mDraftMessage(NULL)
 {
     NM_FUNCTION;
-    
+
     mPluginFactory = NmDataPluginFactory::instance();
     mDataManager = new NmDataManager();
     // Connect to the plugins to receive change notifications
@@ -56,7 +56,7 @@
                  this, SLOT(handleMailboxEvent(NmMailboxEvent, const QList<NmId> &)),
                  Qt::UniqueConnection);
             // connect message events
-            QObject::connect(plugin, 
+            QObject::connect(plugin,
                 SIGNAL(messageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)),
                 this, SLOT(handleMessageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)),
                 Qt::UniqueConnection);
@@ -65,7 +65,7 @@
                 SIGNAL(connectionEvent(NmConnectState, const NmId &, const int)),
                 this,
                 SLOT(handleConnectEvent(NmConnectState, const NmId &, const int)),
-                Qt::UniqueConnection);       
+                Qt::UniqueConnection);
             // do the subscriptions also
             NmDataPluginInterface *pluginInterface = mPluginFactory->interfaceInstance(plugin);
             if (pluginInterface) {
@@ -87,10 +87,9 @@
 NmUiEngine::~NmUiEngine()
 {
     NM_FUNCTION;
-    
-    HbIndicator indicator;
-    indicator.deactivate(syncIndicatorName, QVariant());
-    
+
+    enableSyncIndicator(false);
+
     if (mMessageSearchListModel) {
         delete mMessageSearchListModel;
         mMessageSearchListModel = NULL;
@@ -137,7 +136,7 @@
     }
 
     if (mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) {
-        mRemoveDraftOperation->cancelOperation();        
+        mRemoveDraftOperation->cancelOperation();
     }
 
     if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
@@ -161,7 +160,7 @@
 NmUiEngine *NmUiEngine::instance()
 {
     NM_FUNCTION;
-    
+
     if (!mInstance) {
     	mInstance = new NmUiEngine();
     }
@@ -175,7 +174,7 @@
 void NmUiEngine::releaseInstance(NmUiEngine *&instance)
 {
     NM_FUNCTION;
-    
+
     //can't have passed out instances if we don't have any
     if (mInstance) {
         if(instance == mInstance) {
@@ -196,14 +195,14 @@
 NmMailboxListModel &NmUiEngine::mailboxListModel()
 {
     NM_FUNCTION;
-    
+
     if (!mMailboxListModel) {
         refreshMailboxListModel(); // creates the model too
     }
-    
+
     return *mMailboxListModel;
 }
-        
+
 /*!
     Populate the list model with the mailbox and top level folder objects. The model is
     updated dynamically. Creates the model if needed.
@@ -211,10 +210,10 @@
 void NmUiEngine::refreshMailboxListModel()
 {
     NM_FUNCTION;
-    
+
     if (!mMailboxListModel) {
         mMailboxListModel = new NmMailboxListModel(*mDataManager);
-        
+
         // Connect the model to the plugins to receive change notifications
         QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances();
         for (int i = 0; i < dataPlugins->count(); i++) {
@@ -227,7 +226,7 @@
     } else {
         mMailboxListModel->clear();
     }
-    
+
     QList<NmMailbox*> mailboxList;
     mDataManager->listMailboxes(mailboxList);
     mMailboxListModel->refresh(mailboxList);
@@ -238,7 +237,7 @@
 
 
 /*!
-    Returns a message list model for a folder identified by \a mailboxId and 
+    Returns a message list model for a folder identified by \a mailboxId and
     \a folderId. The model is updated dynamically. The ownership of the model
     object is not moved to the caller.
 */
@@ -252,23 +251,23 @@
     if (standardFolderId(mailboxId,NmFolderInbox)==folderId){
         isInbox=true;
     }
-    if (plugin) { 
+    if (plugin) {
         // Connect plugin message events to handler slot messageEventForListModel
-        QObject::connect(plugin, SIGNAL(messageEvent(NmMessageEvent, const NmId &, 
+        QObject::connect(plugin, SIGNAL(messageEvent(NmMessageEvent, const NmId &,
                                 const QList<NmId> &, const NmId&)),
-                                this, SLOT(messageEventForListModel(NmMessageEvent, 
+                                this, SLOT(messageEventForListModel(NmMessageEvent,
                                 const NmId &, const QList<NmId> &, const NmId&)), Qt::UniqueConnection );
         // Create inbox list model only once when entering to inbox for the first time
-        // or re-create inbox list model when mailbox has changed    
+        // or re-create inbox list model when mailbox has changed
         if ((!mInboxListModel&&isInbox)||
             (mInboxListModel&&isInbox&&mailboxId!=mInboxListModel->currentMailboxId())){
             // Delete previous model and set to NULL. Deleting model will also
-            // delete all items in model. 
+            // delete all items in model.
             if (mInboxListModel){
                 delete mInboxListModel;
                 mInboxListModel=NULL;
             }
-            // Create new inbox model 
+            // Create new inbox model
             mInboxListModel = new NmMessageListModel(*mDataManager);
             // Initial fill up of inbox list model, otherwise updated in the background
             QList<NmMessageEnvelope*> messageEnvelopeList;
@@ -288,18 +287,18 @@
                 mMessageListModel=NULL;
             }
             mMessageListModel = new NmMessageListModel(*mDataManager);
-    
-            // Fill up other model 
+
+            // Fill up other model
             QList<NmMessageEnvelope*> messageEnvelopeList;
             mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList);
             mMessageListModel->refresh(mailboxId, folderId, messageEnvelopeList);
 
             while (!messageEnvelopeList.isEmpty()) {
-                delete messageEnvelopeList.takeFirst(); 
-            }             
-        }    
+                delete messageEnvelopeList.takeFirst();
+            }
+        }
     }
-     
+
     // Connect sync state changed
     if (plugin){
         QObject::connect(
@@ -309,7 +308,7 @@
     }
     NmMessageListModel* ret(NULL);
     if (isInbox){
-        ret = mInboxListModel;    
+        ret = mInboxListModel;
         // Inbox list model is queried, other model is not
         // needed anymore and memory should be freeded
         if (mMessageListModel){
@@ -318,7 +317,7 @@
         }
     }
     else {
-        ret = mMessageListModel;    
+        ret = mMessageListModel;
     }
     return *ret;
 }
@@ -334,7 +333,7 @@
 NmMessageListModel &NmUiEngine::messageListModelForSearch(const NmId &mailboxId)
 {
     NM_FUNCTION;
-    
+
     Q_UNUSED(mailboxId);
 
     if (!mMessageSearchListModel) {
@@ -364,7 +363,7 @@
 
 
 /*!
-    Get the identifier of the standard folder of a type \a folderType 
+    Get the identifier of the standard folder of a type \a folderType
     from the mailbox \a mailboxId.
 */
 NmId NmUiEngine::standardFolderId(
@@ -372,7 +371,7 @@
     NmFolderType folderType)
 {
     NM_FUNCTION;
-    
+
     NmId value;
     if (folderType != NmFolderOther) {
         NmDataPluginInterface *plugin =
@@ -394,7 +393,7 @@
                       const NmId &messageId)
 {
     NM_FUNCTION;
-    
+
     NmMessage *message = mDataManager->message(mailboxId, folderId, messageId);
     return message;
 }
@@ -407,7 +406,7 @@
     const NmId &messageId )
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -427,7 +426,7 @@
     const NmId &messagePartId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -447,7 +446,7 @@
     const QList<NmId> &messagePartIds)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -467,7 +466,7 @@
         const NmId &messagePartId)
 {
     NM_FUNCTION;
-    
+
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
@@ -488,7 +487,7 @@
     NmMessagePart &messagePart)
 {
     NM_FUNCTION;
-    
+
     return mDataManager->contentToMessagePart(mailboxId, folderId, messageId, messagePart);
 }
 
@@ -507,17 +506,17 @@
                                const QList<NmId> &messageIdList)
 {
     NM_FUNCTION;
-    
+
     int result(NmNotFoundError);
-    
+
     bool isInbox(false);
     if (standardFolderId(mailboxId,NmFolderInbox)==folderId){
         isInbox=true;
-    } 
+    }
     if (isInbox&&mInboxListModel){
         mInboxListModel->handleMessageEvent(NmMessageDeleted, folderId,
-                                               messageIdList, mailboxId);   
-    }   
+                                               messageIdList, mailboxId);
+    }
     else if (mMessageListModel) {
 	    mMessageListModel->handleMessageEvent(NmMessageDeleted, folderId,
                                               messageIdList, mailboxId);
@@ -559,7 +558,7 @@
         const QList<const NmMessageEnvelope*> &envelopeList)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmStoreEnvelopesOperation> operation(NULL);
     NmMessageListModel *theMessageListModel = mMessageListModel;
 
@@ -569,7 +568,7 @@
 
     if (theMessageListModel && envelopeList.count()) {
         QList<NmId> messageIdList;
-        
+
         for (int i(0); i < envelopeList.count(); i++){
             messageIdList.append(envelopeList[i]->messageId());
         }
@@ -628,7 +627,7 @@
 QPointer<NmMessageCreationOperation> NmUiEngine::createNewMessage(const NmId &mailboxId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -647,7 +646,7 @@
         const NmId &originalMessageId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -667,7 +666,7 @@
         bool replyAll)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -683,7 +682,7 @@
 int NmUiEngine::saveMessage(const NmMessage &message)
 {
     NM_FUNCTION;
-    
+
     const NmId &mailboxId = message.envelope().mailboxId();
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
@@ -700,15 +699,14 @@
 int NmUiEngine::refreshMailbox(const NmId &mailboxId )
 {
     NM_FUNCTION;
-    
+
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
         ret = plugin->refreshMailbox(mailboxId);
         if (NmNoError == ret) {
-            HbIndicator indicator;
-            indicator.activate(syncIndicatorName, QVariant());
+            enableSyncIndicator(true);
         }
     }
     return ret;
@@ -720,7 +718,7 @@
 int NmUiEngine::goOnline(const NmId &mailboxId )
 {
     NM_FUNCTION;
-    
+
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -736,7 +734,7 @@
 int NmUiEngine::goOffline(const NmId &mailboxId )
 {
     NM_FUNCTION;
-    
+
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -756,7 +754,7 @@
     const NmId &messageId)
 {
     NM_FUNCTION;
-    
+
     int result(NmNotFoundError);
     NmDataPluginInterface *plugin =
             mPluginFactory->interfaceInstance(mailboxId);
@@ -768,7 +766,7 @@
 
 
 /*!
-  Handles draft message deletion after editor has closed, takes ownership of message. 
+  Handles draft message deletion after editor has closed, takes ownership of message.
  */
 void NmUiEngine::removeDraftMessage(NmMessage *message)
 {
@@ -777,7 +775,7 @@
     if (message) {
         NmDataPluginInterface *plugin =
             mPluginFactory->interfaceInstance(message->envelope().mailboxId());
-        
+
         if (plugin) {
             // to be on the safer side:
             // we shouldn't even be here if mRemoveDraftOperation != NULL
@@ -786,15 +784,15 @@
             }
             // ownership of message changes
             mRemoveDraftOperation = plugin->removeDraftMessage(message);
-            
+
             if (mRemoveDraftOperation) {
-                connect(mRemoveDraftOperation, 
-                        SIGNAL(operationCompleted(int)), 
-                        this, 
+                connect(mRemoveDraftOperation,
+                        SIGNAL(operationCompleted(int)),
+                        this,
                         SLOT(handleCompletedRemoveDraftOperation()));
             }
         }
-    }    
+    }
 }
 
 /*!
@@ -804,41 +802,41 @@
                                   const QList<NmOperation*> &preliminaryOperations)
 {
     NM_FUNCTION;
-    
+
     if (message) {
         NmDataPluginInterface *plugin =
             mPluginFactory->interfaceInstance(message->envelope().mailboxId());
-        
+
         if (plugin) {
             // to be on the safer side:
             // we shouldn't even be here if mSaveDraftOperation != NULL
             if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
                 mSaveDraftOperation->cancelOperation();
             }
-            
+
             mSaveDraftOperation = plugin->saveMessageWithSubparts(*message);
-            
+
             if (mSaveDraftOperation) {
-                // Ownership of message changes but saveMessageWithSubparts operation only makes a 
+                // Ownership of message changes but saveMessageWithSubparts operation only makes a
                 // copy so we handle the msg object deletion in engine. mDraftMessage is deleted
-                // in handleCompletedSaveDraftOperation once operation finishes. 
+                // in handleCompletedSaveDraftOperation once operation finishes.
                 if(mDraftMessage) {
                     delete mDraftMessage;
                     mDraftMessage = NULL;
                 }
                 mDraftMessage = message;
                 message = NULL;
-                
+
                 for (int i(0); i < preliminaryOperations.count(); i++ ) {
                     QPointer<NmOperation> op = preliminaryOperations[i];
                     mSaveDraftOperation->addPreliminaryOperation(op);
                 }
-                
-                connect(mSaveDraftOperation, 
-                        SIGNAL(operationCompleted(int)), 
-                        this, 
+
+                connect(mSaveDraftOperation,
+                        SIGNAL(operationCompleted(int)),
+                        this,
                         SLOT(handleCompletedSaveDraftOperation()));
-                
+
             }
         }
     }
@@ -850,12 +848,12 @@
 void NmUiEngine::sendMessage(NmMessage *message, const QList<NmOperation *> &preliminaryOperations)
 {
     NM_FUNCTION;
-    
+
     //First trigger message storing
     if (message) {
         NmDataPluginInterface *plugin =
             mPluginFactory->interfaceInstance(message->envelope().mailboxId());
-        
+
         if (plugin) {
             // to be on the safer side:
             // we shouldn't even be here if mSendOperation != NULL
@@ -871,10 +869,10 @@
                     QPointer<NmOperation> op = preliminaryOperations[i];
                     mSendOperation->addPreliminaryOperation(op);
                 }
-                
-                connect(mSendOperation, 
-                        SIGNAL(operationCompleted(int)), 
-                        this, 
+
+                connect(mSendOperation,
+                        SIGNAL(operationCompleted(int)),
+                        this,
                         SLOT(handleCompletedSendOperation()));
             }
         }
@@ -887,7 +885,7 @@
 bool NmUiEngine::isSendingMessage() const
 {
     NM_FUNCTION;
-    
+
     int ret(false);
     if (mSendOperation && mSendOperation->isRunning()) {
         ret = true;
@@ -901,13 +899,13 @@
 const NmMessage *NmUiEngine::messageBeingSent() const
 {
     NM_FUNCTION;
-    
+
     const NmMessage *message = NULL;
-    
+
     if (mSendOperation != NULL) {
         message = mSendOperation->getMessage();
     }
-    
+
     return message;
 }
 
@@ -920,11 +918,11 @@
     const QList<QString> &fileList)
 {
     NM_FUNCTION;
-    
+
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(message.envelope().mailboxId());
-    
-    QPointer<NmAddAttachmentsOperation> ret(NULL);    
+
+    QPointer<NmAddAttachmentsOperation> ret(NULL);
     if (plugin) {
         ret = plugin->addAttachments(message, fileList);
     }
@@ -940,11 +938,11 @@
     const NmId &attachmentPartId)
 {
     NM_FUNCTION;
-    
+
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(message.envelope().mailboxId());
-    
-    QPointer<NmOperation> ret(NULL);   
+
+    QPointer<NmOperation> ret(NULL);
     if (plugin) {
         ret = plugin->removeAttachment(message, attachmentPartId);
     }
@@ -957,7 +955,7 @@
 NmSyncState NmUiEngine::syncState(const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
     NmDataPluginInterface *plugin =
                 mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
@@ -974,7 +972,7 @@
 NmConnectState NmUiEngine::connectionState(const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
     NmDataPluginInterface *plugin =
                 mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
@@ -998,7 +996,7 @@
                        const QStringList &searchStrings)
 {
     NM_FUNCTION;
-    
+
     // Get the plugin instance.
     QObject *pluginInstance = mPluginFactory->pluginInstance(mailboxId);
 
@@ -1010,11 +1008,11 @@
 
         connect(pluginInstance, SIGNAL(matchFound(const NmId &, const NmId &)),
                 this, SLOT(handleMatchFound(const NmId &, const NmId &)),
-                Qt::UniqueConnection); 
+                Qt::UniqueConnection);
 
         connect(pluginInstance, SIGNAL(searchComplete()),
                 this, SIGNAL(searchComplete()),
-                Qt::UniqueConnection);    
+                Qt::UniqueConnection);
     }
 
     int retVal(NmNoError);
@@ -1027,7 +1025,7 @@
         // Start the search.
         retVal = pluginInterface->search(mailboxId, searchStrings);
     }
-    
+
     return retVal;
 }
 
@@ -1042,7 +1040,7 @@
 int NmUiEngine::cancelSearch(const NmId &mailboxId)
 {
     NM_FUNCTION;
-    
+
     int retVal(NmNoError);
 
     // Get the plugin interface.
@@ -1052,20 +1050,23 @@
     if (pluginInterface) {
         // Cancel the search.
         retVal = pluginInterface->cancelSearch(mailboxId);
-    }  
-    return retVal;    
+    }
+    return retVal;
 }
 
 /*!
+    Get mailbox folder type by folder id
+    \param mailboxId id of the mailbox
+    \param folderId id of the folder
     \return Folder type
 */
 NmFolderType NmUiEngine::folderTypeById(NmId mailboxId, NmId folderId)
 {
     NM_FUNCTION;
-    
+
     NmFolderType ret(NmFolderInbox);
     if (mDataManager){
-        ret = mDataManager->folderTypeById(mailboxId,folderId);    
+        ret = mDataManager->folderTypeById(mailboxId,folderId);
     }
     return ret;
 }
@@ -1078,8 +1079,8 @@
 void NmUiEngine::updateActiveFolder(const NmId &mailboxId, const NmId &folderId)
 {
     NM_FUNCTION;
-    
-    NmApplicationStateInterface *interface = 
+
+    NmApplicationStateInterface *interface =
         mPluginFactory->applicationStateInterfaceInstance(mailboxId);
     if (interface) {
         interface->updateActiveFolder(mailboxId, folderId);
@@ -1092,7 +1093,7 @@
 void NmUiEngine::handleCompletedSendOperation()
 {
     NM_FUNCTION;
-    
+
     emit sendOperationCompleted();
 }
 
@@ -1102,7 +1103,7 @@
 void NmUiEngine::handleCompletedRemoveDraftOperation()
 {
     NM_FUNCTION;
-    
+
     // draft message deletion observing not yet implemented...
 }
 
@@ -1112,7 +1113,7 @@
 void NmUiEngine::handleCompletedSaveDraftOperation()
 {
     NM_FUNCTION;
-    
+
     // delete message object since it's not needed anymore
     if(mDraftMessage) {
         delete mDraftMessage;
@@ -1126,12 +1127,12 @@
 void NmUiEngine::handleSyncStateEvent(NmSyncState syncState, const NmOperationCompletionEvent &event)
 {
     NM_FUNCTION;
-    
+
     if ( syncState == SyncComplete ) {
         // signal for reporting about (sync) operation completion status
         emit operationCompleted(event);
-        HbIndicator indicator;
-        indicator.deactivate(syncIndicatorName, QVariant());
+
+        enableSyncIndicator(false);
     }
 
     // signal for handling sync state icons
@@ -1139,23 +1140,42 @@
 }
 
 /*!
-    Emits signals based on message events coming from plugins. 
+    Enable or disable sync indicator
+
+    \param enabled true if indicator is enabled, false if disabled
+*/
+void NmUiEngine::enableSyncIndicator(bool enabled)
+{
+	NM_FUNCTION;
+
+    HbIndicator indicator;
+    if (enabled) {
+        indicator.activate(syncIndicatorName, QVariant());
+	}
+    else {
+        indicator.deactivate(syncIndicatorName, QVariant());
+	}
+}
+
+
+/*!
+    Emits signals based on message events coming from plugins.
     Currently only NmMessageDeleted is handled.
 */
 void NmUiEngine::handleMessageEvent(NmMessageEvent event,
                                     const NmId &folderId,
-                                    const QList<NmId> &messageIds, 
+                                    const QList<NmId> &messageIds,
                                     const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
     switch (event) {
         case NmMessageDeleted:
         {
             for (int i(0); i < messageIds.count(); i++) {
                 emit messageDeleted(mailboxId, folderId, messageIds[i]);
             }
-           break; 
+           break;
         }
         default:
         break;
@@ -1163,21 +1183,21 @@
 }
 
 /*!
-    Emits signals based on mailbox events coming from plugins. 
+    Emits signals based on mailbox events coming from plugins.
     Currently only NmMailboxDeleted is handled.
 */
 void NmUiEngine::handleMailboxEvent(NmMailboxEvent event,
                                     const QList<NmId> &mailboxIds)
 {
     NM_FUNCTION;
-    
+
     switch (event) {
         case NmMailboxDeleted:
         {
             for (int i(0); i < mailboxIds.count(); i++) {
                 emit mailboxDeleted(mailboxIds[i]);
             }
-           break; 
+           break;
         }
         default:
         break;
@@ -1194,7 +1214,7 @@
 void NmUiEngine::handleMatchFound(const NmId &messageId, const NmId &folderId)
 {
     NM_FUNCTION;
-    
+
     if (!mMessageSearchListModel) {
         // No search list model!
         return;
@@ -1222,21 +1242,21 @@
 */
 void NmUiEngine::messageEventForListModel(NmMessageEvent event,
                         const NmId &folderId,
-                        const QList<NmId> &messageIds, 
+                        const QList<NmId> &messageIds,
                         const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
     // Forward event to both list models. Models will take care of checking
     // whether event really belongs to current mailbox & folder
     if (mInboxListModel){
         mInboxListModel->handleMessageEvent(event, folderId,
-                                            messageIds, mailboxId);   
+                                            messageIds, mailboxId);
     }
     if (mMessageListModel){
         mMessageListModel->handleMessageEvent(event, folderId,
-                                              messageIds, mailboxId);    
-    }  
+                                              messageIds, mailboxId);
+    }
 }
 
 /*!
@@ -1245,13 +1265,13 @@
 void NmUiEngine::handleConnectEvent(NmConnectState connectState, const NmId &mailboxId, const int errorCode)
 {
     NM_FUNCTION;
-    
+
     // signal for connection state icon handling
     emit connectionEvent(connectState, mailboxId);
 
     // in case going offline w/ error, emit signal to UI
     if ( connectState == Disconnected && errorCode!= NmNoError ) {
-        NmOperationCompletionEvent event={NoOp, errorCode, mailboxId, 0, 0}; 
+        NmOperationCompletionEvent event={NoOp, errorCode, mailboxId, 0, 0};
         emit operationCompleted(event);
     }
 }
@@ -1262,7 +1282,7 @@
 NmId NmUiEngine::getPluginIdByMailboxId(quint32 accountId)
 {
     NM_FUNCTION;
-    
+
     NmId fullId = NULL;
     fullId.setId32(accountId);
     QList<NmId> mailboxList;
--- a/emailuis/nmailuiwidgets/nmailuiwidgets.qrc	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailuiwidgets/nmailuiwidgets.qrc	Fri Jul 09 12:17:13 2010 +0300
@@ -3,7 +3,8 @@
         <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="nmeditortexteditblack.css" >resources/nmeditortexteditblack.css</file>
+        <file alias="nmeditortexteditblue.css" >resources/nmeditortexteditblue.css</file>
         <file alias="nmeditortextedit.widgetml" >resources/nmeditortextedit.widgetml</file>
     </qresource>
 </RCC>
--- a/emailuis/nmailuiwidgets/src/nmeditortextedit.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmailuiwidgets/src/nmeditortextedit.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -17,7 +17,8 @@
 
 #include "nmailuiwidgetsheaders.h"
 
-static const QString FILE_PATH_CSS = ":nmeditortextedit.css";
+static const QString FILE_PATH_CSS_DEFAULT = ":nmeditortexteditblack.css";
+static const QString FILE_PATH_CSS_SECONDARY = ":nmeditortexteditblue.css";
 static const QString FILE_PATH_WIDGETML = ":nmeditortextedit.widgetml";
 
 /*!
@@ -29,7 +30,7 @@
     NM_FUNCTION;
     
     HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML);
-    HbStyleLoader::registerFilePath(FILE_PATH_CSS);
+    HbStyleLoader::registerFilePath(FILE_PATH_CSS_DEFAULT);
 
     mCustomTextColor = QPair<bool, QColor>(false, Qt::black);
     
@@ -43,9 +44,6 @@
     QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem (whitePixmap);
     setBackgroundItem(pixmapItem); 
     
-    // disables highlight frame for now - new api to set the frame item should be release somewhere wk26
-    setFocusHighlight(HbStyle::P_TextEdit_frame_highlight, HbWidget::FocusHighlightNone);
-    
     // Create custom palette based on the current one
     QPalette testPalette = QApplication::palette();
 
@@ -61,8 +59,6 @@
 
     // Update custom palette for this widget
     setPalette(testPalette);
-
-    connect(this, SIGNAL(contentsChanged()), this, SLOT(updateCustomTextColor()));
 }
 
 /*!
@@ -73,7 +69,12 @@
     NM_FUNCTION;
     
     HbStyleLoader::unregisterFilePath(FILE_PATH_WIDGETML);
-    HbStyleLoader::unregisterFilePath(FILE_PATH_CSS);    
+    if (mCustomTextColor.first) {
+		HbStyleLoader::unregisterFilePath(FILE_PATH_CSS_SECONDARY);    
+    }
+    else {
+		HbStyleLoader::unregisterFilePath(FILE_PATH_CSS_DEFAULT);    
+    }
 }
 
 /*!
@@ -131,11 +132,13 @@
 {   
     NM_FUNCTION;
     
-    mCustomTextColor.first = useCustom;
-    //check and set custom color
-    mCustomTextColor.first ? mCustomTextColor.second = color : 
-                             mCustomTextColor.second = mCustomTextColor.second;
-    
+    if (!mCustomTextColor.first && useCustom) {
+        HbStyleLoader::unregisterFilePath(FILE_PATH_CSS_DEFAULT);    
+        HbStyleLoader::registerFilePath(FILE_PATH_CSS_SECONDARY);
+
+        mCustomTextColor.first = useCustom;
+        mCustomTextColor.second = color;
+    }		
 }
 
 /*!
--- a/emailuis/nmframeworkadapter/src/nmframeworkadapter.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmframeworkadapter/src/nmframeworkadapter.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -113,7 +113,7 @@
 int NmFrameworkAdapter::listMailboxes(QList<NmMailbox*>& mailboxList)
 {
     NM_FUNCTION;
-    
+
     // get list of mailboxes from all plugins
     TFSMailMsgId id;
     id.SetNullId();
@@ -189,7 +189,7 @@
 int NmFrameworkAdapter::getFolderById( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder )
     {
     NM_FUNCTION;
-    
+
     TRAPD(err, getFolderByIdL( mailboxId, folderId, folder ) );
     return err;
     }
@@ -200,11 +200,11 @@
 void NmFrameworkAdapter::getFolderByIdL( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder )
     {
     NM_FUNCTION;
-    
+
     CFSMailFolder* fsFolder(NULL);
 	if (mFSfw)
 		{
-    	fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); 
+    	fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId));
     	if (fsFolder)
         	{
         	folder = fsFolder->GetNmFolder();
@@ -237,7 +237,7 @@
     NmMessage*& message)
 {
     NM_FUNCTION;
-    
+
     TRAPD(err, getMessageByIdL(mailboxId,folderId,messageId,message));
     return err;
 }
@@ -252,7 +252,7 @@
     NmMessage*& message)
 {
     NM_FUNCTION;
-    
+
     // select message details to be listed
     TFSMailDetails details(EFSMsgDataStructure);
 
@@ -275,10 +275,10 @@
 
 /*!
     Returns list of folders in a mailbox.
-	
+
 	\param mailboxId Id of the mailbox containing the folder.
 	\param folderList Reference to a pointer list to receive pointers to the folders.
-	
+
 	\return Error code.
  */
 int NmFrameworkAdapter::listFolders(
@@ -286,7 +286,7 @@
     QList<NmFolder*>& folderList)
 {
     NM_FUNCTION;
-    
+
     CFSMailBox* currentMailbox = NULL;
     TRAPD (err, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId));
     if (KErrNone == err) {
@@ -316,7 +316,7 @@
      const int maxEnvelopeCount)
 {
     NM_FUNCTION;
-    
+
     if (!folder || maxEnvelopeCount < 1) {
         return;
     }
@@ -342,7 +342,7 @@
     RArray<TFSMailSortCriteria> sorting;
     CleanupClosePushL(sorting);
     sorting.Append(criteria);
-   
+
     // Get the message list from the backend.
     MFSMailIterator* iterator(NULL);
     iterator = folder->ListMessagesL(details, sorting);
@@ -382,7 +382,7 @@
         iterator = NULL;
     }
 
-    CleanupStack::PopAndDestroy(); // sorting  
+    CleanupStack::PopAndDestroy(); // sorting
 }
 
 
@@ -402,7 +402,7 @@
     QList<NmMessageEnvelope*> &messageEnvelopeList)
 {
     NM_FUNCTION;
-    
+
     TRAPD(err, listMessagesL(mailboxId,folderId,messageEnvelopeList, NmMaxItemsInMessageList));
     return err;
 }
@@ -427,7 +427,7 @@
         const int maxAmountOfEnvelopes)
 {
     NM_FUNCTION;
-    
+
     TInt err = KErrNone;
     TRAP(err, listMessagesL(mailboxId,folderId, messageEnvelopeList,maxAmountOfEnvelopes) );
     return err;
@@ -445,7 +445,7 @@
         const int maxAmountOfEnvelopes)
 {
     NM_FUNCTION;
-    
+
     // If we are requesting 0 or less mails, we can just return.
     if (maxAmountOfEnvelopes <= 0) {
         return;
@@ -466,14 +466,14 @@
     if (folder) {
         CleanupStack::PushL(folder);
         getMessagesFromFolderL(folder, messageEnvelopeList, maxAmountOfEnvelopes);
-        CleanupStack::PopAndDestroy(folder);        
+        CleanupStack::PopAndDestroy(folder);
     }
 
     CleanupStack::PopAndDestroy(mailbox);
 }
 
 
-/*! 
+/*!
     Returns list of messages from the backend for specific mailbox and folder.
 
     \param mailboxId Id of the mailbox containing the folder.
@@ -490,7 +490,7 @@
     const int maxAmountOfMessages)
 {
     NM_FUNCTION;
-    
+
     TRAPD(err, listMessagesL(mailboxId,folderId,messageList, maxAmountOfMessages));
     return err;
 }
@@ -506,7 +506,7 @@
         const int maxAmountOfEnvelopes)
 {
     NM_FUNCTION;
-    
+
     CFSMailBox * currentMailbox(NULL);
     CFSMailFolder* folder(NULL);
 
@@ -527,7 +527,7 @@
             blockSize = maxAmountOfEnvelopes;
             }
         }
-   
+
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
     if (!currentMailbox) {
         User::Leave(KErrNotFound);
@@ -568,7 +568,7 @@
                   i += blockSize ) {
                 moreMessagesToFollow = iterator->NextL(
                     messages[i-1]->GetMessageId(), blockSize, messages);
-                
+
             }
 
             //Add all found emails to the result list
@@ -585,7 +585,7 @@
                     messageList.append(newMessage);
                 }
             }
-            
+
             CleanupStack::PopAndDestroy( &messages );
             CleanupStack::Pop(iterator);
             delete iterator;
@@ -613,7 +613,7 @@
                                const QStringList &searchStrings)
 {
     NM_FUNCTION;
-    
+
     if (!mSearchObserver) {
         mSearchObserver = new NmMailboxSearchObserver();
     }
@@ -634,14 +634,13 @@
     Cancels the search if one is ongoing.
 
     \param mailboxId The ID of the mailbox running the search.
-    
 
     \return A possible error code.
 */
 int NmFrameworkAdapter::cancelSearch(const NmId &mailboxId)
 {
     NM_FUNCTION;
-    
+
     // Get the mailbox with the given ID.
     CFSMailBox *mailbox(NULL);
     TRAPD(err, mailbox = mFSfw->GetMailBoxByUidL(mailboxId));
@@ -687,10 +686,10 @@
         mCurrentMailBox = mFSfw->GetMailBoxByUidL(mailboxId);
         }
     CEmailExtension *extension = getEMailStateExtensionL();
-    CMailboxStateExtension *stateExtension = 
-        static_cast<CMailboxStateExtension*>(extension);        
+    CMailboxStateExtension *stateExtension =
+        static_cast<CMailboxStateExtension*>(extension);
     if (stateExtension) {
-        stateExtension->NotifyActiveFolderChanged(mailboxId, folderId);    
+        stateExtension->NotifyActiveFolderChanged(mailboxId, folderId);
     }
 }
 
@@ -698,12 +697,12 @@
    function to process updateActiveFolder. This method may leave.
  */
 CEmailExtension* NmFrameworkAdapter::getEMailStateExtensionL()
-{      
+{
     if (!mStateExtension && mCurrentMailBox) {
         // This extension is owned and deleted by the plugin, so no need to
         // use release unless the extension will be relocated into extensionbase.
         mStateExtension =  mCurrentMailBox->ExtensionL(KEmailMailboxStateExtensionUid);
-    }    
+    }
     return mStateExtension;
 }
 
@@ -712,7 +711,7 @@
 
     \param mailboxId The mailbox to search from.
     \param folderIds (not used)
-    \param searchStrings The strings to search. 
+    \param searchStrings The strings to search.
     \param searchObserver The observer which gets informed about the progress
                           of the search (match found, search complete etc.)
 */
@@ -722,9 +721,9 @@
                                  NmMailboxSearchObserver &searchObserver)
 {
     NM_FUNCTION;
-    
+
     // CFSMailBox has no support for search using folder IDs.
-    Q_UNUSED(folderIds); 
+    Q_UNUSED(folderIds);
 
     // Get the mailbox with the given ID.
     CFSMailBox *mailbox(NULL);
@@ -771,7 +770,7 @@
     const NmId &messageId )
 {
     NM_FUNCTION;
-    
+
     NmOperation *oper = new NmFwaMessageFetchingOperation(mailboxId, folderId, messageId, *mFSfw);
     return oper;
 }
@@ -786,14 +785,14 @@
 
     \return An NmOperation object for the operation, ownership is transferred to caller
  */
-QPointer<NmOperation> NmFrameworkAdapter::fetchMessagePart( 
+QPointer<NmOperation> NmFrameworkAdapter::fetchMessagePart(
     const NmId &mailboxId,
     const NmId &folderId,
     const NmId &messageId,
     const NmId &messagePartId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> oper = new NmFwaMessagePartFetchingOperation(
             mailboxId, folderId, messageId, messagePartId, *mFSfw);
     return oper;
@@ -809,17 +808,17 @@
 
     \return An NmOperation object for the operation, ownership is transferred to caller
  */
-QPointer<NmOperation> NmFrameworkAdapter::fetchMessageParts( 
+QPointer<NmOperation> NmFrameworkAdapter::fetchMessageParts(
     const NmId &mailboxId,
     const NmId &folderId,
     const NmId &messageId,
     const QList<NmId> &messagePartIds)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> oper = new NmFwaMessagePartsFetchingOperation(
             mailboxId, folderId, messageId, messagePartIds, *mFSfw);
-    return oper;  
+    return oper;
 }
 
 /*!
@@ -839,23 +838,23 @@
         const NmId &messagePartId)
 {
     NM_FUNCTION;
-    
+
     XQSharableFile retFile;
     TFSMailDetails details(EFSMsgDataEnvelope);
     TFSMailMsgId fsMboxId(mailboxId);
     TFSMailMsgId fsFolderId(folderId);
     TFSMailMsgId fsMsgId(messageId);
     TFSMailMsgId fsMsgPartId(messagePartId);
-    
+
     CFSMailMessage* fsMessage = NULL;
     int error = KErrNone;
     TRAP(error, fsMessage = mFSfw->GetMessageByUidL(fsMboxId, fsFolderId,
             fsMsgId, details) );
-    
+
     CFSMailMessagePart* fsMessagePart = NULL;
     if (fsMessage && error == KErrNone) {
         TRAP(error, fsMessagePart = fsMessage->ChildPartL(fsMsgPartId) );
-        
+
     }
     if (fsMessagePart && error == KErrNone) {
         RFile file = fsMessagePart->GetContentFileL();
@@ -877,7 +876,7 @@
     NmFolderType folderType )
 {
     NM_FUNCTION;
-    
+
     TFSMailMsgId folderId;
     NmId resultId(0);
     CFSMailBox * currentMailbox(NULL);
@@ -980,7 +979,7 @@
     NmMessagePart &messagePart)
 {
     NM_FUNCTION;
-    
+
     TRAPD(err, contentToMessagePartL(mailboxId,folderId,messageId,messagePart));
     return err;
 }
@@ -995,7 +994,7 @@
     NmMessagePart &messagePart)
 {
     NM_FUNCTION;
-    
+
     CFSMailMessagePart* cfsPart = CFSMailMessagePart::NewLC(messageId,messagePart);
     cfsPart->SetMailBoxId(TFSMailMsgId(mailboxId));
     cfsPart->SetFolderId(TFSMailMsgId(folderId));
@@ -1037,8 +1036,8 @@
                 if (!codec) {
                     codec = QTextCodec::codecForName("UTF-8");
                 }
-                QString encodedStr = codec->toUnicode(msgBytes); 
-                messagePart.setTextContent(encodedStr, contentType);           
+                QString encodedStr = codec->toUnicode(msgBytes);
+                messagePart.setTextContent(encodedStr, contentType);
             }
             else {
                 messagePart.setBinaryContent(QByteArray(
@@ -1071,7 +1070,7 @@
 	const QList<NmId> &messageIdList)
 {
     NM_FUNCTION;
-    
+
     TInt err = NmNoError;
     RArray<TFSMailMsgId> messageIds;
     for (TInt i=0; i<messageIdList.size(); i++) {
@@ -1103,7 +1102,7 @@
 	const QList<const NmMessageEnvelope*> &envelopeList)
 {
     NM_FUNCTION;
-    
+
     Q_UNUSED(folderId);
 
     QPointer<NmStoreEnvelopesOperation> operation(NULL);
@@ -1134,7 +1133,7 @@
 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createNewMessage(const NmId &mailboxId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> oper =
         new NmFwaMessageCreationOperation(mailboxId, *mFSfw);
     return oper;
@@ -1153,7 +1152,7 @@
     const NmId &originalMessageId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> oper =
         new NmFwaForwardMessageCreationOperation(mailboxId, originalMessageId, *mFSfw);
     return oper;
@@ -1174,7 +1173,7 @@
     const bool replyAll)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> oper =
         new NmFwaReplyMessageCreationOperation(mailboxId, originalMessageId, replyAll, *mFSfw);
     return oper;
@@ -1186,7 +1185,7 @@
 int NmFrameworkAdapter::saveMessage(const NmMessage &message)
 {
     NM_FUNCTION;
-    
+
     Q_UNUSED(message);
     return NmNoError;
 }
@@ -1197,7 +1196,7 @@
 QPointer<NmOperation> NmFrameworkAdapter::saveMessageWithSubparts(const NmMessage &message)
 {
     NM_FUNCTION;
-    
+
     CFSMailMessage * cfsMessage = NULL;
     QPointer<NmOperation> oper(NULL);
 
@@ -1224,7 +1223,7 @@
     TAny* param3)
 {
     NM_FUNCTION;
-    
+
     switch (aEvent) {
         // Mailbox related events:
         case TFSEventNewMailbox:
@@ -1339,7 +1338,7 @@
     const NmId& messageId)
 {
     NM_FUNCTION;
-    
+
     TRAPD(error, removeMessageL(mailboxId, folderId, messageId));
     return error;
 }
@@ -1417,7 +1416,7 @@
     const NmId& messageId)
 {
     NM_FUNCTION;
-    
+
     CFSMailFolder* folder = mFSfw->GetFolderByUidL( TFSMailMsgId(mailboxId), TFSMailMsgId(folderId));
     CleanupStack::PushL(folder);
     if ( folder ) {
@@ -1439,25 +1438,25 @@
 
     RArray<TFSMailMsgId> messages;
     RArray<TFSMailMsgId> copiedMessages;
-    
+
     CleanupClosePushL(messages);
     CleanupClosePushL(copiedMessages);
-    
+
     for (TInt i = 0; i < messageIds.count(); i++) {
         NmId tmpId(messageIds[i]);
         messages.AppendL(TFSMailMsgId(tmpId));
     }
-    
+
     CFSMailBox* mailBox = NULL;
     mailBox = mFSfw->GetMailBoxByUidL(mailboxId);
     if (mailBox) {
-        mailBox->CopyMessagesL(messages, copiedMessages, 
-            TFSMailMsgId(sourceFolderId), 
+        mailBox->CopyMessagesL(messages, copiedMessages,
+            TFSMailMsgId(sourceFolderId),
             TFSMailMsgId(destinationFolderId));
         delete mailBox;
     }
-    
-    CleanupStack::PopAndDestroy(2,&messages);    
+
+    CleanupStack::PopAndDestroy(2,&messages);
 }
 
 /*!
@@ -1467,7 +1466,7 @@
     NmMessage *message)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageSendingOperation>oper = new NmFwaMessageSendingOperation(*this, message, *mFSfw);
 	return oper;
 }
@@ -1480,7 +1479,7 @@
     const QList<QString> &fileList)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmAddAttachmentsOperation>oper = new NmFwaAddAttachmentsOperation(message, fileList, *mFSfw);
     return oper;
 }
@@ -1493,7 +1492,7 @@
     const NmId &attachmentPartId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> oper = new NmFwaRemoveAttachmentOperation(message, attachmentPartId, *mFSfw);
     return oper;
 }
@@ -1504,7 +1503,7 @@
 NmSyncState NmFrameworkAdapter::syncState(const NmId& mailboxId) const
 {
     NM_FUNCTION;
-    
+
    CFSMailBox* mailBox = NULL;
    TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) );
    if (KErrNone == err && mailBox) {
@@ -1528,7 +1527,7 @@
 NmConnectState NmFrameworkAdapter::connectionState(const NmId& mailboxId) const
 {
     NM_FUNCTION;
-    
+
     CFSMailBox* mailBox = NULL;
     TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) );
     if (KErrNone == err && mailBox) {
@@ -1554,7 +1553,7 @@
     const NmMessageEnvelope& envelope)
 {
     NM_FUNCTION;
-    
+
     NmMessage* nmMessage = new(ELeave) NmMessage( envelope );
     CFSMailMessage* message = CFSMailMessage::NewL( *nmMessage );
     delete nmMessage;
@@ -1571,7 +1570,7 @@
         NmMessagePart *nmParent)
 {
     NM_FUNCTION;
-    
+
     User::LeaveIfNull(cfsParent);
     User::LeaveIfNull(nmParent);
 
@@ -1596,7 +1595,7 @@
 int NmFrameworkAdapter::RefreshMailboxL(NmId mailboxId)
 {
     NM_FUNCTION;
-    
+
     int result(KErrNotFound);
     CFSMailBox *currentMailbox(NULL);
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
@@ -1615,7 +1614,7 @@
 int NmFrameworkAdapter::GoOnlineL(const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
     int result(KErrNotFound);
     CFSMailBox *currentMailbox(NULL);
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
@@ -1634,7 +1633,7 @@
 int NmFrameworkAdapter::GoOfflineL(const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
 	int result(KErrNotFound);
     CFSMailBox *currentMailbox(NULL);
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
@@ -1653,10 +1652,12 @@
 void NmFrameworkAdapter::handleMailboxEvent( TFSMailMsgId mailbox, NmMailboxEvent event)
 {
     NM_FUNCTION;
-    
+
     QList<NmId> mailboxIds;
     NmId nmId;
-    if (event == NmMailboxDeleted) {
+    if (event == NmMailboxDeleted || 
+        event == NmMailboxCreated ||
+        event == NmMailboxChanged) {
 		nmId = mailbox.GetNmId();
     } else {
 		nmId = getMailboxIdByMailMsgId(mailbox);
@@ -1675,7 +1676,7 @@
     TFSMailMsgId mailbox)
 {
     NM_FUNCTION;
-    
+
     NmId nmMsgId(0);
     QList<NmId> messageIds;
     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
@@ -1697,7 +1698,7 @@
 void NmFrameworkAdapter::handleMailMoved(TAny* param1,TAny* param2,TAny* param3, TFSMailMsgId mailbox)
 {
     NM_FUNCTION;
-    
+
     NmId nmMsgId(0);
     QList<NmId> messageIds;
     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
@@ -1724,7 +1725,7 @@
 void NmFrameworkAdapter::handleMailCopied(TAny* param1,TAny* param2, TFSMailMsgId mailbox)
 {
     NM_FUNCTION;
-    
+
     NmId nmMsgId(0);
     QList<NmId> messageIds;
     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
--- a/emailuis/nmframeworkadapter/src/nmfwamessagepartsfetchingoperation.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmframeworkadapter/src/nmfwamessagepartsfetchingoperation.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -32,18 +32,18 @@
     mMailClient(mailClient), 
     mLastProgressValue(0), 
     mRequestId(0)
-
 {
     NM_FUNCTION;
     
     // Take own copy of the message part id list.
     mMessagePartIds.Reset();
     for (int i=0; i<messagePartIds.count(); ++i) {
-        mMessagePartIds.Append(
+        // let's ignore .Append return value here, the failing messages
+        // just won't be handled at this time
+        int ignore = mMessagePartIds.Append(
             NmConverter::nmIdToMailMsgId(
                 messagePartIds.at(i)));
     }
-    
 }
 
 /*!
--- a/emailuis/nmsettingui/src/nmsettingsviewfactory.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/emailuis/nmsettingui/src/nmsettingsviewfactory.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -65,7 +65,7 @@
    mMessageBox(0)
 {
     NM_FUNCTION;
-    
+
     createMessageBox();
 }
 
@@ -93,7 +93,7 @@
      mPrevView(0), mMessageBox(0)
 {
     NM_FUNCTION;
-    
+
     createMessageBox();
 }
 
@@ -104,7 +104,7 @@
 NmSettingsViewFactory::~NmSettingsViewFactory()
 {
     NM_FUNCTION;
-    
+
     delete mSettingsManager;
     delete mMessageBox;
 }
@@ -120,7 +120,7 @@
 CpBaseSettingView *NmSettingsViewFactory::createSettingView() const
 {
     NM_FUNCTION;
-    
+
     CpBaseSettingView *view = 0;
     QList<NmMailbox *> mailboxList;
     mSettingsManager->listMailboxes(mailboxList);
@@ -161,7 +161,7 @@
                 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
                 view, SLOT(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
     }
-    
+
     return view;
 }
 
@@ -176,66 +176,66 @@
                                               const QString &mailboxName) const
 {
     NM_FUNCTION;
-    
+
     // There's always at least one valid main window available.
     HbMainWindow *mainWindow = hbInstance->allMainWindows().takeFirst();
 
-    NmMailboxSettingView *currentSettingsView = 
+    NmMailboxSettingView *currentSettingsView =
         qobject_cast<NmMailboxSettingView*>(mainWindow->currentView());
-    
-    // Let's have only one same settings view at a time open, 
-    // but if some other mailboxes settings view want's to open while 
+
+    // Let's have only one same settings view at a time open,
+    // but if some other mailboxes settings view want's to open while
     // there is a settings view open let's open it also.
     if (!currentSettingsView || (currentSettingsView->mailboxId().id() != mailboxId.id())) {
         CpBaseSettingView *view =
              new NmMailboxSettingView(mailboxId, mailboxName, *mSettingsManager);
-         
+
          connect(mSettingsManager,
                  SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)),
                  view, SLOT(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)));
-     
+
          connect(mSettingsManager,
                  SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
                  view, SLOT(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
-     
-         // Disconnect mSettingsViewLauncher's previous connections to 
+
+         // Disconnect mSettingsViewLauncher's previous connections to
          // be sure that signals which are offered out will be sent last.
          mSettingsManager->disconnect(
              SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)),
              mSettingsViewLauncher,
              SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)));
-     
+
          mSettingsManager->disconnect(
              SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
              mSettingsViewLauncher,
              SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
-     
+
          // Reconnect mSettingsViewLauncher.
          connect(mSettingsManager,
                  SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)),
                  mSettingsViewLauncher,
                  SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)));
-     
+
          connect(mSettingsManager,
                  SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
                  mSettingsViewLauncher,
                  SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
-     
+
          connect(mSettingsManager,
                  SIGNAL(goOnline(const NmId &)),
                  mSettingsViewLauncher,
                  SIGNAL(goOnline(const NmId &)), Qt::UniqueConnection);
-     
+
          connect(mSettingsManager,
                  SIGNAL(goOffline(const NmId &)),
                  mSettingsViewLauncher,
                  SIGNAL(goOffline(const NmId &)), Qt::UniqueConnection);
-     
+
          connect(this,
                  SIGNAL(aboutToClose()),
                  mSettingsManager,
                  SIGNAL(aboutToClose()), Qt::UniqueConnection);
-     
+
          // Create back navigation action for a view.
          HbAction *action = new HbAction(Hb::BackNaviAction, view);
          connect(action, SIGNAL(triggered()), this, SLOT(backPress()));
@@ -243,7 +243,7 @@
          mPrevView = mainWindow->currentView();
          mainWindow->addView(view);
          mainWindow->setCurrentView(view);
-    }    
+    }
 }
 
 /*!
@@ -254,7 +254,7 @@
 void NmSettingsViewFactory::backPress()
 {
     NM_FUNCTION;
-    
+
     emit aboutToClose();
     HbMainWindow *mainWindow = hbInstance->allMainWindows().takeFirst();
     QList<HbView *> views = mainWindow->views();
@@ -278,7 +278,7 @@
 void NmSettingsViewFactory::launchWizard(HbAction *action)
 {
     NM_FUNCTION;
-    
+
     if (action == mMessageBox->primaryAction()) {
         // Launch mail wizard.
         NM_COMMENT(QString("NmSettingsViewFactory::launchWizard(): launching the mail wizard"));
@@ -294,10 +294,11 @@
 void NmSettingsViewFactory::createMessageBox()
 {
     NM_FUNCTION;
-    
+
     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
     mMessageBox->setText(hbTrId("txt_mail_dialog_no_mailboxes_create_new"));
     mMessageBox->setTimeout(HbMessageBox::NoTimeout);
+    mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
 }
 
 
--- a/ipsservices/ipssosplugin/inc/ipsplgeventhandler.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgeventhandler.h	Fri Jul 09 12:17:13 2010 +0300
@@ -180,9 +180,8 @@
      * Adds property observer, p&s (property) events are signaled to these
      * observers
      * @param aObservers interface to observer object
-     * @return error code from RProperty::Define function
      */
-    TInt RegisterPropertyObserverL( MIpsPlgPropertyObserver* aObserver );
+    void RegisterPropertyObserverL( MIpsPlgPropertyObserver* aObserver );
 
     /**
      * Removes property observer
@@ -389,7 +388,7 @@
     /**
     * Fills RArray FSMessage objects created from CMsvEntrySelection
     */
-    inline void FillFSMessageArray(
+    inline void FillFSMessageArrayL(
             RArray<TFSMailMsgId>& aFSArray,
             const CMsvEntrySelection* aSelection,
             TUint aMtmUid );
--- a/ipsservices/ipssosplugin/inc/ipsplgmsgiterator.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgmsgiterator.h	Fri Jul 09 12:17:13 2010 +0300
@@ -210,8 +210,7 @@
     CIpsPlgMsgIterator( 
         CIpsPlgSosBasePlugin& aPlugin,
         const TFSMailMsgId& aMailBoxId,
-        const TFSMailDetails aDetails,
-        const RArray<TFSMailSortCriteria>& aSorting );
+        const TFSMailDetails aDetails );
     
     void ConstructL(        
         CMsvSession& aMsvSession,
@@ -221,7 +220,10 @@
     void ConstructL(        
         CMsvEntry* aFolderEntry, 
         const RArray<TFSMailSortCriteria>& aSorting);
-
+    
+    void StoreSortCriteriaL( 
+        const RArray<TFSMailSortCriteria>& aSorting );
+    
 private: // data
 
     
@@ -236,6 +238,7 @@
      */
     CMsvEntry* iFolderEntry;
     
+    CMsvEntrySelection* iMessages;
     /**
      * Controls data to be returned
      */    
@@ -249,10 +252,10 @@
     /**
      * Sorting objects
      */    
-    TIpsPlgMsgKey*  iMsgSortKey;
-    TIpsPlgMsgSwap* iMsgSwapper;
-    TBool           iSortingOn;
-    const RArray<TFSMailSortCriteria>& iSortingCriteria;
+    TIpsPlgMsgKey*                  iMsgSortKey;
+    TIpsPlgMsgSwap*                 iMsgSwapper;
+    TBool                           iSortingOn;
+    RArray<TFSMailSortCriteria>     iSortingCriteria;
 
     /**
      * Mailbox identifier
--- a/ipsservices/ipssosplugin/inc/ipsplgmsgkey.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgmsgkey.h	Fri Jul 09 12:17:13 2010 +0300
@@ -83,7 +83,7 @@
     /**
      * Compares the subject strings omitting the reply & forward prefixes
      */
-    TInt CompareSubjectsL( const TDesC& aLeft, const TDesC& aRight ) const; // <cmail> change to leaving function
+    TInt CompareSubjects( const TDesC& aLeft, const TDesC& aRight ) const;
 
 private:
     // Folder objects the messages of which are sorted. Not owned.    
--- a/ipsservices/ipssosplugin/inc/ipsplgsearch.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgsearch.h	Fri Jul 09 12:17:13 2010 +0300
@@ -367,11 +367,16 @@
         /**
          * @param aCriteria Sorting criterias.
          */
-        TMsgContainer( 
-            const TMsvId& aId, 
+
+
+        /*TMsgContainer(
+            const TMsvId& aId,
             const TFSMailSortCriteria& aCriteria,
-            CMsvSession& aMsvSession );
-        
+            CMsvSession& aMsvSession );*/
+
+        TMsgContainer( const TMsvEntry& aEntry,
+            const TFSMailSortCriteria& aCriteria );
+
         /**
          * @param aMsgContainer MsgContainer to be compared.
          * @return ETrue, when content is greater than in parameter.
@@ -446,17 +451,19 @@
         /**
          * Entry to be used for compare operations.
          */
-        TMsvId iId;
+        //TMsvId iId;
                 
         /**
          * Reference to existing sort criteria.
          */
         const TFSMailSortCriteria& iCriteria;
         
+        TMsvEntry iEntry;
+
         /**
          * Message server session.
          */
-        CMsvSession& iMsvSession;
+        //CMsvSession& iMsvSession;
         };
 
     /**
--- a/ipsservices/ipssosplugin/inc/ipsplgsearch.inl	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgsearch.inl	Fri Jul 09 12:17:13 2010 +0300
@@ -209,7 +209,7 @@
 //
 TMsvId CIpsPlgSearch::TMsgContainer::Id() const
     {
-    return iId;
+    return iEntry.Id();
     }
 
 // End of File
--- a/ipsservices/ipssosplugin/inc/ipsplgsyncstatehandler.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgsyncstatehandler.h	Fri Jul 09 12:17:13 2010 +0300
@@ -95,7 +95,7 @@
     * @param aMailbox  id of mailbox to be append
     * @param aState state to be updated or added to mailbox
     */
-    void AppendMailboxToSyncingMailbox( TMsvId aMailbox, TInt aState );
+    void AppendMailboxToSyncingMailboxL( TMsvId aMailbox, TInt aState );
     
     TInt GetMailboxIpsState( TMsvId aMailbox );
     
--- a/ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -154,7 +154,7 @@
         TMsvId mboxId = iMBoxObservers[i]->iMBoxId.Id();
         if ( mboxes.Find(mboxId) == KErrNotFound )
             {
-            mboxes.Append( mboxId );
+            mboxes.AppendL( mboxId );
             }
         }
 
@@ -206,7 +206,7 @@
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
-TInt CIpsPlgEventHandler::RegisterPropertyObserverL(
+void CIpsPlgEventHandler::RegisterPropertyObserverL(
         MIpsPlgPropertyObserver* aObserver )
     {
     FUNC_LOG;
@@ -221,7 +221,7 @@
                 CActive::EPriorityIdle, *this );
         }
 
-    return iPropertyObservers.Append( aObserver );
+    iPropertyObservers.AppendL( aObserver );
     }
 
 // ----------------------------------------------------------------------------
@@ -492,7 +492,7 @@
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
-inline void CIpsPlgEventHandler::FillFSMessageArray(
+inline void CIpsPlgEventHandler::FillFSMessageArrayL(
     RArray<TFSMailMsgId>& aFSArray,
     const CMsvEntrySelection* aSelection,
     TUint aMtmUid )
@@ -504,7 +504,7 @@
 
     for ( TInt i = 0; i < aSelection->Count(); i++ )
         {
-        aFSArray.Append( SymId2FsId(aSelection->At(i), aMtmUid) );
+        aFSArray.AppendL( SymId2FsId(aSelection->At(i), aMtmUid) );
         }
     }
 
@@ -694,7 +694,7 @@
             RArray<TFSMailMsgId> array(KEventGranularity);
             CleanupClosePushL( array );
 
-            FillFSMessageArray(
+            FillFSMessageArrayL(
                 array,
                 static_cast<const CMsvEntrySelection*>(aArg1),
                 tNew.iMtm.iUid );
@@ -717,7 +717,7 @@
             // set entries array pointer
             RArray<TFSMailMsgId> array(1);
             CleanupClosePushL( array );
-            array.Append( SymId2FsId( tNew ) );
+            array.AppendL( SymId2FsId( tNew ) );
             arg1 = &array;
 
             // set parent pointer
@@ -766,7 +766,7 @@
 
         RArray<TFSMailMsgId> array(KEventGranularity);
         CleanupClosePushL( array );
-        FillFSMessageArray(
+        FillFSMessageArrayL(
             array,
             static_cast<const CMsvEntrySelection*>(aArg1),
             tMoved.iMtm.iUid );
@@ -935,7 +935,7 @@
                 }
             else
                 {
-                array.Append( SymId2FsId(deletedId, tEntry.iMtm.iUid) );
+                array.AppendL( SymId2FsId(deletedId, tEntry.iMtm.iUid) );
                 arg1 = &array;
                 arg2 = &parentId;
 
@@ -992,7 +992,7 @@
 
             RArray<TFSMailMsgId> array(1);
             CleanupClosePushL( array );
-            array.Append( msg );
+            array.AppendL( msg );
             arg1 = &array;
             arg2 = &parent;
             event = TFSEventMailDeleted;
@@ -1054,7 +1054,7 @@
             }
 
         // message entry
-        array.Append( SymId2FsId( tChanged )  );
+        array.AppendL( SymId2FsId( tChanged )  );
         arg1 = &array;
 
         // parent entry
@@ -1066,7 +1066,7 @@
         {
         event = TFSEventFolderChanged;
 
-        array.Append( SymId2FsId( tChanged ) );
+        array.AppendL( SymId2FsId( tChanged ) );
         arg1 = &array;
 
         TFSMailMsgId id = SymId2FsId( *(static_cast<TMsvId*>(aArg2)), tChanged.iMtm.iUid );
@@ -1078,7 +1078,7 @@
             TInt index = iImapFolderIds.Find(tChanged.Id());
             if ( eml.LocalSubscription() && index == KErrNotFound )
                 {
-                iImapFolderIds.Append( tChanged.Id() );
+                iImapFolderIds.AppendL( tChanged.Id() );
                 }
             else if ( !eml.LocalSubscription() && index != KErrNotFound )
                 {
@@ -1482,7 +1482,7 @@
         aFSParent.SetId( aParent.Id() );
         for ( TInt i = 0; i < aDeletedIds.Count(); i++ )
             {
-            aFSDeletedArray.Append(
+            aFSDeletedArray.AppendL(
                     TFSMailMsgId( iPluginId, aDeletedIds.At(i) ) );
             }
         }
--- a/ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -659,7 +659,7 @@
         if( folder )
      	    {
      	    CleanupStack::PushL( folder );
-     	    aFolderList.Append( folder );
+     	    aFolderList.AppendL( folder );
      	    CleanupStack::Pop( folder );
      	    }
         
@@ -669,7 +669,7 @@
         if( folder )
      	    {
      	    CleanupStack::PushL( folder );
-     	    aFolderList.Append( folder );
+     	    aFolderList.AppendL( folder );
      	    CleanupStack::Pop( folder );
      	    } 	    
      	    
@@ -679,7 +679,7 @@
         if( folder )
      	    {
      	    CleanupStack::PushL( folder );
-     	    aFolderList.Append( folder );
+     	    aFolderList.AppendL( folder );
      	    CleanupStack::Pop( folder );
      	    } 	   
         
--- a/ipsservices/ipssosplugin/src/ipsplgmsgiterator.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgmsgiterator.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -33,8 +33,7 @@
     {
     FUNC_LOG;
     CIpsPlgMsgIterator* self = 
-        new( ELeave ) CIpsPlgMsgIterator( aPlugin, aMailboxId, aDetails, 
-            aSorting );
+        new( ELeave ) CIpsPlgMsgIterator( aPlugin, aMailboxId, aDetails );
     CleanupStack::PushL( self );
     self->ConstructL( aMsvSession, aFolderId, aSorting );
     CleanupStack::Pop( self );
@@ -53,8 +52,7 @@
     {
     FUNC_LOG;
     CIpsPlgMsgIterator* self = 
-        new( ELeave ) CIpsPlgMsgIterator( aPlugin, aMailboxId, aDetails, 
-            aSorting );
+        new( ELeave ) CIpsPlgMsgIterator( aPlugin, aMailboxId, aDetails );
     CleanupStack::PushL( self );
     self->ConstructL( aFolderEntry, aSorting );
     CleanupStack::Pop( self );
@@ -73,6 +71,8 @@
     delete iMsgMapper;
     delete iMsgSortKey;
     delete iMsgSwapper;
+    delete iMessages;
+    iSortingCriteria.Reset();
     }
 
 // ---------------------------------------------------------------------------
@@ -89,15 +89,16 @@
     TBool result = EFalse;
     TInt baseIndex;
     
-    // Messages are sorted always before reading the messages 
-    Sort();
-    
-    CMsvEntrySelection* messages = FilterMessagesL();
-    CleanupStack::PushL( messages );
+    if ( !iMessages )
+        {
+        // Messages are sorted before first reading the messages 
+        Sort();
+        iMessages = FilterMessagesL();
+        }
 
     if ( !aCurrentMessageId.IsNullId() )
         {
-        baseIndex = messages->Find( aCurrentMessageId.Id() );
+        baseIndex = iMessages->Find( aCurrentMessageId.Id() );
         
         // aCurrentMessageId is not included to the result set
         if ( baseIndex != KErrNotFound )
@@ -112,12 +113,11 @@
         }
         
     if ( ( baseIndex != KErrNotFound ) && 
-         ( baseIndex < messages->Count() ) )
+         ( baseIndex < iMessages->Count() ) )
         {
-        result = NextL(baseIndex, messages, aCount, aMessages);
+        result = NextL(baseIndex, iMessages, aCount, aMessages);
         }
 
-    CleanupStack::PopAndDestroy(messages);
     return result;
     }
 
@@ -136,20 +136,20 @@
     TInt status;
     TInt baseIndex;
     
-    // Messages are sorted always before reading the messages 
-    Sort();
+    if ( !iMessages )
+        {
+        // Messages are sorted before first reading the messages 
+        Sort();
+        iMessages = FilterMessagesL();
+        }
 
-    CMsvEntrySelection* messages = FilterMessagesL();
-    CleanupStack::PushL( messages );
-
-    status = SearchL( messages, aStartWith, baseIndex );
+    status = SearchL( iMessages, aStartWith, baseIndex );
     
     if ( status == KErrNone )
         {
-        result = NextL(baseIndex, messages, aCount, aMessages);
+        result = NextL( baseIndex, iMessages, aCount, aMessages );
         }
 
-    CleanupStack::PopAndDestroy(messages);
     return result;
     }
 
@@ -168,15 +168,16 @@
     TBool result = EFalse;
     TInt baseIndex;
     
-    // Messages are sorted always before reading the messages 
-    Sort();
-
-    CMsvEntrySelection* messages = FilterMessagesL();
-    CleanupStack::PushL(messages);
+    if ( !iMessages )
+        {
+        // Messages are sorted before first reading the messages 
+        Sort();
+        iMessages = FilterMessagesL();
+        }
 
     if ( !aCurrentMessageId.IsNullId() )
         {
-        baseIndex = messages->Find(aCurrentMessageId.Id());
+        baseIndex = iMessages->Find(aCurrentMessageId.Id());
         
         // aCurrentMessageId is not included to the result set
         if ( baseIndex != KErrNotFound )
@@ -188,7 +189,7 @@
         {
         // check whether we should start from the end of 
         // the message list in the case of a NULL ID
-        baseIndex = messages->Count() - 1;
+        baseIndex = iMessages->Count() - 1;
         }
 
     // Actually, if the matching message is the first one, baseIndex is equal
@@ -198,10 +199,9 @@
     if ( ( baseIndex != KErrNotFound ) &&
          ( baseIndex >= 0 ) )
         {
-        result = PreviousL(baseIndex, messages, aCount, aMessages);
+        result = PreviousL(baseIndex, iMessages, aCount, aMessages);
         }
 
-    CleanupStack::PopAndDestroy(messages);
     return result;
     }
 
@@ -231,14 +231,13 @@
     CMsvEntrySelection* messages = FilterMessagesL();
     CleanupStack::PushL( messages );
 
-    status = SearchL( messages, aStartWith, baseIndex );
+    status = SearchL( iMessages, aStartWith, baseIndex );
     
     if (  status == KErrNone ) 
         {
-        result = PreviousL(baseIndex, messages, aCount, aMessages);
+        result = PreviousL(baseIndex, iMessages, aCount, aMessages);
         }
 
-    CleanupStack::PopAndDestroy(messages);
     return result;
     }
 
@@ -267,7 +266,7 @@
             {
             fsMsg = iMsgMapper->GetMailMessageL( iMailboxId, entry, 
                 iRequestedDetails );
-            aMessages.Append( fsMsg );
+            aMessages.AppendL( fsMsg );
             counter++;
             }
         i++;
@@ -307,7 +306,7 @@
             {
             fsMsg = iMsgMapper->GetMailMessageL( iMailboxId, entry, 
                 iRequestedDetails );
-            aMessages.Insert( fsMsg, 0 );
+            aMessages.InsertL( fsMsg, 0 );
             counter++;
             }
         i--;
@@ -323,10 +322,9 @@
 CIpsPlgMsgIterator::CIpsPlgMsgIterator( 
     CIpsPlgSosBasePlugin& aPlugin,
     const TFSMailMsgId& aMailboxId,
-    const TFSMailDetails aDetails,
-    const RArray<TFSMailSortCriteria>& aSorting )
+    const TFSMailDetails aDetails )
     : iPlugin( aPlugin ), iRequestedDetails( aDetails ), 
-      iSortingCriteria( aSorting ), iMailboxId( aMailboxId )
+      iMailboxId( aMailboxId )
     {
     FUNC_LOG;
     // none
@@ -344,7 +342,9 @@
     {
     FUNC_LOG;
     iFolderEntry  = aMsvSession.GetEntryL( aFolderId.Id() );
-    iMsgSortKey   = new (ELeave) TIpsPlgMsgKey( *iFolderEntry, aSorting );
+    
+    StoreSortCriteriaL(aSorting);
+    iMsgSortKey   = new (ELeave) TIpsPlgMsgKey( *iFolderEntry, iSortingCriteria );
     iMsgSwapper   = new (ELeave) TIpsPlgMsgSwap( *iFolderEntry );
     iSortingOn    = 
         ( aSorting.Count() > 0 ) && ( aSorting[0].iField != EFSMailDontCare);
@@ -363,7 +363,8 @@
     {
     FUNC_LOG;
     iFolderEntry  = aFolderEntry;
-    iMsgSortKey   = new (ELeave) TIpsPlgMsgKey( *iFolderEntry, aSorting );
+    StoreSortCriteriaL(aSorting);
+    iMsgSortKey   = new (ELeave) TIpsPlgMsgKey( *iFolderEntry, iSortingCriteria );
     iMsgSwapper   = new (ELeave) TIpsPlgMsgSwap( *iFolderEntry );
     iSortingOn    = 
         ( aSorting.Count() > 0 ) && ( aSorting[0].iField != EFSMailDontCare);
@@ -482,3 +483,19 @@
 	return filteredEntries;
 	}
 
+// -----------------------------------------------------------------------------
+// stores sort criteria given by user
+// -----------------------------------------------------------------------------
+void CIpsPlgMsgIterator::StoreSortCriteriaL( 
+     const RArray<TFSMailSortCriteria>& aSorting )
+    {
+    for ( TInt i=0; i < aSorting.Count(); i++ )
+        {
+        const TFSMailSortCriteria& criteria  = aSorting[i];
+        TFSMailSortCriteria fsCriteria;
+        fsCriteria.iField = criteria.iField;
+        fsCriteria.iOrder = criteria.iOrder;
+        iSortingCriteria.AppendL(fsCriteria);
+        }
+    }
+
--- a/ipsservices/ipssosplugin/src/ipsplgmsgkey.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgmsgkey.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -104,10 +104,8 @@
                 }
             case EFSMailSortBySubject:
                 {
-                // <cmail> due to changes in CompareSubject method
-                TRAP_IGNORE( result = CompareSubjectsL( 
-                    leftEntry.iDescription, rightEntry.iDescription ) );
-                // </cmail>
+                result = CompareSubjects( leftEntry.iDescription,
+                    rightEntry.iDescription );
                 break;
                 }
             case EFSMailSortByPriority:
@@ -142,7 +140,7 @@
                 }
             case EFSMailSortByUnread:
                 {
-                // In this context, an unread message is 'greater' than
+                // In this context, an read message is 'greater' than
                 // a read one
                 if ( !leftEntry.Unread() && rightEntry.Unread() ) 
                     {
@@ -212,7 +210,7 @@
 // Strips the subject prefixes before comparing the strings
 // ---------------------------------------------------------------------------
 
-TInt TIpsPlgMsgKey::CompareSubjectsL( 
+TInt TIpsPlgMsgKey::CompareSubjects(
     const TDesC& aLeft, 
     const TDesC& aRight ) const
     {
--- a/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -1085,7 +1085,7 @@
             childPart = GetMessagePartL( (*cEntry)[0].Id(), aMailBoxId, aMessageId );
             if( childPart )
                 {
-                aParts.Append( childPart );
+                aParts.AppendL( childPart );
                 }
             }
         }
@@ -1147,7 +1147,7 @@
         // Insert the new child part to the result array
         if ( childPart )
             {
-            aParts.Insert( childPart, position );
+            aParts.InsertL( childPart, position );
             childPart = NULL;
             }
         }
--- a/ipsservices/ipssosplugin/src/ipsplgsearch.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgsearch.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -107,8 +107,9 @@
 // CIpsPlgSearch::TMsgContainer::TMsgContainer()
 // ---------------------------------------------------------------------------
 //
-CIpsPlgSearch::TMsgContainer::TMsgContainer( 
-    const TMsvId& aId, 
+/*
+CIpsPlgSearch::TMsgContainer::TMsgContainer(
+    const TMsvId& aId,
     const TFSMailSortCriteria& aCriteria,
     CMsvSession& aMsvSession )
     :
@@ -118,6 +119,13 @@
     {
     FUNC_LOG;
     }
+*/
+CIpsPlgSearch::TMsgContainer::TMsgContainer( const TMsvEntry& aEntry,
+    const TFSMailSortCriteria& aCriteria ) :
+    iCriteria( aCriteria ), iEntry( aEntry )
+    {
+    FUNC_LOG;
+    }
 
 // ---------------------------------------------------------------------------
 // CIpsPlgSearch::TMsgContainer::TMsgContainer()
@@ -136,12 +144,12 @@
         break;
         
     case EFSMailSortByDate:
-        result = Entry( iId ).iDate > Entry( aMsgContainer.Id() ).iDate;
+        result = iEntry.iDate > aMsgContainer.iEntry.iDate;
         break;
 
     case EFSMailSortBySender:
         {
-        HBufC* leftSender = NULL;
+        /*HBufC* leftSender = NULL;
         HBufC* rightSender = NULL;
         
         GetSenderStringsCC( 
@@ -151,13 +159,14 @@
             rightSender );
         
         result = *leftSender > *rightSender;
-        CleanupStack::PopAndDestroy( 2, leftSender ); 
+        CleanupStack::PopAndDestroy( 2, leftSender );*/
+        result = iEntry.iDetails > aMsgContainer.iEntry.iDetails;
         }
         break;
     
     case EFSMailSortBySubject:
         {
-        HBufC* leftSubject = NULL;
+        /*HBufC* leftSubject = NULL;
         HBufC* rightSubject = NULL;
         
         GetSubjectStringsCC( 
@@ -167,28 +176,29 @@
             rightSubject );
 
         result = *leftSubject > *rightSubject;
-        CleanupStack::PopAndDestroy( 2, leftSubject ); 
+        CleanupStack::PopAndDestroy( 2, leftSubject );*/
+        result = iEntry.iDescription > aMsgContainer.iEntry.iDescription;
         }
         break;
 
     case EFSMailSortByPriority:
-        result = Entry( iId ).Priority() > Entry( aMsgContainer.Id() ).Priority();        
+        result = iEntry.Priority() > aMsgContainer.iEntry.Priority();
         break;
     
     case EFSMailSortByFlagStatus:
-        result = Entry( iId ).New() > Entry( aMsgContainer.Id() ).New();
+        result = iEntry.New() > aMsgContainer.iEntry.New();
         break;
     
     case EFSMailSortByUnread:
-        result = Entry( iId ).Unread() > Entry( aMsgContainer.Id() ).Unread();
+        result = iEntry.Unread() > aMsgContainer.iEntry.Unread();
         break;
     
     case EFSMailSortBySize:
-        result = Entry( iId ).iSize > Entry( aMsgContainer.Id() ).iSize;
+        result = iEntry.iSize > aMsgContainer.iEntry.iSize;
         break;
     
     case EFSMailSortByAttachment:
-        result = Entry( iId ).iDate > Entry( aMsgContainer.Id() ).iDate;        
+        result = iEntry.iDate > aMsgContainer.iEntry.iDate;
         break;
         }
            
@@ -212,12 +222,12 @@
         break;
         
     case EFSMailSortByDate:
-        result = Entry( iId ).iDate >= Entry( aMsgContainer.Id() ).iDate;
+        result = iEntry.iDate >= aMsgContainer.iEntry.iDate;
         break;
         
     case EFSMailSortBySender:
         {
-        HBufC* leftSender = NULL;
+        /*HBufC* leftSender = NULL;
         HBufC* rightSender = NULL;
         
         GetSenderStringsCC( 
@@ -227,13 +237,14 @@
             rightSender );
         
         result = *leftSender >= *rightSender;
-        CleanupStack::PopAndDestroy( 2, leftSender ); 
+        CleanupStack::PopAndDestroy( 2, leftSender );*/
+        result = iEntry.iDetails > aMsgContainer.iEntry.iDetails;
         }
         break;
         
     case EFSMailSortBySubject:
         {
-        HBufC* leftSubject = NULL;
+        /*HBufC* leftSubject = NULL;
         HBufC* rightSubject = NULL;
         
         GetSubjectStringsCC( 
@@ -243,32 +254,33 @@
             rightSubject );
 
         result = *leftSubject >= *rightSubject;
-        CleanupStack::PopAndDestroy( 2, leftSubject ); 
+        CleanupStack::PopAndDestroy( 2, leftSubject );*/
+        result = iEntry.iDescription > aMsgContainer.iEntry.iDescription;
         }
         break;
-            
+
     case EFSMailSortByPriority:
-        result = Entry( iId ).Priority() >= Entry( aMsgContainer.Id() ).Priority();        
+        result = iEntry.Priority() >= aMsgContainer.iEntry.Priority();
         break;
-    
+
     case EFSMailSortByFlagStatus:
-        result = Entry( iId ).New() >= Entry( aMsgContainer.Id() ).New();
+        result = iEntry.New() >= aMsgContainer.iEntry.New();
         break;
-    
+
     case EFSMailSortByUnread:
-        result = Entry( iId ).Unread() >= Entry( aMsgContainer.Id() ).Unread();
+        result = iEntry.Unread() >= aMsgContainer.iEntry.Unread();
         break;
-    
+
     case EFSMailSortBySize:
-        result = Entry( iId ).iSize >= Entry( aMsgContainer.Id() ).iSize;
+        result = iEntry.iSize >= aMsgContainer.iEntry.iSize;
         break;
-    
+
     case EFSMailSortByAttachment:
-        result = Entry( iId ).iDate >= Entry( aMsgContainer.Id() ).iDate;        
+        result = iEntry.iDate >= aMsgContainer.iEntry.iDate;
         break;
         }
-        
-    return result;        
+
+    return result;
     }
 
 // ---------------------------------------------------------------------------
@@ -288,12 +300,12 @@
         break;
         
     case EFSMailSortByDate:
-        result = Entry( iId ).iDate <= Entry( aMsgContainer.Id() ).iDate;
+        result = iEntry.iDate <= aMsgContainer.iEntry.iDate;
         break;
 
     case EFSMailSortBySender:
         {
-        HBufC* leftSender = NULL;
+        /*HBufC* leftSender = NULL;
         HBufC* rightSender = NULL;
         
         GetSenderStringsCC( 
@@ -303,13 +315,14 @@
             rightSender );
         
         result = *leftSender <= *rightSender;
-        CleanupStack::PopAndDestroy( 2, leftSender ); 
+        CleanupStack::PopAndDestroy( 2, leftSender );*/
+        result = iEntry.iDetails > aMsgContainer.iEntry.iDetails;
         }
         break;
     
     case EFSMailSortBySubject:
         {
-        HBufC* leftSubject = NULL;
+        /*HBufC* leftSubject = NULL;
         HBufC* rightSubject = NULL;
         
         GetSubjectStringsCC( 
@@ -319,34 +332,36 @@
             rightSubject );
 
         result = *leftSubject <= *rightSubject;
-        CleanupStack::PopAndDestroy( 2, leftSubject ); 
+        CleanupStack::PopAndDestroy( 2, leftSubject );*/
+        result = iEntry.iDescription > aMsgContainer.iEntry.iDescription;
         }
         break;
 
     case EFSMailSortByPriority:
-        result = Entry( iId ).Priority() <= Entry( aMsgContainer.Id() ).Priority();        
+        result = iEntry.Priority() <= aMsgContainer.iEntry.Priority();
         break;
-    
+
     case EFSMailSortByFlagStatus:
-        result = Entry( iId ).New() <= Entry( aMsgContainer.Id() ).New();
+        result = iEntry.New() <= aMsgContainer.iEntry.New();
         break;
-    
+
     case EFSMailSortByUnread:
-        result = Entry( iId ).Unread() <= Entry( aMsgContainer.Id() ).Unread();
+        result = iEntry.Unread() <= aMsgContainer.iEntry.Unread();
         break;
-    
+
     case EFSMailSortBySize:
-        result = Entry( iId ).iSize <= Entry( aMsgContainer.Id() ).iSize;
+        result = iEntry.iSize <= aMsgContainer.iEntry.iSize;
         break;
-    
+
     case EFSMailSortByAttachment:
-        result = Entry( iId ).iDate <= Entry( aMsgContainer.Id() ).iDate;        
+        result = iEntry.iDate <= aMsgContainer.iEntry.iDate;
         break;
         }
         
     return result;        
     }
 
+/*
 // ---------------------------------------------------------------------------
 // CIpsPlgSearch::TMsgContainer::GetSenderStringsCC()
 // ---------------------------------------------------------------------------
@@ -386,7 +401,7 @@
     aRightSubject = entry.iDescription.Alloc();
     TRAP_IGNORE( CleanupStack::PushL( aRightSubject ) );
     }
-
+*/
 // ---------------------------------------------------------------------------
 // CIpsPlgSearch::TMsgContainer::TMsgContainer()
 // ---------------------------------------------------------------------------
@@ -395,10 +410,11 @@
     const TMsgContainer& aMsgContainer )
     {
     FUNC_LOG;
-    iId = aMsgContainer.Id();
+    iEntry = aMsgContainer.iEntry;
+    /*Id() = aMsgContainer.Id();*/
     return *this;
     }
-
+/*
 // ---------------------------------------------------------------------------
 // CIpsPlgSearch::TMsgContainer::Entry()
 // ---------------------------------------------------------------------------
@@ -423,6 +439,7 @@
     aMsvSession.GetEntry( aId, service, entry );
     return entry;
     }
+    */
 
 // ======== CLASS CIPSPLGSEARCH ========     
     
@@ -993,11 +1010,11 @@
                  ( entry.iMtm.iUid == KSenduiMtmSmtpUidValue ||
                    entry.iMtm.iUid == iPlugin.MtmId().iUid ) )
                 {
-                iEmailMessages.AppendL( TMsgContainer( 
-                    entry.Id(), iCurrentSearch.iSortCriteria, iMsvSession ) );
-                }        
+                iEmailMessages.AppendL( TMsgContainer( entry,
+                    iCurrentSearch.iSortCriteria ) );
+                }
             }
-        }    
+        }
     }
 
 //Ask client if it wants to change the search prority (i.e. to enable search for contact)
--- a/ipsservices/ipssosplugin/src/ipsplgsyncstatehandler.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgsyncstatehandler.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -73,7 +73,7 @@
     if ( ( iPlugin.PluginId() == aPluginId ) &&
         ( aEvent == KIpsSosEmailSyncStarted || aEvent == KIpsSosEmailSyncCompleted ) )
         {
-        AppendMailboxToSyncingMailbox( aMailbox, aEvent );
+        AppendMailboxToSyncingMailboxL( aMailbox, aEvent );
         }
     }
 
@@ -210,7 +210,10 @@
             {
             ipsState = KIpsSosEmailSyncCompleted;
             }
-        TInt count = iSyncingMailboxes.Append( 
+        // the next call, FindMailbox, handles the case
+        // if .Append is failing, thus the return value can
+        // be ignored
+        TInt ignore = iSyncingMailboxes.Append( 
                 TIpsMailboxState( aMailbox, ipsState ) );
         index = FindMailbox( aMailbox );
         }
@@ -237,14 +240,14 @@
 
 // ---------------------------------------------------------------------------
 // --------------------------------------------------------------------------- 
-void CIpsPlgSyncStateHandler::AppendMailboxToSyncingMailbox( 
+void CIpsPlgSyncStateHandler::AppendMailboxToSyncingMailboxL( 
         TMsvId aMailbox, TInt aState )
     {
     FUNC_LOG;
     TInt index = FindMailbox( aMailbox );
     if ( index == KErrNotFound )
         {
-        iSyncingMailboxes.Append( TIpsMailboxState( aMailbox, aState ) );
+        iSyncingMailboxes.AppendL( TIpsMailboxState( aMailbox, aState ) );
         }
     else
         {
--- a/ipsservices/nmimapclientplugin/src/nmimapclientplugin.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/nmimapclientplugin/src/nmimapclientplugin.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -83,25 +83,25 @@
             HbMenu *standardFolders = new HbMenu();
             NmAction *inboxAction = new NmAction(0);
             inboxAction->setObjectName("imapclientplugin_folders_inbox");
-            inboxAction->setText(hbTrId("txt_mail_opt_folders_inbox"));
+            inboxAction->setText(hbTrId("txt_mail_opt_folder_sub_inbox"));
             inboxAction->setCheckable(true);
             connect(inboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderInbox()));
             standardFolders->addAction(inboxAction);
             NmAction *outboxAction = new NmAction(0);
             outboxAction->setObjectName("imapclientplugin_folders_outbox");
-            outboxAction->setText(hbTrId("txt_mail_opt_folders_outbox"));
+            outboxAction->setText(hbTrId("txt_mail_opt_folder_sub_outbox"));
             outboxAction->setCheckable(true);
             connect(outboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderOutbox()));
             standardFolders->addAction(outboxAction);
             NmAction *draftsAction = new NmAction(0);
             draftsAction->setObjectName("imapclientplugin_folders_drafts");
-            draftsAction->setText(hbTrId("txt_mail_opt_folders_drafts"));
+            draftsAction->setText(hbTrId("txt_mail_opt_folder_sub_drafts"));
             draftsAction->setCheckable(true);
             connect(draftsAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderDrafts()));
             standardFolders->addAction(draftsAction);
             NmAction *sentAction = new NmAction(0);
             sentAction->setObjectName("imapclientplugin_folders_sent");
-            sentAction->setText(hbTrId("txt_mail_opt_folders_sent"));
+            sentAction->setText(hbTrId("txt_mail_opt_folder_sub_sent"));
             sentAction->setCheckable(true);
             connect(sentAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderSent()));
             standardFolders->addAction(sentAction);
@@ -132,7 +132,7 @@
             // Add folders selection with sub-menu
             NmAction *foldersAction = new NmAction(0);
             foldersAction->setObjectName("baseclientplugin_folders");
-            foldersAction->setText(hbTrId("txt_mail_opt_folders"));
+            foldersAction->setText(hbTrId("txt_mail_opt_change_folder"));
             foldersAction->setMenu(standardFolders);
             actionList.append(foldersAction);
             }
--- a/ipsservices/nmipssettings/inc/nmipssettingsplugin.h	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/nmipssettings/inc/nmipssettingsplugin.h	Fri Jul 09 12:17:13 2010 +0300
@@ -62,6 +62,7 @@
 
     void createUserDefinedMode();
     void showMailInInboxModified(QPersistentModelIndex, QVariant value);
+    void itemPress(const QModelIndex &index);
 
 private:
 
--- a/ipsservices/nmipssettings/src/nmipssettingshelper.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/nmipssettings/src/nmipssettingshelper.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -346,10 +346,10 @@
     Creates the setting items under the Serverinfo group items user authentication.
 */
 void NmIpsSettingsHelper::createServerInfoGroupDynamicItems(bool hiddenItem)
-{   
+{
     HbDataFormModelItem *item = mContentItems.value(IpsServices::SMTPAuthentication);
     int insertIndex = mServerInfoGroupItem->indexOf(item) + 1;
-        
+
     // Username
     QVariant username;
     mSettingsManager.readSetting(IpsServices::OutgoingLoginName, username);
@@ -378,7 +378,7 @@
     mDataForm.addConnection(passwordItem, SIGNAL(editingFinished()),
                             this, SLOT(saveOutgoingPassword()));
     mServerInfoGroupItem->insertChild(insertIndex + 1, passwordItem);
-    
+
     mServerInfoDynamicItemsVisible = true;
 }
 
@@ -597,11 +597,12 @@
 void NmIpsSettingsHelper::deleteButtonPress()
 {
     if(!mDeleteConfirmationDialog) {
-        mDeleteConfirmationDialog = 
+        mDeleteConfirmationDialog =
             new HbMessageBox(HbMessageBox::MessageTypeQuestion);
         mDeleteConfirmationDialog->setText(
             hbTrId("txt_mail_dialog_do_you_want_to_delete_the_mailbox"));
         mDeleteConfirmationDialog->setTimeout(HbMessageBox::NoTimeout);
+        mDeleteConfirmationDialog->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
     }
     mDeleteConfirmationDialog->open(this, SLOT(handleMailboxDelete(HbAction *)));
 }
@@ -611,20 +612,20 @@
 */
 void NmIpsSettingsHelper::handleMailboxDelete(HbAction *action)
 {
-    if (action == mDeleteConfirmationDialog->actions().at(0)) {        
+    if (action == mDeleteConfirmationDialog->actions().at(0)) {
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = false;
-    
+
         QVariant mailboxName;
         mSettingsManager.readSetting(IpsServices::MailboxName, mailboxName);
-    
+
         // Display the progress note. Before display the note, remove the cancel
         // button.
         HbProgressDialog progressNote(HbProgressDialog::WaitDialog);
         progressNote.setText(hbTrId("txt_common_info_deleting"));
         progressNote.removeAction(progressNote.actions().at(0));
         progressNote.delayedShow();
-    
+
         if (!mSettingsManager.deleteMailbox()) {
             // The mailbox was deleted successfully.
 
@@ -633,16 +634,16 @@
 
             // Hide the progress note and display the "mailbox deleted" dialog.
             progressNote.close();
-            
+
             if (!mDeleteInformationDialog) {
-                mDeleteInformationDialog = 
+                mDeleteInformationDialog =
                     new HbMessageBox(HbMessageBox::MessageTypeInformation);
                 mDeleteInformationDialog->setText(
                     hbTrId("txt_mail_dpophead _1_deleted").arg(mailboxName.toString()));
                 mDeleteInformationDialog->setTimeout(HbMessageBox::NoTimeout);
             }
-            mDeleteInformationDialog->open(this, SLOT(handleMailboxDeleteUpdate(HbAction *)));            
-            
+            mDeleteInformationDialog->open(this, SLOT(handleMailboxDeleteUpdate(HbAction *)));
+
         } else {
             // Failed to delete the mailbox!
             progressNote.close();
@@ -824,13 +825,13 @@
 void NmIpsSettingsHelper::incomingPortChange(int index)
 {
     int previousindex = getCorrectIncomingPortRadioButtonIndex();
-    
+
     if (index == IpsServices::NmIpsSettingsDefault) {
         if (index != previousindex) {
             emit goOffline(mSettingsManager.mailboxId());
             mEmitOnline = true;
             int port = mSettingsManager.determineDefaultIncomingPort();
-            mSettingsManager.writeSetting(IpsServices::IncomingPort, port);    
+            mSettingsManager.writeSetting(IpsServices::IncomingPort, port);
         }
     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
         showIncomingPortInputDialog();
@@ -841,24 +842,24 @@
     Shows an input dialog for allowing the user to specify a incoming port.
 */
 void NmIpsSettingsHelper::showIncomingPortInputDialog()
-{    
+{
     // User can open the dialog multiple times, so delete the old ones first.
     delete mIncomingPortInputDialog;
     mIncomingPortInputDialog = 0;
     delete mIncomingPortInputValidator;
     mIncomingPortInputValidator = 0;
-    
+
     mIncomingPortInputDialog = new HbInputDialog();
     mIncomingPortInputDialog->setInputMode(HbInputDialog::IntInput);
     QVariant currentPort;
     mSettingsManager.readSetting(IpsServices::IncomingPort, currentPort);
     mIncomingPortInputValidator = new HbValidator();
-    mIncomingPortInputValidator->addField(new QIntValidator(0, 65535, 0), 
+    mIncomingPortInputValidator->addField(new QIntValidator(0, 65535, 0),
                         HbStringUtil::convertDigits(QString::number(currentPort.toInt())));
     mIncomingPortInputDialog->setValidator(mIncomingPortInputValidator);
     mIncomingPortInputDialog->setPromptText(
         hbTrId("txt_mailips_setlabel_incoming_port_user_defined"));
-    
+
     mIncomingPortInputDialog->open(this, SLOT(handleUserDefinedIncomingPortInput(HbAction *)));
 }
 
@@ -868,7 +869,7 @@
 void NmIpsSettingsHelper::handleUserDefinedIncomingPortInput(HbAction *action)
 {
     int previousindex = getCorrectIncomingPortRadioButtonIndex();
-    
+
     if (action == mIncomingPortInputDialog->actions().at(0)) {
         QVariant newPort = mIncomingPortInputDialog->value();
         emit goOffline(mSettingsManager.mailboxId());
@@ -882,7 +883,7 @@
 }
 
 /*!
-    Used for getting the index to display in the port radio button list 
+    Used for getting the index to display in the port radio button list
     \return index Used to set the selected value
 */
 int NmIpsSettingsHelper::getCorrectIncomingPortRadioButtonIndex()
@@ -903,9 +904,9 @@
     Saves the incoming secure connection value into database if user has changed the value.
 */
 void NmIpsSettingsHelper::incomingSecureConnectionItemChange(int index)
-{  
+{
     int previousindex = getCorrectIncomingSecureRadioButtonIndex();
-    
+
     if (previousindex != index) {
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
@@ -914,17 +915,17 @@
                 mSettingsManager.writeSetting(IpsServices::IncomingSecureSockets, true);
                 mSettingsManager.writeSetting(IpsServices::IncomingSSLWrapper, false);
                 break;
-    
+
             case IpsServices::EMailSslTls: // On (SSL/TLS)
                 mSettingsManager.writeSetting(IpsServices::IncomingSecureSockets, false);
                 mSettingsManager.writeSetting(IpsServices::IncomingSSLWrapper, true);
                 break;
-    
+
             case IpsServices::EMailSecurityOff: // Off
                 mSettingsManager.writeSetting(IpsServices::IncomingSecureSockets, false);
                 mSettingsManager.writeSetting(IpsServices::IncomingSSLWrapper, false);
                 break;
-    
+
              default:
                 break;
         }
@@ -949,10 +950,10 @@
     QVariant secureSSLWrapper;
     mSettingsManager.readSetting(IpsServices::IncomingSecureSockets, secureSockets);
     mSettingsManager.readSetting(IpsServices::IncomingSSLWrapper, secureSSLWrapper);
-    
+
     IpsServices::TIpsSetDataSecurityTypes securityType = IpsServices::EMailStartTls;
     // secureSockets == True
-    if (secureSockets.toBool()) { 
+    if (secureSockets.toBool()) {
         securityType = IpsServices::EMailStartTls;
     }
     // secureSockets == False & secureSSLWrapper == True
@@ -976,10 +977,10 @@
     QVariant secureSSLWrapper;
     mSettingsManager.readSetting(IpsServices::OutgoingSecureSockets, secureSockets);
     mSettingsManager.readSetting(IpsServices::OutgoingSSLWrapper, secureSSLWrapper);
-    
+
     IpsServices::TIpsSetDataSecurityTypes securityType = IpsServices::EMailStartTls;
     // secureSockets == True
-    if (secureSockets.toBool()) { 
+    if (secureSockets.toBool()) {
         securityType = IpsServices::EMailStartTls;
     }
     // secureSockets == False & secureSSLWrapper == True
@@ -999,14 +1000,14 @@
 void NmIpsSettingsHelper::folderPathChange(int index)
 {
     int previousindex = getCorrectFolderPathRadioButtonIndex();
-        
+
     if (index == IpsServices::NmIpsSettingsDefault) {
         if (index != previousindex ) {
             // Empty string sets the folder path to default.
-            mSettingsManager.writeSetting(IpsServices::FolderPath, "");    
+            mSettingsManager.writeSetting(IpsServices::FolderPath, "");
         }
     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
-        showFolderPathInputDialog();       
+        showFolderPathInputDialog();
     }
 }
 
@@ -1014,19 +1015,19 @@
     Show a input dialog for allowing the user to specify a folder path.
 */
 void NmIpsSettingsHelper::showFolderPathInputDialog()
-{   
+{
     // User can open the dialog multiple times, so delete the old one first.
     delete mFolderPathInputDialog;
     mFolderPathInputDialog = 0;
-    
+
     QVariant folderPath;
     mSettingsManager.readSetting(IpsServices::FolderPath, folderPath);
-    
+
     mFolderPathInputDialog = new HbInputDialog();
     mFolderPathInputDialog->setInputMode(HbInputDialog::TextInput);
     mFolderPathInputDialog->setPromptText(hbTrId("txt_mailips_setlabel_folder_path_user_defined"));
     mFolderPathInputDialog->setValue(folderPath.toString());
-    
+
     mFolderPathInputDialog->open(this, SLOT(handleUserDefinedFolderPathInput(HbAction *)));
 }
 
@@ -1036,10 +1037,10 @@
 void NmIpsSettingsHelper::handleUserDefinedFolderPathInput(HbAction *action)
 {
     int previousindex = getCorrectFolderPathRadioButtonIndex();
-    
+
     HbDataFormModelItem *item = mContentItems.value(IpsServices::FolderPath);
-    
-    if (action == mFolderPathInputDialog->actions().at(0)) { 
+
+    if (action == mFolderPathInputDialog->actions().at(0)) {
         QVariant newFolderPath = mFolderPathInputDialog->value();
         mSettingsManager.writeSetting(IpsServices::FolderPath, newFolderPath);
         //set selected index to default if user inputed empty string.
@@ -1135,14 +1136,14 @@
 }
 
 /*!
-    Used for getting the index to display in the inbox path radio button list 
+    Used for getting the index to display in the inbox path radio button list
     \return index Used to set the selected value
 */
 int NmIpsSettingsHelper::getCorrectFolderPathRadioButtonIndex()
 {
     QVariant folderPath;
     mSettingsManager.readSetting(IpsServices::FolderPath, folderPath);
-    
+
     int index(0);
     if (folderPath.toString().isEmpty()) {
         index = IpsServices::NmIpsSettingsDefault;
@@ -1282,13 +1283,13 @@
 void NmIpsSettingsHelper::outgoingPortChange(int index)
 {
     int previousindex = getCorrectOutgoingPortRadioButtonIndex();
-    
+
     if (index == IpsServices::NmIpsSettingsDefault) {
         if (index != previousindex) {
             emit goOffline(mSettingsManager.mailboxId());
             mEmitOnline = true;
             int port = mSettingsManager.determineDefaultOutgoingPort();
-            mSettingsManager.writeSetting(IpsServices::OutgoingPort, port);    
+            mSettingsManager.writeSetting(IpsServices::OutgoingPort, port);
         }
     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
         showOutgoingPortInputDialog();
@@ -1305,18 +1306,18 @@
     mOutgoingPortInputDialog = 0;
     delete mOutgoingPortInputValidator;
     mOutgoingPortInputValidator = 0;
-    
+
     mOutgoingPortInputDialog = new HbInputDialog();
     mOutgoingPortInputDialog->setInputMode(HbInputDialog::IntInput);
     QVariant currentPort;
     mSettingsManager.readSetting(IpsServices::OutgoingPort, currentPort);
     mOutgoingPortInputValidator = new HbValidator();
-    mOutgoingPortInputValidator->addField(new QIntValidator(0, 65535, 0), 
+    mOutgoingPortInputValidator->addField(new QIntValidator(0, 65535, 0),
                         HbStringUtil::convertDigits(QString::number(currentPort.toInt())));
     mOutgoingPortInputDialog->setValidator(mOutgoingPortInputValidator);
     mOutgoingPortInputDialog->setPromptText(
         hbTrId("txt_mailips_setlabel_incoming_port_user_defined"));
-    
+
     mOutgoingPortInputDialog->open(this, SLOT(handleUserDefinedOutgoingPortInput(HbAction *)));
 }
 
@@ -1327,7 +1328,7 @@
 void NmIpsSettingsHelper::handleUserDefinedOutgoingPortInput(HbAction *action)
 {
     int previousindex = getCorrectOutgoingPortRadioButtonIndex();
-    
+
     if (action == mOutgoingPortInputDialog->actions().at(0)) {
         QVariant newPort = mOutgoingPortInputDialog->value();
         emit goOffline(mSettingsManager.mailboxId());
@@ -1365,7 +1366,7 @@
 {
     QVariant outgoingPort;
     mSettingsManager.readSetting(IpsServices::OutgoingPort, outgoingPort);
-    
+
     int index = 0;
     int port = mSettingsManager.determineDefaultOutgoingPort();
     if (port == outgoingPort.toInt()) {
@@ -1399,7 +1400,7 @@
     incomingLoginName = temp.toString();
     mSettingsManager.readSetting(IpsServices::IncomingPassword, temp);
     incomingPassword = temp.toString();
-    
+
     if (outgoingAuthentication) {
         if (outgoingLoginName == incomingLoginName && outgoingPassword == incomingPassword) {
             index = IpsServices::EMailAuthSameAsIncoming;
@@ -1419,9 +1420,9 @@
     \param index Selected radio button index.
 */
 void NmIpsSettingsHelper::outgoingSecureConnectionItemChange(int index)
-{      
+{
     int previousindex = getCorrectOutgoingSecureRadioButtonIndex();
-    
+
     if (previousindex != index) {
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
@@ -1463,7 +1464,7 @@
 void NmIpsSettingsHelper::outgoingAuthenticationChange(int index)
 {
     int previousindex = getCorrectOutgoingAuthenticationRadioButtonIndex();
-    
+
     if (previousindex != index) {
         QVariant loginName;
         QVariant loginPassword;
@@ -1478,10 +1479,10 @@
             case IpsServices::EMailAuthSameAsIncoming: // Same as Incoming
                 deleteServerInfoGroupDynamicItems();
                 mSettingsManager.writeSetting(IpsServices::SMTPAuthentication, true);
-              
+
                 mSettingsManager.readSetting(IpsServices::IncomingLoginName, loginName);
                 mSettingsManager.writeSetting(IpsServices::OutgoingLoginName, loginName);
-                
+
                 mSettingsManager.readSetting(IpsServices::IncomingPassword, loginPassword);
                 mSettingsManager.writeSetting(IpsServices::OutgoingPassword, loginPassword);
                 break;
@@ -1490,7 +1491,7 @@
                 mSettingsManager.writeSetting(IpsServices::SMTPAuthentication, true);
                 createServerInfoGroupDynamicItems(false);
                 break;
-                
+
              default:
                 break;
         }
--- a/ipsservices/nmipssettings/src/nmipssettingsplugin.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/nmipssettings/src/nmipssettingsplugin.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -135,6 +135,8 @@
         connect(mSettingsHelper, SIGNAL(createUserDefinedMode()),
                 this, SLOT(createUserDefinedMode()));
         
+        connect(mForm, SIGNAL(pressed(QModelIndex)),
+                this, SLOT(itemPress(QModelIndex)));
         // Get the value if some ui items need to be hidden.
         QVariant data;
         mSettingsManager->readSetting(IpsServices::UserNameHidden, data);
@@ -655,4 +657,32 @@
     }
 }
 
+/*!
+    Called when item is pressed on the view.
+
+    \param index Index to the pressed item.
+*/
+void NmIpsSettingsPlugin::itemPress(const QModelIndex &index)
+{
+    NM_FUNCTION;
+    
+    int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt());
+    
+    if (type == HbDataFormModelItem::GroupItem) {
+        // Scroll the groupitem to top if needed.
+        HbDataFormViewItem *item = static_cast<HbDataFormViewItem *>(mForm->itemByIndex(index));
+        bool expanded = item->isExpanded();
+        
+        if (!expanded) {
+            mForm->scrollTo(index, HbAbstractItemView::PositionAtTop);
+        }
+    }
+    
+    if (type == HbDataFormModelItem::TextItem) {
+        // Turn off predictive input for line-edit.
+        HbDataFormViewItem *item = static_cast<HbDataFormViewItem *>(mForm->itemByIndex(index));
+        HbWidget *widget = item->dataItemContentWidget();
+        widget->setInputMethodHints(Qt::ImhNoPredictiveText);
+    }
+}
 Q_EXPORT_PLUGIN2(nmipssettings, NmIpsSettingsPlugin);
--- a/ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp	Fri Jul 02 15:55:16 2010 +0300
+++ b/ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp	Fri Jul 09 12:17:13 2010 +0300
@@ -88,25 +88,25 @@
             HbMenu *standardFolders = new HbMenu();
             NmAction *inboxAction = new NmAction(0);
             inboxAction->setObjectName("popclientplugin_folders_inbox");
-            inboxAction->setText(hbTrId("txt_mail_opt_folders_inbox"));
+            inboxAction->setText(hbTrId("txt_mail_opt_folder_sub_inbox"));
             inboxAction->setCheckable(true);
             connect(inboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderInbox()));
             standardFolders->addAction(inboxAction);
             NmAction *outboxAction = new NmAction(0);
             outboxAction->setObjectName("popclientplugin_folders_outbox");
-            outboxAction->setText(hbTrId("txt_mail_opt_folders_outbox"));
+            outboxAction->setText(hbTrId("txt_mail_opt_folder_sub_outbox"));
             outboxAction->setCheckable(true);
             connect(outboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderOutbox()));
             standardFolders->addAction(outboxAction);
             NmAction *draftsAction = new NmAction(0);
             draftsAction->setObjectName("popclientplugin_folders_drafts");
-            draftsAction->setText(hbTrId("txt_mail_opt_folders_drafts"));
+            draftsAction->setText(hbTrId("txt_mail_opt_folder_sub_drafts"));
             draftsAction->setCheckable(true);
             connect(draftsAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderDrafts()));
             standardFolders->addAction(draftsAction);
             NmAction *sentAction = new NmAction(0);
             sentAction->setObjectName("popclientplugin_folders_sent");
-            sentAction->setText(hbTrId("txt_mail_opt_folders_sent"));
+            sentAction->setText(hbTrId("txt_mail_opt_folder_sub_sent"));
             sentAction->setCheckable(true);
             connect(sentAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderSent()));
             standardFolders->addAction(sentAction);
@@ -137,7 +137,7 @@
             // Add folders selection with sub-menu
             NmAction *foldersAction = new NmAction(0);
             foldersAction->setObjectName("baseclientplugin_folders");
-            foldersAction->setText(hbTrId("txt_mail_opt_folders"));
+            foldersAction->setText(hbTrId("txt_mail_opt_change_folder"));
             foldersAction->setMenu(standardFolders);
             actionList.append(foldersAction);
             }