lazy-expunge-plugin.c revision 64eec253d2098aadf923ff74b38b2f2dd16ff65a
/* Copyright (c) 2006-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "str.h"
#include "seq-range-array.h"
#include "mkdir-parents.h"
#include "mail-storage-private.h"
#include "mailbox-list-private.h"
#include "mail-namespace.h"
#include "lazy-expunge-plugin.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <time.h>
#define LAZY_EXPUNGE_CONTEXT(obj) \
#define LAZY_EXPUNGE_LIST_CONTEXT(obj) \
#define LAZY_EXPUNGE_USER_CONTEXT(obj) \
#define LAZY_EXPUNGE_MAIL_CONTEXT(obj) \
enum lazy_namespace {
};
struct lazy_expunge_mail_user {
const char *env;
};
struct lazy_expunge_mailbox_list {
struct mail_storage *storage;
};
struct lazy_expunge_mail_storage {
bool internal_namespace;
};
struct lazy_expunge_transaction {
struct mailbox_transaction_context *dest_trans;
bool failed;
};
const char *lazy_expunge_plugin_version = PACKAGE_VERSION;
static void (*lazy_expunge_next_hook_mail_namespaces_created)
(struct mail_namespace *namespaces);
static void (*lazy_expunge_next_hook_mail_storage_created)
(struct mail_storage *storage);
static void (*lazy_expunge_next_hook_mailbox_list_created)
(struct mailbox_list *list);
static struct mailbox *
{
enum mail_error error;
return box;
if (error != MAIL_ERROR_NOTFOUND)
return NULL;
/* try creating it. */
return NULL;
/* and try opening again */
return box;
}
static struct mail_storage *
{
}
{
struct lazy_expunge_transaction *lt =
struct mail_storage *deststorage;
struct mail_save_context *save_ctx;
struct mail_keywords *keywords;
const char *const *keywords_list;
"lazy_expunge: Couldn't open expunge mailbox");
return;
}
"lazy_expunge: Couldn't sync expunge mailbox");
return;
}
}
keywords);
}
static struct mailbox_transaction_context *
{
struct mailbox_transaction_context *t;
struct lazy_expunge_transaction *lt;
return t;
}
{
}
static int
{
int ret;
}
ret = -1;
} else {
}
return ret;
}
static void
{
}
static struct mail *
struct mailbox_header_lookup_ctx *wanted_headers)
{
union mail_module_context *mmail;
struct mail_private *mail;
return _mail;
}
static struct mailbox *
{
struct lazy_expunge_mail_storage *lstorage =
union mailbox_module_context *mbox;
return box;
return box;
}
static int
{
enum mail_error error;
/* make sure the destination root directory exists */
"mkdir_parents_chown(%s) failed: %m", dir);
return -1;
}
switch (error) {
case MAIL_ERROR_EXISTS:
return -1;
case MAIL_ERROR_NOTFOUND:
return 0;
default:
break;
}
/* mailbox is being deleted multiple times per second.
update the filename. */
}
return 1;
}
static int
{
struct lazy_expunge_mailbox_list *llist =
struct lazy_expunge_mail_storage *lstorage;
struct mailbox_list *dest_list;
enum mailbox_name_status status;
const char *destname;
char timestamp[256];
int ret;
if (lstorage->internal_namespace)
/* first do the normal sanity checks */
"INBOX can't be deleted.");
return -1;
}
return -1;
if (status == MAILBOX_NAME_INVALID) {
"Invalid mailbox name");
return -1;
}
/* destination mailbox name needs to contain a timestamp */
/* first move the actual mailbox */
return -1;
if (ret == 0) {
return -1;
}
/* next move the expunged messages mailbox, if it exists */
return 0;
}
{
struct lazy_expunge_mail_user *luser =
struct lazy_expunge_mailbox_list *llist =
struct lazy_expunge_mail_storage *lstorage;
const char *const *p;
unsigned int i;
return;
/* if this is one of our internal storages, mark it as such before
quota plugin sees it */
for (i = 0; i < LAZY_NAMESPACE_COUNT; i++, p++) {
break;
}
}
}
{
}
{
struct lazy_expunge_mail_user *luser =
struct lazy_expunge_mailbox_list *llist;
llist);
}
}
static void
{
struct lazy_expunge_mail_user *luser =
struct lazy_expunge_mail_storage *lstorage;
const char *const *p;
int i;
return;
for (i = 0; i < LAZY_NAMESPACE_COUNT; i++, p++) {
const char *name = *p;
operations. */
}
}
{
struct lazy_expunge_mail_user *luser;
const char *env;
} else if (user->mail_debug) {
i_info("lazy_expunge: No lazy_expunge setting - "
"plugin disabled");
}
}
void lazy_expunge_plugin_init(void)
{
}
void lazy_expunge_plugin_deinit(void)
{
}