241 foreach(QObject* pluginObject, *plugins) { |
241 foreach(QObject* pluginObject, *plugins) { |
242 NmDataPluginInterface *plugin = |
242 NmDataPluginInterface *plugin = |
243 mPluginFactory->interfaceInstance(pluginObject); |
243 mPluginFactory->interfaceInstance(pluginObject); |
244 if (plugin) { |
244 if (plugin) { |
245 plugin->listMailboxes(mailboxes); |
245 plugin->listMailboxes(mailboxes); |
246 } |
246 |
247 |
247 // Add the indicators |
248 // Add the indicators |
248 // Must be made in reverse order to show them properly in |
249 // Must be made in reverse order to show them properly in |
249 // HbIndicator menu |
250 // HbIndicator menu |
250 QListIterator<NmMailbox *> i(mailboxes); |
251 QListIterator<NmMailbox *> i(mailboxes); |
251 i.toBack(); |
252 i.toBack(); |
252 while (i.hasPrevious()) { |
253 while (i.hasPrevious()) { |
253 const NmMailbox *mailbox = i.previous(); |
254 const NmMailbox *mailbox = i.previous(); |
254 if (mailbox) { |
255 if (mailbox) { |
255 NmMailboxInfo *mailboxInfo = createMailboxInfo(*mailbox, plugin); |
256 NmMailboxInfo *mailboxInfo = createMailboxInfo(*mailbox, plugin); |
256 if (mailboxInfo) { |
257 if (mailboxInfo) { |
257 bool activate = updateUnreadCount(mailbox->id(), *mailboxInfo); |
258 bool activate = updateUnreadCount(mailbox->id(), *mailboxInfo); |
258 NM_COMMENT(QString("Mailbox %1 initial state: newUnread=%2 total=%3"). |
259 NM_COMMENT(QString("Mailbox %1 initial state: newUnread=%2 total=%3"). |
259 arg(mailboxInfo->mName). |
260 arg(mailboxInfo->mName). |
260 arg(mailboxInfo->mNewUnreadMailIdList.count()). |
261 arg(mailboxInfo->mNewUnreadMailIdList.count()). |
261 arg(mailboxInfo->mMailIdList.count())); |
262 arg(mailboxInfo->mMailIdList.count())); |
262 |
263 |
263 bool wasActive = isMailboxActive(mailbox->id()); |
264 bool wasActive = isMailboxActive(mailbox->id()); |
264 if (!wasActive) { |
265 if (!wasActive) { |
265 // do not activate the mailbox if it was left as hidden last time |
266 // do not activate the mailbox if it was left as hidden last time |
266 activate = false; |
267 activate = false; |
267 mailboxInfo->mNewUnreadMailIdList.clear(); |
268 mailboxInfo->mNewUnreadMailIdList.clear(); |
268 } |
|
269 |
|
270 mailboxInfo->mOutboxMails = getOutboxCount(mailbox->id(), |
|
271 mailboxInfo->mOutboxFolderId); |
|
272 if (mailboxInfo->mOutboxMails > 0 && wasActive) { |
|
273 activate = true; |
|
274 } |
|
275 |
|
276 // Create indicator for visible mailboxes |
|
277 updateMailboxState(mailbox->id(), activate, false); |
269 } |
278 } |
270 |
|
271 mailboxInfo->mOutboxMails = getOutboxCount(mailbox->id(), |
|
272 mailboxInfo->mOutboxFolderId); |
|
273 if (mailboxInfo->mOutboxMails > 0 && wasActive) { |
|
274 activate = true; |
|
275 } |
|
276 |
|
277 // Create indicator for visible mailboxes |
|
278 updateMailboxState(mailbox->id(), activate, false); |
|
279 } |
279 } |
280 } |
280 } |
281 } |
281 qDeleteAll(mailboxes); |
282 qDeleteAll(mailboxes); |
282 } |
283 } |
283 } |
284 updateUnreadIndicator(); |
284 updateUnreadIndicator(); |
285 updateSendIndicator(); |
285 updateSendIndicator(); |
286 } |
286 } |
287 |
287 |
704 { |
704 { |
705 NM_FUNCTION; |
705 NM_FUNCTION; |
706 |
706 |
707 NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); |
707 NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); |
708 |
708 |
709 if (mailboxInfo && folderId == mailboxInfo->mInboxFolderId) { |
709 if (mailboxInfo) { |
710 mailboxInfo->mInboxDeletedMessages++; |
710 if (folderId == mailboxInfo->mInboxFolderId) { |
711 |
711 mailboxInfo->mInboxDeletedMessages++; |
712 // Clear the IDs from 'new unread messages' list |
712 |
713 foreach (NmId messageId, messageIds) { |
713 // Clear the IDs from 'new unread messages' list |
714 mailboxInfo->mNewUnreadMailIdList.removeAll(messageId); |
714 foreach (NmId messageId, messageIds) { |
715 } |
715 mailboxInfo->mNewUnreadMailIdList.removeAll(messageId); |
716 |
716 } |
717 // All new unread messages are now deleted |
717 |
718 if (mailboxInfo->mNewUnreadMailIdList.count()==0) { |
718 // All new unread messages are now deleted |
719 NM_COMMENT(" No more new unread messages"); |
719 if (mailboxInfo->mNewUnreadMailIdList.count()==0) { |
720 updateUnreadIndicator(); |
720 NM_COMMENT(" No more new unread messages"); |
|
721 updateUnreadIndicator(); |
|
722 updateMailboxState(mailboxId); |
|
723 } |
|
724 } |
|
725 |
|
726 // Deleted mails from the outbox |
|
727 if (mailboxInfo->mOutboxFolderId == folderId) { |
|
728 mailboxInfo->mOutboxMails -= messageIds.count(); |
|
729 |
|
730 // Sanity check for the outbox count |
|
731 if (mailboxInfo->mOutboxMails < 0) { |
|
732 mailboxInfo->mOutboxMails = 0; |
|
733 } |
|
734 |
|
735 // The last mail was now deleted from outbox |
|
736 if (mailboxInfo->mOutboxMails == 0) { |
|
737 NM_COMMENT("NmMailAgent: last mail deleted from outbox"); |
|
738 updateSendIndicator(); |
|
739 } |
721 updateMailboxState(mailboxId); |
740 updateMailboxState(mailboxId); |
722 } |
741 } |
723 } |
|
724 |
|
725 // Deleted mails from the outbox |
|
726 if (mailboxInfo->mOutboxFolderId == folderId) { |
|
727 mailboxInfo->mOutboxMails -= messageIds.count(); |
|
728 |
|
729 // Sanity check for the outbox count |
|
730 if (mailboxInfo->mOutboxMails < 0) { |
|
731 mailboxInfo->mOutboxMails = 0; |
|
732 } |
|
733 |
|
734 // The last mail was now deleted from outbox |
|
735 if (mailboxInfo->mOutboxMails == 0) { |
|
736 NM_COMMENT("NmMailAgent: last mail deleted from outbox"); |
|
737 updateSendIndicator(); |
|
738 } |
|
739 updateMailboxState(mailboxId); |
|
740 } |
742 } |
741 } |
743 } |
742 |
744 |
743 /*! |
745 /*! |
744 Get next free indicator index, starting from 0. |
746 Get next free indicator index, starting from 0. |