annotate src/lib-storage/mail-storage-private.h @ 22276:5fac15015445

lib-storage: Move .vsize.lock creation to a generic mailbox_lock_file_create()
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 22 Jun 2017 02:19:18 +0300
parents 540b5d44c561
children d4f4499c2a3a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6410
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 6354
diff changeset
1 #ifndef MAIL_STORAGE_PRIVATE_H
e4eb71ae8e96 Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents: 6354
diff changeset
2 #define MAIL_STORAGE_PRIVATE_H
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
4 #include "module-context.h"
15141
99305e4dd403 Backported parts of normalizer_func_t changes from v2.2 tree.
Timo Sirainen <tss@iki.fi>
parents: 14556
diff changeset
5 #include "unichar.h"
4876
f1d77064884c Lock handling changes. Everything goes through file-lock API now and there's
Timo Sirainen <tss@iki.fi>
parents: 4853
diff changeset
6 #include "file-lock.h"
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include "mail-storage.h"
10412
a9eda7672869 lib-storage: Plugin hook API changed to support per-user plugins within a process.
Timo Sirainen <tss@iki.fi>
parents: 10347
diff changeset
8 #include "mail-storage-hooks.h"
9002
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents: 8518
diff changeset
9 #include "mail-storage-settings.h"
18516
5f43c88e2c87 mail-storage: Moved mailbox attributes API to separate module.
Stephan Bosch <stephan@rename-it.nl>
parents: 17833
diff changeset
10 #include "mailbox-attribute-private.h"
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
11 #include "mail-index-private.h"
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12
15341
15dfd6475f64 Replaced *_INDEX_PREFIX macros with a common MAIL_INDEX_PREFIX.
Timo Sirainen <tss@iki.fi>
parents: 15275
diff changeset
13 /* Default prefix for indexes */
15dfd6475f64 Replaced *_INDEX_PREFIX macros with a common MAIL_INDEX_PREFIX.
Timo Sirainen <tss@iki.fi>
parents: 15275
diff changeset
14 #define MAIL_INDEX_PREFIX "dovecot.index"
15dfd6475f64 Replaced *_INDEX_PREFIX macros with a common MAIL_INDEX_PREFIX.
Timo Sirainen <tss@iki.fi>
parents: 15275
diff changeset
15
9779
72b79f58ce1b Use separate read block sizes when reading only message header vs. full message.
Timo Sirainen <tss@iki.fi>
parents: 9710
diff changeset
16 /* Block size when read()ing message header. */
72b79f58ce1b Use separate read block sizes when reading only message header vs. full message.
Timo Sirainen <tss@iki.fi>
parents: 9710
diff changeset
17 #define MAIL_READ_HDR_BLOCK_SIZE (1024*4)
72b79f58ce1b Use separate read block sizes when reading only message header vs. full message.
Timo Sirainen <tss@iki.fi>
parents: 9710
diff changeset
18 /* Block size when read()ing message (header and) body. */
11309
88d7a36c7fa5 Use IO_BLOCK_SIZE macro to specify how large read/write syscalls to use.
Timo Sirainen <tss@iki.fi>
parents: 11291
diff changeset
19 #define MAIL_READ_FULL_BLOCK_SIZE IO_BLOCK_SIZE
9132
dad05c75bd48 Moved MAIL_READ_BLOCK_SIZE to mail-storage-private.h
Timo Sirainen <tss@iki.fi>
parents: 9061
diff changeset
20
17582
9bb653472f16 lib-storage: Move "shared" storage name to mail-storage-private.h where it can be used.
Timo Sirainen <tss@iki.fi>
parents: 17298
diff changeset
21 #define MAIL_SHARED_STORAGE_NAME "shared"
9bb653472f16 lib-storage: Move "shared" storage name to mail-storage-private.h where it can be used.
Timo Sirainen <tss@iki.fi>
parents: 17298
diff changeset
22
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
23 struct 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
24 unsigned int id;
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
25 };
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
26
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
27 struct mail_module_register {
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
28 unsigned int id;
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
29 };
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
30
4453
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
31 struct mail_storage_vfuncs {
9002
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents: 8518
diff changeset
32 const struct setting_parser_info *(*get_setting_parser_info)(void);
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents: 8518
diff changeset
33
5460
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
34 struct mail_storage *(*alloc)(void);
9434
e374a365521d Initial commit for making mail_storage:mailbox_list to be from 1:1 to n:n.
Timo Sirainen <tss@iki.fi>
parents: 9174
diff changeset
35 int (*create)(struct mail_storage *storage, struct mail_namespace *ns,
6023
56879cc53cec mail_storage.create() now returns error message string. Also fixed handling
Timo Sirainen <tss@iki.fi>
parents: 5614
diff changeset
36 const char **error_r);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 void (*destroy)(struct mail_storage *storage);
9436
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
38 void (*add_list)(struct mail_storage *storage,
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
39 struct mailbox_list *list);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40
9434
e374a365521d Initial commit for making mail_storage:mailbox_list to be from 1:1 to n:n.
Timo Sirainen <tss@iki.fi>
parents: 9174
diff changeset
41 void (*get_list_settings)(const struct mail_namespace *ns,
e374a365521d Initial commit for making mail_storage:mailbox_list to be from 1:1 to n:n.
Timo Sirainen <tss@iki.fi>
parents: 9174
diff changeset
42 struct mailbox_list_settings *set);
e374a365521d Initial commit for making mail_storage:mailbox_list to be from 1:1 to n:n.
Timo Sirainen <tss@iki.fi>
parents: 9174
diff changeset
43 bool (*autodetect)(const struct mail_namespace *ns,
e374a365521d Initial commit for making mail_storage:mailbox_list to be from 1:1 to n:n.
Timo Sirainen <tss@iki.fi>
parents: 9174
diff changeset
44 struct mailbox_list_settings *set);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45
9468
653183a81b6c Mailbox opening and closing APIs changed.
Timo Sirainen <tss@iki.fi>
parents: 9455
diff changeset
46 struct mailbox *(*mailbox_alloc)(struct mail_storage *storage,
653183a81b6c Mailbox opening and closing APIs changed.
Timo Sirainen <tss@iki.fi>
parents: 9455
diff changeset
47 struct mailbox_list *list,
12586
a2780b694b2d lib-storage: mailbox_alloc() now takes a virtual mailbox name and other related API changes.
Timo Sirainen <tss@iki.fi>
parents: 12583
diff changeset
48 const char *vname,
9468
653183a81b6c Mailbox opening and closing APIs changed.
Timo Sirainen <tss@iki.fi>
parents: 9455
diff changeset
49 enum mailbox_flags flags);
9061
f3cfa467b3b3 Added mail_storage_purge() for dbox. dbox no longer calls it automatically at logout.
Timo Sirainen <tss@iki.fi>
parents: 9015
diff changeset
50 int (*purge)(struct mail_storage *storage);
21225
2f077146c48e lib-storage: Add mail_storage.list_index_corrupted()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21196
diff changeset
51 /* Called when mailbox list index corruption has been detected.
2f077146c48e lib-storage: Add mail_storage.list_index_corrupted()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21196
diff changeset
52 The callback should add any missing mailboxes to the list index.
2f077146c48e lib-storage: Add mail_storage.list_index_corrupted()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21196
diff changeset
53 Returns 0 on success, -1 on temporary failure that didn't properly
2f077146c48e lib-storage: Add mail_storage.list_index_corrupted()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21196
diff changeset
54 fix the index. */
2f077146c48e lib-storage: Add mail_storage.list_index_corrupted()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21196
diff changeset
55 int (*list_index_corrupted)(struct mail_storage *storage);
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
56 };
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
57
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
58 union mail_storage_module_context {
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
59 struct mail_storage_vfuncs super;
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
60 struct mail_storage_module_register *reg;
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
61 };
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
62
9436
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
63 enum mail_storage_class_flags {
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
64 /* mailboxes are files, not directories */
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
65 MAIL_STORAGE_CLASS_FLAG_MAILBOX_IS_FILE = 0x01,
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
66 /* root_dir points to a unique directory */
10690
b7c8221cea5b lib-storage: Removed input parameter from mailbox_alloc(), added mailbox_open_stream()
Timo Sirainen <tss@iki.fi>
parents: 10685
diff changeset
67 MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT = 0x02,
b7c8221cea5b lib-storage: Removed input parameter from mailbox_alloc(), added mailbox_open_stream()
Timo Sirainen <tss@iki.fi>
parents: 10685
diff changeset
68 /* mailbox_open_stream() is supported */
12390
37833c393ef8 virtual: Set MAIL_STORAGE_CLASS_FLAG_NOQUOTA to storage's class_flags.
Timo Sirainen <tss@iki.fi>
parents: 12322
diff changeset
69 MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS = 0x04,
37833c393ef8 virtual: Set MAIL_STORAGE_CLASS_FLAG_NOQUOTA to storage's class_flags.
Timo Sirainen <tss@iki.fi>
parents: 12322
diff changeset
70 /* never use quota for this storage (e.g. virtual mailboxes) */
12626
aa131065b53d imapc: Don't force a root directory to exist.
Timo Sirainen <tss@iki.fi>
parents: 12611
diff changeset
71 MAIL_STORAGE_CLASS_FLAG_NOQUOTA = 0x08,
aa131065b53d imapc: Don't force a root directory to exist.
Timo Sirainen <tss@iki.fi>
parents: 12611
diff changeset
72 /* Storage doesn't need a mail root directory */
12874
0461e23ae57c Search supports now prefetching data for returned mails. Dropped imapc's own prefetching.
Timo Sirainen <tss@iki.fi>
parents: 12870
diff changeset
73 MAIL_STORAGE_CLASS_FLAG_NO_ROOT = 0x10,
0461e23ae57c Search supports now prefetching data for returned mails. Dropped imapc's own prefetching.
Timo Sirainen <tss@iki.fi>
parents: 12870
diff changeset
74 /* Storage uses one file per message */
15749
91f60f0d72df lib-storage: Added mailbox_status.have_guids flag
Timo Sirainen <tss@iki.fi>
parents: 15741
diff changeset
75 MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG = 0x20,
91f60f0d72df lib-storage: Added mailbox_status.have_guids flag
Timo Sirainen <tss@iki.fi>
parents: 15741
diff changeset
76 /* Messages have GUIDs (always set mailbox_status.have_guids=TRUE) */
16373
35871cb142df lib-storage: Added mailbox_status.have_save_guids.
Timo Sirainen <tss@iki.fi>
parents: 16053
diff changeset
77 MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS = 0x40,
35871cb142df lib-storage: Added mailbox_status.have_save_guids.
Timo Sirainen <tss@iki.fi>
parents: 16053
diff changeset
78 /* mailbox_save_set_guid() works (always set
35871cb142df lib-storage: Added mailbox_status.have_save_guids.
Timo Sirainen <tss@iki.fi>
parents: 16053
diff changeset
79 mailbox_status.have_save_guids=TRUE) */
16501
102d8a59eeda lib-storage: Added MAIL_STORAGE_CLASS_FLAG_BINARY_DATA flag for classes.
Timo Sirainen <tss@iki.fi>
parents: 16440
diff changeset
80 MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS = 0x80,
102d8a59eeda lib-storage: Added MAIL_STORAGE_CLASS_FLAG_BINARY_DATA flag for classes.
Timo Sirainen <tss@iki.fi>
parents: 16440
diff changeset
81 /* message content can be unstructured binary data
102d8a59eeda lib-storage: Added MAIL_STORAGE_CLASS_FLAG_BINARY_DATA flag for classes.
Timo Sirainen <tss@iki.fi>
parents: 16440
diff changeset
82 (e.g. zlib plugin is allowed to compress/decompress mails) */
16977
8a7ecddca4ad dsync: Support syncing storages with 128bit GUIDs <-> string GUIDs.
Timo Sirainen <tss@iki.fi>
parents: 16501
diff changeset
83 MAIL_STORAGE_CLASS_FLAG_BINARY_DATA = 0x100,
8a7ecddca4ad dsync: Support syncing storages with 128bit GUIDs <-> string GUIDs.
Timo Sirainen <tss@iki.fi>
parents: 16501
diff changeset
84 /* Message GUIDs can only be 128bit (always set
8a7ecddca4ad dsync: Support syncing storages with 128bit GUIDs <-> string GUIDs.
Timo Sirainen <tss@iki.fi>
parents: 16501
diff changeset
85 mailbox_status.have_only_guid128) */
20035
5ac1609ab311 lib-storage: Added MAIL_STORAGE_CLASS_FLAG_NO_LIST_DELETES and MAILBOX_LIST_FLAG_NO_DELETES
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19882
diff changeset
86 MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUID128 = 0x200,
5ac1609ab311 lib-storage: Added MAIL_STORAGE_CLASS_FLAG_NO_LIST_DELETES and MAILBOX_LIST_FLAG_NO_DELETES
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19882
diff changeset
87 /* Storage deletes all files internally - mailbox list's
5ac1609ab311 lib-storage: Added MAIL_STORAGE_CLASS_FLAG_NO_LIST_DELETES and MAILBOX_LIST_FLAG_NO_DELETES
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19882
diff changeset
88 delete_mailbox() shouldn't delete anything itself. */
21196
4a0841b9fcc4 lib-storage: require MAIL_STORAGE_CLASS_FLAG_STUBS when caching
Josef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
parents: 21165
diff changeset
89 MAIL_STORAGE_CLASS_FLAG_NO_LIST_DELETES = 0x400,
4a0841b9fcc4 lib-storage: require MAIL_STORAGE_CLASS_FLAG_STUBS when caching
Josef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
parents: 21165
diff changeset
90 /* Storage supports stubs (used for caching purposes). */
4a0841b9fcc4 lib-storage: require MAIL_STORAGE_CLASS_FLAG_STUBS when caching
Josef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
parents: 21165
diff changeset
91 MAIL_STORAGE_CLASS_FLAG_STUBS = 0x800,
9436
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
92 };
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
93
14859
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
94 struct mail_binary_cache {
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
95 struct timeout *to;
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
96 struct mailbox *box;
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
97 uint32_t uid;
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
98
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
99 uoff_t orig_physical_pos;
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
100 bool include_hdr;
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
101 struct istream *input;
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
102 uoff_t size;
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
103 };
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
104
17708
3e461af4f0ff lib-storage: Added mail_storage_last_error_push/pop()
Timo Sirainen <tss@iki.fi>
parents: 17582
diff changeset
105 struct mail_storage_error {
3e461af4f0ff lib-storage: Added mail_storage_last_error_push/pop()
Timo Sirainen <tss@iki.fi>
parents: 17582
diff changeset
106 char *error_string;
3e461af4f0ff lib-storage: Added mail_storage_last_error_push/pop()
Timo Sirainen <tss@iki.fi>
parents: 17582
diff changeset
107 enum mail_error error;
22084
540b5d44c561 lib-storage: Fix mail_storage_last_error_push/pop() to work with internal errors
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22035
diff changeset
108 char *last_internal_error;
540b5d44c561 lib-storage: Fix mail_storage_last_error_push/pop() to work with internal errors
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22035
diff changeset
109 bool last_error_is_internal;
17708
3e461af4f0ff lib-storage: Added mail_storage_last_error_push/pop()
Timo Sirainen <tss@iki.fi>
parents: 17582
diff changeset
110 };
3e461af4f0ff lib-storage: Added mail_storage_last_error_push/pop()
Timo Sirainen <tss@iki.fi>
parents: 17582
diff changeset
111
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
112 struct mail_storage {
4822
4b54fc2cb12a const fix
Timo Sirainen <tss@iki.fi>
parents: 4808
diff changeset
113 const char *name;
9436
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
114 enum mail_storage_class_flags class_flags;
21982
9282e5b090f1 lib-storage: Add mail_storage.nonbody_access_fields
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21879
diff changeset
115 /* Fields that the storage backend can get by other means than parsing
9282e5b090f1 lib-storage: Add mail_storage.nonbody_access_fields
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21879
diff changeset
116 the message header/body. For example the imapc backend can lookup
9282e5b090f1 lib-storage: Add mail_storage.nonbody_access_fields
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21879
diff changeset
117 MAIL_FETCH_IMAP_BODYSTRUCTURE from the remote server. Adding fields
9282e5b090f1 lib-storage: Add mail_storage.nonbody_access_fields
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21879
diff changeset
118 here avoids adding them to index_mail_data.access_part. */
9282e5b090f1 lib-storage: Add mail_storage.nonbody_access_fields
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21879
diff changeset
119 enum mail_fetch_field nonbody_access_fields;
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
120
11488
4b20e692c606 lib-storage: Plugin API changed to run plugin functions in correct order.
Timo Sirainen <tss@iki.fi>
parents: 11487
diff changeset
121 struct mail_storage_vfuncs v, *vlast;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
122
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
123 /* private: */
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
124 pool_t pool;
9436
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
125 struct mail_storage *prev, *next;
11106
085253f549f8 lib-storage: Panic if deiniting storage before closing its mailboxes.
Timo Sirainen <tss@iki.fi>
parents: 11000
diff changeset
126 /* counting number of times mail_storage_create() has returned this
085253f549f8 lib-storage: Panic if deiniting storage before closing its mailboxes.
Timo Sirainen <tss@iki.fi>
parents: 11000
diff changeset
127 same storage. */
9436
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
128 int refcount;
11106
085253f549f8 lib-storage: Panic if deiniting storage before closing its mailboxes.
Timo Sirainen <tss@iki.fi>
parents: 11000
diff changeset
129 /* counting number of objects (e.g. mailbox) that have a pointer
085253f549f8 lib-storage: Panic if deiniting storage before closing its mailboxes.
Timo Sirainen <tss@iki.fi>
parents: 11000
diff changeset
130 to this storage. */
085253f549f8 lib-storage: Panic if deiniting storage before closing its mailboxes.
Timo Sirainen <tss@iki.fi>
parents: 11000
diff changeset
131 int obj_refcount;
13754
deaebb4dc98c lib-storage: Track storage's all mailboxes to make it easier to debug if one isn't closed.
Timo Sirainen <tss@iki.fi>
parents: 13633
diff changeset
132 /* Linked list of all mailboxes in the storage */
deaebb4dc98c lib-storage: Track storage's all mailboxes to make it easier to debug if one isn't closed.
Timo Sirainen <tss@iki.fi>
parents: 13633
diff changeset
133 struct mailbox *mailboxes;
21163
a3cb1f46a9ab lib-storage: treat empty root_dir as an empty string
Josef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
parents: 21138
diff changeset
134 /* A "root dir" to enable storage sharing. It is only ever used for
a3cb1f46a9ab lib-storage: treat empty root_dir as an empty string
Josef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
parents: 21138
diff changeset
135 * uniqueness checking (via strcmp) and never used as a path. */
9436
4f46cee3a1d4 mail storages can now be shared between namespaces.
Timo Sirainen <tss@iki.fi>
parents: 9434
diff changeset
136 const char *unique_root_dir;
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
137
21812
8a1d6c2f9313 lib-storage: Add mail_storage_get_last_internal_error()
Martti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
parents: 21567
diff changeset
138 /* Last error set in mail_storage_set_critical(). */
8a1d6c2f9313 lib-storage: Add mail_storage_get_last_internal_error()
Martti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
parents: 21567
diff changeset
139 char *last_internal_error;
8a1d6c2f9313 lib-storage: Add mail_storage_get_last_internal_error()
Martti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
parents: 21567
diff changeset
140
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5607
diff changeset
141 char *error_string;
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5607
diff changeset
142 enum mail_error error;
17708
3e461af4f0ff lib-storage: Added mail_storage_last_error_push/pop()
Timo Sirainen <tss@iki.fi>
parents: 17582
diff changeset
143 ARRAY(struct mail_storage_error) error_stack;
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5607
diff changeset
144
8319
8553bb4c53ad Fixed shared mailboxes to work with plugins.
Timo Sirainen <tss@iki.fi>
parents: 8082
diff changeset
145 const struct mail_storage *storage_class;
9434
e374a365521d Initial commit for making mail_storage:mailbox_list to be from 1:1 to n:n.
Timo Sirainen <tss@iki.fi>
parents: 9174
diff changeset
146 struct mail_user *user;
8786
db9811ec1f47 Added mail_user_get_temp_prefix() and mail_storage_get_temp_prefix().
Timo Sirainen <tss@iki.fi>
parents: 8726
diff changeset
147 const char *temp_path_prefix;
9002
9d0037a997f4 Initial commit for config rewrite.
Timo Sirainen <tss@iki.fi>
parents: 8518
diff changeset
148 const struct mail_storage_settings *set;
5459
78eaf595359c Removed struct index_storage abstraction. It's pointless.
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
149
3033
146897976cfa Added mail_debug setting. Moved full_filesystem_access from global variable
Timo Sirainen <tss@iki.fi>
parents: 3016
diff changeset
150 enum mail_storage_flags flags;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
151
9453
2a3390530f6a struct mail_storage.callbacks is no longer a pointer.
Timo Sirainen <tss@iki.fi>
parents: 9436
diff changeset
152 struct mail_storage_callbacks callbacks;
4949
a959d4208b54 Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
153 void *callback_context;
a959d4208b54 Moved storage callbacks to struct mail_storage. If searching takes over 10
Timo Sirainen <tss@iki.fi>
parents: 4939
diff changeset
154
14859
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
155 struct mail_binary_cache binary_cache;
15275
4c84efce3a94 lib-storage: Fixes to handling separation of private/shared attributes.
Timo Sirainen <tss@iki.fi>
parents: 15272
diff changeset
156 /* Filled lazily by mailbox_attribute_*() when accessing shared
4c84efce3a94 lib-storage: Fixes to handling separation of private/shared attributes.
Timo Sirainen <tss@iki.fi>
parents: 15272
diff changeset
157 attributes. */
4c84efce3a94 lib-storage: Fixes to handling separation of private/shared attributes.
Timo Sirainen <tss@iki.fi>
parents: 15272
diff changeset
158 struct dict *_shared_attr_dict;
14859
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
159
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
160 /* Module-specific contexts. See mail_storage_module_id. */
14920
a097ef0a9d6d Array API changed: ARRAY_DEFINE(name, type) -> ARRAY(type) name
Timo Sirainen <tss@iki.fi>
parents: 14859
diff changeset
161 ARRAY(union mail_storage_module_context *) module_contexts;
15272
ca10d2e8d8e3 lib-storage: Moved mail attribute dict to struct mail_storage.
Timo Sirainen <tss@iki.fi>
parents: 15237
diff changeset
162
15275
4c84efce3a94 lib-storage: Fixes to handling separation of private/shared attributes.
Timo Sirainen <tss@iki.fi>
parents: 15272
diff changeset
163 /* Failed to create shared attribute dict, don't try again */
4c84efce3a94 lib-storage: Fixes to handling separation of private/shared attributes.
Timo Sirainen <tss@iki.fi>
parents: 15272
diff changeset
164 unsigned int shared_attr_dict_failed:1;
21812
8a1d6c2f9313 lib-storage: Add mail_storage_get_last_internal_error()
Martti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
parents: 21567
diff changeset
165 unsigned int last_error_is_internal:1;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
166 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
167
12312
28eaaa23f2c6 lib-storage: Added support for saving mail attachments separately via filesystem API.
Timo Sirainen <tss@iki.fi>
parents: 12040
diff changeset
168 struct mail_attachment_part {
28eaaa23f2c6 lib-storage: Added support for saving mail attachments separately via filesystem API.
Timo Sirainen <tss@iki.fi>
parents: 12040
diff changeset
169 struct message_part *part;
28eaaa23f2c6 lib-storage: Added support for saving mail attachments separately via filesystem API.
Timo Sirainen <tss@iki.fi>
parents: 12040
diff changeset
170 const char *content_type, *content_disposition;
28eaaa23f2c6 lib-storage: Added support for saving mail attachments separately via filesystem API.
Timo Sirainen <tss@iki.fi>
parents: 12040
diff changeset
171 };
28eaaa23f2c6 lib-storage: Added support for saving mail attachments separately via filesystem API.
Timo Sirainen <tss@iki.fi>
parents: 12040
diff changeset
172
20272
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
173 struct virtual_mailbox_vfuncs {
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
174 /* convert backend UIDs to virtual UIDs. if some backend UID doesn't
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
175 exist in mailbox, it's simply ignored */
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
176 void (*get_virtual_uids)(struct mailbox *box,
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
177 struct mailbox *backend_mailbox,
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
178 const ARRAY_TYPE(seq_range) *backend_uids,
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
179 ARRAY_TYPE(seq_range) *virtual_uids_r);
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
180 /* like get_virtual_uids(), but if a backend UID doesn't exist,
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
181 convert it to 0. */
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
182 void (*get_virtual_uid_map)(struct mailbox *box,
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
183 struct mailbox *backend_mailbox,
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
184 const ARRAY_TYPE(seq_range) *backend_uids,
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
185 ARRAY_TYPE(uint32_t) *virtual_uids_r);
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
186 void (*get_virtual_backend_boxes)(struct mailbox *box,
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
187 ARRAY_TYPE(mailboxes) *mailboxes,
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
188 bool only_with_msgs);
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
189 };
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
190
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
191 struct mailbox_vfuncs {
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3735
diff changeset
192 bool (*is_readonly)(struct mailbox *box);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
193
7620
4b8c1c164d8f Initial CONDSTORE support.
Timo Sirainen <tss@iki.fi>
parents: 7414
diff changeset
194 int (*enable)(struct mailbox *box, enum mailbox_feature features);
13125
4dca25ea4a1c lib-storage: Added auto_boxes parameter to mailbox_exists().
Timo Sirainen <tss@iki.fi>
parents: 13120
diff changeset
195 int (*exists)(struct mailbox *box, bool auto_boxes,
4dca25ea4a1c lib-storage: Added auto_boxes parameter to mailbox_exists().
Timo Sirainen <tss@iki.fi>
parents: 13120
diff changeset
196 enum mailbox_existence *existence_r);
9468
653183a81b6c Mailbox opening and closing APIs changed.
Timo Sirainen <tss@iki.fi>
parents: 9455
diff changeset
197 int (*open)(struct mailbox *box);
653183a81b6c Mailbox opening and closing APIs changed.
Timo Sirainen <tss@iki.fi>
parents: 9455
diff changeset
198 void (*close)(struct mailbox *box);
10718
e8fc01d03aea lib-storage: Added mailbox.free() method. Use it instead of close() where necessary.
Timo Sirainen <tss@iki.fi>
parents: 10711
diff changeset
199 void (*free)(struct mailbox *box);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
200
15041
7c6d30280cff lib-storage API change to allow using it from C++ code
Timo Sirainen <tss@iki.fi>
parents: 15040
diff changeset
201 int (*create_box)(struct mailbox *box,
7c6d30280cff lib-storage API change to allow using it from C++ code
Timo Sirainen <tss@iki.fi>
parents: 15040
diff changeset
202 const struct mailbox_update *update, bool directory);
7c6d30280cff lib-storage API change to allow using it from C++ code
Timo Sirainen <tss@iki.fi>
parents: 15040
diff changeset
203 int (*update_box)(struct mailbox *box,
7c6d30280cff lib-storage API change to allow using it from C++ code
Timo Sirainen <tss@iki.fi>
parents: 15040
diff changeset
204 const struct mailbox_update *update);
7c6d30280cff lib-storage API change to allow using it from C++ code
Timo Sirainen <tss@iki.fi>
parents: 15040
diff changeset
205 int (*delete_box)(struct mailbox *box);
7c6d30280cff lib-storage API change to allow using it from C++ code
Timo Sirainen <tss@iki.fi>
parents: 15040
diff changeset
206 int (*rename_box)(struct mailbox *src, struct mailbox *dest);
9533
530bbade4e3f Added support for creating/updating mailboxes with given metadata (guid, uid validity, etc).
Timo Sirainen <tss@iki.fi>
parents: 9508
diff changeset
207
12549
bbfa924bc4bc lib-storage: mailbox_get_status() can now fail.
Timo Sirainen <tss@iki.fi>
parents: 12545
diff changeset
208 int (*get_status)(struct mailbox *box, enum mailbox_status_items items,
bbfa924bc4bc lib-storage: mailbox_get_status() can now fail.
Timo Sirainen <tss@iki.fi>
parents: 12545
diff changeset
209 struct mailbox_status *status_r);
12550
2c299c0e3bc8 lib-storage: Moved some items from mailbox_get_status() to a new mailbox_get_metadata().
Timo Sirainen <tss@iki.fi>
parents: 12549
diff changeset
210 int (*get_metadata)(struct mailbox *box,
2c299c0e3bc8 lib-storage: Moved some items from mailbox_get_status() to a new mailbox_get_metadata().
Timo Sirainen <tss@iki.fi>
parents: 12549
diff changeset
211 enum mailbox_metadata_items items,
2c299c0e3bc8 lib-storage: Moved some items from mailbox_get_status() to a new mailbox_get_metadata().
Timo Sirainen <tss@iki.fi>
parents: 12549
diff changeset
212 struct mailbox_metadata *metadata_r);
13876
bc9217cb0193 lib-storage: Added struct mailbox.set_subscribed() virtual method.
Timo Sirainen <tss@iki.fi>
parents: 13793
diff changeset
213 int (*set_subscribed)(struct mailbox *box, bool set);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
214
16024
f3cd9e5cbe99 lib-storage: Changed mailbox_attribute_get/set() APIs to have a transaction and update index.
Timo Sirainen <tss@iki.fi>
parents: 15835
diff changeset
215 int (*attribute_set)(struct mailbox_transaction_context *t,
16044
2396eb0a3e3f lib-storage: mailbox_attribute_set() now uses struct mail_attribute_value.
Timo Sirainen <tss@iki.fi>
parents: 16024
diff changeset
216 enum mail_attribute_type type, const char *key,
2396eb0a3e3f lib-storage: mailbox_attribute_set() now uses struct mail_attribute_value.
Timo Sirainen <tss@iki.fi>
parents: 16024
diff changeset
217 const struct mail_attribute_value *value);
16024
f3cd9e5cbe99 lib-storage: Changed mailbox_attribute_get/set() APIs to have a transaction and update index.
Timo Sirainen <tss@iki.fi>
parents: 15835
diff changeset
218 int (*attribute_get)(struct mailbox_transaction_context *t,
f3cd9e5cbe99 lib-storage: Changed mailbox_attribute_get/set() APIs to have a transaction and update index.
Timo Sirainen <tss@iki.fi>
parents: 15835
diff changeset
219 enum mail_attribute_type type, const char *key,
f3cd9e5cbe99 lib-storage: Changed mailbox_attribute_get/set() APIs to have a transaction and update index.
Timo Sirainen <tss@iki.fi>
parents: 15835
diff changeset
220 struct mail_attribute_value *value_r);
15224
5659c178bdeb lib-storage: Added support to get/set/iterate mailbox attributes.
Timo Sirainen <tss@iki.fi>
parents: 15163
diff changeset
221 struct mailbox_attribute_iter *
5659c178bdeb lib-storage: Added support to get/set/iterate mailbox attributes.
Timo Sirainen <tss@iki.fi>
parents: 15163
diff changeset
222 (*attribute_iter_init)(struct mailbox *box,
5659c178bdeb lib-storage: Added support to get/set/iterate mailbox attributes.
Timo Sirainen <tss@iki.fi>
parents: 15163
diff changeset
223 enum mail_attribute_type type,
5659c178bdeb lib-storage: Added support to get/set/iterate mailbox attributes.
Timo Sirainen <tss@iki.fi>
parents: 15163
diff changeset
224 const char *prefix);
5659c178bdeb lib-storage: Added support to get/set/iterate mailbox attributes.
Timo Sirainen <tss@iki.fi>
parents: 15163
diff changeset
225 const char *(*attribute_iter_next)(struct mailbox_attribute_iter *iter);
5659c178bdeb lib-storage: Added support to get/set/iterate mailbox attributes.
Timo Sirainen <tss@iki.fi>
parents: 15163
diff changeset
226 int (*attribute_iter_deinit)(struct mailbox_attribute_iter *iter);
5659c178bdeb lib-storage: Added support to get/set/iterate mailbox attributes.
Timo Sirainen <tss@iki.fi>
parents: 15163
diff changeset
227
6062
8341db7a1698 Moved mailbox list index sync stamp checking and updating to
Timo Sirainen <tss@iki.fi>
parents: 6052
diff changeset
228 /* Lookup sync extension record and figure out if it mailbox has
8341db7a1698 Moved mailbox list index sync stamp checking and updating to
Timo Sirainen <tss@iki.fi>
parents: 6052
diff changeset
229 changed since. Returns 1 = yes, 0 = no, -1 = error. */
8341db7a1698 Moved mailbox list index sync stamp checking and updating to
Timo Sirainen <tss@iki.fi>
parents: 6052
diff changeset
230 int (*list_index_has_changed)(struct mailbox *box,
8341db7a1698 Moved mailbox list index sync stamp checking and updating to
Timo Sirainen <tss@iki.fi>
parents: 6052
diff changeset
231 struct mail_index_view *list_view,
8341db7a1698 Moved mailbox list index sync stamp checking and updating to
Timo Sirainen <tss@iki.fi>
parents: 6052
diff changeset
232 uint32_t seq);
12646
87f84a76fb1e lib-storage: Return STATUS replies from mailbox list index only when it's fully up-to-date.
Timo Sirainen <tss@iki.fi>
parents: 12626
diff changeset
233 /* Update the sync extension record. */
87f84a76fb1e lib-storage: Return STATUS replies from mailbox list index only when it's fully up-to-date.
Timo Sirainen <tss@iki.fi>
parents: 12626
diff changeset
234 void (*list_index_update_sync)(struct mailbox *box,
87f84a76fb1e lib-storage: Return STATUS replies from mailbox list index only when it's fully up-to-date.
Timo Sirainen <tss@iki.fi>
parents: 12626
diff changeset
235 struct mail_index_transaction *trans,
87f84a76fb1e lib-storage: Return STATUS replies from mailbox list index only when it's fully up-to-date.
Timo Sirainen <tss@iki.fi>
parents: 12626
diff changeset
236 uint32_t seq);
6062
8341db7a1698 Moved mailbox list index sync stamp checking and updating to
Timo Sirainen <tss@iki.fi>
parents: 6052
diff changeset
237
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2225
diff changeset
238 struct mailbox_sync_context *
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2225
diff changeset
239 (*sync_init)(struct mailbox *box,
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2225
diff changeset
240 enum mailbox_sync_flags flags);
6279
f52e7d1402b5 mail_index_view_sync_next() and mailbox_sync_next() returns now bool.
Timo Sirainen <tss@iki.fi>
parents: 6277
diff changeset
241 bool (*sync_next)(struct mailbox_sync_context *ctx,
f52e7d1402b5 mail_index_view_sync_next() and mailbox_sync_next() returns now bool.
Timo Sirainen <tss@iki.fi>
parents: 6277
diff changeset
242 struct mailbox_sync_rec *sync_rec_r);
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2225
diff changeset
243 int (*sync_deinit)(struct mailbox_sync_context *ctx,
10509
50364f04cf13 lib-storage: Changed mailbox_sync() and mailbox_sync_deinit() APIs.
Timo Sirainen <tss@iki.fi>
parents: 10412
diff changeset
244 struct mailbox_sync_status *status_r);
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2225
diff changeset
245
5564
47274663a71c Call sync_notify() once at the end of syncing. Allow accessing mails even
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
246 /* Called once for each expunge. Called one or more times for
47274663a71c Call sync_notify() once at the end of syncing. Allow accessing mails even
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
247 flag/keyword changes. Once the sync is finished, called with
47274663a71c Call sync_notify() once at the end of syncing. Allow accessing mails even
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
248 uid=0 and sync_type=0. */
5562
24b751bc0995 Added sync_notify() callback to struct mail_storage. It's now called for
Timo Sirainen <tss@iki.fi>
parents: 5500
diff changeset
249 void (*sync_notify)(struct mailbox *box, uint32_t uid,
24b751bc0995 Added sync_notify() callback to struct mail_storage. It's now called for
Timo Sirainen <tss@iki.fi>
parents: 5500
diff changeset
250 enum mailbox_sync_type sync_type);
24b751bc0995 Added sync_notify() callback to struct mail_storage. It's now called for
Timo Sirainen <tss@iki.fi>
parents: 5500
diff changeset
251
5465
014236cf3dcc Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents: 5462
diff changeset
252 void (*notify_changes)(struct mailbox *box);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
253
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
254 struct mailbox_transaction_context *
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
255 (*transaction_begin)(struct mailbox *box,
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
256 enum mailbox_transaction_flags flags);
2518
f8be7a5e273a Added sync flags parameter to mailbox_transaction_commit(), so EXPUNGE can
Timo Sirainen <tss@iki.fi>
parents: 2446
diff changeset
257 int (*transaction_commit)(struct mailbox_transaction_context *t,
9649
47356e8dda45 mailbox_transaction_commit_get_uids() changed to _get_changes() with more generic API.
Timo Sirainen <tss@iki.fi>
parents: 9643
diff changeset
258 struct mail_transaction_commit_changes *changes_r);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
259 void (*transaction_rollback)(struct mailbox_transaction_context *t);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
260
12533
67257180c7ea lib-storage: Moved box->private_flags_mask to mailbox_get_private_flags_mask()
Timo Sirainen <tss@iki.fi>
parents: 12521
diff changeset
261 enum mail_flags (*get_private_flags_mask)(struct mailbox *box);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
262
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
263 struct mail *
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
264 (*mail_alloc)(struct mailbox_transaction_context *t,
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
265 enum mail_fetch_field wanted_fields,
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
266 struct mailbox_header_lookup_ctx *wanted_headers);
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
267
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
268 struct mail_search_context *
2327
7d02e2a7672d Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
269 (*search_init)(struct mailbox_transaction_context *t,
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7629
diff changeset
270 struct mail_search_args *args,
12870
1fbd59c48414 lib-storage: Changed mailbox_search_*() API to return pointer struct mail.
Timo Sirainen <tss@iki.fi>
parents: 12866
diff changeset
271 const enum mail_sort_type *sort_program,
1fbd59c48414 lib-storage: Changed mailbox_search_*() API to return pointer struct mail.
Timo Sirainen <tss@iki.fi>
parents: 12866
diff changeset
272 enum mail_fetch_field wanted_fields,
1fbd59c48414 lib-storage: Changed mailbox_search_*() API to return pointer struct mail.
Timo Sirainen <tss@iki.fi>
parents: 12866
diff changeset
273 struct mailbox_header_lookup_ctx *wanted_headers);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
274 int (*search_deinit)(struct mail_search_context *ctx);
10347
0156d98bc822 mailbox_search_next*() API changed to return bool.
Timo Sirainen <tss@iki.fi>
parents: 10255
diff changeset
275 bool (*search_next_nonblock)(struct mail_search_context *ctx,
12870
1fbd59c48414 lib-storage: Changed mailbox_search_*() API to return pointer struct mail.
Timo Sirainen <tss@iki.fi>
parents: 12866
diff changeset
276 struct mail **mail_r, bool *tryagain_r);
4196
6ac0d63b297f Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents: 4076
diff changeset
277 /* Internal search function which updates ctx->seq */
8477
c033b3e2d9b6 mail_storage.search_next_update_seq returns now bool. It was never failing.
Timo Sirainen <tss@iki.fi>
parents: 8428
diff changeset
278 bool (*search_next_update_seq)(struct mail_search_context *ctx);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
279
8075
8a068f879cd1 mailbox_save_init() API was split to multiple functions.
Timo Sirainen <tss@iki.fi>
parents: 8042
diff changeset
280 struct mail_save_context *
8a068f879cd1 mailbox_save_init() API was split to multiple functions.
Timo Sirainen <tss@iki.fi>
parents: 8042
diff changeset
281 (*save_alloc)(struct mailbox_transaction_context *t);
8a068f879cd1 mailbox_save_init() API was split to multiple functions.
Timo Sirainen <tss@iki.fi>
parents: 8042
diff changeset
282 int (*save_begin)(struct mail_save_context *ctx, struct istream *input);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2350
diff changeset
283 int (*save_continue)(struct mail_save_context *ctx);
4268
7112aad504ae Changed mailbox_save_*() API a bit: Moved the struct mail *dest_mail to
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4196
diff changeset
284 int (*save_finish)(struct mail_save_context *ctx);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2350
diff changeset
285 void (*save_cancel)(struct mail_save_context *ctx);
8726
68db63cc32b3 Mail copying API changed to be based on save API. This allows extending it easily in future.
Timo Sirainen <tss@iki.fi>
parents: 8518
diff changeset
286 int (*copy)(struct mail_save_context *ctx, struct mail *mail);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
287
12866
59e4c0d1457b lib-storage: Moved index_mailbox_context.save_*() methods to mailbox_vfuncs.
Timo Sirainen <tss@iki.fi>
parents: 12860
diff changeset
288 /* Called during transaction commit/rollback if saving was done */
59e4c0d1457b lib-storage: Moved index_mailbox_context.save_*() methods to mailbox_vfuncs.
Timo Sirainen <tss@iki.fi>
parents: 12860
diff changeset
289 int (*transaction_save_commit_pre)(struct mail_save_context *save_ctx);
59e4c0d1457b lib-storage: Moved index_mailbox_context.save_*() methods to mailbox_vfuncs.
Timo Sirainen <tss@iki.fi>
parents: 12860
diff changeset
290 void (*transaction_save_commit_post)
59e4c0d1457b lib-storage: Moved index_mailbox_context.save_*() methods to mailbox_vfuncs.
Timo Sirainen <tss@iki.fi>
parents: 12860
diff changeset
291 (struct mail_save_context *save_ctx,
59e4c0d1457b lib-storage: Moved index_mailbox_context.save_*() methods to mailbox_vfuncs.
Timo Sirainen <tss@iki.fi>
parents: 12860
diff changeset
292 struct mail_index_transaction_commit_result *result_r);
59e4c0d1457b lib-storage: Moved index_mailbox_context.save_*() methods to mailbox_vfuncs.
Timo Sirainen <tss@iki.fi>
parents: 12860
diff changeset
293 void (*transaction_save_rollback)(struct mail_save_context *save_ctx);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
294
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3735
diff changeset
295 bool (*is_inconsistent)(struct mailbox *box);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
296 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
297
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
298 union mailbox_module_context {
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
299 struct mailbox_vfuncs super;
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
300 struct mail_storage_module_register *reg;
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
301 };
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
302
14622
6fb61872b30a lib-imap-storage: imap-msgpart rewrite and API change.
Timo Sirainen <tss@iki.fi>
parents: 14613
diff changeset
303 struct mail_msgpart_partial_cache {
6fb61872b30a lib-imap-storage: imap-msgpart rewrite and API change.
Timo Sirainen <tss@iki.fi>
parents: 14613
diff changeset
304 uint32_t uid;
6fb61872b30a lib-imap-storage: imap-msgpart rewrite and API change.
Timo Sirainen <tss@iki.fi>
parents: 14613
diff changeset
305 uoff_t physical_start;
6fb61872b30a lib-imap-storage: imap-msgpart rewrite and API change.
Timo Sirainen <tss@iki.fi>
parents: 14613
diff changeset
306 uoff_t physical_pos, virtual_pos;
6fb61872b30a lib-imap-storage: imap-msgpart rewrite and API change.
Timo Sirainen <tss@iki.fi>
parents: 14613
diff changeset
307 };
6fb61872b30a lib-imap-storage: imap-msgpart rewrite and API change.
Timo Sirainen <tss@iki.fi>
parents: 14613
diff changeset
308
18903
7cdef26d857d lib-storage: Renamed struct index_vsize_header to struct mailbox_index_vsize
Timo Sirainen <tss@iki.fi>
parents: 18516
diff changeset
309 struct mailbox_index_vsize {
7cdef26d857d lib-storage: Renamed struct index_vsize_header to struct mailbox_index_vsize
Timo Sirainen <tss@iki.fi>
parents: 18516
diff changeset
310 uint64_t vsize;
7cdef26d857d lib-storage: Renamed struct index_vsize_header to struct mailbox_index_vsize
Timo Sirainen <tss@iki.fi>
parents: 18516
diff changeset
311 uint32_t highest_uid;
7cdef26d857d lib-storage: Renamed struct index_vsize_header to struct mailbox_index_vsize
Timo Sirainen <tss@iki.fi>
parents: 18516
diff changeset
312 uint32_t message_count;
7cdef26d857d lib-storage: Renamed struct index_vsize_header to struct mailbox_index_vsize
Timo Sirainen <tss@iki.fi>
parents: 18516
diff changeset
313 };
7cdef26d857d lib-storage: Renamed struct index_vsize_header to struct mailbox_index_vsize
Timo Sirainen <tss@iki.fi>
parents: 18516
diff changeset
314
20393
53ba3feb039a dbox: Optimize POP3 MAIL_FETCH_UIDL_BACKEND.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20272
diff changeset
315 struct mailbox_index_pop3_uidl {
53ba3feb039a dbox: Optimize POP3 MAIL_FETCH_UIDL_BACKEND.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20272
diff changeset
316 uint32_t max_uid_with_pop3_uidl;
53ba3feb039a dbox: Optimize POP3 MAIL_FETCH_UIDL_BACKEND.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20272
diff changeset
317 };
53ba3feb039a dbox: Optimize POP3 MAIL_FETCH_UIDL_BACKEND.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20272
diff changeset
318
19421
82e6a3baa001 Added mailbox { autoexpunge } setting.
Timo Sirainen <tss@iki.fi>
parents: 19103
diff changeset
319 struct mailbox_index_first_saved {
82e6a3baa001 Added mailbox { autoexpunge } setting.
Timo Sirainen <tss@iki.fi>
parents: 19103
diff changeset
320 uint32_t uid;
82e6a3baa001 Added mailbox { autoexpunge } setting.
Timo Sirainen <tss@iki.fi>
parents: 19103
diff changeset
321 uint32_t timestamp;
82e6a3baa001 Added mailbox { autoexpunge } setting.
Timo Sirainen <tss@iki.fi>
parents: 19103
diff changeset
322 };
82e6a3baa001 Added mailbox { autoexpunge } setting.
Timo Sirainen <tss@iki.fi>
parents: 19103
diff changeset
323
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
324 struct mailbox {
9468
653183a81b6c Mailbox opening and closing APIs changed.
Timo Sirainen <tss@iki.fi>
parents: 9455
diff changeset
325 const char *name;
12521
b22766c1aa51 lib-storage: Don't allocate index until mailbox_open()
Timo Sirainen <tss@iki.fi>
parents: 12520
diff changeset
326 /* mailbox's virtual name (from mail_namespace_get_vname()) */
b22766c1aa51 lib-storage: Don't allocate index until mailbox_open()
Timo Sirainen <tss@iki.fi>
parents: 12520
diff changeset
327 const char *vname;
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
328 struct mail_storage *storage;
9434
e374a365521d Initial commit for making mail_storage:mailbox_list to be from 1:1 to n:n.
Timo Sirainen <tss@iki.fi>
parents: 9174
diff changeset
329 struct mailbox_list *list;
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
330
20272
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
331 struct mailbox_vfuncs v, *vlast;
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
332 /* virtual mailboxes: */
3d60b96543fd virtual: Moved virtual_mailbox_vfuncs to lib-storage.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20035
diff changeset
333 const struct virtual_mailbox_vfuncs *virtual_vfuncs;
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
334 /* private: */
14524
3b4c336ed01b lib-storage: Allocate MAILBOX_METADATA_CACHE_FIELDS from a new metadata mempool.
Timo Sirainen <tss@iki.fi>
parents: 14463
diff changeset
335 pool_t pool, metadata_pool;
13754
deaebb4dc98c lib-storage: Track storage's all mailboxes to make it easier to debug if one isn't closed.
Timo Sirainen <tss@iki.fi>
parents: 13633
diff changeset
336 /* Linked list of all mailboxes in this storage */
deaebb4dc98c lib-storage: Track storage's all mailboxes to make it easier to debug if one isn't closed.
Timo Sirainen <tss@iki.fi>
parents: 13633
diff changeset
337 struct mailbox *prev, *next;
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
338
12520
b26d6da05d48 lib-storage: Lazily look up mailbox path and permissions. Added functions to get them.
Timo Sirainen <tss@iki.fi>
parents: 12518
diff changeset
339 /* these won't be set until mailbox is opened: */
10657
e7f066508299 lib-storage: Moved struct mail_index_* from index_mailbox to mailbox.
Timo Sirainen <tss@iki.fi>
parents: 10653
diff changeset
340 struct mail_index *index;
e7f066508299 lib-storage: Moved struct mail_index_* from index_mailbox to mailbox.
Timo Sirainen <tss@iki.fi>
parents: 10653
diff changeset
341 struct mail_index_view *view;
e7f066508299 lib-storage: Moved struct mail_index_* from index_mailbox to mailbox.
Timo Sirainen <tss@iki.fi>
parents: 10653
diff changeset
342 struct mail_cache *cache;
14599
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
343 /* Private per-user index/view for shared mailboxes. These are synced
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
344 against the primary index and used to store per-user flags.
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
345 These are non-NULL only when mailbox has per-user flags. */
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
346 struct mail_index *index_pvt;
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
347 struct mail_index_view *view_pvt;
12520
b26d6da05d48 lib-storage: Lazily look up mailbox path and permissions. Added functions to get them.
Timo Sirainen <tss@iki.fi>
parents: 12518
diff changeset
348 /* Filled lazily by mailbox_get_permissions() */
b26d6da05d48 lib-storage: Lazily look up mailbox path and permissions. Added functions to get them.
Timo Sirainen <tss@iki.fi>
parents: 12518
diff changeset
349 struct mailbox_permissions _perm;
15163
c7a99d41e39e lib-storage: mailbox_get_path() and friends can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15162
diff changeset
350 /* Filled lazily when mailbox is opened, use mailbox_get_path()
c7a99d41e39e lib-storage: mailbox_get_path() and friends can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15162
diff changeset
351 to access it */
12520
b26d6da05d48 lib-storage: Lazily look up mailbox path and permissions. Added functions to get them.
Timo Sirainen <tss@iki.fi>
parents: 12518
diff changeset
352 const char *_path;
17833
936435377584 lib-storage: Added mailbox_get_index_path() and caching of the index path.
Timo Sirainen <tss@iki.fi>
parents: 17758
diff changeset
353 /* Filled lazily when mailbox is opened, use mailbox_get_index_path()
936435377584 lib-storage: Added mailbox_get_index_path() and caching of the index path.
Timo Sirainen <tss@iki.fi>
parents: 17758
diff changeset
354 to access it */
936435377584 lib-storage: Added mailbox_get_index_path() and caching of the index path.
Timo Sirainen <tss@iki.fi>
parents: 17758
diff changeset
355 const char *_index_path;
21877
d703b0fde204 lib-storage: Add mailbox_set_reason()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21831
diff changeset
356 /* Reason for why mailbox is being accessed or NULL if unknown. */
d703b0fde204 lib-storage: Add mailbox_set_reason()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21831
diff changeset
357 const char *reason;
10657
e7f066508299 lib-storage: Moved struct mail_index_* from index_mailbox to mailbox.
Timo Sirainen <tss@iki.fi>
parents: 10653
diff changeset
358
e7f066508299 lib-storage: Moved struct mail_index_* from index_mailbox to mailbox.
Timo Sirainen <tss@iki.fi>
parents: 10653
diff changeset
359 /* default vfuncs for new struct mails. */
e7f066508299 lib-storage: Moved struct mail_index_* from index_mailbox to mailbox.
Timo Sirainen <tss@iki.fi>
parents: 10653
diff changeset
360 const struct mail_vfuncs *mail_vfuncs;
13793
ee783a878120 Moved autocreate plugin functionality into lib-storage.
Timo Sirainen <tss@iki.fi>
parents: 13754
diff changeset
361 /* Mailbox settings, or NULL if defaults */
ee783a878120 Moved autocreate plugin functionality into lib-storage.
Timo Sirainen <tss@iki.fi>
parents: 13754
diff changeset
362 const struct mailbox_settings *set;
10657
e7f066508299 lib-storage: Moved struct mail_index_* from index_mailbox to mailbox.
Timo Sirainen <tss@iki.fi>
parents: 10653
diff changeset
363
13219
7098642a0374 lib-storage: Added mailbox_alloc_guid() for opening mailbox by its GUID.
Timo Sirainen <tss@iki.fi>
parents: 13218
diff changeset
364 /* If non-zero, fail mailbox_open() with this error. mailbox_alloc()
7098642a0374 lib-storage: Added mailbox_alloc_guid() for opening mailbox by its GUID.
Timo Sirainen <tss@iki.fi>
parents: 13218
diff changeset
365 can set this to force open to fail. */
7098642a0374 lib-storage: Added mailbox_alloc_guid() for opening mailbox by its GUID.
Timo Sirainen <tss@iki.fi>
parents: 13218
diff changeset
366 enum mail_error open_error;
7098642a0374 lib-storage: Added mailbox_alloc_guid() for opening mailbox by its GUID.
Timo Sirainen <tss@iki.fi>
parents: 13218
diff changeset
367
9468
653183a81b6c Mailbox opening and closing APIs changed.
Timo Sirainen <tss@iki.fi>
parents: 9455
diff changeset
368 struct istream *input;
12521
b22766c1aa51 lib-storage: Don't allocate index until mailbox_open()
Timo Sirainen <tss@iki.fi>
parents: 12520
diff changeset
369 const char *index_prefix;
9468
653183a81b6c Mailbox opening and closing APIs changed.
Timo Sirainen <tss@iki.fi>
parents: 9455
diff changeset
370 enum mailbox_flags flags;
4939
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4876
diff changeset
371 unsigned int transaction_count;
7620
4b8c1c164d8f Initial CONDSTORE support.
Timo Sirainen <tss@iki.fi>
parents: 7414
diff changeset
372 enum mailbox_feature enabled_features;
14622
6fb61872b30a lib-imap-storage: imap-msgpart rewrite and API change.
Timo Sirainen <tss@iki.fi>
parents: 14613
diff changeset
373 struct mail_msgpart_partial_cache partial_cache;
18904
8e47bb182a42 lib-storage: Moved vsize_hdr_ext_id to struct mailbox for more global access.
Timo Sirainen <tss@iki.fi>
parents: 18903
diff changeset
374 uint32_t vsize_hdr_ext_id;
20393
53ba3feb039a dbox: Optimize POP3 MAIL_FETCH_UIDL_BACKEND.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20272
diff changeset
375 uint32_t pop3_uidl_hdr_ext_id;
21134
025a27734fda LAYOUT=index: Update mailbox name to mailbox index's header when opening.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20805
diff changeset
376 uint32_t box_name_hdr_ext_id;
21362
ef9c844a24bd index-storage: Update mailbox last_rename_stamp on rename
Aki Tuomi <aki.tuomi@dovecot.fi>
parents: 21253
diff changeset
377 uint32_t box_last_rename_stamp_ext_id;
21457
19f7a147c56f lib-storage: Move index_mail.vsize_ext_id to mailbox.mail_vsize_ext_id
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21362
diff changeset
378 uint32_t mail_vsize_ext_id;
4939
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4876
diff changeset
379
18975
f78bd5be4e47 lib-storage: Moved most of the \Recent flag handling code to mailbox-recent-flags.c
Timo Sirainen <tss@iki.fi>
parents: 18904
diff changeset
380 /* MAIL_RECENT flags handling */
f78bd5be4e47 lib-storage: Moved most of the \Recent flag handling code to mailbox-recent-flags.c
Timo Sirainen <tss@iki.fi>
parents: 18904
diff changeset
381 ARRAY_TYPE(seq_range) recent_flags;
f78bd5be4e47 lib-storage: Moved most of the \Recent flag handling code to mailbox-recent-flags.c
Timo Sirainen <tss@iki.fi>
parents: 18904
diff changeset
382 uint32_t recent_flags_prev_uid;
f78bd5be4e47 lib-storage: Moved most of the \Recent flag handling code to mailbox-recent-flags.c
Timo Sirainen <tss@iki.fi>
parents: 18904
diff changeset
383 uint32_t recent_flags_count;
f78bd5be4e47 lib-storage: Moved most of the \Recent flag handling code to mailbox-recent-flags.c
Timo Sirainen <tss@iki.fi>
parents: 18904
diff changeset
384
14374
fb70195b5d47 quota: Added a kludge to avoid recalculating quota.
Timo Sirainen <tss@iki.fi>
parents: 14254
diff changeset
385 struct mail_index_view *tmp_sync_view;
fb70195b5d47 quota: Added a kludge to avoid recalculating quota.
Timo Sirainen <tss@iki.fi>
parents: 14254
diff changeset
386
5465
014236cf3dcc Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents: 5462
diff changeset
387 /* Mailbox notification settings: */
014236cf3dcc Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents: 5462
diff changeset
388 mailbox_notify_callback_t *notify_callback;
014236cf3dcc Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents: 5462
diff changeset
389 void *notify_context;
18981
f84c81ed5d09 lib-storage: Moved index/index-mailbox-check.c code to mailbox-watch.c
Timo Sirainen <tss@iki.fi>
parents: 18975
diff changeset
390 struct timeout *to_notify, *to_notify_delay;
f84c81ed5d09 lib-storage: Moved index/index-mailbox-check.c code to mailbox-watch.c
Timo Sirainen <tss@iki.fi>
parents: 18975
diff changeset
391 struct mailbox_notify_file *notify_files;
5465
014236cf3dcc Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents: 5462
diff changeset
392
13218
bd0e7cdbb6b2 lib-storage: Added struct mailbox.generation_sequence.
Timo Sirainen <tss@iki.fi>
parents: 13125
diff changeset
393 /* Increased by one for each new struct mailbox. */
bd0e7cdbb6b2 lib-storage: Added struct mailbox.generation_sequence.
Timo Sirainen <tss@iki.fi>
parents: 13125
diff changeset
394 unsigned int generation_sequence;
bd0e7cdbb6b2 lib-storage: Added struct mailbox.generation_sequence.
Timo Sirainen <tss@iki.fi>
parents: 13125
diff changeset
395
7647
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7642
diff changeset
396 /* Saved search results */
14920
a097ef0a9d6d Array API changed: ARRAY_DEFINE(name, type) -> ARRAY(type) name
Timo Sirainen <tss@iki.fi>
parents: 14859
diff changeset
397 ARRAY(struct mail_search_result *) search_results;
7647
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7642
diff changeset
398
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
399 /* Module-specific contexts. See mail_storage_module_id. */
14920
a097ef0a9d6d Array API changed: ARRAY_DEFINE(name, type) -> ARRAY(type) name
Timo Sirainen <tss@iki.fi>
parents: 14859
diff changeset
400 ARRAY(union mailbox_module_context *) module_contexts;
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents: 4822
diff changeset
401
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents: 4822
diff changeset
402 /* When FAST open flag is used, the mailbox isn't actually opened until
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents: 4822
diff changeset
403 it's synced for the first time. */
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents: 4822
diff changeset
404 unsigned int opened:1;
6771
fd9effba151d Moved mailbox_deleted to struct mailbox. Added and used
Timo Sirainen <tss@iki.fi>
parents: 6598
diff changeset
405 /* Mailbox was deleted while we had it open. */
fd9effba151d Moved mailbox_deleted to struct mailbox. Added and used
Timo Sirainen <tss@iki.fi>
parents: 6598
diff changeset
406 unsigned int mailbox_deleted:1;
12809
1ffeb083c993 sdbox: Fixed creating mailbox with given GUID.
Timo Sirainen <tss@iki.fi>
parents: 12458
diff changeset
407 /* Mailbox is being created */
1ffeb083c993 sdbox: Fixed creating mailbox with given GUID.
Timo Sirainen <tss@iki.fi>
parents: 12458
diff changeset
408 unsigned int creating:1;
10678
9740c4858a57 Mailbox deletion: Fixed race condition where a mailbox couldn't get deleted.
Timo Sirainen <tss@iki.fi>
parents: 10676
diff changeset
409 /* Mailbox is being deleted */
9740c4858a57 Mailbox deletion: Fixed race condition where a mailbox couldn't get deleted.
Timo Sirainen <tss@iki.fi>
parents: 10676
diff changeset
410 unsigned int deleting:1;
21567
8004757eeee0 lib-storage: Make sure mailbox undeletion won't go to infinite loop
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21539
diff changeset
411 /* Mailbox is being undeleted */
8004757eeee0 lib-storage: Make sure mailbox undeletion won't go to infinite loop
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21539
diff changeset
412 unsigned int mailbox_undeleting:1;
17758
6980c53bf7d7 lib-index, lib-storage: Fixed race conditions with deleting mailbox.
Timo Sirainen <tss@iki.fi>
parents: 17708
diff changeset
413 /* Don't use MAIL_INDEX_SYNC_FLAG_DELETING_INDEX for sync flag */
6980c53bf7d7 lib-index, lib-storage: Fixed race conditions with deleting mailbox.
Timo Sirainen <tss@iki.fi>
parents: 17708
diff changeset
414 unsigned int delete_sync_check:1;
14463
2d8bafd11569 lib-storage: Added mailbox_delete_empty().
Timo Sirainen <tss@iki.fi>
parents: 14399
diff changeset
415 /* Delete mailbox only if it's empty */
2d8bafd11569 lib-storage: Added mailbox_delete_empty().
Timo Sirainen <tss@iki.fi>
parents: 14399
diff changeset
416 unsigned int deleting_must_be_empty:1;
16440
7af6795f40ed imapc: Fixed mailbox deletion.
Timo Sirainen <tss@iki.fi>
parents: 16373
diff changeset
417 /* The backend wants to skip checking if there are 0 messages before
7af6795f40ed imapc: Fixed mailbox deletion.
Timo Sirainen <tss@iki.fi>
parents: 16373
diff changeset
418 calling mailbox_list.delete_mailbox() */
7af6795f40ed imapc: Fixed mailbox deletion.
Timo Sirainen <tss@iki.fi>
parents: 16373
diff changeset
419 unsigned int delete_skip_empty_check:1;
12040
72b5a0af6e4e lib-storage: Allow mailbox_mark_index_deleted() to be called multiple times within same mailbox alloc.
Timo Sirainen <tss@iki.fi>
parents: 11740
diff changeset
420 /* Mailbox was already marked as deleted within this allocation. */
72b5a0af6e4e lib-storage: Allow mailbox_mark_index_deleted() to be called multiple times within same mailbox alloc.
Timo Sirainen <tss@iki.fi>
parents: 11740
diff changeset
421 unsigned int marked_deleted:1;
11740
07353259bb41 Fixes to INBOX sharing.
Timo Sirainen <tss@iki.fi>
parents: 11665
diff changeset
422 /* TRUE if this is an INBOX for this user */
07353259bb41 Fixes to INBOX sharing.
Timo Sirainen <tss@iki.fi>
parents: 11665
diff changeset
423 unsigned int inbox_user:1;
07353259bb41 Fixes to INBOX sharing.
Timo Sirainen <tss@iki.fi>
parents: 11665
diff changeset
424 /* TRUE if this is an INBOX for this namespace (user or shared) */
07353259bb41 Fixes to INBOX sharing.
Timo Sirainen <tss@iki.fi>
parents: 11665
diff changeset
425 unsigned int inbox_any:1;
12458
10c2540e91b9 lib-storage: If disable_reflink_copy_to=TRUE, disable hardlink/refcount copying.
Timo Sirainen <tss@iki.fi>
parents: 12390
diff changeset
426 /* When copying to this mailbox, require that mailbox_copy() uses
10c2540e91b9 lib-storage: If disable_reflink_copy_to=TRUE, disable hardlink/refcount copying.
Timo Sirainen <tss@iki.fi>
parents: 12390
diff changeset
427 mailbox_save_*() to actually save a new physical copy rather than
10c2540e91b9 lib-storage: If disable_reflink_copy_to=TRUE, disable hardlink/refcount copying.
Timo Sirainen <tss@iki.fi>
parents: 12390
diff changeset
428 simply incrementing a reference count (e.g. via hard link) */
10c2540e91b9 lib-storage: If disable_reflink_copy_to=TRUE, disable hardlink/refcount copying.
Timo Sirainen <tss@iki.fi>
parents: 12390
diff changeset
429 unsigned int disable_reflink_copy_to:1;
13394
d15b173688f9 lib-storage: Added mailbox.disallow_new_keywords and use it for mailbox_status.
Timo Sirainen <tss@iki.fi>
parents: 13337
diff changeset
430 /* Don't allow creating any new keywords */
d15b173688f9 lib-storage: Added mailbox.disallow_new_keywords and use it for mailbox_status.
Timo Sirainen <tss@iki.fi>
parents: 13337
diff changeset
431 unsigned int disallow_new_keywords:1;
14556
eab6ce7a5ad6 lib-storage: Added a mailbox.synced flag, which is set when mailbox sync has succeeded.
Timo Sirainen <tss@iki.fi>
parents: 14524
diff changeset
432 /* Mailbox has been synced at least once */
eab6ce7a5ad6 lib-storage: Added a mailbox.synced flag, which is set when mailbox sync has succeeded.
Timo Sirainen <tss@iki.fi>
parents: 14524
diff changeset
433 unsigned int synced:1;
17298
c1719de47d5e lib-storage: mail_never_cache_fields=* means now to disable all caching.
Timo Sirainen <tss@iki.fi>
parents: 17297
diff changeset
434 /* Updating cache file is disabled */
c1719de47d5e lib-storage: mail_never_cache_fields=* means now to disable all caching.
Timo Sirainen <tss@iki.fi>
parents: 17297
diff changeset
435 unsigned int mail_cache_disabled:1;
19423
d4e5b4ab01dd lib-storage: Don't add first_saved to mailbox list index unless autoexpunge is set.
Timo Sirainen <tss@iki.fi>
parents: 19421
diff changeset
436 /* Update first_saved field to mailbox list index. */
d4e5b4ab01dd lib-storage: Don't add first_saved to mailbox list index unless autoexpunge is set.
Timo Sirainen <tss@iki.fi>
parents: 19421
diff changeset
437 unsigned int update_first_saved:1;
19525
5b5c36bc38e0 dsync: Don't restrict what mailbox names can be created (except basic sanity checks)
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19423
diff changeset
438 /* mailbox_verify_create_name() only checks for mailbox_verify_name() */
5b5c36bc38e0 dsync: Don't restrict what mailbox names can be created (except basic sanity checks)
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19423
diff changeset
439 unsigned int skip_create_name_restrictions:1;
20405
8518e1a31640 lib-storage: Added a kludgy quick-"parameter" to list_index_has_changed()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20393
diff changeset
440 /* v2.2.x API kludge: quick-parameter to list_index_has_changed() */
8518e1a31640 lib-storage: Added a kludgy quick-"parameter" to list_index_has_changed()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20393
diff changeset
441 unsigned int list_index_has_changed_quick:1;
21138
b24657e6abe7 lib-storage: Added struct mailbox.corrupted_mailbox_name
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21134
diff changeset
442 /* Using LAYOUT=index and mailbox is being opened with a corrupted
b24657e6abe7 lib-storage: Added struct mailbox.corrupted_mailbox_name
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21134
diff changeset
443 mailbox name. Try to revert to the previously known good name. */
b24657e6abe7 lib-storage: Added struct mailbox.corrupted_mailbox_name
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21134
diff changeset
444 unsigned int corrupted_mailbox_name:1;
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
445 };
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
446
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
447 struct mail_vfuncs {
6289
4a57baddc8b8 Added mail.close() virtual function.
Timo Sirainen <tss@iki.fi>
parents: 6280
diff changeset
448 void (*close)(struct mail *mail);
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
449 void (*free)(struct mail *mail);
13120
06873db0bfef lib-storage: mail->saving was set too late, which could have caused crashes.
Timo Sirainen <tss@iki.fi>
parents: 13080
diff changeset
450 void (*set_seq)(struct mail *mail, uint32_t seq, bool saving);
6277
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
451 bool (*set_uid)(struct mail *mail, uint32_t uid);
8925
a1d920a81adc Mail copying: Avoid updating cache file because of copying.
Timo Sirainen <tss@iki.fi>
parents: 8921
diff changeset
452 void (*set_uid_cache_updates)(struct mail *mail, bool set);
12874
0461e23ae57c Search supports now prefetching data for returned mails. Dropped imapc's own prefetching.
Timo Sirainen <tss@iki.fi>
parents: 12870
diff changeset
453 bool (*prefetch)(struct mail *mail);
13337
51e9b2fb0596 Redesigned mail precaching APIs.
Timo Sirainen <tss@iki.fi>
parents: 13289
diff changeset
454 void (*precache)(struct mail *mail);
13633
e77601949937 lib-storage: Added mail_log_update_wanted_fields()
Timo Sirainen <tss@iki.fi>
parents: 13601
diff changeset
455 void (*add_temp_wanted_fields)(struct mail *mail,
e77601949937 lib-storage: Added mail_log_update_wanted_fields()
Timo Sirainen <tss@iki.fi>
parents: 13601
diff changeset
456 enum mail_fetch_field fields,
e77601949937 lib-storage: Added mail_log_update_wanted_fields()
Timo Sirainen <tss@iki.fi>
parents: 13601
diff changeset
457 struct mailbox_header_lookup_ctx *headers);
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
458
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
459 enum mail_flags (*get_flags)(struct mail *mail);
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
460 const char *const *(*get_keywords)(struct mail *mail);
6985
58b8daf695bf Added mail_get_keyword_indexes()
Timo Sirainen <tss@iki.fi>
parents: 6777
diff changeset
461 const ARRAY_TYPE(keyword_indexes) *
58b8daf695bf Added mail_get_keyword_indexes()
Timo Sirainen <tss@iki.fi>
parents: 6777
diff changeset
462 (*get_keyword_indexes)(struct mail *mail);
7620
4b8c1c164d8f Initial CONDSTORE support.
Timo Sirainen <tss@iki.fi>
parents: 7414
diff changeset
463 uint64_t (*get_modseq)(struct mail *mail);
15495
69371578720f lib-storage: Added support for "private modseqs" for INDEXPVT index.
Timo Sirainen <tss@iki.fi>
parents: 15411
diff changeset
464 uint64_t (*get_pvt_modseq)(struct mail *mail);
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
465
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
466 int (*get_parts)(struct mail *mail,
11000
679e99e430d7 lib-storage: mail_get_parts() no longer returns const pointer.
Timo Sirainen <tss@iki.fi>
parents: 10946
diff changeset
467 struct message_part **parts_r);
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
468 int (*get_date)(struct mail *mail, time_t *date_r, int *timezone_r);
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
469 int (*get_received_date)(struct mail *mail, time_t *date_r);
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
470 int (*get_save_date)(struct mail *mail, time_t *date_r);
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
471 int (*get_virtual_size)(struct mail *mail, uoff_t *size_r);
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
472 int (*get_physical_size)(struct mail *mail, uoff_t *size_r);
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
473
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
474 int (*get_first_header)(struct mail *mail, const char *field,
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
475 bool decode_to_utf8, const char **value_r);
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
476 int (*get_headers)(struct mail *mail, const char *field,
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
477 bool decode_to_utf8, const char *const **value_r);
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
478 int (*get_header_stream)(struct mail *mail,
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
479 struct mailbox_header_lookup_ctx *headers,
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
480 struct istream **stream_r);
13601
276a39ebda4d lib-storage: Added mail_get_hdr_stream() and use it where possible.
Timo Sirainen <tss@iki.fi>
parents: 13592
diff changeset
481 int (*get_stream)(struct mail *mail, bool get_body,
276a39ebda4d lib-storage: Added mail_get_hdr_stream() and use it where possible.
Timo Sirainen <tss@iki.fi>
parents: 13592
diff changeset
482 struct message_size *hdr_size,
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
483 struct message_size *body_size,
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
484 struct istream **stream_r);
14859
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
485 int (*get_binary_stream)(struct mail *mail,
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
486 const struct message_part *part,
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
487 bool include_hdr, uoff_t *size_r,
15237
3484591230ac imap: URLFETCH BINARY BODYPARTSTRUCTURE returns binary-decoded line counts.
Timo Sirainen <tss@iki.fi>
parents: 15224
diff changeset
488 unsigned int *lines_r, bool *binary_r,
3484591230ac imap: URLFETCH BINARY BODYPARTSTRUCTURE returns binary-decoded line counts.
Timo Sirainen <tss@iki.fi>
parents: 15224
diff changeset
489 struct istream **stream_r);
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
490
6280
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
491 int (*get_special)(struct mail *mail, enum mail_fetch_field field,
eb7c9d8ece54 mail_*() APIs changed to return int and return the actual data as pointer.
Timo Sirainen <tss@iki.fi>
parents: 6279
diff changeset
492 const char **value_r);
17297
5c4205a95028 lib-storage: Partially reverted the mail.get_real_mail() API change for backwards compatibility.
Timo Sirainen <tss@iki.fi>
parents: 17289
diff changeset
493 /* FIXME: v2.3 API should change this to return -1 on failure.
5c4205a95028 lib-storage: Partially reverted the mail.get_real_mail() API change for backwards compatibility.
Timo Sirainen <tss@iki.fi>
parents: 17289
diff changeset
494 for now NULL means failure so we don't break backwards
5c4205a95028 lib-storage: Partially reverted the mail.get_real_mail() API change for backwards compatibility.
Timo Sirainen <tss@iki.fi>
parents: 17289
diff changeset
495 compatibility. */
5c4205a95028 lib-storage: Partially reverted the mail.get_real_mail() API change for backwards compatibility.
Timo Sirainen <tss@iki.fi>
parents: 17289
diff changeset
496 struct mail *(*get_real_mail)(struct mail *mail);
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
497
6277
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
498 void (*update_flags)(struct mail *mail, enum modify_type modify_type,
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
499 enum mail_flags flags);
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
500 void (*update_keywords)(struct mail *mail, enum modify_type modify_type,
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
501 struct mail_keywords *keywords);
9691
b09d9350a2d9 Added ability to specify message's minimum modseq value.
Timo Sirainen <tss@iki.fi>
parents: 9681
diff changeset
502 void (*update_modseq)(struct mail *mail, uint64_t min_modseq);
15495
69371578720f lib-storage: Added support for "private modseqs" for INDEXPVT index.
Timo Sirainen <tss@iki.fi>
parents: 15411
diff changeset
503 void (*update_pvt_modseq)(struct mail *mail, uint64_t min_pvt_modseq);
9847
ecb05365f520 Added pop3_save_uidl setting.
Timo Sirainen <tss@iki.fi>
parents: 9825
diff changeset
504 void (*update_pop3_uidl)(struct mail *mail, const char *uidl);
6277
5f66277bbe40 mail_index_lookup*() can't fail anymore. Changed several APIs not to return
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
505 void (*expunge)(struct mail *mail);
7241
a6c066f50877 Added mail_set_cache_corrupted() to rebuild the cache file and force
Timo Sirainen <tss@iki.fi>
parents: 7175
diff changeset
506 void (*set_cache_corrupted)(struct mail *mail,
a6c066f50877 Added mail_set_cache_corrupted() to rebuild the cache file and force
Timo Sirainen <tss@iki.fi>
parents: 7175
diff changeset
507 enum mail_fetch_field field);
12322
d94957cafd3e lib-storage: Added istream_opened() method to struct mail.
Timo Sirainen <tss@iki.fi>
parents: 12312
diff changeset
508 int (*istream_opened)(struct mail *mail, struct istream **input);
19882
0ff471005aa0 lib-storage: Added mail_set_cache_corrupted_reason()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19525
diff changeset
509 void (*set_cache_corrupted_reason)(struct mail *mail,
0ff471005aa0 lib-storage: Added mail_set_cache_corrupted_reason()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19525
diff changeset
510 enum mail_fetch_field field,
0ff471005aa0 lib-storage: Added mail_set_cache_corrupted_reason()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19525
diff changeset
511 const char *reason);
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
512 };
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
513
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
514 union mail_module_context {
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
515 struct mail_vfuncs super;
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
516 struct mail_module_register *reg;
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
517 };
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
518
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
519 struct mail_private {
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
520 struct mail mail;
11488
4b20e692c606 lib-storage: Plugin API changed to run plugin functions in correct order.
Timo Sirainen <tss@iki.fi>
parents: 11487
diff changeset
521 struct mail_vfuncs v, *vlast;
15497
5bb879b6e3f3 lib-storage: Bypass virtual storage when copying mail to allow optimizations.
Timo Sirainen <tss@iki.fi>
parents: 15495
diff changeset
522 /* normally NULL, but in case this is a "backend mail" for a mail
5bb879b6e3f3 lib-storage: Bypass virtual storage when copying mail to allow optimizations.
Timo Sirainen <tss@iki.fi>
parents: 15495
diff changeset
523 created by virtual storage, this points back to the original virtual
5bb879b6e3f3 lib-storage: Bypass virtual storage when copying mail to allow optimizations.
Timo Sirainen <tss@iki.fi>
parents: 15495
diff changeset
524 mail. at least mailbox_copy() bypasses the virtual storage, so this
5bb879b6e3f3 lib-storage: Bypass virtual storage when copying mail to allow optimizations.
Timo Sirainen <tss@iki.fi>
parents: 15495
diff changeset
525 allows mail_log plugin to log the copy operation using the original
5bb879b6e3f3 lib-storage: Bypass virtual storage when copying mail to allow optimizations.
Timo Sirainen <tss@iki.fi>
parents: 15495
diff changeset
526 mailbox name. */
5bb879b6e3f3 lib-storage: Bypass virtual storage when copying mail to allow optimizations.
Timo Sirainen <tss@iki.fi>
parents: 15495
diff changeset
527 struct mail *vmail;
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
528
14599
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
529 uint32_t seq_pvt;
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
530
13633
e77601949937 lib-storage: Added mail_log_update_wanted_fields()
Timo Sirainen <tss@iki.fi>
parents: 13601
diff changeset
531 /* initial wanted fields/headers, set by mail_alloc(): */
8482
1ff129ed866a Added wanted_fields and wanted_headers fields to struct mail_search_context.
Timo Sirainen <tss@iki.fi>
parents: 8477
diff changeset
532 enum mail_fetch_field wanted_fields;
1ff129ed866a Added wanted_fields and wanted_headers fields to struct mail_search_context.
Timo Sirainen <tss@iki.fi>
parents: 8477
diff changeset
533 struct mailbox_header_lookup_ctx *wanted_headers;
1ff129ed866a Added wanted_fields and wanted_headers fields to struct mail_search_context.
Timo Sirainen <tss@iki.fi>
parents: 8477
diff changeset
534
15055
c436a6c3f7d2 lib-storage: Moved index_mail.data_pool to mail_private.data_pool
Timo Sirainen <tss@iki.fi>
parents: 15053
diff changeset
535 pool_t pool, data_pool;
14920
a097ef0a9d6d Array API changed: ARRAY_DEFINE(name, type) -> ARRAY(type) name
Timo Sirainen <tss@iki.fi>
parents: 14859
diff changeset
536 ARRAY(union mail_module_context *) module_contexts;
20558
df08a7bc2b0d lib-storage: Added mail_get_stream_because() and mail_get_hdr_stream_because()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20405
diff changeset
537
df08a7bc2b0d lib-storage: Added mail_get_stream_because() and mail_get_hdr_stream_because()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20405
diff changeset
538 const char *get_stream_reason;
21831
a9b10b0a6bd3 lib-storage: Indicate mail is being autoexpunged
Aki Tuomi <aki.tuomi@dovecot.fi>
parents: 21812
diff changeset
539
a9b10b0a6bd3 lib-storage: Indicate mail is being autoexpunged
Aki Tuomi <aki.tuomi@dovecot.fi>
parents: 21812
diff changeset
540 bool autoexpunged:1;
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
541 };
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
542
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
543 struct mailbox_list_context {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
544 struct mail_storage *storage;
4076
7f48190f868f Moved mailbox_list_flags to struct mailbox_list_context so plugins can see the flags more easily.
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4044
diff changeset
545 enum mailbox_list_flags flags;
4041
9d7420b0e1ef Make life easier for plugins:
Timo Sirainen <timo.sirainen@movial.fi>
parents: 3863
diff changeset
546 bool failed;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
547 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
548
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
549 union mailbox_transaction_module_context {
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
550 struct mail_storage_module_register *reg;
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
551 };
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
552
13289
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
553 struct mailbox_transaction_stats {
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
554 unsigned long open_lookup_count;
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
555 unsigned long stat_lookup_count;
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
556 unsigned long fstat_lookup_count;
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
557 /* number of files we've opened and read */
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
558 unsigned long files_read_count;
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
559 /* number of bytes we've had to read from files */
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
560 unsigned long long files_read_bytes;
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
561 /* number of cache lookup hits */
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
562 unsigned long cache_hit_count;
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
563 };
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
564
15835
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
565 struct mail_save_private_changes {
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
566 /* first saved mail is 0, second is 1, etc. we'll map these to UIDs
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
567 using struct mail_transaction_commit_changes. */
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
568 unsigned int mailnum;
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
569 enum mail_flags flags;
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
570 };
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
571
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
572 struct mailbox_transaction_context {
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
573 struct mailbox *box;
7413
5d96b15832fc Added transaction flags to struct mailbox_transaction_context.
Timo Sirainen <tss@iki.fi>
parents: 7241
diff changeset
574 enum mailbox_transaction_flags flags;
21879
313601eae9a8 lib-storage: Add mailbox_transaction_set_reason()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21877
diff changeset
575 char *reason;
7413
5d96b15832fc Added transaction flags to struct mailbox_transaction_context.
Timo Sirainen <tss@iki.fi>
parents: 7241
diff changeset
576
12518
88577ccb1380 lib-storage: Removed struct index_transaction_context.
Timo Sirainen <tss@iki.fi>
parents: 12458
diff changeset
577 union mail_index_transaction_module_context module_ctx;
88577ccb1380 lib-storage: Removed struct index_transaction_context.
Timo Sirainen <tss@iki.fi>
parents: 12458
diff changeset
578 struct mail_index_transaction_vfuncs super;
88577ccb1380 lib-storage: Removed struct index_transaction_context.
Timo Sirainen <tss@iki.fi>
parents: 12458
diff changeset
579 int mail_ref_count;
88577ccb1380 lib-storage: Removed struct index_transaction_context.
Timo Sirainen <tss@iki.fi>
parents: 12458
diff changeset
580
10946
0cf62ad4c7bf lib-storage: Moved index transaction/view from index_transaction to mailbox_transaction.
Timo Sirainen <tss@iki.fi>
parents: 10765
diff changeset
581 struct mail_index_transaction *itrans;
16024
f3cd9e5cbe99 lib-storage: Changed mailbox_attribute_get/set() APIs to have a transaction and update index.
Timo Sirainen <tss@iki.fi>
parents: 15835
diff changeset
582 struct dict_transaction_context *attr_pvt_trans, *attr_shared_trans;
10946
0cf62ad4c7bf lib-storage: Moved index transaction/view from index_transaction to mailbox_transaction.
Timo Sirainen <tss@iki.fi>
parents: 10765
diff changeset
583 /* view contains all changes done within this transaction */
0cf62ad4c7bf lib-storage: Moved index transaction/view from index_transaction to mailbox_transaction.
Timo Sirainen <tss@iki.fi>
parents: 10765
diff changeset
584 struct mail_index_view *view;
0cf62ad4c7bf lib-storage: Moved index transaction/view from index_transaction to mailbox_transaction.
Timo Sirainen <tss@iki.fi>
parents: 10765
diff changeset
585
14599
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
586 /* for private index updates: */
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
587 struct mail_index_transaction *itrans_pvt;
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
588 struct mail_index_view *view_pvt;
dbd42f7198eb shared mailboxes: Per-user flags can now be stored in private index files.
Timo Sirainen <tss@iki.fi>
parents: 14576
diff changeset
589
12994
55ff92050bd7 lib-storage: Added mail_is_cached()
Timo Sirainen <tss@iki.fi>
parents: 12910
diff changeset
590 struct mail_cache_view *cache_view;
55ff92050bd7 lib-storage: Added mail_is_cached()
Timo Sirainen <tss@iki.fi>
parents: 12910
diff changeset
591 struct mail_cache_transaction_ctx *cache_trans;
55ff92050bd7 lib-storage: Added mail_is_cached()
Timo Sirainen <tss@iki.fi>
parents: 12910
diff changeset
592
9649
47356e8dda45 mailbox_transaction_commit_get_uids() changed to _get_changes() with more generic API.
Timo Sirainen <tss@iki.fi>
parents: 9643
diff changeset
593 struct mail_transaction_commit_changes *changes;
14920
a097ef0a9d6d Array API changed: ARRAY_DEFINE(name, type) -> ARRAY(type) name
Timo Sirainen <tss@iki.fi>
parents: 14859
diff changeset
594 ARRAY(union mailbox_transaction_module_context *) module_contexts;
9708
ef135231b675 index-storage: Simplified the way transactions are are created/finished.
Timo Sirainen <tss@iki.fi>
parents: 9694
diff changeset
595
20393
53ba3feb039a dbox: Optimize POP3 MAIL_FETCH_UIDL_BACKEND.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20272
diff changeset
596 uint32_t prev_pop3_uidl_tracking_seq;
53ba3feb039a dbox: Optimize POP3 MAIL_FETCH_UIDL_BACKEND.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20272
diff changeset
597 uint32_t highest_pop3_uidl_uid;
53ba3feb039a dbox: Optimize POP3 MAIL_FETCH_UIDL_BACKEND.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20272
diff changeset
598
9708
ef135231b675 index-storage: Simplified the way transactions are are created/finished.
Timo Sirainen <tss@iki.fi>
parents: 9694
diff changeset
599 struct mail_save_context *save_ctx;
15835
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
600 /* number of mails saved/copied within this transaction. */
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
601 unsigned int save_count;
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
602 /* List of private flags added with save/copy. These are added to the
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
603 private index after committing the mails to the shared index. */
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
604 ARRAY(struct mail_save_private_changes) pvt_saves;
13250
b7a6573dacca lib-storage: Moved stats_* from mail to transaction.
Timo Sirainen <tss@iki.fi>
parents: 13243
diff changeset
605
b7a6573dacca lib-storage: Moved stats_* from mail to transaction.
Timo Sirainen <tss@iki.fi>
parents: 13243
diff changeset
606 /* these statistics are never reset by mail-storage API: */
13289
4317429862e1 lib-storage: Moved all transaction stats_* to struct mailbox_transaction_stats.
Timo Sirainen <tss@iki.fi>
parents: 13250
diff changeset
607 struct mailbox_transaction_stats stats;
13250
b7a6573dacca lib-storage: Moved stats_* from mail to transaction.
Timo Sirainen <tss@iki.fi>
parents: 13243
diff changeset
608 /* Set to TRUE to update stats_* fields */
b7a6573dacca lib-storage: Moved stats_* from mail to transaction.
Timo Sirainen <tss@iki.fi>
parents: 13243
diff changeset
609 unsigned int stats_track:1;
14254
3e9f91d8b2af lib-storage: mail_transaction_commit_changes.changed=TRUE only when something actually changed.
Timo Sirainen <tss@iki.fi>
parents: 13896
diff changeset
610 /* We've done some non-transactional (e.g. dovecot-uidlist updates) */
3e9f91d8b2af lib-storage: mail_transaction_commit_changes.changed=TRUE only when something actually changed.
Timo Sirainen <tss@iki.fi>
parents: 13896
diff changeset
611 unsigned int nontransactional_changes:1;
19103
5d3c7d882bfb lib-storage: Allow set/get for Dovecot-private attributes via internal attributes.
Timo Sirainen <tss@iki.fi>
parents: 18981
diff changeset
612 /* FIXME: v2.3: this should be in attribute_get/set() parameters */
5d3c7d882bfb lib-storage: Allow set/get for Dovecot-private attributes via internal attributes.
Timo Sirainen <tss@iki.fi>
parents: 18981
diff changeset
613 unsigned int internal_attribute:1;
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
614 };
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
615
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
616 union mail_search_module_context {
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
617 struct mail_storage_module_register *reg;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
618 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
619
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
620 struct mail_search_context {
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
621 struct mailbox_transaction_context *transaction;
4607
71b3570946f8 Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
622
7642
077bb84e9e77 Make mail_search_args an independent structure that can be used for multiple
Timo Sirainen <tss@iki.fi>
parents: 7629
diff changeset
623 struct mail_search_args *args;
4607
71b3570946f8 Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
624 struct mail_search_sort_program *sort_program;
12874
0461e23ae57c Search supports now prefetching data for returned mails. Dropped imapc's own prefetching.
Timo Sirainen <tss@iki.fi>
parents: 12870
diff changeset
625 enum mail_fetch_field wanted_fields;
0461e23ae57c Search supports now prefetching data for returned mails. Dropped imapc's own prefetching.
Timo Sirainen <tss@iki.fi>
parents: 12870
diff changeset
626 struct mailbox_header_lookup_ctx *wanted_headers;
15141
99305e4dd403 Backported parts of normalizer_func_t changes from v2.2 tree.
Timo Sirainen <tss@iki.fi>
parents: 14556
diff changeset
627 normalizer_func_t *normalizer;
4607
71b3570946f8 Moved some search parameters to public struct mail_search_context and added
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
628
7647
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7642
diff changeset
629 /* if non-NULL, specifies that a search resulting is being updated.
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7642
diff changeset
630 this can be used as a search optimization: if searched message
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7642
diff changeset
631 already exists in search result, it's not necessary to check if
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7642
diff changeset
632 static data matches. */
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7642
diff changeset
633 struct mail_search_result *update_result;
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7642
diff changeset
634 /* add matches to these search results */
14920
a097ef0a9d6d Array API changed: ARRAY_DEFINE(name, type) -> ARRAY(type) name
Timo Sirainen <tss@iki.fi>
parents: 14859
diff changeset
635 ARRAY(struct mail_search_result *) results;
7647
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7642
diff changeset
636
4196
6ac0d63b297f Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents: 4076
diff changeset
637 uint32_t seq;
8507
f323bf2465bd Give more correct "* OK searched n%" notifications with fts and virtual mailboxes.
Timo Sirainen <tss@iki.fi>
parents: 8499
diff changeset
638 uint32_t progress_cur, progress_max;
f323bf2465bd Give more correct "* OK searched n%" notifications with fts and virtual mailboxes.
Timo Sirainen <tss@iki.fi>
parents: 8499
diff changeset
639
14920
a097ef0a9d6d Array API changed: ARRAY_DEFINE(name, type) -> ARRAY(type) name
Timo Sirainen <tss@iki.fi>
parents: 14859
diff changeset
640 ARRAY(union mail_search_module_context *) module_contexts;
8411
abd0ef855a33 Implemented imap-response-codes draft.
Timo Sirainen <tss@iki.fi>
parents: 8336
diff changeset
641
abd0ef855a33 Implemented imap-response-codes draft.
Timo Sirainen <tss@iki.fi>
parents: 8336
diff changeset
642 unsigned int seen_lost_data:1;
8508
689a63a99363 fts: Hide "Searching .." notify while indexing.
Timo Sirainen <tss@iki.fi>
parents: 8507
diff changeset
643 unsigned int progress_hidden:1;
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
644 };
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
645
14952
b966759dd48c lib-storage: Moved per-mail data in struct mail_save_context to separate struct.
Timo Sirainen <tss@iki.fi>
parents: 14920
diff changeset
646 struct mail_save_data {
8075
8a068f879cd1 mailbox_save_init() API was split to multiple functions.
Timo Sirainen <tss@iki.fi>
parents: 8042
diff changeset
647 enum mail_flags flags;
15835
02529503c59c lib-storage: Saving/copying no longer discards private message flags.
Timo Sirainen <tss@iki.fi>
parents: 15774
diff changeset
648 enum mail_flags pvt_flags;
8075
8a068f879cd1 mailbox_save_init() API was split to multiple functions.
Timo Sirainen <tss@iki.fi>
parents: 8042
diff changeset
649 struct mail_keywords *keywords;
9691
b09d9350a2d9 Added ability to specify message's minimum modseq value.
Timo Sirainen <tss@iki.fi>
parents: 9681
diff changeset
650 uint64_t min_modseq;
8075
8a068f879cd1 mailbox_save_init() API was split to multiple functions.
Timo Sirainen <tss@iki.fi>
parents: 8042
diff changeset
651
9554
49f736dce881 Mailbox saving: Allow setting IMAP UID, POP3 UIDL and save date.
Timo Sirainen <tss@iki.fi>
parents: 9537
diff changeset
652 time_t received_date, save_date;
8075
8a068f879cd1 mailbox_save_init() API was split to multiple functions.
Timo Sirainen <tss@iki.fi>
parents: 8042
diff changeset
653 int received_tz_offset;
8a068f879cd1 mailbox_save_init() API was split to multiple functions.
Timo Sirainen <tss@iki.fi>
parents: 8042
diff changeset
654
21165
e912e661fa6f lib-storage: Add support for storing "mail stubs"
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21163
diff changeset
655 uint32_t uid, stub_seq;
9554
49f736dce881 Mailbox saving: Allow setting IMAP UID, POP3 UIDL and save date.
Timo Sirainen <tss@iki.fi>
parents: 9537
diff changeset
656 char *guid, *pop3_uidl, *from_envelope;
14399
82cd7aa65faf lib-storage: Added mailbox_save_set_pop3_order() and implemented for Maildir.
Timo Sirainen <tss@iki.fi>
parents: 14374
diff changeset
657 unsigned int pop3_order;
9825
9f5bbc4780a1 mailbox_copy() now sets mail_save_context.copying=TRUE.
Timo Sirainen <tss@iki.fi>
parents: 9779
diff changeset
658
14952
b966759dd48c lib-storage: Moved per-mail data in struct mail_save_context to separate struct.
Timo Sirainen <tss@iki.fi>
parents: 14920
diff changeset
659 struct ostream *output;
12312
28eaaa23f2c6 lib-storage: Added support for saving mail attachments separately via filesystem API.
Timo Sirainen <tss@iki.fi>
parents: 12040
diff changeset
660 struct mail_save_attachment *attach;
14952
b966759dd48c lib-storage: Moved per-mail data in struct mail_save_context to separate struct.
Timo Sirainen <tss@iki.fi>
parents: 14920
diff changeset
661 };
b966759dd48c lib-storage: Moved per-mail data in struct mail_save_context to separate struct.
Timo Sirainen <tss@iki.fi>
parents: 14920
diff changeset
662
b966759dd48c lib-storage: Moved per-mail data in struct mail_save_context to separate struct.
Timo Sirainen <tss@iki.fi>
parents: 14920
diff changeset
663 struct mail_save_context {
b966759dd48c lib-storage: Moved per-mail data in struct mail_save_context to separate struct.
Timo Sirainen <tss@iki.fi>
parents: 14920
diff changeset
664 struct mailbox_transaction_context *transaction;
b966759dd48c lib-storage: Moved per-mail data in struct mail_save_context to separate struct.
Timo Sirainen <tss@iki.fi>
parents: 14920
diff changeset
665 struct mail *dest_mail;
21253
ba5c04b9457b lib-storage: Add struct mail_save_context.copy_src_mail
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21225
diff changeset
666 /* Set during mailbox_copy(). This is useful when copying is
ba5c04b9457b lib-storage: Add struct mail_save_context.copy_src_mail
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21225
diff changeset
667 implemented via save, and the save_*() methods want to access the
ba5c04b9457b lib-storage: Add struct mail_save_context.copy_src_mail
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21225
diff changeset
668 source mail. */
ba5c04b9457b lib-storage: Add struct mail_save_context.copy_src_mail
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21225
diff changeset
669 struct mail *copy_src_mail;
14952
b966759dd48c lib-storage: Moved per-mail data in struct mail_save_context to separate struct.
Timo Sirainen <tss@iki.fi>
parents: 14920
diff changeset
670
b966759dd48c lib-storage: Moved per-mail data in struct mail_save_context to separate struct.
Timo Sirainen <tss@iki.fi>
parents: 14920
diff changeset
671 /* data that changes for each saved mail */
b966759dd48c lib-storage: Moved per-mail data in struct mail_save_context to separate struct.
Timo Sirainen <tss@iki.fi>
parents: 14920
diff changeset
672 struct mail_save_data data;
12312
28eaaa23f2c6 lib-storage: Added support for saving mail attachments separately via filesystem API.
Timo Sirainen <tss@iki.fi>
parents: 12040
diff changeset
673
12545
9507a067233b lib-storage: Moved mailbox.save_is_attachment() to mail_save_context.part_is_attachment()
Timo Sirainen <tss@iki.fi>
parents: 12544
diff changeset
674 /* returns TRUE if message part is an attachment. */
9507a067233b lib-storage: Moved mailbox.save_is_attachment() to mail_save_context.part_is_attachment()
Timo Sirainen <tss@iki.fi>
parents: 12544
diff changeset
675 bool (*part_is_attachment)(struct mail_save_context *ctx,
9507a067233b lib-storage: Moved mailbox.save_is_attachment() to mail_save_context.part_is_attachment()
Timo Sirainen <tss@iki.fi>
parents: 12544
diff changeset
676 const struct mail_attachment_part *part);
9507a067233b lib-storage: Moved mailbox.save_is_attachment() to mail_save_context.part_is_attachment()
Timo Sirainen <tss@iki.fi>
parents: 12544
diff changeset
677
15774
9847164c6fd7 lib-storage: Assert-crash if mailbox_save_context isn't properly freed before reusing.
Timo Sirainen <tss@iki.fi>
parents: 15749
diff changeset
678 /* mailbox_save_alloc() called, but finish/cancel not.
9847164c6fd7 lib-storage: Assert-crash if mailbox_save_context isn't properly freed before reusing.
Timo Sirainen <tss@iki.fi>
parents: 15749
diff changeset
679 the same context is usually returned by the backends for reuse. */
9847164c6fd7 lib-storage: Assert-crash if mailbox_save_context isn't properly freed before reusing.
Timo Sirainen <tss@iki.fi>
parents: 15749
diff changeset
680 unsigned int unfinished:1;
17289
db216ddbb5c2 lib-storage: Fixed crash if mailbox_save_cancel() was called in save_finish()/copy() method.
Timo Sirainen <tss@iki.fi>
parents: 17212
diff changeset
681 /* mailbox_save_finish() or mailbox_copy() is being called. */
db216ddbb5c2 lib-storage: Fixed crash if mailbox_save_cancel() was called in save_finish()/copy() method.
Timo Sirainen <tss@iki.fi>
parents: 17212
diff changeset
682 unsigned int finishing:1;
20805
073625e2d619 lib-storage: Don't reset mail_save_context.saving too early.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20558
diff changeset
683 /* mail was copied or moved using saving (requires:
073625e2d619 lib-storage: Don't reset mail_save_context.saving too early.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20558
diff changeset
684 copying_or_moving==TRUE). */
13895
7f549b7eb77f lib-storage: Renamed mail_save_context.copying to copying_via_save.
Timo Sirainen <tss@iki.fi>
parents: 13876
diff changeset
685 unsigned int copying_via_save:1;
20805
073625e2d619 lib-storage: Don't reset mail_save_context.saving too early.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20558
diff changeset
686 /* mail is being saved, not copied. However, this is set also with
073625e2d619 lib-storage: Don't reset mail_save_context.saving too early.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20558
diff changeset
687 mailbox_save_using_mail() and then copying_or_moving==TRUE. */
13896
1e58372ee6f0 lib-storage: Added mailbox_save_using_mail()
Timo Sirainen <tss@iki.fi>
parents: 13895
diff changeset
688 unsigned int saving:1;
20805
073625e2d619 lib-storage: Don't reset mail_save_context.saving too early.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20558
diff changeset
689 /* mail is being moved - ignore quota (requires:
073625e2d619 lib-storage: Don't reset mail_save_context.saving too early.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20558
diff changeset
690 copying_or_moving==TRUE && saving==FALSE). */
14613
8d596b5adbab lib-storage: Added mailbox_move(), which is basically copy+expunge.
Timo Sirainen <tss@iki.fi>
parents: 14599
diff changeset
691 unsigned int moving:1;
20805
073625e2d619 lib-storage: Don't reset mail_save_context.saving too early.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20558
diff changeset
692 /* mail is being copied or moved. However, this is set also with
073625e2d619 lib-storage: Don't reset mail_save_context.saving too early.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20558
diff changeset
693 mailbox_save_using_mail() and then saving==TRUE. */
073625e2d619 lib-storage: Don't reset mail_save_context.saving too early.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20558
diff changeset
694 unsigned int copying_or_moving:1;
21539
eafb085567bb lib-storage: Always create mail_save_context.dest_mail
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21457
diff changeset
695 /* dest_mail was set via mailbox_save_set_dest_mail() */
eafb085567bb lib-storage: Always create mail_save_context.dest_mail
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21457
diff changeset
696 unsigned int dest_mail_external:1;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2350
diff changeset
697 };
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2350
diff changeset
698
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2225
diff changeset
699 struct mailbox_sync_context {
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2225
diff changeset
700 struct mailbox *box;
13075
8c76426a9e53 Moved the main functionality from "doveadm index" to MAILBOX_SYNC_FLAG_PRECACHE
Timo Sirainen <tss@iki.fi>
parents: 12995
diff changeset
701 enum mailbox_sync_flags flags;
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2225
diff changeset
702 };
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2225
diff changeset
703
2327
7d02e2a7672d Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
704 struct mailbox_header_lookup_ctx {
7d02e2a7672d Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
705 struct mailbox *box;
12544
dc3b59b71fca lib-storage: Unvirtualized mailbox_header_lookup_*()
Timo Sirainen <tss@iki.fi>
parents: 12543
diff changeset
706 pool_t pool;
9454
87e533f1127d mailbox_header_lookup*() private API changed.
Timo Sirainen <tss@iki.fi>
parents: 9453
diff changeset
707 int refcount;
12544
dc3b59b71fca lib-storage: Unvirtualized mailbox_header_lookup_*()
Timo Sirainen <tss@iki.fi>
parents: 12543
diff changeset
708
dc3b59b71fca lib-storage: Unvirtualized mailbox_header_lookup_*()
Timo Sirainen <tss@iki.fi>
parents: 12543
diff changeset
709 unsigned int count;
dc3b59b71fca lib-storage: Unvirtualized mailbox_header_lookup_*()
Timo Sirainen <tss@iki.fi>
parents: 12543
diff changeset
710 const char *const *name;
dc3b59b71fca lib-storage: Unvirtualized mailbox_header_lookup_*()
Timo Sirainen <tss@iki.fi>
parents: 12543
diff changeset
711 unsigned int *idx;
2327
7d02e2a7672d Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
712 };
7d02e2a7672d Header caching redesigned. New design allows caching decisions per field, so
Timo Sirainen <tss@iki.fi>
parents: 2322
diff changeset
713
4453
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
714 /* Modules should use do "my_id = mail_storage_module_id++" and
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
715 use objects' module_contexts[id] for their own purposes. */
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
716 extern struct mail_storage_module_register mail_storage_module_register;
4453
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
717
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
718 /* Storage's module_id for mail_index. */
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
719 extern struct mail_module_register mail_module_register;
4453
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
720
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
721 #define MAIL_STORAGE_CONTEXT(obj) \
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
722 MODULE_CONTEXT(obj, mail_storage_mail_index_module)
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
723 extern MODULE_CONTEXT_DEFINE(mail_storage_mail_index_module,
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
724 &mail_index_module_register);
4453
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4451
diff changeset
725
11106
085253f549f8 lib-storage: Panic if deiniting storage before closing its mailboxes.
Timo Sirainen <tss@iki.fi>
parents: 11000
diff changeset
726 void mail_storage_obj_ref(struct mail_storage *storage);
085253f549f8 lib-storage: Panic if deiniting storage before closing its mailboxes.
Timo Sirainen <tss@iki.fi>
parents: 11000
diff changeset
727 void mail_storage_obj_unref(struct mail_storage *storage);
085253f549f8 lib-storage: Panic if deiniting storage before closing its mailboxes.
Timo Sirainen <tss@iki.fi>
parents: 11000
diff changeset
728
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
729 /* Set error message in storage. Critical errors are logged with i_error(),
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
730 but user sees only "internal error" message. */
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
731 void mail_storage_clear_error(struct mail_storage *storage);
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
732 void mail_storage_set_error(struct mail_storage *storage,
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5607
diff changeset
733 enum mail_error error, const char *string);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
734 void mail_storage_set_critical(struct mail_storage *storage,
6411
6a64e64fa3a3 Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents: 6410
diff changeset
735 const char *fmt, ...) ATTR_FORMAT(2, 3);
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
736 void mail_storage_set_internal_error(struct mail_storage *storage);
15342
5479887eb461 lib-storage: Renamed mail_storage_set_index_error() to mailbox_set_index_error()
Timo Sirainen <tss@iki.fi>
parents: 15341
diff changeset
737 void mailbox_set_index_error(struct mailbox *box);
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5607
diff changeset
738 bool mail_storage_set_error_from_errno(struct mail_storage *storage);
10676
1fd7833c16ca lib-storage: Mailbox deletion API changed.
Timo Sirainen <tss@iki.fi>
parents: 10660
diff changeset
739 void mail_storage_copy_list_error(struct mail_storage *storage,
1fd7833c16ca lib-storage: Mailbox deletion API changed.
Timo Sirainen <tss@iki.fi>
parents: 10660
diff changeset
740 struct mailbox_list *list);
15098
3b01d09f7762 lib-storage: Added mail_storage_copy_error()
Timo Sirainen <tss@iki.fi>
parents: 15055
diff changeset
741 void mail_storage_copy_error(struct mail_storage *dest,
3b01d09f7762 lib-storage: Added mail_storage_copy_error()
Timo Sirainen <tss@iki.fi>
parents: 15055
diff changeset
742 struct mail_storage *src);
22034
c68622bea90c lib-storage: Use new mail_cache_set_seq_corrupted_reason
Aki Tuomi <aki.tuomi@dovecot.fi>
parents: 21982
diff changeset
743 /* set record in mail cache corrupted */
22035
86b3bb91add1 lib-storage: Add missing ATTR_FORMAT to mail_set_mail_cache_corrupted()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22034
diff changeset
744 void mail_set_mail_cache_corrupted(struct mail *mail, const char *fmt, ...)
86b3bb91add1 lib-storage: Add missing ATTR_FORMAT to mail_set_mail_cache_corrupted()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22034
diff changeset
745 ATTR_FORMAT(2, 3);
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4607
diff changeset
746
21831
a9b10b0a6bd3 lib-storage: Indicate mail is being autoexpunged
Aki Tuomi <aki.tuomi@dovecot.fi>
parents: 21812
diff changeset
747 /* Indicate mail being expunged by autoexpunge */
a9b10b0a6bd3 lib-storage: Indicate mail is being autoexpunged
Aki Tuomi <aki.tuomi@dovecot.fi>
parents: 21812
diff changeset
748 void mail_autoexpunge(struct mail *mail);
a9b10b0a6bd3 lib-storage: Indicate mail is being autoexpunged
Aki Tuomi <aki.tuomi@dovecot.fi>
parents: 21812
diff changeset
749
15411
f64a91637f9b lib-storage: Comment update for mail_prefetch()
Timo Sirainen <tss@iki.fi>
parents: 15342
diff changeset
750 /* Returns TRUE if everything should already be in memory after this call
f64a91637f9b lib-storage: Comment update for mail_prefetch()
Timo Sirainen <tss@iki.fi>
parents: 15342
diff changeset
751 or if prefetching is not supported, i.e. the caller shouldn't do more
f64a91637f9b lib-storage: Comment update for mail_prefetch()
Timo Sirainen <tss@iki.fi>
parents: 15342
diff changeset
752 prefetching before this message is handled. */
12874
0461e23ae57c Search supports now prefetching data for returned mails. Dropped imapc's own prefetching.
Timo Sirainen <tss@iki.fi>
parents: 12870
diff changeset
753 bool mail_prefetch(struct mail *mail);
14682
d0d7b810646b Make sure we check all the functions' return values. Minor API changes to simplify this.
Timo Sirainen <tss@iki.fi>
parents: 14622
diff changeset
754 void mail_set_aborted(struct mail *mail);
5614
a4e5053fb31a Added MAIL_ERROR_EXPUNGED. Set the error whenever expunged message is tried
Timo Sirainen <tss@iki.fi>
parents: 5613
diff changeset
755 void mail_set_expunged(struct mail *mail);
13120
06873db0bfef lib-storage: mail->saving was set too late, which could have caused crashes.
Timo Sirainen <tss@iki.fi>
parents: 13080
diff changeset
756 void mail_set_seq_saving(struct mail *mail, uint32_t seq);
6771
fd9effba151d Moved mailbox_deleted to struct mailbox. Added and used
Timo Sirainen <tss@iki.fi>
parents: 6598
diff changeset
757 void mailbox_set_deleted(struct mailbox *box);
11487
3a0601cb9e67 Mailbox deletion: Delay marking its index deleted until ACL has had a chance to abort the deletion.
Timo Sirainen <tss@iki.fi>
parents: 11378
diff changeset
758 int mailbox_mark_index_deleted(struct mailbox *box, bool del);
15163
c7a99d41e39e lib-storage: mailbox_get_path() and friends can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15162
diff changeset
759 /* Easy wrapper for getting mailbox's MAILBOX_LIST_PATH_TYPE_MAILBOX.
c7a99d41e39e lib-storage: mailbox_get_path() and friends can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15162
diff changeset
760 The mailbox must already be opened and the caller must know that the
c7a99d41e39e lib-storage: mailbox_get_path() and friends can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15162
diff changeset
761 storage has mailbox files (i.e. NULL/empty path is never returned). */
12520
b26d6da05d48 lib-storage: Lazily look up mailbox path and permissions. Added functions to get them.
Timo Sirainen <tss@iki.fi>
parents: 12518
diff changeset
762 const char *mailbox_get_path(struct mailbox *box) ATTR_PURE;
17833
936435377584 lib-storage: Added mailbox_get_index_path() and caching of the index path.
Timo Sirainen <tss@iki.fi>
parents: 17758
diff changeset
763 /* Similar to mailbox_get_path() but for MAILBOX_LIST_PATH_TYPE_INDEX. */
936435377584 lib-storage: Added mailbox_get_index_path() and caching of the index path.
Timo Sirainen <tss@iki.fi>
parents: 17758
diff changeset
764 const char *mailbox_get_index_path(struct mailbox *box) ATTR_PURE;
15163
c7a99d41e39e lib-storage: mailbox_get_path() and friends can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15162
diff changeset
765 /* Wrapper to mailbox_list_get_path() */
c7a99d41e39e lib-storage: mailbox_get_path() and friends can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15162
diff changeset
766 int mailbox_get_path_to(struct mailbox *box, enum mailbox_list_path_type type,
c7a99d41e39e lib-storage: mailbox_get_path() and friends can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15162
diff changeset
767 const char **path_r);
12520
b26d6da05d48 lib-storage: Lazily look up mailbox path and permissions. Added functions to get them.
Timo Sirainen <tss@iki.fi>
parents: 12518
diff changeset
768 /* Get mailbox permissions. */
b26d6da05d48 lib-storage: Lazily look up mailbox path and permissions. Added functions to get them.
Timo Sirainen <tss@iki.fi>
parents: 12518
diff changeset
769 const struct mailbox_permissions *mailbox_get_permissions(struct mailbox *box);
b26d6da05d48 lib-storage: Lazily look up mailbox path and permissions. Added functions to get them.
Timo Sirainen <tss@iki.fi>
parents: 12518
diff changeset
770 /* Force permissions to be refreshed on next lookup */
10653
5fe70b5da1b8 lib-storage: Moved mailbox directory creation code to mailbox_list backend.
Timo Sirainen <tss@iki.fi>
parents: 10509
diff changeset
771 void mailbox_refresh_permissions(struct mailbox *box);
5fe70b5da1b8 lib-storage: Moved mailbox directory creation code to mailbox_list backend.
Timo Sirainen <tss@iki.fi>
parents: 10509
diff changeset
772
15495
69371578720f lib-storage: Added support for "private modseqs" for INDEXPVT index.
Timo Sirainen <tss@iki.fi>
parents: 15411
diff changeset
773 /* Open private index files for mailbox. Returns 1 if opened, 0 if there
69371578720f lib-storage: Added support for "private modseqs" for INDEXPVT index.
Timo Sirainen <tss@iki.fi>
parents: 15411
diff changeset
774 are no private indexes (or flags) in this mailbox, -1 if error. */
69371578720f lib-storage: Added support for "private modseqs" for INDEXPVT index.
Timo Sirainen <tss@iki.fi>
parents: 15411
diff changeset
775 int mailbox_open_index_pvt(struct mailbox *box);
15118
02d00843dd79 lib-storage: Cleanups to mailbox mkdir() related functions.
Timo Sirainen <tss@iki.fi>
parents: 15100
diff changeset
776 /* Create path's directory with proper permissions. The root directory is also
02d00843dd79 lib-storage: Cleanups to mailbox mkdir() related functions.
Timo Sirainen <tss@iki.fi>
parents: 15100
diff changeset
777 created if necessary. Returns 1 if created, 0 if it already existed,
02d00843dd79 lib-storage: Cleanups to mailbox mkdir() related functions.
Timo Sirainen <tss@iki.fi>
parents: 15100
diff changeset
778 -1 if error. */
02d00843dd79 lib-storage: Cleanups to mailbox mkdir() related functions.
Timo Sirainen <tss@iki.fi>
parents: 15100
diff changeset
779 int mailbox_mkdir(struct mailbox *box, const char *path,
02d00843dd79 lib-storage: Cleanups to mailbox mkdir() related functions.
Timo Sirainen <tss@iki.fi>
parents: 15100
diff changeset
780 enum mailbox_list_path_type type);
02d00843dd79 lib-storage: Cleanups to mailbox mkdir() related functions.
Timo Sirainen <tss@iki.fi>
parents: 15100
diff changeset
781 /* Create a non-mailbox type directory for mailbox if it's missing (e.g. index).
02d00843dd79 lib-storage: Cleanups to mailbox mkdir() related functions.
Timo Sirainen <tss@iki.fi>
parents: 15100
diff changeset
782 Optimized for case where the directory usually exists. */
02d00843dd79 lib-storage: Cleanups to mailbox mkdir() related functions.
Timo Sirainen <tss@iki.fi>
parents: 15100
diff changeset
783 int mailbox_create_missing_dir(struct mailbox *box,
02d00843dd79 lib-storage: Cleanups to mailbox mkdir() related functions.
Timo Sirainen <tss@iki.fi>
parents: 15100
diff changeset
784 enum mailbox_list_path_type type);
02d00843dd79 lib-storage: Cleanups to mailbox mkdir() related functions.
Timo Sirainen <tss@iki.fi>
parents: 15100
diff changeset
785
10653
5fe70b5da1b8 lib-storage: Moved mailbox directory creation code to mailbox_list backend.
Timo Sirainen <tss@iki.fi>
parents: 10509
diff changeset
786 /* Returns -1 if error, 0 if failed with EEXIST, 1 if ok */
5fe70b5da1b8 lib-storage: Moved mailbox directory creation code to mailbox_list backend.
Timo Sirainen <tss@iki.fi>
parents: 10509
diff changeset
787 int mailbox_create_fd(struct mailbox *box, const char *path, int flags,
5fe70b5da1b8 lib-storage: Moved mailbox directory creation code to mailbox_list backend.
Timo Sirainen <tss@iki.fi>
parents: 10509
diff changeset
788 int *fd_r);
22276
5fac15015445 lib-storage: Move .vsize.lock creation to a generic mailbox_lock_file_create()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22084
diff changeset
789 /* Create a lock file to the mailbox with the given filename. If it succeeds,
5fac15015445 lib-storage: Move .vsize.lock creation to a generic mailbox_lock_file_create()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22084
diff changeset
790 returns 1 and lock_r, which needs to be freed once finished with the lock.
5fac15015445 lib-storage: Move .vsize.lock creation to a generic mailbox_lock_file_create()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22084
diff changeset
791 If lock_secs is reached, returns 0 and error_r. Returns -1 and sets error_r
5fac15015445 lib-storage: Move .vsize.lock creation to a generic mailbox_lock_file_create()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22084
diff changeset
792 on other errors. */
5fac15015445 lib-storage: Move .vsize.lock creation to a generic mailbox_lock_file_create()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22084
diff changeset
793 int mailbox_lock_file_create(struct mailbox *box, const char *lock_fname,
5fac15015445 lib-storage: Move .vsize.lock creation to a generic mailbox_lock_file_create()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22084
diff changeset
794 unsigned int lock_secs, struct file_lock **lock_r,
5fac15015445 lib-storage: Move .vsize.lock creation to a generic mailbox_lock_file_create()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22084
diff changeset
795 const char **error_r);
11623
c3ee4421e86a Added mail_max_lock_timeout setting.
Timo Sirainen <tss@iki.fi>
parents: 11488
diff changeset
796 unsigned int mail_storage_get_lock_timeout(struct mail_storage *storage,
c3ee4421e86a Added mail_max_lock_timeout setting.
Timo Sirainen <tss@iki.fi>
parents: 11488
diff changeset
797 unsigned int secs);
14859
f3ef88e19cd5 IMAP BINARY extension supports now FETCH BINARY command.
Timo Sirainen <tss@iki.fi>
parents: 14682
diff changeset
798 void mail_storage_free_binary_cache(struct mail_storage *storage);
2225
5947497c3e40 get_last_error() wasn't virtualizable
Timo Sirainen <tss@iki.fi>
parents: 2190
diff changeset
799
15040
d7dd5cdf1ba7 lib-storage: Moved mail_storage_settings_to_index_flags to mail-storage-private.h
Timo Sirainen <tss@iki.fi>
parents: 15038
diff changeset
800 enum mail_index_open_flags
d7dd5cdf1ba7 lib-storage: Moved mail_storage_settings_to_index_flags to mail-storage-private.h
Timo Sirainen <tss@iki.fi>
parents: 15038
diff changeset
801 mail_storage_settings_to_index_flags(const struct mail_storage_settings *set);
21539
eafb085567bb lib-storage: Always create mail_save_context.dest_mail
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21457
diff changeset
802 void mailbox_save_context_deinit(struct mail_save_context *ctx);
2225
5947497c3e40 get_last_error() wasn't virtualizable
Timo Sirainen <tss@iki.fi>
parents: 2190
diff changeset
803
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
804 #endif