On Fri, 2007-08-17 at 13:33 +0200, Erland Nylend wrote:
> 1) if I'm using perl, is there any way I can read in the information
> in the index files? Is the data formatted in some standarized way,
> so that I can parse it, or use a module which read in the data?

With v1.0 it would be pretty easy, but v1.1 makes this more difficult
because it doesn't keep dovecot.index up-to-date all the time. Instead
you'd have to read dovecot.index and apply new changes from
dovecot.index.log.

> 2) how would you proceed, if the aim is to end up with dovecot
> notifying a database regarding the number of messages, and unread
> messages?

Create a plugin which overrides mail_storage.sync_deinit(). Quota plugin
could be used as an example:

static int quota_mailbox_sync_deinit(struct mailbox_sync_context *ctx,
                                     enum mailbox_status_items status_items,
                                     struct mailbox_status *status_r)
{
        struct quota_mailbox *qbox = QUOTA_CONTEXT(ctx->box);

        /* just in case sync_notify() wasn't called with uid=0 */
        quota_mailbox_sync_finish(qbox);

        return qbox->module_ctx.super.sync_deinit(ctx, status_items, status_r);
}

Call super.sync_deinit() with status_items having STATUS_UNREAD.
status_r->unseen then contains the unseen counter.

If you want to avoid useless database updates, you could call
mailbox_get_status() in sync_init() and save the unseen count there, and
then compare in sync_deinit() if it got changed.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to