mail-log-plugin.c revision afb7901ecb5d5566d4cf19be969654946fbaad4b
/* Copyright (c) 2007-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "llist.h"
#include "str.h"
#include "str-sanitize.h"
#include "imap-util.h"
#include "mail-storage-private.h"
#include "mailbox-list-private.h"
#include "notify-plugin.h"
#include "mail-log-plugin.h"
#include <stdlib.h>
#define MAILBOX_NAME_LOG_LEN 64
#define HEADER_LOG_LEN 80
#define MAIL_LOG_CONTEXT(obj) \
#define MAIL_LOG_MAIL_CONTEXT(obj) \
#define MAIL_LOG_LIST_CONTEXT(obj) \
enum mail_log_field {
MAIL_LOG_FIELD_UID = 0x01,
MAIL_LOG_FIELD_BOX = 0x02,
MAIL_LOG_FIELD_MSGID = 0x04,
MAIL_LOG_FIELD_PSIZE = 0x08,
MAIL_LOG_FIELD_VSIZE = 0x10,
MAIL_LOG_FIELD_FLAGS = 0x20,
MAIL_LOG_FIELD_FROM = 0x40,
MAIL_LOG_FIELD_SUBJECT = 0x80
};
#define MAIL_LOG_DEFAULT_FIELDS \
enum mail_log_event {
MAIL_LOG_EVENT_DELETE = 0x01,
MAIL_LOG_EVENT_UNDELETE = 0x02,
MAIL_LOG_EVENT_EXPUNGE = 0x04,
MAIL_LOG_EVENT_SAVE = 0x08,
MAIL_LOG_EVENT_MAILBOX_DELETE = 0x10,
MAIL_LOG_EVENT_MAILBOX_RENAME = 0x20,
MAIL_LOG_EVENT_FLAG_CHANGE = 0x40
};
#define MAIL_LOG_DEFAULT_EVENTS \
static const char *field_names[] = {
"uid",
"box",
"msgid",
"size",
"vsize",
"flags",
"from",
"subject",
};
static const char *event_names[] = {
"delete",
"undelete",
"expunge",
"save",
"mailbox_delete",
"mailbox_rename",
"flag_change",
};
struct mail_log_settings {
enum mail_log_field fields;
enum mail_log_event events;
};
struct mail_log_message {
};
struct mail_log_mail_txn_context {
};
static struct mail_log_settings mail_log_set;
{
unsigned int i;
for (i = 0; field_names[i] != NULL; i++) {
return 1 << i;
}
return 0;
}
{
unsigned int i;
for (i = 0; event_names[i] != NULL; i++) {
return 1 << i;
}
return 0;
}
{
const char *const *tmp;
if (field == 0)
}
return fields;
}
{
const char *const *tmp;
if (event == 0)
}
return events;
}
{
const char *str;
}
{
const char *mailbox_str;
}
static void
{
const char *value;
value = "";
}
static void
{
if (uid != 0)
else {
/* we don't know the uid yet, assign it later */
str_truncate(str, 0);
}
}
static void
const char *desc)
{
struct mail_log_message *msg;
}
if (event != MAIL_LOG_EVENT_SAVE)
else {
/* with mbox mail->uid contains the uid, but handle
this consistently with all mailbox formats */
}
}
}
else
}
else
}
}
}
}
}
static void
const char *desc)
{
return;
T_BEGIN {
} T_END;
}
static void *
{
struct mail_log_mail_txn_context *ctx;
return ctx;
}
{
struct mail_log_mail_txn_context *ctx =
(struct mail_log_mail_txn_context *)txn;
}
{
struct mail_log_mail_txn_context *ctx =
(struct mail_log_mail_txn_context *)txn;
const char *desc;
desc = "save";
} else {
}
}
{
struct mail_log_mail_txn_context *ctx =
(struct mail_log_mail_txn_context *)txn;
"expunge");
}
enum mail_flags old_flags)
{
struct mail_log_mail_txn_context *ctx =
(struct mail_log_mail_txn_context *)txn;
"flag_change");
} else if ((old_flags & MAIL_DELETED) == 0) {
"delete");
} else {
"undelete");
}
}
static void
const char *const *old_keywords ATTR_UNUSED)
{
struct mail_log_mail_txn_context *ctx =
(struct mail_log_mail_txn_context *)txn;
"flag_change");
}
static void
struct mail_transaction_commit_changes *changes)
{
struct mail_log_mail_txn_context *ctx =
(struct mail_log_mail_txn_context *)txn;
struct mail_log_message *msg;
struct seq_range_iter iter;
unsigned int n = 0;
bool ret;
} else {
}
}
}
static void mail_log_mail_transaction_rollback(void *txn)
{
struct mail_log_mail_txn_context *ctx =
(struct mail_log_mail_txn_context *)txn;
}
static void
{
return;
i_info("Mailbox deleted: %s",
}
static void
{
return;
i_info("Mailbox renamed: %s -> %s",
}
static const struct notify_vfuncs mail_log_vfuncs = {
/* mail_transaction_begin */ mail_log_mail_transaction_begin,
/* mail_save */ mail_log_mail_save,
/* mail_copy */ mail_log_mail_copy,
/* mail_expunge */ mail_log_mail_expunge,
/* mail_update_flags */ mail_log_mail_update_flags,
/* mail_update_keywords */ mail_log_mail_update_keywords,
/* mail_transaction_commit */ mail_log_mail_transaction_commit,
/* mail_transaction_rollback */ mail_log_mail_transaction_rollback,
/* mailbox_delete_begin */ notify_noop_mailbox_delete_begin,
/* mailbox_delete_commit */ mail_log_mailbox_delete_commit,
/* mailbox_delete_rollback */ notify_noop_mailbox_delete_rollback,
/* mailbox_rename */ mail_log_mailbox_rename,
};
static struct notify_context *mail_log_ctx;
{
}
void mail_log_plugin_deinit(void)
{
}