[Dovecot] Know when a Folder is Expunged or Deleted

Alex Baule alexwbaule at gmail.com
Wed Nov 3 13:38:17 EET 2010


Hi Timo....

I try to do what you said, but i can't delete a folder from maildir, because
the box->opened it's allways true.

This is my hooked function...

static int emexis_mailbox_delete(struct mailbox *box)
{
    union mailbox_module_context *zbox = EMEXIS_CONTEXT(box);

    if (!box->opened) {
        i_warning("Empty Folder...");
        return zbox->super.delete(box);
    }
    i_warning("Full Folder...");
    return -1;
}

Can i do that in "rename mailbox" function ? If Rename has .Trash in the
name, i don't rename and return -1.

Another Question...

i Try too, don't let the user "move" one message from any folder to my
"quarantine" folder, i intercept the copy function with a hook, but i only
can do this, returning -1 in the copy function, but with -1 i will get a
error message in the client like "Mailbox already exist" if i return 0 the
source email is flaged as Trash and don't show anymore in the source
folder... Can i do this, returning some value that works well and dont cause
a client message ?

Tks Timo !



2010/11/2 Timo Sirainen <tss at iki.fi>

> On Mon, 2010-11-01 at 14:26 -0200, Alex Baule wrote:
>
> > I intercept the expunge function, to treat my files expunged, but when i
> > expunge a folder, this function it's not called, and my emails don't get
> my
> > treatment to be expunged.
>
> Yeah.. Maybe some day I should change the mailbox deletion to work by
> sending expunge to all mails and then simply removing the empty mailbox.
> This is how it works with multi-dbox, but not with others.
>
> > Basically i need to do something like this:
> >
> > It's empty ? No --> return OK but Dont Delete folder, because it's not
> > empty.
> >                   Yes --> Return OK and Delete the Folder to be expunged.
>
> So you want to disallow deleting non-empty folders? Anyway, you need to
> hook into struct mailbox.delete. See quota_mailbox_delete() in quota
> plugin. box->opened=TRUE if it was a real selectable mailbox, while it's
> FALSE if it was simply a directory (Maildir++ has only selectable
> mailboxes).
>
>
>


More information about the dovecot mailing list