mail-log-plugin.c revision 3320f4770d1f6c2cdd10f3c4ca5a324beb335339
/* Copyright (c) 2007-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "str-sanitize.h"
#include "imap-util.h"
#include "mail-storage-private.h"
#include "mailbox-list-private.h"
#include "mail-log-plugin.h"
#include <stdlib.h>
#define MAILBOX_NAME_LOG_LEN 64
#define MSGID_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
};
#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_COPY = 0x08,
MAIL_LOG_EVENT_MAILBOX_DELETE = 0x10,
MAIL_LOG_EVENT_MAILBOX_RENAME = 0x20,
MAIL_LOG_EVENT_FLAG_CHANGE = 0x40,
MAIL_LOG_EVENT_MASK_ALL = 0x1f
};
#define MAIL_LOG_DEFAULT_EVENTS \
static const char *field_names[] = {
"uid",
"box",
"msgid",
"size",
"vsize",
"flags",
};
static const char *event_names[] = {
"delete",
"undelete",
"expunge",
"copy",
"mailbox_delete",
"mailbox_rename",
"flag_change",
};
struct mail_log_settings {
enum mail_log_field fields;
enum mail_log_event events;
unsigned int group_events:1;
};
struct mail_log_group_changes {
enum mail_log_event event;
const char *data;
};
struct mail_log_transaction_context {
unsigned int changes;
};
const char *mail_log_plugin_version = PACKAGE_VERSION;
static struct mail_log_settings mail_log_set;
static void (*mail_log_next_hook_mail_storage_created)
(struct mail_storage *storage);
static void (*mail_log_next_hook_mailbox_list_created)
(struct mailbox_list *list);
{
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;
}
{
unsigned int i;
for (i = 0; event_names[i] != NULL; i++) {
if ((unsigned)event == (unsigned)(1 << i))
return event_names[i];
}
i_unreached();
return NULL;
}
static struct mail_log_group_changes *
{
struct mail_log_group_changes *group;
unsigned int i, count;
for (i = 0; i < count; i++) {
return &group[i];
}
return group;
}
static void
const char *data)
{
struct mail_log_group_changes *group;
}
}
}
}
{
const char *mailbox_str;
/* most operations are for INBOX, and POP3 has only INBOX,
so don't add it. */
}
}
static void
{
unsigned int i, count;
for (i = 0; i < count; i++) {
if (i != 0)
}
}
if (group->psize_total != 0)
if (group->vsize_total != 0)
}
static void
struct mail_log_transaction_context *lt)
{
const struct mail_log_group_changes *group;
unsigned int i, count;
for (i = 0; i < count; i++) {
T_BEGIN {
} T_END;
}
}
const char *data)
{
const char *msgid;
return;
}
if (mail_log_set.group_events) {
return;
}
}
if (event == MAIL_LOG_EVENT_COPY)
msgid = "(null)";
}
}
}
}
{
T_BEGIN {
} T_END;
}
static void
enum mail_flags flags)
{
switch (modify_type) {
case MODIFY_ADD:
break;
case MODIFY_REMOVE:
break;
case MODIFY_REPLACE:
break;
}
(new_flags & MAIL_DELETED) != 0 ?
} T_END;
}
}
static void
struct mail_keywords *keywords)
{
const char *const *old_keywords, *const *new_keywords;
unsigned int i;
break;
}
}
}
static struct mail *
mail_log_mail_alloc(struct mailbox_transaction_context *t,
struct mailbox_header_lookup_ctx *wanted_headers)
{
union mail_module_context *lmail;
struct mail_private *mail;
return _mail;
}
static int
{
const char *name;
return -1;
T_BEGIN {
} T_END;
return 0;
}
static int
{
}
}
static void
{
i_info("Transaction rolled back: "
}
}
}
static struct mailbox *
{
union mailbox_module_context *lbox;
return NULL;
return box;
}
static int
{
return -1;
return 0;
return 0;
}
static int
const char *newname)
{
return -1;
return 0;
i_info("Mailbox renamed: %s -> %s",
return 0;
}
{
union mail_storage_module_context *lstorage;
}
{
union mailbox_list_module_context *llist;
}
{
const char *const *tmp;
if (field == 0)
}
return fields;
}
{
const char *const *tmp;
if (event == 0)
}
return events;
}
{
const char *str;
}
void mail_log_plugin_init(void)
{
}
void mail_log_plugin_deinit(void)
{
}