mail-log-plugin.c revision 23fdad6c7e2581921f511e24cd9371c9eaebcef9
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen#include "lib.h"
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen#include "array.h"
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen#include "str.h"
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen#include "str-sanitize.h"
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen#include "imap-util.h"
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen#include "mail-storage-private.h"
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen#include "mailbox-list-private.h"
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen#include "notify-plugin.h"
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen#include "mail-log-plugin.h"
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen#include <stdlib.h>
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen#define MAILBOX_NAME_LOG_LEN 64
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen#define HEADER_LOG_LEN 80
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen#define MAIL_LOG_CONTEXT(obj) \
3448096d5b1cd324ed5132045de0345cd7120a25Timo Sirainen MODULE_CONTEXT(obj, mail_log_storage_module)
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen#define MAIL_LOG_MAIL_CONTEXT(obj) \
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen MODULE_CONTEXT(obj, mail_log_mail_module)
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen#define MAIL_LOG_LIST_CONTEXT(obj) \
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmody MODULE_CONTEXT(obj, mail_log_mailbox_list_module)
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmody
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmodyenum mail_log_field {
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen MAIL_LOG_FIELD_UID = 0x01,
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen MAIL_LOG_FIELD_BOX = 0x02,
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen MAIL_LOG_FIELD_MSGID = 0x04,
b04e76cbc807707d299055be79500f8ff131da43Timo Sirainen MAIL_LOG_FIELD_PSIZE = 0x08,
b04e76cbc807707d299055be79500f8ff131da43Timo Sirainen MAIL_LOG_FIELD_VSIZE = 0x10,
72c4ef3b44c50c662b37bba93b463b0caeb63a4fTimo Sirainen MAIL_LOG_FIELD_FLAGS = 0x20,
0c5854b6891c59c1c3f443569bc823d7db571582Teemu Huovila MAIL_LOG_FIELD_FROM = 0x40,
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmody MAIL_LOG_FIELD_SUBJECT = 0x80
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmody};
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen#define MAIL_LOG_DEFAULT_FIELDS \
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen (MAIL_LOG_FIELD_UID | MAIL_LOG_FIELD_BOX | \
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen MAIL_LOG_FIELD_MSGID | MAIL_LOG_FIELD_PSIZE)
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainenenum mail_log_event {
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen MAIL_LOG_EVENT_DELETE = 0x01,
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen MAIL_LOG_EVENT_UNDELETE = 0x02,
202468f94e6c6c8b5d3d98ee74e01bb0d0bb04aaTimo Sirainen MAIL_LOG_EVENT_EXPUNGE = 0x04,
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen MAIL_LOG_EVENT_SAVE = 0x08,
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen MAIL_LOG_EVENT_MAILBOX_DELETE = 0x10,
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen MAIL_LOG_EVENT_MAILBOX_RENAME = 0x20,
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen MAIL_LOG_EVENT_FLAG_CHANGE = 0x40
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen};
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen#define MAIL_LOG_DEFAULT_EVENTS \
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen (MAIL_LOG_EVENT_DELETE | MAIL_LOG_EVENT_UNDELETE | \
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen MAIL_LOG_EVENT_EXPUNGE | MAIL_LOG_EVENT_SAVE | \
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen MAIL_LOG_EVENT_MAILBOX_DELETE | MAIL_LOG_EVENT_MAILBOX_RENAME)
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainenstatic const char *field_names[] = {
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila "uid",
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen "box",
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila "msgid",
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila "size",
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen "vsize",
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen "flags",
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainen "from",
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainen "subject",
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainen NULL
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainen};
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainen
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainenstatic const char *event_names[] = {
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainen "delete",
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainen "undelete",
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen "expunge",
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen "save",
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen "mailbox_delete",
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen "mailbox_rename",
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen "flag_change",
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen NULL
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen};
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainenstruct mail_log_settings {
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen enum mail_log_field fields;
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen enum mail_log_event events;
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen};
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainenstruct mail_log_message {
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen struct mail_log_message *prev, *next;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen const char *pretext, *text;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen};
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainenstruct mail_log_mail_txn_context {
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen pool_t pool;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen struct mail_log_message *messages, *messages_tail;
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen};
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainenstatic struct mail_log_settings mail_log_set;
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainenstatic enum mail_log_field mail_log_field_find(const char *name)
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen{
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen unsigned int i;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen for (i = 0; field_names[i] != NULL; i++) {
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen if (strcmp(name, field_names[i]) == 0)
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen return 1 << i;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen }
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen return 0;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen}
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainenstatic enum mail_log_event mail_log_event_find(const char *name)
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen{
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen unsigned int i;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen for (i = 0; event_names[i] != NULL; i++) {
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen if (strcmp(name, event_names[i]) == 0)
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen return 1 << i;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen }
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen return 0;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen}
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainenstatic enum mail_log_field mail_log_parse_fields(const char *str)
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen{
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen const char *const *tmp;
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen static enum mail_log_field field, fields = 0;
0c5854b6891c59c1c3f443569bc823d7db571582Teemu Huovila
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen for (tmp = t_strsplit_spaces(str, ", "); *tmp != NULL; tmp++) {
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen field = mail_log_field_find(*tmp);
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen if (field == 0)
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen i_fatal("Unknown field in mail_log_fields: '%s'", *tmp);
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen fields |= field;
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen }
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen return fields;
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen}
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainenstatic enum mail_log_event mail_log_parse_events(const char *str)
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen{
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen const char *const *tmp;
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen static enum mail_log_event event, events = 0;
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen for (tmp = t_strsplit_spaces(str, ", "); *tmp != NULL; tmp++) {
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen event = mail_log_event_find(*tmp);
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen if (event == 0)
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen i_fatal("Unknown event in mail_log_events: '%s'", *tmp);
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen events |= event;
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen }
3448096d5b1cd324ed5132045de0345cd7120a25Timo Sirainen return events;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen}
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmodystatic void mail_log_read_settings(struct mail_log_settings *set)
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen{
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen const char *str;
78f87ea1d30f3f54bdf8560ea947ab7ee094283aTeemu Huovila
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen memset(set, 0, sizeof(*set));
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen
b04e76cbc807707d299055be79500f8ff131da43Timo Sirainen str = getenv("MAIL_LOG_FIELDS");
b04e76cbc807707d299055be79500f8ff131da43Timo Sirainen set->fields = str == NULL ? MAIL_LOG_DEFAULT_FIELDS :
0c5854b6891c59c1c3f443569bc823d7db571582Teemu Huovila mail_log_parse_fields(str);
0c5854b6891c59c1c3f443569bc823d7db571582Teemu Huovila
0c5854b6891c59c1c3f443569bc823d7db571582Teemu Huovila str = getenv("MAIL_LOG_EVENTS");
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmody set->events = str == NULL ? MAIL_LOG_DEFAULT_EVENTS :
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen mail_log_parse_events(str);
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen}
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainenstatic void mail_log_append_mailbox_name(string_t *str, struct mail *mail)
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen{
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen const char *mailbox_str;
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen mailbox_str = mailbox_get_name(mail->box);
202468f94e6c6c8b5d3d98ee74e01bb0d0bb04aaTimo Sirainen str_printfa(str, "box=%s",
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen str_sanitize(mailbox_str, MAILBOX_NAME_LOG_LEN));
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen}
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainenstatic void
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainenmail_log_append_mail_header(string_t *str, struct mail *mail,
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen const char *name, const char *header)
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen{
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen const char *value;
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen if (mail_get_first_header(mail, header, &value) <= 0)
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen value = "";
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila str_printfa(str, "%s=%s", name, str_sanitize(value, HEADER_LOG_LEN));
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila}
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainenstatic void
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainenmail_log_append_uid(struct mail_log_mail_txn_context *ctx,
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen struct mail_log_message *msg, string_t *str, uint32_t uid)
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen{
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen if (uid != 0)
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainen str_printfa(str, "uid=%u", uid);
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen else {
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen /* we don't know the uid yet, assign it later */
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen str_printfa(str, "uid=");
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen msg->pretext = p_strdup(ctx->pool, str_c(str));
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen str_truncate(str, 0);
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen }
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen}
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainenstatic void
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainenmail_log_append_mail_message_real(struct mail_log_mail_txn_context *ctx,
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen struct mail *mail, enum mail_log_event event,
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen const char *desc)
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen{
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen struct mail_log_message *msg;
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen string_t *text;
3448096d5b1cd324ed5132045de0345cd7120a25Timo Sirainen uoff_t size;
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila msg = p_new(ctx->pool, struct mail_log_message, 1);
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmody
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen text = t_str_new(128);
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen str_append(text, desc);
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen str_append(text, ": ");
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila if ((mail_log_set.fields & MAIL_LOG_FIELD_BOX) != 0) {
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen mail_log_append_mailbox_name(text, mail);
b04e76cbc807707d299055be79500f8ff131da43Timo Sirainen str_append(text, ", ");
b04e76cbc807707d299055be79500f8ff131da43Timo Sirainen }
0c5854b6891c59c1c3f443569bc823d7db571582Teemu Huovila if ((mail_log_set.fields & MAIL_LOG_FIELD_UID) != 0) {
0c5854b6891c59c1c3f443569bc823d7db571582Teemu Huovila if (event == MAIL_LOG_EVENT_SAVE)
0c5854b6891c59c1c3f443569bc823d7db571582Teemu Huovila mail_log_append_uid(ctx, msg, text, 0);
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmody else
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen mail_log_append_uid(ctx, msg, text, mail->uid);
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen str_append(text, ", ");
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen }
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen if ((mail_log_set.fields & MAIL_LOG_FIELD_MSGID) != 0) {
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen mail_log_append_mail_header(text, mail, "msgid", "Message-ID");
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen str_append(text, ", ");
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen }
b6b06530d654f0436bfbaefc1e988d53fff0cbeeTimo Sirainen if ((mail_log_set.fields & MAIL_LOG_FIELD_PSIZE) != 0) {
202468f94e6c6c8b5d3d98ee74e01bb0d0bb04aaTimo Sirainen if (mail_get_physical_size(mail, &size) == 0)
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen str_printfa(text, "size=%"PRIuUOFF_T, size);
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen else
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen str_printfa(text, "size=error");
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen str_append(text, ", ");
83172e28d4ac684dfed83f7c9db933493d7c5922Timo Sirainen }
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen if ((mail_log_set.fields & MAIL_LOG_FIELD_VSIZE) != 0) {
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen if (mail_get_virtual_size(mail, &size) == 0)
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen str_printfa(text, "vsize=%"PRIuUOFF_T, size);
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen else
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen str_printfa(text, "vsize=error");
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen str_append(text, ", ");
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila }
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen if ((mail_log_set.fields & MAIL_LOG_FIELD_FROM) != 0) {
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen mail_log_append_mail_header(text, mail, "from", "From");
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen str_append(text, ", ");
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen }
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen if ((mail_log_set.fields & MAIL_LOG_FIELD_SUBJECT) != 0) {
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen mail_log_append_mail_header(text, mail, "subject", "Subject");
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainen str_append(text, ", ");
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen }
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen if ((mail_log_set.fields & MAIL_LOG_FIELD_FLAGS) != 0) {
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen str_printfa(text, "flags=(");
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen imap_write_flags(text, mail_get_flags(mail),
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen mail_get_keywords(mail));
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila str_append(text, "), ");
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila }
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila str_truncate(text, str_len(text)-2);
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila msg->text = p_strdup(ctx->pool, str_c(text));
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila msg->prev = ctx->messages_tail;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila ctx->messages_tail = msg;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila if (msg->prev != NULL)
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila msg->prev->next = msg;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila if (ctx->messages == NULL)
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila ctx->messages = msg;
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmody}
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovilastatic void
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovilamail_log_append_mail_message(struct mail_log_mail_txn_context *ctx,
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila struct mail *mail, enum mail_log_event event,
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila const char *desc)
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila{
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila if ((mail_log_set.events & event) == 0)
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila return;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila T_BEGIN {
19ed8f08b23d6ed204e6b27e5d1c0c6fe6bb11ddPhil Carmody mail_log_append_mail_message_real(ctx, mail, event, desc);
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila } T_END;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila}
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovilastatic void *
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovilamail_log_mail_transaction_begin(struct mailbox_transaction_context *t ATTR_UNUSED)
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila{
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila pool_t pool;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila struct mail_log_mail_txn_context *ctx;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila pool = pool_alloconly_create("mail-log", 1024);
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila ctx = p_new(pool, struct mail_log_mail_txn_context, 1);
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila ctx->pool = pool;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila return ctx;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila}
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovilastatic void mail_log_mail_save(void *txn, struct mail *mail)
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila{
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila struct mail_log_mail_txn_context *ctx =
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila (struct mail_log_mail_txn_context *)txn;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila mail_log_append_mail_message(ctx, mail, MAIL_LOG_EVENT_SAVE, "save");
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila}
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovilastatic void mail_log_mail_copy(void *txn, struct mail *src, struct mail *dst)
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila{
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila struct mail_log_mail_txn_context *ctx =
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila (struct mail_log_mail_txn_context *)txn;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila const char *desc;
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila desc = t_strdup_printf("copy from %s",
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila str_sanitize(mailbox_get_name(src->box),
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila MAILBOX_NAME_LOG_LEN));
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila mail_log_append_mail_message(ctx, dst, MAIL_LOG_EVENT_SAVE, desc);
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila}
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainenstatic void mail_log_mail_expunge(void *txn, struct mail *mail)
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen{
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen struct mail_log_mail_txn_context *ctx =
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen (struct mail_log_mail_txn_context *)txn;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen mail_log_append_mail_message(ctx, mail, MAIL_LOG_EVENT_EXPUNGE,
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen "expunge");
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen}
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainenstatic void mail_log_mail_update_flags(void *txn, struct mail *mail,
908c417cc19ec4a2a01db542498c13ade3943601Timo Sirainen enum mail_flags old_flags)
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen{
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen struct mail_log_mail_txn_context *ctx =
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen (struct mail_log_mail_txn_context *)txn;
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen enum mail_flags new_flags = mail_get_flags(mail);
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila if (((old_flags ^ new_flags) & MAIL_DELETED) == 0) {
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen mail_log_append_mail_message(ctx, mail,
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen MAIL_LOG_EVENT_FLAG_CHANGE,
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen "flag_change");
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen } else if ((old_flags & MAIL_DELETED) == 0) {
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen mail_log_append_mail_message(ctx, mail, MAIL_LOG_EVENT_DELETE,
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen "delete");
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen } else {
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen mail_log_append_mail_message(ctx, mail, MAIL_LOG_EVENT_UNDELETE,
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen "undelete");
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen }
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen}
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovilastatic void
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainenmail_log_mail_update_keywords(void *txn, struct mail *mail,
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen const char *const *old_keywords ATTR_UNUSED)
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen{
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen struct mail_log_mail_txn_context *ctx =
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen (struct mail_log_mail_txn_context *)txn;
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen mail_log_append_mail_message(ctx, mail, MAIL_LOG_EVENT_FLAG_CHANGE,
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila "flag_change");
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila}
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovilastatic void
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovilamail_log_mail_transaction_commit(void *txn,
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila struct mail_transaction_commit_changes *changes)
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila{
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila struct mail_log_mail_txn_context *ctx =
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila (struct mail_log_mail_txn_context *)txn;
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila struct mail_log_message *msg;
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila struct seq_range_iter iter;
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen unsigned int n = 0;
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen uint32_t uid;
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen bool ret;
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen seq_range_array_iter_init(&iter, &changes->saved_uids);
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen for (msg = ctx->messages; msg != NULL; msg = msg->next) {
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen if (msg->pretext == NULL) {
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen i_info("%s", msg->text);
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen } else {
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen ret = seq_range_array_iter_nth(&iter, n++, &uid);
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen i_assert(ret);
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen i_info("%s%u%s", msg->pretext, uid, msg->text);
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen }
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen }
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen i_assert(!seq_range_array_iter_nth(&iter, n, &uid));
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen
62fc0b4f07eb6f18a3bff4b1fccb636e6fae3cf4Timo Sirainen pool_unref(&ctx->pool);
c4b772bfbdafe68ac1a0076eab26cd681f8e5046Timo Sirainen}
2730605833442b5ddcb261f90b8375fc98201e35Timo Sirainen
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainenstatic void mail_log_mail_transaction_rollback(void *txn)
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen{
2730605833442b5ddcb261f90b8375fc98201e35Timo Sirainen struct mail_log_mail_txn_context *ctx =
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen (struct mail_log_mail_txn_context *)txn;
c4b772bfbdafe68ac1a0076eab26cd681f8e5046Timo Sirainen
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen pool_unref(&ctx->pool);
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen}
2730605833442b5ddcb261f90b8375fc98201e35Timo Sirainen
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainenstatic void
c4b772bfbdafe68ac1a0076eab26cd681f8e5046Timo Sirainenmail_log_mailbox_delete_commit(void *txn ATTR_UNUSED,
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen struct mailbox_list *list ATTR_UNUSED,
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen const char *name)
2730605833442b5ddcb261f90b8375fc98201e35Timo Sirainen{
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen if ((mail_log_set.events & MAIL_LOG_EVENT_MAILBOX_DELETE) == 0)
c4b772bfbdafe68ac1a0076eab26cd681f8e5046Timo Sirainen return;
2730605833442b5ddcb261f90b8375fc98201e35Timo Sirainen
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen i_info("Mailbox deleted: %s", str_sanitize(name, MAILBOX_NAME_LOG_LEN));
2730605833442b5ddcb261f90b8375fc98201e35Timo Sirainen}
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainenstatic void
2730605833442b5ddcb261f90b8375fc98201e35Timo Sirainenmail_log_mailbox_rename(struct mailbox_list *oldlist ATTR_UNUSED,
8b1a9a4d63b0abccdf7cb1acb8359d5396dd657bTimo Sirainen const char *oldname,
2730605833442b5ddcb261f90b8375fc98201e35Timo Sirainen struct mailbox_list *newlist ATTR_UNUSED,
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen const char *newname, bool rename_children ATTR_UNUSED)
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen{
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen if ((mail_log_set.events & MAIL_LOG_EVENT_MAILBOX_RENAME) == 0)
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen return;
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen i_info("Mailbox renamed: %s -> %s",
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen str_sanitize(oldname, MAILBOX_NAME_LOG_LEN),
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen str_sanitize(newname, MAILBOX_NAME_LOG_LEN));
f5c0d5cada4da23a167c38426d0c481a3e1d5583Timo Sirainen}
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainenstatic const struct notify_vfuncs mail_log_vfuncs = {
3a54211bd6c4dc3f8687c16020770551cf83a548Teemu Huovila /* mail_transaction_begin */ mail_log_mail_transaction_begin,
568fec5b1e629f25d288b48007485b9aa4a018b1Timo Sirainen /* mail_save */ mail_log_mail_save,
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila /* mail_copy */ mail_log_mail_copy,
fdf70410de49eadfbb77997bb60ebba19aee4752Teemu Huovila /* mail_expunge */ mail_log_mail_expunge,
e4bf76afb82ea28ec9d06823fa7deed5f8277183Timo Sirainen /* mail_update_flags */ mail_log_mail_update_flags,
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen /* mail_update_keywords */ mail_log_mail_update_keywords,
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen /* mail_transaction_commit */ mail_log_mail_transaction_commit,
b1965419f329eb7cf78ee39e7c5942462eabb256Timo Sirainen /* mail_transaction_rollback */ mail_log_mail_transaction_rollback,
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen /* mailbox_delete_begin */ notify_noop_mailbox_delete_begin,
b1965419f329eb7cf78ee39e7c5942462eabb256Timo Sirainen /* mailbox_delete_commit */ mail_log_mailbox_delete_commit,
b1965419f329eb7cf78ee39e7c5942462eabb256Timo Sirainen /* mailbox_delete_rollback */ notify_noop_mailbox_delete_rollback,
b1965419f329eb7cf78ee39e7c5942462eabb256Timo Sirainen /* mailbox_rename */ mail_log_mailbox_rename,
b1965419f329eb7cf78ee39e7c5942462eabb256Timo Sirainen};
c865b0e9c65fd77f7b2ab6f8616d3def5501ecb3Timo Sirainen
static struct notify_context *mail_log_ctx;
void mail_log_plugin_init(void)
{
mail_log_read_settings(&mail_log_set);
mail_log_ctx = notify_register(&mail_log_vfuncs);
}
void mail_log_plugin_deinit(void)
{
notify_unregister(mail_log_ctx);
}
const char *mail_log_plugin_dependencies[] = { "notify", NULL };