return refcount <= 1 ? 1 : 0;
}
+static bool lazy_expunge_is_internal_mailbox(struct mailbox *box)
+{
+ struct mail_namespace *ns = box->list->ns;
+ struct lazy_expunge_mail_user *luser =
+ LAZY_EXPUNGE_USER_CONTEXT(ns->user);
+ struct lazy_expunge_mailbox_list *llist =
+ LAZY_EXPUNGE_LIST_CONTEXT(box->list);
+
+ if (llist == NULL) {
+ /* lazy_expunge not enabled at all */
+ return FALSE;
+ }
+ if (llist->internal_namespace) {
+ /* lazy-expunge namespace */
+ return TRUE;
+ }
+ if (luser->lazy_mailbox_vname != NULL &&
+ strcmp(luser->lazy_mailbox_vname, box->vname) == 0) {
+ /* lazy-expunge mailbox */
+ return TRUE;
+ }
+ return FALSE;
+}
+
static void lazy_expunge_mail_expunge(struct mail *_mail)
{
struct mail_namespace *ns = _mail->box->list->ns;
union mail_module_context *mmail = LAZY_EXPUNGE_MAIL_CONTEXT(mail);
struct lazy_expunge_transaction *lt =
LAZY_EXPUNGE_CONTEXT(_mail->transaction);
- struct lazy_expunge_mailbox_list *llist;
- struct mailbox *real_box;
struct mail *real_mail;
struct mail_save_context *save_ctx;
const char *error;
lt->failed = TRUE;
return;
}
- real_box = real_mail->box;
- llist = LAZY_EXPUNGE_LIST_CONTEXT(real_box->list);
- if (llist != NULL && llist->internal_namespace) {
+ if (lazy_expunge_is_internal_mailbox(real_mail->box)) {
mmail->super.expunge(_mail);
return;
}
box->vlast = &mbox->super;
MODULE_CONTEXT_SET_SELF(box, lazy_expunge_mail_storage_module, mbox);
- if (!llist->internal_namespace) {
+ if (!lazy_expunge_is_internal_mailbox(box)) {
v->transaction_begin = lazy_expunge_transaction_begin;
v->transaction_commit = lazy_expunge_transaction_commit;
v->transaction_rollback = lazy_expunge_transaction_rollback;
v->rename_box = lazy_expunge_mailbox_rename;
- } else {
+ } else if (llist->internal_namespace) {
v->rename_box = lazy_expunge_mailbox_rename;
+ } else {
+ /* internal mailbox in a non-internal namespace -
+ don't add any unnecessary restrictions to it. if it's not
+ wanted, just use the ACL plugin. */
}
}
return;
luser->lazy_ns = mail_namespace_find_prefix(namespaces, luser->env);
- if (luser->lazy_ns == NULL) {
+ if (luser->lazy_ns != NULL) {
+ /* we don't want to override this namespace's expunge operation. */
+ llist = LAZY_EXPUNGE_LIST_CONTEXT(luser->lazy_ns->list);
+ llist->internal_namespace = TRUE;
+ } else {
/* store the the expunged mails to the specified mailbox. */
luser->lazy_ns = mail_namespace_find(namespaces, luser->env);
luser->lazy_mailbox_vname = luser->env;
}
mail_namespace_ref(luser->lazy_ns);
-
- /* we don't want to override this namespace's expunge operation. */
- llist = LAZY_EXPUNGE_LIST_CONTEXT(luser->lazy_ns->list);
- llist->internal_namespace = TRUE;
}
static void lazy_expunge_user_deinit(struct mail_user *user)