emailservices/emailserver/cmailhandlerplugin/src/fsnotificationhandlerbaseimpl.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 11 0396474f30f5
child 22 d620048b4810
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
   237             if ( MessagesCauseNotificationL(
   237             if ( MessagesCauseNotificationL(
   238                      aMailbox,
   238                      aMailbox,
   239                      *parentFolder,
   239                      *parentFolder,
   240                      *newEntries ) )
   240                      *newEntries ) )
   241                 {
   241                 {
   242                 // it doesn't matter if the mailindicator won't get updated
   242                 TurnNotificationOn();
   243                 // its better have it not updated compared to a leave
       
   244                 TRAP_IGNORE(MailIndicatorHandlingL(aMailbox));                
       
   245                 }
   243                 }
   246             }
   244             }
   247          else
   245          else
   248             {
   246             {
   249             // If messages are in some other folder than in inbox
   247             // If messages are in some other folder than in inbox
   257         // moving of messages and changing message status has no
   255         // moving of messages and changing message status has no
   258         // effect on the notification.
   256         // effect on the notification.
   259         }
   257         }
   260     }
   258     }
   261 
   259 
   262 void CFSNotificationHandlerBase::MailIndicatorHandlingL(TFSMailMsgId aMailbox)
       
   263     {
       
   264     /** 
       
   265      * There is always a pair of keys for one mailbox
       
   266      * 1st keys is the plugin id (numberOfMailboxes*2-1)
       
   267      * 2nd is the mailboxId (numberOfMailboxes*2)
       
   268      */
       
   269     TInt numberOfMailboxes(0);
       
   270     CRepository* emailRepository = CRepository::NewL( KFreestyleEmailCenRep );
       
   271     CleanupStack::PushL(emailRepository);
       
   272     emailRepository->Get(KNumberOfMailboxesWithNewEmails, numberOfMailboxes);
       
   273     CRepository* commonEmailRepository = CRepository::NewL( KCmailDataRepository );
       
   274     CleanupStack::PushL(commonEmailRepository);
       
   275     if(numberOfMailboxes != 0)
       
   276         {
       
   277         RArray<TInt> repositoryIds;
       
   278         CleanupClosePushL(repositoryIds);
       
   279         TInt tmp(0);
       
   280         for(TInt i = 1 ; i <= numberOfMailboxes * 2; i++ )
       
   281             {                        
       
   282             emailRepository->Get(KNumberOfMailboxesWithNewEmails+i, tmp);
       
   283             repositoryIds.Append(tmp);
       
   284             }                    
       
   285         TInt index = repositoryIds.Find(static_cast<TInt>(aMailbox.Id()));
       
   286         // If it is we delete it from the array
       
   287         if(index != KErrNotFound )
       
   288             {
       
   289             //unless it is the last item, then we don't have to do anything
       
   290             if(index != (repositoryIds.Count()-1))
       
   291                 {
       
   292                 repositoryIds.Remove(index);
       
   293                 repositoryIds.Remove(index-1);               
       
   294                 // Rearrange the mailbox/mailplugin ids
       
   295                 // in the repository
       
   296                 for(TInt j = 0; j < repositoryIds.Count(); j++)
       
   297                     {
       
   298                     emailRepository->Set(KNumberOfMailboxesWithNewEmails + 1 + j, repositoryIds.operator [](j));
       
   299                     }       
       
   300                 // And write the current mailbox/plugin ids back to repository as the last items
       
   301                 emailRepository->Set(KNumberOfMailboxesWithNewEmails + ( numberOfMailboxes * 2 - 1 ), static_cast<TInt>(aMailbox.PluginId().iUid));
       
   302                 emailRepository->Set(KNumberOfMailboxesWithNewEmails + ( numberOfMailboxes * 2 ),static_cast<TInt>(aMailbox.Id()) );
       
   303                 commonEmailRepository->Set(KCmailNewEmailDisplayText,MailClient().GetMailBoxByUidL(aMailbox)->GetName());
       
   304                 }
       
   305             }
       
   306         else
       
   307             {
       
   308             //Create keys with right values and update the number of mailboxes
       
   309             numberOfMailboxes += 1;
       
   310             emailRepository->Set(KNumberOfMailboxesWithNewEmails, numberOfMailboxes);
       
   311             emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2 - 1), static_cast<TInt>(aMailbox.PluginId().iUid));
       
   312             emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2), static_cast<TInt>(aMailbox.Id()));  
       
   313             commonEmailRepository->Set(KCmailNewEmailDisplayText,MailClient().GetMailBoxByUidL(aMailbox)->GetName());
       
   314             }
       
   315         repositoryIds.Reset();
       
   316         CleanupStack::PopAndDestroy();//repositoryIds
       
   317         }
       
   318     else
       
   319         {
       
   320         //Create keys with right values and pudate the number of mailboxes
       
   321         numberOfMailboxes += 1;
       
   322         emailRepository->Set(KNumberOfMailboxesWithNewEmails, numberOfMailboxes);
       
   323         emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2 - 1), static_cast<TInt>(aMailbox.PluginId().iUid));
       
   324         emailRepository->Create(KNumberOfMailboxesWithNewEmails + (numberOfMailboxes * 2), static_cast<TInt>(aMailbox.Id()));
       
   325         commonEmailRepository->Set(KCmailNewEmailDisplayText,MailClient().GetMailBoxByUidL(aMailbox)->GetName());
       
   326         }
       
   327     CleanupStack::PopAndDestroy(2);// emailRepository, CommonEmailRepository    
       
   328     TurnNotificationOn();
       
   329     }
       
   330 
   260 
   331 CFSMailMessage* CFSNotificationHandlerBase::NewestMsgInFolderL(
   261 CFSMailMessage* CFSNotificationHandlerBase::NewestMsgInFolderL(
   332     /*const*/ CFSMailFolder& aFolder ) const
   262     /*const*/ CFSMailFolder& aFolder ) const
   333     {
   263     {
   334     FUNC_LOG;
   264     FUNC_LOG;