emailservices/emailserver/cmailhandlerplugin/src/cmailcpshandler.cpp
changeset 4 e7aa27f58ae1
parent 3 a4d6f1ea0416
child 8 e1b6206813b4
--- a/emailservices/emailserver/cmailhandlerplugin/src/cmailcpshandler.cpp	Tue Jan 26 11:45:42 2010 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/src/cmailcpshandler.cpp	Tue Feb 02 00:02:40 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2008 - 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"
@@ -23,6 +23,7 @@
 #include <apgcli.h>
 #include <centralrepository.h>
 #include <starterdomaincrkeys.h>
+#include <startupdomainpskeys.h>
 
 #include "emailtrace.h"
 #include "CFSMailClient.h"
@@ -326,7 +327,6 @@
     {
     FUNC_LOG;    
 
-    TBool mailBoxFound(EFalse);
     if ( aMailBoxNumber < iAccountsArray.Count() )
         {
         TFSMailMsgId mailBoxId;
@@ -336,7 +336,6 @@
         mailbox = MailClient().GetMailBoxByUidL( mailBoxId );
         if(mailbox)
             {
-            mailBoxFound = ETrue;
             TFSMailMsgId parentFolder( mailbox->GetStandardFolderId( EFSInbox ) );
             // Check that folder is correct
             CFSMailFolder* folder = MailClient().GetFolderByUidL( mailBoxId, parentFolder );
@@ -348,7 +347,8 @@
             CleanupStack::PushL( folder );
 
             TInt msgCount = folder->GetMessageCount();
-            if(msgCount<1)
+            
+            if(msgCount<1 || (msgCount == 1 && aRow == 3))
                 {
                 UpdateEmptyMessagesL( aWidgetInstance, aRow );
                 CleanupStack::PopAndDestroy( folder );
@@ -376,7 +376,7 @@
             TFSMailMsgId dummy;
             iterator->NextL( dummy, aMessageNumber, folderMessages);
             TInt count (folderMessages.Count());
-            if(!count)
+            if(!count || (count == 1 && aRow == 3))
                 {
                 UpdateEmptyMessagesL( aWidgetInstance, aRow );
             
@@ -429,10 +429,6 @@
             CleanupStack::PopAndDestroy( folder );
             }
         }
-    else if(!mailBoxFound)
-        {
-        UpdateEmptyMessagesL( aWidgetInstance, aRow );
-        }
     }
 
 
@@ -793,7 +789,7 @@
     }
 
 // ---------------------------------------------------------
-// CMailCpsHandler::HandleMailborRenamedEventL
+// CMailCpsHandler::HandleMailboxRenamedEventL
 // ---------------------------------------------------------
 //
 void CMailCpsHandler::HandleMailboxRenamedEventL( const TFSMailMsgId aMailbox )
@@ -1646,7 +1642,13 @@
 void CMailCpsHandler::DissociateWidgetFromSettingL( const TDesC& aContentId )
     {
     FUNC_LOG;
-    iSettings->DissociateWidgetFromSettingL( aContentId );
+    //Do not dissociate if device is shutting down
+    TInt status( 0 );
+    RProperty::Get( KPSUidStartup, KPSGlobalSystemState, status );
+    if (status != ESwStateShuttingDown)
+        {
+        iSettings->DissociateWidgetFromSettingL( aContentId );
+        }
     }
 
 // ---------------------------------------------------------------------------