annotate src/plugins/mail-log/mail-log-plugin.c @ 8550:613151990b79 HEAD

mail-log plugin: Added flag_change event and flags field.
author Timo Sirainen <tss@iki.fi>
date Sun, 14 Dec 2008 07:21:12 +0200
parents 068f6eefc62b
children 2dcfd12f70f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7086
7ed926ed7aa4 Updated copyright notices to include year 2008.
Timo Sirainen <tss@iki.fi>
parents: 6940
diff changeset
1 /* Copyright (c) 2007-2008 Dovecot authors, see the included COPYING file */
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "lib.h"
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 #include "array.h"
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
5 #include "str.h"
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #include "str-sanitize.h"
8550
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
7 #include "imap-util.h"
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #include "mail-storage-private.h"
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
9 #include "mailbox-list-private.h"
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10 #include "mail-log-plugin.h"
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
12 #include <stdlib.h>
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
13
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14 #define MAILBOX_NAME_LOG_LEN 64
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 #define MSGID_LOG_LEN 80
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17 #define MAIL_LOG_CONTEXT(obj) \
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
18 MODULE_CONTEXT(obj, mail_log_storage_module)
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
19 #define MAIL_LOG_MAIL_CONTEXT(obj) \
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
20 MODULE_CONTEXT(obj, mail_log_mail_module)
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
21 #define MAIL_LOG_LIST_CONTEXT(obj) \
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
22 MODULE_CONTEXT(obj, mail_log_mailbox_list_module)
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
24 enum mail_log_field {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
25 MAIL_LOG_FIELD_UID = 0x01,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
26 MAIL_LOG_FIELD_BOX = 0x02,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
27 MAIL_LOG_FIELD_MSGID = 0x04,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
28 MAIL_LOG_FIELD_PSIZE = 0x08,
8550
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
29 MAIL_LOG_FIELD_VSIZE = 0x10,
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
30 MAIL_LOG_FIELD_FLAGS = 0x20
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
31 };
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
32 #define MAIL_LOG_DEFAULT_FIELDS \
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
33 (MAIL_LOG_FIELD_UID | MAIL_LOG_FIELD_BOX | \
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
34 MAIL_LOG_FIELD_MSGID | MAIL_LOG_FIELD_PSIZE)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
35
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
36 enum mail_log_event {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
37 MAIL_LOG_EVENT_DELETE = 0x01,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
38 MAIL_LOG_EVENT_UNDELETE = 0x02,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
39 MAIL_LOG_EVENT_EXPUNGE = 0x04,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
40 MAIL_LOG_EVENT_COPY = 0x08,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
41 MAIL_LOG_EVENT_MAILBOX_DELETE = 0x10,
6536
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
42 MAIL_LOG_EVENT_MAILBOX_RENAME = 0x20,
8550
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
43 MAIL_LOG_EVENT_FLAG_CHANGE = 0x40,
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
44
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
45 MAIL_LOG_EVENT_MASK_ALL = 0x1f
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
46 };
8550
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
47 #define MAIL_LOG_DEFAULT_EVENTS \
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
48 (MAIL_LOG_EVENT_DELETE | MAIL_LOG_EVENT_UNDELETE | \
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
49 MAIL_LOG_EVENT_EXPUNGE | MAIL_LOG_EVENT_COPY | \
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
50 MAIL_LOG_EVENT_MAILBOX_DELETE | MAIL_LOG_EVENT_MAILBOX_RENAME)
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
51
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
52 static const char *field_names[] = {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
53 "uid",
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
54 "box",
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
55 "msgid",
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
56 "size",
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
57 "vsize",
8550
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
58 "flags",
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
59 NULL
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
60 };
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
61
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
62 static const char *event_names[] = {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
63 "delete",
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
64 "undelete",
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
65 "expunge",
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
66 "copy",
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
67 "mailbox_delete",
8550
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
68 "mailbox_rename",
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
69 "flag_change",
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
70 NULL
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
71 };
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
72
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
73 struct mail_log_settings {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
74 enum mail_log_field fields;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
75 enum mail_log_event events;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
76
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
77 unsigned int group_events:1;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
78 };
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
79
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
80 struct mail_log_group_changes {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
81 enum mail_log_event event;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
82 const char *data;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
83
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
84 ARRAY_TYPE(seq_range) uids;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
85 uoff_t psize_total, vsize_total;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
86 };
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
87
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
88 struct mail_log_transaction_context {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
89 union mailbox_transaction_module_context module_ctx;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
90 pool_t pool;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
91
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
92 ARRAY_DEFINE(group_changes, struct mail_log_group_changes);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
93
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
94 unsigned int changes;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
95 };
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
96
5185
24f4a959a24c Added <plugin_name>_version string.
Timo Sirainen <tss@iki.fi>
parents: 5117
diff changeset
97 const char *mail_log_plugin_version = PACKAGE_VERSION;
24f4a959a24c Added <plugin_name>_version string.
Timo Sirainen <tss@iki.fi>
parents: 5117
diff changeset
98
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
99 static struct mail_log_settings mail_log_set;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
100
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
101 static void (*mail_log_next_hook_mail_storage_created)
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
102 (struct mail_storage *storage);
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
103 static void (*mail_log_next_hook_mailbox_list_created)
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
104 (struct mailbox_list *list);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
105
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
106 static MODULE_CONTEXT_DEFINE_INIT(mail_log_storage_module,
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
107 &mail_storage_module_register);
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
108 static MODULE_CONTEXT_DEFINE_INIT(mail_log_mail_module, &mail_module_register);
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
109 static MODULE_CONTEXT_DEFINE_INIT(mail_log_mailbox_list_module,
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
110 &mailbox_list_module_register);
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
111
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
112 static enum mail_log_field mail_log_field_find(const char *name)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
113 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
114 unsigned int i;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
115
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
116 for (i = 0; field_names[i] != NULL; i++) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
117 if (strcmp(name, field_names[i]) == 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
118 return 1 << i;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
119 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
120 return 0;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
121 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
122
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
123 static enum mail_log_event mail_log_event_find(const char *name)
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
124 {
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
125 unsigned int i;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
126
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
127 for (i = 0; event_names[i] != NULL; i++) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
128 if (strcmp(name, event_names[i]) == 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
129 return 1 << i;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
130 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
131 return 0;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
132 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
133
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
134 static const char *mail_log_event_get_name(enum mail_log_event event)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
135 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
136 unsigned int i;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
137
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
138 for (i = 0; event_names[i] != NULL; i++) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
139 if ((unsigned)event == (unsigned)(1 << i))
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
140 return event_names[i];
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
141 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
142 i_unreached();
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
143 return NULL;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
144 }
5258
1fffd36401eb Log the mailbox name, unless it's INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5205
diff changeset
145
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
146 static struct mail_log_group_changes *
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
147 mail_log_action_get_group(struct mail_log_transaction_context *lt,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
148 enum mail_log_event event, const char *data)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
149 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
150 struct mail_log_group_changes *group;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
151 unsigned int i, count;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
152
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
153 if (!array_is_created(&lt->group_changes))
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
154 p_array_init(&lt->group_changes, lt->pool, 8);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
155
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
156 group = array_get_modifiable(&lt->group_changes, &count);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
157 for (i = 0; i < count; i++) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
158 if (group[i].event == event &&
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
159 null_strcmp(data, group[i].data) == 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
160 return &group[i];
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
161 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
162
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
163 group = array_append_space(&lt->group_changes);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
164 group->event = event;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
165 group->data = p_strdup(lt->pool, data);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
166 return group;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
167 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
168
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
169 static void
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
170 mail_log_action_add_group(struct mail_log_transaction_context *lt,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
171 struct mail *mail, enum mail_log_event event,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
172 const char *data)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
173 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
174 struct mail_log_group_changes *group;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
175 uoff_t size;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
176
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
177 group = mail_log_action_get_group(lt, event, data);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
178
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
179 if ((mail_log_set.fields & MAIL_LOG_FIELD_UID) != 0) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
180 if (!array_is_created(&group->uids))
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
181 p_array_init(&group->uids, lt->pool, 32);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
182 seq_range_array_add(&group->uids, 0, mail->uid);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
183 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
184
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
185 if ((mail_log_set.fields & MAIL_LOG_FIELD_PSIZE) != 0 &&
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
186 (event & (MAIL_LOG_EVENT_EXPUNGE | MAIL_LOG_EVENT_COPY)) != 0) {
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6277
diff changeset
187 if (mail_get_physical_size(mail, &size) == 0)
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
188 group->psize_total += size;
5258
1fffd36401eb Log the mailbox name, unless it's INBOX.
Timo Sirainen <tss@iki.fi>
parents: 5205
diff changeset
189 }
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
190
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
191 if ((mail_log_set.fields & MAIL_LOG_FIELD_VSIZE) != 0 &&
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
192 (event & (MAIL_LOG_EVENT_EXPUNGE | MAIL_LOG_EVENT_COPY)) != 0) {
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6277
diff changeset
193 if (mail_get_virtual_size(mail, &size) == 0)
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
194 group->vsize_total += size;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
195 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
196 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
197
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
198 static void mail_log_append_mailbox_name(string_t *str, struct mailbox *box)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
199 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
200 const char *mailbox_str;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
201
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
202 /* most operations are for INBOX, and POP3 has only INBOX,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
203 so don't add it. */
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
204 mailbox_str = mailbox_get_name(box);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
205 if (strcmp(mailbox_str, "INBOX") != 0) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
206 str_printfa(str, "box=%s, ",
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
207 str_sanitize(mailbox_str, MAILBOX_NAME_LOG_LEN));
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
208 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
209 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
210
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
211 static void
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
212 mail_log_group(struct mailbox *box, const struct mail_log_group_changes *group)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
213 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
214 const struct seq_range *range;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
215 unsigned int i, count;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
216 string_t *str;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
217
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
218 str = t_str_new(128);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
219 str_printfa(str, "%s: ", mail_log_event_get_name(group->event));
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
220
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
221 if ((mail_log_set.fields & MAIL_LOG_FIELD_UID) != 0 &&
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
222 array_is_created(&group->uids)) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
223 str_append(str, "uids=");
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
224
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
225 range = array_get(&group->uids, &count);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
226 for (i = 0; i < count; i++) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
227 if (i != 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
228 str_append_c(str, ',');
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
229
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
230 str_printfa(str, "%u", range[i].seq1);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
231 if (range[i].seq1 != range[i].seq2)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
232 str_printfa(str, "-%u", range[i].seq2);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
233 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
234 str_append(str, ", ");
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
235 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
236
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
237 if ((mail_log_set.fields & MAIL_LOG_FIELD_BOX) != 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
238 mail_log_append_mailbox_name(str, box);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
239
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
240 if (group->event == MAIL_LOG_EVENT_COPY)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
241 str_printfa(str, "dest=%s, ", group->data);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
242
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
243 if (group->psize_total != 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
244 str_printfa(str, "size=%"PRIuUOFF_T", ", group->psize_total);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
245 if (group->vsize_total != 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
246 str_printfa(str, "size=%"PRIuUOFF_T", ", group->vsize_total);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
247 str_truncate(str, str_len(str)-2);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
248
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
249 i_info("%s", str_c(str));
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
250 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
251
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
252 static void
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
253 mail_log_group_changes(struct mailbox *box,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
254 struct mail_log_transaction_context *lt)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
255 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
256 const struct mail_log_group_changes *group;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
257 unsigned int i, count;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
258
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
259 group = array_get(&lt->group_changes, &count);
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6536
diff changeset
260 for (i = 0; i < count; i++) {
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
261 T_BEGIN {
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6536
diff changeset
262 mail_log_group(box, &group[i]);
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
263 } T_END;
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6536
diff changeset
264 }
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
265 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
266
7315
3f53f528d338 Copies were tracked using the source transaction instead of destination
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
267 static void mail_log_action(struct mailbox_transaction_context *dest_trans,
3f53f528d338 Copies were tracked using the source transaction instead of destination
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
268 struct mail *mail, enum mail_log_event event,
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
269 const char *data)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
270 {
7315
3f53f528d338 Copies were tracked using the source transaction instead of destination
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
271 struct mail_log_transaction_context *lt = MAIL_LOG_CONTEXT(dest_trans);
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
272 const char *msgid;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
273 uoff_t size;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
274 string_t *str;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
275 pool_t pool;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
276
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
277 if ((mail_log_set.events & event) == 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
278 return;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
279
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
280 if (lt == NULL) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
281 pool = pool_alloconly_create("mail log transaction", 1024);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
282 lt = p_new(pool, struct mail_log_transaction_context, 1);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
283 lt->pool = pool;
7315
3f53f528d338 Copies were tracked using the source transaction instead of destination
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
284 MODULE_CONTEXT_SET(dest_trans, mail_log_storage_module, lt);
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
285 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
286 lt->changes++;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
287
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
288 if (mail_log_set.group_events) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
289 mail_log_action_add_group(lt, mail, event, data);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
290 return;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
291 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
292
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
293 str = t_str_new(128);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
294 str_printfa(str, "%s: ", mail_log_event_get_name(event));
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
295
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
296 if ((mail_log_set.fields & MAIL_LOG_FIELD_UID) != 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
297 str_printfa(str, "uid=%u, ", mail->uid);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
298
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
299 if ((mail_log_set.fields & MAIL_LOG_FIELD_BOX) != 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
300 mail_log_append_mailbox_name(str, mail->box);
8550
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
301 if ((mail_log_set.fields & MAIL_LOG_FIELD_FLAGS) != 0) {
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
302 str_printfa(str, "flags=(");
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
303 imap_write_flags(str, mail_get_flags(mail),
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
304 mail_get_keywords(mail));
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
305 str_append(str, "), ");
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
306 }
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
307 if (event == MAIL_LOG_EVENT_COPY)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
308 str_printfa(str, "dest=%s, ", data);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
309
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
310 if ((mail_log_set.fields & MAIL_LOG_FIELD_MSGID) != 0) {
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6277
diff changeset
311 if (mail_get_first_header(mail, "Message-ID", &msgid) <= 0)
6284
2392908727b8 typofix: "(null" -> "(null)"
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
312 msgid = "(null)";
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6277
diff changeset
313 str_printfa(str, "msgid=%s, ",
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
314 str_sanitize(msgid, MSGID_LOG_LEN));
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
315 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
316
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
317 if ((mail_log_set.fields & MAIL_LOG_FIELD_PSIZE) != 0 &&
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
318 (event & (MAIL_LOG_EVENT_EXPUNGE | MAIL_LOG_EVENT_COPY)) != 0) {
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6277
diff changeset
319 if (mail_get_physical_size(mail, &size) == 0)
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
320 str_printfa(str, "size=%"PRIuUOFF_T", ", size);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
321 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
322 if ((mail_log_set.fields & MAIL_LOG_FIELD_VSIZE) != 0 &&
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
323 (event & (MAIL_LOG_EVENT_EXPUNGE | MAIL_LOG_EVENT_COPY)) != 0) {
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6277
diff changeset
324 if (mail_get_virtual_size(mail, &size) == 0)
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
325 str_printfa(str, "vsize=%"PRIuUOFF_T", ", size);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
326 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
327 str_truncate(str, str_len(str)-2);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
328
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
329 i_info("%s", str_c(str));
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
330 }
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
331
6277
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6274
diff changeset
332 static void mail_log_mail_expunge(struct mail *_mail)
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
333 {
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
334 struct mail_private *mail = (struct mail_private *)_mail;
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
335 union mail_module_context *lmail = MAIL_LOG_MAIL_CONTEXT(mail);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
336
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
337 T_BEGIN {
7315
3f53f528d338 Copies were tracked using the source transaction instead of destination
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
338 mail_log_action(_mail->transaction, _mail,
3f53f528d338 Copies were tracked using the source transaction instead of destination
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
339 MAIL_LOG_EVENT_EXPUNGE, NULL);
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
340 } T_END;
6277
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6274
diff changeset
341 lmail->super.expunge(_mail);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
342 }
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
343
6277
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6274
diff changeset
344 static void
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
345 mail_log_mail_update_flags(struct mail *_mail, enum modify_type modify_type,
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
346 enum mail_flags flags)
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
347 {
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
348 struct mail_private *mail = (struct mail_private *)_mail;
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
349 union mail_module_context *lmail = MAIL_LOG_MAIL_CONTEXT(mail);
5205
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
350 enum mail_flags old_flags, new_flags;
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
351
5205
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
352 old_flags = mail_get_flags(_mail);
6277
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6274
diff changeset
353 lmail->super.update_flags(_mail, modify_type, flags);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
354
5205
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
355 new_flags = old_flags;
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
356 switch (modify_type) {
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
357 case MODIFY_ADD:
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
358 new_flags |= flags;
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
359 break;
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
360 case MODIFY_REMOVE:
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
361 new_flags &= ~flags;
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
362 break;
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
363 case MODIFY_REPLACE:
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
364 new_flags = flags;
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
365 break;
f33e5ce7a73c Fixed deleted/undeleted logging.
Timo Sirainen <tss@iki.fi>
parents: 5185
diff changeset
366 }
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
367
8550
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
368 if (((old_flags ^ new_flags) & MAIL_DELETED) != 0) T_BEGIN {
7315
3f53f528d338 Copies were tracked using the source transaction instead of destination
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
369 mail_log_action(_mail->transaction, _mail,
3f53f528d338 Copies were tracked using the source transaction instead of destination
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
370 (new_flags & MAIL_DELETED) != 0 ?
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6536
diff changeset
371 MAIL_LOG_EVENT_DELETE :
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6536
diff changeset
372 MAIL_LOG_EVENT_UNDELETE, NULL);
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
373 } T_END;
8550
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
374
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
375 if ((old_flags & ~MAIL_DELETED) != (new_flags & ~MAIL_DELETED)) {
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
376 mail_log_action(_mail->transaction, _mail,
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
377 MAIL_LOG_EVENT_FLAG_CHANGE, NULL);
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
378 }
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
379 }
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
380
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
381 static void
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
382 mail_log_mail_update_keywords(struct mail *_mail, enum modify_type modify_type,
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
383 struct mail_keywords *keywords)
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
384 {
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
385 struct mail_private *mail = (struct mail_private *)_mail;
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
386 union mail_module_context *lmail = MAIL_LOG_MAIL_CONTEXT(mail);
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
387 const char *const *old_keywords, *const *new_keywords;
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
388 unsigned int i;
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
389
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
390 old_keywords = mail_get_keywords(_mail);
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
391 lmail->super.update_keywords(_mail, modify_type, keywords);
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
392 new_keywords = mail_get_keywords(_mail);
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
393
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
394 for (i = 0; old_keywords[i] != NULL && new_keywords[i] != NULL; i++) {
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
395 if (strcmp(old_keywords[i], new_keywords[i]) != 0)
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
396 break;
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
397 }
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
398
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
399 if (old_keywords[i] != NULL || new_keywords[i] != NULL) {
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
400 mail_log_action(_mail->transaction, _mail,
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
401 MAIL_LOG_EVENT_FLAG_CHANGE, NULL);
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
402 }
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
403 }
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
404
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
405 static struct mail *
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
406 mail_log_mail_alloc(struct mailbox_transaction_context *t,
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
407 enum mail_fetch_field wanted_fields,
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
408 struct mailbox_header_lookup_ctx *wanted_headers)
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
409 {
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
410 union mailbox_module_context *lbox = MAIL_LOG_CONTEXT(t->box);
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
411 union mail_module_context *lmail;
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
412 struct mail *_mail;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
413 struct mail_private *mail;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
414
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
415 _mail = lbox->super.mail_alloc(t, wanted_fields, wanted_headers);
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
416 mail = (struct mail_private *)_mail;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
417
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
418 lmail = p_new(mail->pool, union mail_module_context, 1);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
419 lmail->super = mail->v;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
420
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
421 mail->v.update_flags = mail_log_mail_update_flags;
8550
613151990b79 mail-log plugin: Added flag_change event and flags field.
Timo Sirainen <tss@iki.fi>
parents: 7462
diff changeset
422 mail->v.update_keywords = mail_log_mail_update_keywords;
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
423 mail->v.expunge = mail_log_mail_expunge;
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
424 MODULE_CONTEXT_SET_SELF(mail, mail_log_mail_module, lmail);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
425 return _mail;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
426 }
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
427
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
428 static int
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
429 mail_log_copy(struct mailbox_transaction_context *t, struct mail *mail,
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
430 enum mail_flags flags, struct mail_keywords *keywords,
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
431 struct mail *dest_mail)
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
432 {
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
433 union mailbox_module_context *lbox = MAIL_LOG_CONTEXT(t->box);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
434 const char *name;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
435
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
436 if (lbox->super.copy(t, mail, flags, keywords, dest_mail) < 0)
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
437 return -1;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
438
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
439 T_BEGIN {
6940
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6536
diff changeset
440 name = str_sanitize(mailbox_get_name(t->box),
414c9d631a81 Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents: 6536
diff changeset
441 MAILBOX_NAME_LOG_LEN);
7315
3f53f528d338 Copies were tracked using the source transaction instead of destination
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
442 mail_log_action(t, mail, MAIL_LOG_EVENT_COPY, name);
7226
e6693a0ec8e1 Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
443 } T_END;
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
444 return 0;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
445 }
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
446
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
447 static int
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
448 mail_log_transaction_commit(struct mailbox_transaction_context *t,
6274
bd67afb92ee5 More transaction_commit() compile fixes.
Timo Sirainen <tss@iki.fi>
parents: 5794
diff changeset
449 uint32_t *uid_validity_r,
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
450 uint32_t *first_saved_uid_r,
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
451 uint32_t *last_saved_uid_r)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
452 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
453 struct mail_log_transaction_context *lt = MAIL_LOG_CONTEXT(t);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
454 union mailbox_module_context *lbox = MAIL_LOG_CONTEXT(t->box);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
455
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
456 if (lt != NULL) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
457 if (lt->changes > 0 && mail_log_set.group_events)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
458 mail_log_group_changes(t->box, lt);
6428
7cad076906eb pool_unref() now takes ** pointer.
Timo Sirainen <tss@iki.fi>
parents: 6284
diff changeset
459 pool_unref(&lt->pool);
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
460 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
461
6512
1a3604c8ee05 mailbox_transaction_commit*() doesn't sync the mailbox anymore, so it
Timo Sirainen <tss@iki.fi>
parents: 6430
diff changeset
462 return lbox->super.transaction_commit(t, uid_validity_r,
6274
bd67afb92ee5 More transaction_commit() compile fixes.
Timo Sirainen <tss@iki.fi>
parents: 5794
diff changeset
463 first_saved_uid_r,
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
464 last_saved_uid_r);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
465 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
466
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
467 static void
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
468 mail_log_transaction_rollback(struct mailbox_transaction_context *t)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
469 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
470 struct mail_log_transaction_context *lt = MAIL_LOG_CONTEXT(t);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
471 union mailbox_module_context *lbox = MAIL_LOG_CONTEXT(t->box);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
472
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
473 if (lt != NULL) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
474 if (lt->changes > 0 && !mail_log_set.group_events) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
475 i_info("Transaction rolled back: "
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
476 "Ignore last %u changes", lt->changes);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
477 }
6428
7cad076906eb pool_unref() now takes ** pointer.
Timo Sirainen <tss@iki.fi>
parents: 6284
diff changeset
478 pool_unref(&lt->pool);
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
479 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
480
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
481 lbox->super.transaction_rollback(t);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
482 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
483
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
484 static struct mailbox *
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
485 mail_log_mailbox_open(struct mail_storage *storage, const char *name,
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
486 struct istream *input, enum mailbox_open_flags flags)
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
487 {
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
488 union mail_storage_module_context *lstorage = MAIL_LOG_CONTEXT(storage);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
489 struct mailbox *box;
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
490 union mailbox_module_context *lbox;
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
491
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
492 box = lstorage->super.mailbox_open(storage, name, input, flags);
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
493 if (box == NULL)
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
494 return NULL;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
495
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
496 lbox = p_new(box->pool, union mailbox_module_context, 1);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
497 lbox->super = box->v;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
498
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
499 box->v.mail_alloc = mail_log_mail_alloc;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
500 box->v.copy = mail_log_copy;
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
501 box->v.transaction_commit = mail_log_transaction_commit;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
502 box->v.transaction_rollback = mail_log_transaction_rollback;
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
503 MODULE_CONTEXT_SET_SELF(box, mail_log_storage_module, lbox);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
504 return box;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
505 }
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
506
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
507 static int
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
508 mail_log_mailbox_list_delete(struct mailbox_list *list, const char *name)
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
509 {
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
510 union mailbox_list_module_context *llist = MAIL_LOG_LIST_CONTEXT(list);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
511
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
512 if (llist->super.delete_mailbox(list, name) < 0)
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
513 return -1;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
514
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
515 if ((mail_log_set.events & MAIL_LOG_EVENT_MAILBOX_DELETE) == 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
516 return 0;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
517
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
518 i_info("Mailbox deleted: %s", str_sanitize(name, MAILBOX_NAME_LOG_LEN));
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
519 return 0;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
520 }
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
521
6536
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
522 static int
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
523 mail_log_mailbox_list_rename(struct mailbox_list *list, const char *oldname,
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
524 const char *newname)
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
525 {
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
526 union mailbox_list_module_context *llist = MAIL_LOG_LIST_CONTEXT(list);
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
527
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
528 if (llist->super.rename_mailbox(list, oldname, newname) < 0)
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
529 return -1;
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
530
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
531 if ((mail_log_set.events & MAIL_LOG_EVENT_MAILBOX_RENAME) == 0)
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
532 return 0;
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
533
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
534 i_info("Mailbox renamed: %s -> %s",
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
535 str_sanitize(oldname, MAILBOX_NAME_LOG_LEN),
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
536 str_sanitize(newname, MAILBOX_NAME_LOG_LEN));
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
537 return 0;
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
538 }
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
539
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
540 static void mail_log_mail_storage_created(struct mail_storage *storage)
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
541 {
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
542 union mail_storage_module_context *lstorage;
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
543
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
544 lstorage = p_new(storage->pool, union mail_storage_module_context, 1);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
545 lstorage->super = storage->v;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
546 storage->v.mailbox_open = mail_log_mailbox_open;
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
547
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
548 MODULE_CONTEXT_SET_SELF(storage, mail_log_storage_module, lstorage);
7462
068f6eefc62b next_hook should be called after our hook is finished with its doings, that
Timo Sirainen <tss@iki.fi>
parents: 7315
diff changeset
549
068f6eefc62b next_hook should be called after our hook is finished with its doings, that
Timo Sirainen <tss@iki.fi>
parents: 7315
diff changeset
550 if (mail_log_next_hook_mail_storage_created != NULL)
068f6eefc62b next_hook should be called after our hook is finished with its doings, that
Timo Sirainen <tss@iki.fi>
parents: 7315
diff changeset
551 mail_log_next_hook_mail_storage_created(storage);
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
552 }
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
553
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
554 static void mail_log_mailbox_list_created(struct mailbox_list *list)
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
555 {
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
556 union mailbox_list_module_context *llist;
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
557
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
558 llist = p_new(list->pool, union mailbox_list_module_context, 1);
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
559 llist->super = list->v;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
560 list->v.delete_mailbox = mail_log_mailbox_list_delete;
6536
2a2fd5c3b42e Log mailbox renames also.
Timo Sirainen <tss@iki.fi>
parents: 6512
diff changeset
561 list->v.rename_mailbox = mail_log_mailbox_list_rename;
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
562
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
563 MODULE_CONTEXT_SET_SELF(list, mail_log_mailbox_list_module, llist);
7462
068f6eefc62b next_hook should be called after our hook is finished with its doings, that
Timo Sirainen <tss@iki.fi>
parents: 7315
diff changeset
564
068f6eefc62b next_hook should be called after our hook is finished with its doings, that
Timo Sirainen <tss@iki.fi>
parents: 7315
diff changeset
565 if (mail_log_next_hook_mailbox_list_created != NULL)
068f6eefc62b next_hook should be called after our hook is finished with its doings, that
Timo Sirainen <tss@iki.fi>
parents: 7315
diff changeset
566 mail_log_next_hook_mailbox_list_created(list);
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
567 }
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
568
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
569 static enum mail_log_field mail_log_parse_fields(const char *str)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
570 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
571 const char *const *tmp;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
572 static enum mail_log_field field, fields = 0;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
573
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
574 for (tmp = t_strsplit_spaces(str, ", "); *tmp != NULL; tmp++) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
575 field = mail_log_field_find(*tmp);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
576 if (field == 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
577 i_fatal("Unknown field in mail_log_fields: '%s'", *tmp);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
578 fields |= field;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
579 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
580 return fields;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
581 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
582
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
583 static enum mail_log_event mail_log_parse_events(const char *str)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
584 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
585 const char *const *tmp;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
586 static enum mail_log_event event, events = 0;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
587
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
588 for (tmp = t_strsplit_spaces(str, ", "); *tmp != NULL; tmp++) {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
589 event = mail_log_event_find(*tmp);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
590 if (event == 0)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
591 i_fatal("Unknown event in mail_log_events: '%s'", *tmp);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
592 events |= event;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
593 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
594 return events;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
595 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
596
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
597 static void mail_log_read_settings(struct mail_log_settings *set)
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
598 {
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
599 const char *str;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
600
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
601 memset(set, 0, sizeof(*set));
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
602
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
603 str = getenv("MAIL_LOG_FIELDS");
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
604 set->fields = str == NULL ? MAIL_LOG_DEFAULT_FIELDS :
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
605 mail_log_parse_fields(str);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
606
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
607 str = getenv("MAIL_LOG_EVENTS");
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
608 set->events = str == NULL ? MAIL_LOG_DEFAULT_EVENTS :
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
609 mail_log_parse_events(str);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
610
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
611 set->group_events = getenv("MAIL_LOG_GROUP_EVENTS") != NULL;
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
612 }
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
613
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
614 void mail_log_plugin_init(void)
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
615 {
5794
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
616 mail_log_read_settings(&mail_log_set);
ea050869097b Added mail_log_events, mail_log_group_events and mail_log_fields settings to
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
617
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
618 mail_log_next_hook_mail_storage_created = hook_mail_storage_created;
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
619 hook_mail_storage_created = mail_log_mail_storage_created;
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
620
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
621 mail_log_next_hook_mailbox_list_created = hook_mailbox_list_created;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
622 hook_mailbox_list_created = mail_log_mailbox_list_created;
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
623 }
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
624
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
625 void mail_log_plugin_deinit(void)
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
626 {
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
627 hook_mail_storage_created = mail_log_next_hook_mail_storage_created;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5338
diff changeset
628 hook_mailbox_list_created = mail_log_next_hook_mailbox_list_created;
5034
1b28e0434d85 Added mail_log plugin to log various mail operations. Currently it logs mail
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
629 }