From 29a5598ab4ccdb0c9a6646f26932cc37889a781d Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Tue, 28 Dec 2010 17:30:37 +0200 Subject: imap4d: speed up asynchronous mailbox notifications. * imap4d/imap4d.h (util_format_attribute_flags): New prototype. * imap4d/sync.c: Rewrite using flag table to keep attribute flags, mu_mailbox_translate to convert uids to message numbers and MU_EVT_MAILBOX_MESSAGE_EXPUNGE event to report expunged messages. * imap4d/util.c (_imap4d_attrlist): Remove \Recent (util_attribute_to_type): Handle \Recent separately. (util_format_attribute_flags): New function. (util_print_flags): Rewrite as an extra entry point to the above. mailboxes: New event MU_EVT_MAILBOX_MESSAGE_EXPUNGE. * include/mailutils/observer.h: Rearrange and partially rename event constants (all uses updated): MU_EVT_MESSAGE_APPEND => MU_EVT_MAILBOX_MESSAGE_APPEND MU_EVT_AUTHORITY_FAILED => MU_EVT_FOLDER_AUTHORITY_FAILED (MU_EVT_MAILBOX_MESSAGE_EXPUNGE): New event. * libproto/mbox/mbox.c: Generate MU_EVT_MAILBOX_MESSAGE_EXPUNGE. * libproto/pop/mbox.c: Likewise. * libmailutils/base/amd.c: Likewise. --- libmailutils/base/amd.c | 10 +++++++++- libmailutils/mailbox/message.c | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'libmailutils') diff --git a/libmailutils/base/amd.c b/libmailutils/base/amd.c index 96d55cc39..0bda6734b 100644 --- a/libmailutils/base/amd.c +++ b/libmailutils/base/amd.c @@ -900,7 +900,8 @@ amd_append_message (mu_mailbox_t mailbox, mu_message_t msg) char *qid; if (amd->cur_msg_file_name (mhm, &qid) == 0) { - mu_observable_notify (mailbox->observable, MU_EVT_MESSAGE_APPEND, + mu_observable_notify (mailbox->observable, + MU_EVT_MAILBOX_MESSAGE_APPEND, qid); free (qid); } @@ -1148,6 +1149,7 @@ amd_expunge (mu_mailbox_t mailbox) struct _amd_message *mhm; size_t i; int updated = amd->has_new_msg; + size_t expcount = 0; if (amd == NULL) return EINVAL; @@ -1175,9 +1177,15 @@ amd_expunge (mu_mailbox_t mailbox) if (amd->delete_msg) { + size_t expevt[2] = { i + 1, expcount }; rc = amd->delete_msg (amd, mhm); if (rc) return rc; + + mu_observable_notify (mailbox->observable, + MU_EVT_MAILBOX_MESSAGE_EXPUNGE, + expevt); + ++expcount; } else { diff --git a/libmailutils/mailbox/message.c b/libmailutils/mailbox/message.c index 644cd00bf..684fe39e4 100644 --- a/libmailutils/mailbox/message.c +++ b/libmailutils/mailbox/message.c @@ -534,9 +534,7 @@ mu_message_destroy (mu_message_t *pmsg, void *owner) is very unfortunate. The `owner' stuff is a leftover from older mailutils versions. - There is an ongoing attempt to remove it in the stream-cleanup - branch. When it is ready, it will be merged to the HEAD and this - will finally resolve this issue. */ + We are heading to removing it altogether. */ if (msg->ref > 0) msg->ref--; if ((msg->owner && msg->owner == owner) -- cgit v1.2.1