expire-plugin.c revision bbd4c4cf902539c25c471157eb9849459734759c
/* Copyright (c) 2006-2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "str.h"
#include "master-service.h"
#include "dict.h"
#include "mail-namespace.h"
#include "index-mail.h"
#include "index-storage.h"
#include "expire-set.h"
#include "expire-plugin.h"
#include <stdlib.h>
#define EXPIRE_CONTEXT(obj) \
#define EXPIRE_MAIL_CONTEXT(obj) \
#define EXPIRE_USER_CONTEXT(obj) \
struct expire_mail_user {
struct expire_set *set;
};
struct expire_mailbox {
union mailbox_module_context module_ctx;
};
struct expire_transaction_context {
unsigned int saves:1;
unsigned int first_expunged:1;
};
const char *expire_plugin_version = DOVECOT_VERSION;
static struct mailbox_transaction_context *
{
struct mailbox_transaction_context *t;
struct expire_transaction_context *xt;
return t;
}
static void first_nonexpunged_timestamp(struct mailbox_transaction_context *t,
{
const struct mail_index_header *hdr;
/* find the first non-expunged mail. we're here because the first
mail was expunged, so don't bother checking it. */
break;
}
}
/* everything expunged */
*stamp_r = 0;
}
}
{
struct mailbox_transaction_context *t;
const struct mail_index_header *hdr;
*stamp_r = ioloop_time;
t = mailbox_transaction_begin(box, 0);
/* find the first non-expunged mail. we're here because the first
mail was expunged, so don't bother checking it. */
if (hdr->messages_count > 0) {
}
(void)mailbox_transaction_commit(&t);
}
static int
struct mail_transaction_commit_changes *changes_r)
{
bool update_dict = FALSE;
int ret;
if (xt->first_expunged) {
/* first mail expunged. dict needs updating. */
update_dict = TRUE;
}
return -1;
}
/* transaction is freed now */
t = NULL;
if (xt->first_expunged) {
} else {
/* saved new mails. dict needs to be updated only if
this is the first mail in the database */
if (ret == 0) {
/* first time saving here with expire enabled */
update_dict = TRUE;
/* we're saving the first mail to this mailbox.
ioloop_time may not be exactly the first
message's save time, but a few seconds
difference doesn't matter */
update_dict = TRUE;
} else {
/* already exists */
}
}
if (update_dict) {
struct dict_transaction_context *dctx;
}
} T_END;
return 0;
}
static void
{
}
{
struct expire_transaction_context *xt =
/* first mail expunged, database needs to be updated */
}
}
{
union mail_module_context *xpr_mail;
return;
v->expunge = expire_mail_expunge;
}
{
struct expire_transaction_context *xt =
}
static int
{
struct expire_transaction_context *xt =
}
{
struct expire_mailbox *xpr_box;
v->copy = expire_copy;
}
{
struct expire_mail_user *euser =
}
{
}
{
const char *str;
char set_name[20];
unsigned int i;
}
(void)array_append_space(&patterns);
}
{
struct expire_mail_user *euser;
const char *dict_uri;
if (user->mail_debug)
i_debug("expire: No expire setting - plugin disabled");
i_error("expire plugin: expire_dict setting missing");
} else {
/* we're using only shared dictionary, the username
doesn't matter. */
else
}
}
static struct mail_storage_hooks expire_mail_storage_hooks = {
};
{
}
void expire_plugin_deinit(void)
{
}