[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-mail.c, 1.22,
1.23 mbox-save.c, 1.72, 1.73 mbox-storage.c, 1.111,
1.112 mbox-storage.h, 1.34, 1.35 mbox-transaction.c, 1.10, 1.11
cras at dovecot.org
cras at dovecot.org
Tue Mar 15 21:01:56 EET 2005
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/index index-fetch.c, 1.55,
1.56 index-mail-headers.c, 1.41, 1.42 index-mail.c, 1.71,
1.72 index-mail.h, 1.28, 1.29 index-search.c, 1.99,
1.100 index-storage.c, 1.69, 1.70 index-storage.h, 1.88,
1.89 index-transaction.c, 1.11, 1.12
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-copy.c,
1.33, 1.34 maildir-mail.c, 1.11, 1.12 maildir-save.c, 1.47,
1.48 maildir-storage.c, 1.92, 1.93 maildir-storage.h, 1.34,
1.35 maildir-transaction.c, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv16056/lib-storage/index/mbox
Modified Files:
mbox-mail.c mbox-save.c mbox-storage.c mbox-storage.h
mbox-transaction.c
Log Message:
Major mail-storage API changes. It's now a bit cleaner and much more plugin
friendly. Removed proxy_mailbox* stuff, they were difficult to use and
there's now much easier way to replace them.
Index: mbox-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-mail.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- mbox-mail.c 15 Mar 2005 11:30:13 -0000 1.22
+++ mbox-mail.c 15 Mar 2005 19:01:53 -0000 1.23
@@ -22,7 +22,7 @@
enum mbox_sync_flags sync_flags = 0;
int ret, deleted;
- if (mail->mail.expunged)
+ if (mail->mail.mail.expunged)
return 0;
__again:
@@ -45,11 +45,11 @@
if (mbox_file_open_stream(ibox) < 0)
return -1;
- ret = mbox_file_seek(ibox, mail->trans->trans_view, mail->mail.seq,
- &deleted);
+ ret = mbox_file_seek(ibox, mail->trans->trans_view,
+ mail->mail.mail.seq, &deleted);
if (ret < 0) {
if (deleted) {
- mail->mail.expunged = TRUE;
+ mail->mail.mail.expunged = TRUE;
return 0;
}
return -1;
@@ -160,8 +160,9 @@
return index_mail_init_stream(mail, hdr_size, body_size);
}
-struct mail mbox_mail = {
- 0, 0, 0, 0, 0, 0, 0,
+struct mail_vfuncs mbox_mail_vfuncs = {
+ index_mail_free,
+ index_mail_set_seq,
index_mail_get_flags,
index_mail_get_keywords,
Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- mbox-save.c 10 Jan 2005 17:37:24 -0000 1.72
+++ mbox-save.c 15 Mar 2005 19:01:53 -0000 1.73
@@ -40,7 +40,6 @@
uoff_t extra_hdr_offset, eoh_offset, eoh_input_offset;
char last_char;
- struct index_mail mail;
struct mbox_md5_context *mbox_md5_ctx;
unsigned int synced:1;
@@ -191,8 +190,6 @@
ctx->next_uid = hdr->next_uid;
ctx->synced = TRUE;
t->mbox_modified = TRUE;
-
- index_mail_init(&t->ictx, &ctx->mail, 0, NULL);
}
static void status_flags_append(string_t *str, enum mail_flags flags,
@@ -312,16 +309,17 @@
enum mail_flags save_flags;
uint64_t offset;
+ i_assert((t->ictx.flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0);
+
/* FIXME: we could write timezone_offset to From-line.. */
if (received_date == (time_t)-1)
received_date = ioloop_time;
if (ctx == NULL) {
ctx = t->save_ctx = i_new(struct mbox_save_context, 1);
- ctx->ctx.box = &ibox->box;
+ ctx->ctx.transaction = &t->ictx.mailbox_ctx;
ctx->ibox = ibox;
- ctx->trans = mail_index_transaction_begin(ibox->view,
- FALSE, TRUE);
+ ctx->trans = t->ictx.trans;
ctx->append_offset = (uoff_t)-1;
ctx->headers = str_new(default_pool, 512);
ctx->save_crlf = getenv("MAIL_SAVE_CRLF") != NULL;
@@ -463,7 +461,7 @@
return ctx->input->eof && size == 0 ? 0 : mbox_save_continue(_ctx);
}
-int mbox_save_finish(struct mail_save_context *_ctx, struct mail **mail_r)
+int mbox_save_finish(struct mail_save_context *_ctx, struct mail *dest_mail)
{
struct mbox_save_context *ctx = (struct mbox_save_context *)_ctx;
@@ -501,12 +499,11 @@
return -1;
}
- if (mail_r != NULL) {
+ if (dest_mail != NULL) {
i_assert(ctx->seq != 0);
- if (index_mail_next(&ctx->mail, ctx->seq) < 0)
+ if (mail_set_seq(dest_mail, ctx->seq) < 0)
return -1;
- *mail_r = &ctx->mail.mail;
}
return 0;
@@ -524,9 +521,6 @@
{
i_assert(ctx->body_output == NULL);
- if (ctx->mail.pool != NULL)
- index_mail_deinit(&ctx->mail);
-
if (ctx->output != NULL)
o_stream_unref(ctx->output);
str_free(ctx->headers);
@@ -535,8 +529,6 @@
int mbox_transaction_save_commit(struct mbox_save_context *ctx)
{
- uint32_t seq;
- uoff_t offset;
int ret = 0;
if (ctx->synced) {
@@ -553,9 +545,6 @@
}
}
- if (mail_index_transaction_commit(ctx->trans, &seq, &offset) < 0)
- ret = -1;
-
mbox_transaction_save_deinit(ctx);
return ret;
}
@@ -576,6 +565,5 @@
mbox_set_syscall_error(ibox, "ftruncate()");
}
- mail_index_transaction_rollback(ctx->trans);
mbox_transaction_save_deinit(ctx);
}
Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- mbox-storage.c 9 Feb 2005 21:16:29 -0000 1.111
+++ mbox-storage.c 15 Mar 2005 19:01:53 -0000 1.112
@@ -11,6 +11,7 @@
#include "mbox-file.h"
#include "mbox-sync-private.h"
#include "mail-copy.h"
+#include "index-mail.h"
#include <stdio.h>
#include <stdlib.h>
@@ -248,6 +249,7 @@
const char *root_dir, *inbox_file, *index_dir, *p;
struct stat st;
int autodetect;
+ pool_t pool;
root_dir = inbox_file = index_dir = NULL;
@@ -325,14 +327,16 @@
inbox_file == NULL ? "" : inbox_file);
}
- storage = i_new(struct index_storage, 1);
+ pool = pool_alloconly_create("storage", 256);
+ storage = p_new(pool, struct index_storage, 1);
storage->storage = mbox_storage;
+ storage->storage.pool = pool;
- storage->dir = i_strdup(home_expand(root_dir));
- storage->inbox_path = i_strdup(home_expand(inbox_file));
- storage->index_dir = i_strdup(home_expand(index_dir));
- storage->user = i_strdup(user);
- storage->callbacks = i_new(struct mail_storage_callbacks, 1);
+ storage->dir = p_strdup(pool, home_expand(root_dir));
+ storage->inbox_path = p_strdup(pool, home_expand(inbox_file));
+ storage->index_dir = p_strdup(pool, home_expand(index_dir));
+ storage->user = p_strdup(pool, user);
+ storage->callbacks = p_new(pool, struct mail_storage_callbacks, 1);
index_storage_init(storage, flags);
return &storage->storage;
}
@@ -342,13 +346,7 @@
struct index_storage *storage = (struct index_storage *)_storage;
index_storage_deinit(storage);
-
- i_free(storage->dir);
- i_free(storage->inbox_path);
- i_free(storage->index_dir);
- i_free(storage->user);
- i_free(storage->callbacks);
- i_free(storage);
+ pool_unref(storage->storage.pool);
}
int mbox_is_valid_mask(struct mail_storage *storage, const char *mask)
@@ -488,6 +486,7 @@
struct mail_index *index;
const char *path, *index_dir;
uint32_t mbox_ext_idx;
+ pool_t pool;
if (strcmp(name, "INBOX") == 0) {
/* name = "INBOX"
@@ -507,18 +506,25 @@
mbox_ext_idx = mail_index_ext_register(index, "mbox", 0,
sizeof(uint64_t),
sizeof(uint64_t));
- ibox = index_storage_mailbox_init(storage, &mbox_mailbox,
- index, name, flags);
- if (ibox == NULL)
+
+ pool = pool_alloconly_create("mailbox", 256);
+ ibox = p_new(pool, struct index_mailbox, 1);
+ ibox->box = mbox_mailbox;
+ ibox->box.pool = pool;
+ ibox->storage = storage;
+
+ if (index_storage_mailbox_init(ibox, index, name, flags) < 0) {
+ /* the memory was already freed */
return NULL;
+ }
- ibox->path = i_strdup(path);
+ ibox->path = p_strdup(pool, path);
ibox->mbox_fd = -1;
ibox->mbox_lock_type = F_UNLCK;
ibox->mbox_ext_idx = mbox_ext_idx;
ibox->is_recent = mbox_mail_is_recent;
- ibox->mail_interface = &mbox_mail;
+ ibox->mail_vfuncs = &mbox_mail_vfuncs;
ibox->mbox_very_dirty_syncs = getenv("MBOX_VERY_DIRTY_SYNCS") != NULL;
ibox->mbox_do_dirty_syncs = ibox->mbox_very_dirty_syncs ||
getenv("MBOX_DIRTY_SYNCS") != NULL;
@@ -931,59 +937,67 @@
}
struct mail_storage mbox_storage = {
- "mbox", /* name */
-
- '/', /* hierarchy separator */
+ MEMBER(name) "mbox",
+ MEMBER(hierarchy_sep) '/',
- mbox_create,
- mbox_free,
- mbox_autodetect,
- index_storage_set_callbacks,
- mbox_mailbox_open,
- mbox_mailbox_create,
- mbox_mailbox_delete,
- mbox_mailbox_rename,
- mbox_mailbox_list_init,
- mbox_mailbox_list_next,
- mbox_mailbox_list_deinit,
- mbox_set_subscribed,
- mbox_get_mailbox_name_status,
- index_storage_get_last_error,
+ {
+ mbox_create,
+ mbox_free,
+ mbox_autodetect,
+ index_storage_set_callbacks,
+ mbox_mailbox_open,
+ mbox_mailbox_create,
+ mbox_mailbox_delete,
+ mbox_mailbox_rename,
+ mbox_mailbox_list_init,
+ mbox_mailbox_list_next,
+ mbox_mailbox_list_deinit,
+ mbox_set_subscribed,
+ mbox_get_mailbox_name_status,
+ index_storage_get_last_error
+ },
- NULL,
- 0,
- 0
+ MEMBER(pool) NULL,
+ MEMBER(error) NULL,
+ MEMBER(flags) 0,
+ MEMBER(module_contexts) ARRAY_INIT,
+ MEMBER(syntax_error) 0
};
struct mailbox mbox_mailbox = {
- NULL, /* name */
- NULL, /* storage */
+ MEMBER(name) NULL,
+ MEMBER(storage) NULL,
- index_storage_is_readonly,
- index_storage_allow_new_keywords,
- mbox_storage_close,
- index_storage_get_status,
- mbox_storage_sync_init,
- index_mailbox_sync_next,
- index_mailbox_sync_deinit,
- mbox_notify_changes,
- mbox_transaction_begin,
- mbox_transaction_commit,
- mbox_transaction_rollback,
- index_keywords_create,
- index_keywords_free,
- index_storage_fetch,
- index_storage_get_uids,
- index_header_lookup_init,
- index_header_lookup_deinit,
- index_storage_search_get_sorting,
- index_storage_search_init,
- index_storage_search_deinit,
- index_storage_search_next,
- mbox_save_init,
- mbox_save_continue,
- mbox_save_finish,
- mbox_save_cancel,
- mail_storage_copy,
- index_storage_is_inconsistent
+ {
+ index_storage_is_readonly,
+ index_storage_allow_new_keywords,
+ mbox_storage_close,
+ index_storage_get_status,
+ mbox_storage_sync_init,
+ index_mailbox_sync_next,
+ index_mailbox_sync_deinit,
+ mbox_notify_changes,
+ mbox_transaction_begin,
+ mbox_transaction_commit,
+ mbox_transaction_rollback,
+ index_keywords_create,
+ index_keywords_free,
+ index_storage_get_uids,
+ index_mail_alloc,
+ index_header_lookup_init,
+ index_header_lookup_deinit,
+ index_storage_search_get_sorting,
+ index_storage_search_init,
+ index_storage_search_deinit,
+ index_storage_search_next,
+ mbox_save_init,
+ mbox_save_continue,
+ mbox_save_finish,
+ mbox_save_cancel,
+ mail_storage_copy,
+ index_storage_is_inconsistent
+ },
+
+ MEMBER(pool) NULL,
+ MEMBER(module_contexts) ARRAY_INIT
};
Index: mbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- mbox-storage.h 10 Jan 2005 17:37:24 -0000 1.34
+++ mbox-storage.h 15 Mar 2005 19:01:53 -0000 1.35
@@ -19,7 +19,7 @@
unsigned int mbox_modified:1;
};
-extern struct mail mbox_mail;
+extern struct mail_vfuncs mbox_mail_vfuncs;
extern const char *mbox_hide_headers[];
extern size_t mbox_hide_headers_count;
@@ -33,7 +33,8 @@
struct mailbox_list *mbox_mailbox_list_next(struct mailbox_list_context *ctx);
struct mailbox_transaction_context *
-mbox_transaction_begin(struct mailbox *box, int hide);
+mbox_transaction_begin(struct mailbox *box,
+ enum mailbox_transaction_flags flags);
int mbox_transaction_commit(struct mailbox_transaction_context *t,
enum mailbox_sync_flags flags);
void mbox_transaction_rollback(struct mailbox_transaction_context *t);
@@ -47,7 +48,7 @@
time_t received_date, int timezone_offset,
const char *from_envelope, struct istream *input, int want_mail);
int mbox_save_continue(struct mail_save_context *ctx);
-int mbox_save_finish(struct mail_save_context *ctx, struct mail **mail_r);
+int mbox_save_finish(struct mail_save_context *ctx, struct mail *dest_mail);
void mbox_save_cancel(struct mail_save_context *ctx);
int mbox_transaction_save_commit(struct mbox_save_context *ctx);
Index: mbox-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-transaction.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mbox-transaction.c 15 Dec 2004 17:02:00 -0000 1.10
+++ mbox-transaction.c 15 Mar 2005 19:01:53 -0000 1.11
@@ -6,13 +6,14 @@
#include "mbox-sync-private.h"
struct mailbox_transaction_context *
-mbox_transaction_begin(struct mailbox *box, int hide)
+mbox_transaction_begin(struct mailbox *box,
+ enum mailbox_transaction_flags flags)
{
struct index_mailbox *ibox = (struct index_mailbox *)box;
struct mbox_transaction_context *t;
t = i_new(struct mbox_transaction_context, 1);
- index_transaction_init(&t->ictx, ibox, hide);
+ index_transaction_init(&t->ictx, ibox, flags);
return &t->ictx.mailbox_ctx;
}
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/index index-fetch.c, 1.55,
1.56 index-mail-headers.c, 1.41, 1.42 index-mail.c, 1.71,
1.72 index-mail.h, 1.28, 1.29 index-search.c, 1.99,
1.100 index-storage.c, 1.69, 1.70 index-storage.h, 1.88,
1.89 index-transaction.c, 1.11, 1.12
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-copy.c,
1.33, 1.34 maildir-mail.c, 1.11, 1.12 maildir-save.c, 1.47,
1.48 maildir-storage.c, 1.92, 1.93 maildir-storage.h, 1.34,
1.35 maildir-transaction.c, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list