equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008 - 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
21 #include <emailwidget.rsg> |
21 #include <emailwidget.rsg> |
22 #include <AknUtils.h> |
22 #include <AknUtils.h> |
23 #include <apgcli.h> |
23 #include <apgcli.h> |
24 #include <centralrepository.h> |
24 #include <centralrepository.h> |
25 #include <starterdomaincrkeys.h> |
25 #include <starterdomaincrkeys.h> |
|
26 #include <startupdomainpskeys.h> |
26 |
27 |
27 #include "emailtrace.h" |
28 #include "emailtrace.h" |
28 #include "CFSMailClient.h" |
29 #include "CFSMailClient.h" |
29 #include "CFSMailBox.h" |
30 #include "CFSMailBox.h" |
30 #include "CFSMailFolder.h" |
31 #include "CFSMailFolder.h" |
324 const TInt aMessageNumber, |
325 const TInt aMessageNumber, |
325 const TInt aRow ) |
326 const TInt aRow ) |
326 { |
327 { |
327 FUNC_LOG; |
328 FUNC_LOG; |
328 |
329 |
329 TBool mailBoxFound(EFalse); |
|
330 if ( aMailBoxNumber < iAccountsArray.Count() ) |
330 if ( aMailBoxNumber < iAccountsArray.Count() ) |
331 { |
331 { |
332 TFSMailMsgId mailBoxId; |
332 TFSMailMsgId mailBoxId; |
333 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
333 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
334 |
334 |
335 CFSMailBox* mailbox( NULL ); |
335 CFSMailBox* mailbox( NULL ); |
336 mailbox = MailClient().GetMailBoxByUidL( mailBoxId ); |
336 mailbox = MailClient().GetMailBoxByUidL( mailBoxId ); |
337 if(mailbox) |
337 if(mailbox) |
338 { |
338 { |
339 mailBoxFound = ETrue; |
|
340 TFSMailMsgId parentFolder( mailbox->GetStandardFolderId( EFSInbox ) ); |
339 TFSMailMsgId parentFolder( mailbox->GetStandardFolderId( EFSInbox ) ); |
341 // Check that folder is correct |
340 // Check that folder is correct |
342 CFSMailFolder* folder = MailClient().GetFolderByUidL( mailBoxId, parentFolder ); |
341 CFSMailFolder* folder = MailClient().GetFolderByUidL( mailBoxId, parentFolder ); |
343 if ( !folder ) |
342 if ( !folder ) |
344 { |
343 { |
346 return; |
345 return; |
347 } |
346 } |
348 CleanupStack::PushL( folder ); |
347 CleanupStack::PushL( folder ); |
349 |
348 |
350 TInt msgCount = folder->GetMessageCount(); |
349 TInt msgCount = folder->GetMessageCount(); |
351 if(msgCount<1) |
350 |
|
351 if(msgCount<1 || (msgCount == 1 && aRow == 3)) |
352 { |
352 { |
353 UpdateEmptyMessagesL( aWidgetInstance, aRow ); |
353 UpdateEmptyMessagesL( aWidgetInstance, aRow ); |
354 CleanupStack::PopAndDestroy( folder ); |
354 CleanupStack::PopAndDestroy( folder ); |
355 return; |
355 return; |
356 } |
356 } |
374 CleanupDeletePushL( iterator ); // standard CleanupStack::PushL does not work with non-C-class pointer |
374 CleanupDeletePushL( iterator ); // standard CleanupStack::PushL does not work with non-C-class pointer |
375 |
375 |
376 TFSMailMsgId dummy; |
376 TFSMailMsgId dummy; |
377 iterator->NextL( dummy, aMessageNumber, folderMessages); |
377 iterator->NextL( dummy, aMessageNumber, folderMessages); |
378 TInt count (folderMessages.Count()); |
378 TInt count (folderMessages.Count()); |
379 if(!count) |
379 if(!count || (count == 1 && aRow == 3)) |
380 { |
380 { |
381 UpdateEmptyMessagesL( aWidgetInstance, aRow ); |
381 UpdateEmptyMessagesL( aWidgetInstance, aRow ); |
382 |
382 |
383 CleanupStack::PopAndDestroy( iterator ); |
383 CleanupStack::PopAndDestroy( iterator ); |
384 CleanupStack::PopAndDestroy( &sorting ); |
384 CleanupStack::PopAndDestroy( &sorting ); |
427 CleanupStack::PopAndDestroy( &sorting ); |
427 CleanupStack::PopAndDestroy( &sorting ); |
428 CleanupStack::PopAndDestroy( &folderMessages ); |
428 CleanupStack::PopAndDestroy( &folderMessages ); |
429 CleanupStack::PopAndDestroy( folder ); |
429 CleanupStack::PopAndDestroy( folder ); |
430 } |
430 } |
431 } |
431 } |
432 else if(!mailBoxFound) |
|
433 { |
|
434 UpdateEmptyMessagesL( aWidgetInstance, aRow ); |
|
435 } |
|
436 } |
432 } |
437 |
433 |
438 |
434 |
439 // --------------------------------------------------------- |
435 // --------------------------------------------------------- |
440 // CMailCpsHandler::GetMessageTimeStringL |
436 // CMailCpsHandler::GetMessageTimeStringL |
791 |
787 |
792 iSettings->AddMailboxL( aMailbox ); |
788 iSettings->AddMailboxL( aMailbox ); |
793 } |
789 } |
794 |
790 |
795 // --------------------------------------------------------- |
791 // --------------------------------------------------------- |
796 // CMailCpsHandler::HandleMailborRenamedEventL |
792 // CMailCpsHandler::HandleMailboxRenamedEventL |
797 // --------------------------------------------------------- |
793 // --------------------------------------------------------- |
798 // |
794 // |
799 void CMailCpsHandler::HandleMailboxRenamedEventL( const TFSMailMsgId aMailbox ) |
795 void CMailCpsHandler::HandleMailboxRenamedEventL( const TFSMailMsgId aMailbox ) |
800 { |
796 { |
801 for ( TInt ii = iAccountsArray.Count() - 1; ii >= 0; --ii ) |
797 for ( TInt ii = iAccountsArray.Count() - 1; ii >= 0; --ii ) |
1644 // --------------------------------------------------------------------------- |
1640 // --------------------------------------------------------------------------- |
1645 // |
1641 // |
1646 void CMailCpsHandler::DissociateWidgetFromSettingL( const TDesC& aContentId ) |
1642 void CMailCpsHandler::DissociateWidgetFromSettingL( const TDesC& aContentId ) |
1647 { |
1643 { |
1648 FUNC_LOG; |
1644 FUNC_LOG; |
1649 iSettings->DissociateWidgetFromSettingL( aContentId ); |
1645 //Do not dissociate if device is shutting down |
|
1646 TInt status( 0 ); |
|
1647 RProperty::Get( KPSUidStartup, KPSGlobalSystemState, status ); |
|
1648 if (status != ESwStateShuttingDown) |
|
1649 { |
|
1650 iSettings->DissociateWidgetFromSettingL( aContentId ); |
|
1651 } |
1650 } |
1652 } |
1651 |
1653 |
1652 // --------------------------------------------------------------------------- |
1654 // --------------------------------------------------------------------------- |
1653 // CMailCpsHandler::GetMailboxCount |
1655 // CMailCpsHandler::GetMailboxCount |
1654 // --------------------------------------------------------------------------- |
1656 // --------------------------------------------------------------------------- |