| branch | RCL_3 |
| changeset 12 | f5907b1a1053 |
| parent 8 | e1b6206813b4 |
| child 13 | 0396474f30f5 |
--- a/emailservices/emailserver/cmailhandlerplugin/src/fsnotificationhandlerbaseimpl.cpp Fri Feb 19 22:37:30 2010 +0200 +++ b/emailservices/emailserver/cmailhandlerplugin/src/fsnotificationhandlerbaseimpl.cpp Fri Mar 12 15:41:14 2010 +0200 @@ -15,7 +15,7 @@ * */ - +#include <centralrepository.h> //<cmail> #include "emailtrace.h" #include "cfsmailclient.h" @@ -24,6 +24,9 @@ #include "fsnotificationhandlermgr.h" #include "fsnotificationhandlerbase.h" #include "cmailhandlerpluginpanic.h" +#include "commonemailcrkeys.h" +#include "FreestyleEmailCenRepKeys.h" +#include "FreestyleEmailuiConstants.h" // ======== MEMBER FUNCTIONS ======== @@ -236,7 +239,9 @@ *parentFolder, *newEntries ) ) { - TurnNotificationOn(); + // it doesn't matter if the mailindicator won't get updated + // its better have it not updated compared to a leave + TRAP_IGNORE(MailIndicatorHandlingL(aMailbox)); } } else @@ -254,7 +259,74 @@ } } - +void CFSNotificationHandlerBase::MailIndicatorHandlingL(TFSMailMsgId aMailbox) + { + /** + * There is always a pair of keys for one mailbox + * 1st keys is the plugin id (numberOfMailboxes*2-1) + * 2nd is the mailboxId (numberOfMailboxes*2) + */ + TInt numberOfMailboxes(0); + CRepository* emailRepository = CRepository::NewL( KFreestyleEmailCenRep ); + CleanupStack::PushL(emailRepository); + emailRepository->Get(KNumberOfMailboxesWithNewEmails, numberOfMailboxes); + CRepository* commonEmailRepository = CRepository::NewL( KCmailDataRepository ); + CleanupStack::PushL(commonEmailRepository); + if(numberOfMailboxes != 0) + { + RArray<TInt> repositoryIds; + CleanupClosePushL(repositoryIds); + TInt tmp(0); + for(TInt i = 1 ; i <= numberOfMailboxes * 2; i++ ) + { + emailRepository->Get(KNumberOfMailboxesWithNewEmails+i, tmp); + repositoryIds.Append(tmp); + } + TInt index = repositoryIds.Find(static_cast<TInt>(aMailbox.Id())); + // If it is we delete it from the array + if(index != KErrNotFound ) + { + //unless it is the last item, then we don't have to do anything + if(index != (repositoryIds.Count()-1)) + { + repositoryIds.Remove(index); + repositoryIds.Remove(index-1); + // Rearrange the mailbox/mailplugin ids + // in the repository + for(TInt j = 0; j < repositoryIds.Count(); j++) + { + emailRepository->Set(KNumberOfMailboxesWithNewEmails + 1 + j, repositoryIds.operator [](j)); + } + // And write the current mailbox/plugin ids back to repository as the last items + emailRepository->Set(KNumberOfMailboxesWithNewEmails + ( numberOfMailboxes * 2 - 1 ), static_cast<TInt>(aMailbox.PluginId().iUid)); + emailRepository->Set(KNumberOfMailboxesWithNewEmails + ( numberOfMailboxes * 2 ),static_cast<TInt>(aMailbox.Id()) ); + commonEmailRepository->Set(KCmailNewEmailDisplayText,MailClient().GetMailBoxByUidL(aMailbox)->GetName()); + } + } + else + { + //Create keys with right values and update the number of mailboxes + numberOfMailboxes += 1; + emailRepository->Set(KNumberOfMailboxesWithNewEmails, numberOfMailboxes); + emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2 - 1), static_cast<TInt>(aMailbox.PluginId().iUid)); + emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2), static_cast<TInt>(aMailbox.Id())); + commonEmailRepository->Set(KCmailNewEmailDisplayText,MailClient().GetMailBoxByUidL(aMailbox)->GetName()); + } + repositoryIds.Reset(); + CleanupStack::PopAndDestroy();//repositoryIds + } + else + { + //Create keys with right values and pudate the number of mailboxes + numberOfMailboxes += 1; + emailRepository->Set(KNumberOfMailboxesWithNewEmails, numberOfMailboxes); + emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2 - 1), static_cast<TInt>(aMailbox.PluginId().iUid)); + emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2), static_cast<TInt>(aMailbox.Id())); + commonEmailRepository->Set(KCmailNewEmailDisplayText,MailClient().GetMailBoxByUidL(aMailbox)->GetName()); + } + CleanupStack::PopAndDestroy(2);// emailRepository, CommonEmailRepository + TurnNotificationOn(); + } CFSMailMessage* CFSNotificationHandlerBase::NewestMsgInFolderL( /*const*/ CFSMailFolder& aFolder ) const