[dovecot-cvs] dovecot/src/lib-storage Makefile.am, 1.12,
1.13 mail-copy.c, 1.3, 1.4 mail-copy.h, 1.1,
1.2 mail-storage-private.h, 1.13, 1.14 mail-storage.c, 1.35,
1.36 mail-storage.h, 1.90, 1.91 mail.c, NONE,
1.1 proxy-mail-storage.c, 1.6, NONE proxy-mail-storage.h, 1.2,
NONE proxy-mail.c, 1.8, NONE proxy-mail.h, 1.1,
NONE proxy-mailbox.c, 1.15, NONE proxy-mailbox.h, 1.3, NONE
cras at dovecot.org
cras at dovecot.org
Tue Mar 15 21:01:53 EET 2005
- Previous message: [dovecot-cvs] dovecot/src/deliver deliver.c,1.1,1.2
- Next message: [dovecot-cvs] dovecot/src/imap cmd-append.c, 1.55, 1.56 cmd-copy.c,
1.26, 1.27 cmd-search.c, 1.23, 1.24 cmd-store.c, 1.31,
1.32 common.h, 1.19, 1.20 imap-expunge.c, 1.5,
1.6 imap-fetch-body.c, 1.17, 1.18 imap-fetch.c, 1.37,
1.38 imap-fetch.h, 1.14, 1.15 imap-sort.c, 1.19,
1.20 imap-sync.c, 1.9, 1.10 imap-thread.c, 1.14, 1.15 main.c,
1.61, 1.62 namespace.c, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib-storage
In directory talvi:/tmp/cvs-serv16056/lib-storage
Modified Files:
Makefile.am mail-copy.c mail-copy.h mail-storage-private.h
mail-storage.c mail-storage.h
Added Files:
mail.c
Removed Files:
proxy-mail-storage.c proxy-mail-storage.h proxy-mail.c
proxy-mail.h proxy-mailbox.c proxy-mailbox.h
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: Makefile.am
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/Makefile.am,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- Makefile.am 20 Oct 2004 23:05:58 -0000 1.12
+++ Makefile.am 15 Mar 2005 19:01:51 -0000 1.13
@@ -8,20 +8,15 @@
-I$(top_srcdir)/src/lib-imap
libstorage_a_SOURCES = \
+ mail.c \
mail-copy.c \
mail-search.c \
mail-storage.c \
- mailbox-tree.c \
- proxy-mail.c \
- proxy-mail-storage.c \
- proxy-mailbox.c
+ mailbox-tree.c
noinst_HEADERS = \
mail-copy.h \
mail-search.h \
mail-storage.h \
mail-storage-private.h \
- mailbox-tree.h \
- proxy-mail.h \
- proxy-mail-storage.h \
- proxy-mailbox.h
+ mailbox-tree.h
Index: mail-copy.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-copy.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mail-copy.c 5 Feb 2005 12:01:49 -0000 1.3
+++ mail-copy.c 15 Mar 2005 19:01:51 -0000 1.4
@@ -6,25 +6,25 @@
#include "mail-copy.h"
int mail_storage_copy(struct mailbox_transaction_context *t, struct mail *mail,
- struct mail **dest_mail_r)
+ struct mail *dest_mail)
{
struct mail_save_context *ctx;
struct istream *input;
struct mail_keywords *keywords;
const char *from_envelope, *const *keywords_list;
- input = mail->get_stream(mail, NULL, NULL);
+ input = mail_get_stream(mail, NULL, NULL);
if (input == NULL)
return -1;
- from_envelope = mail->get_special(mail, MAIL_FETCH_FROM_ENVELOPE);
+ from_envelope = mail_get_special(mail, MAIL_FETCH_FROM_ENVELOPE);
- keywords_list = mail->get_keywords(mail);
+ keywords_list = mail_get_keywords(mail);
keywords = keywords_list == NULL ? NULL :
mailbox_keywords_create(t, keywords_list);
- ctx = mailbox_save_init(t, mail->get_flags(mail), keywords,
- mail->get_received_date(mail),
- 0, from_envelope, input, dest_mail_r != NULL);
+ ctx = mailbox_save_init(t, mail_get_flags(mail), keywords,
+ mail_get_received_date(mail),
+ 0, from_envelope, input, dest_mail != NULL);
if (keywords != NULL)
mailbox_keywords_free(t, keywords);
@@ -38,5 +38,5 @@
return -1;
}
- return mailbox_save_finish(ctx, dest_mail_r);
+ return mailbox_save_finish(ctx, dest_mail);
}
Index: mail-copy.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-copy.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mail-copy.h 22 Aug 2004 09:17:08 -0000 1.1
+++ mail-copy.h 15 Mar 2005 19:01:51 -0000 1.2
@@ -2,6 +2,6 @@
#define __MAIL_COPY_H
int mail_storage_copy(struct mailbox_transaction_context *t, struct mail *mail,
- struct mail **dest_mail_r);
+ struct mail *dest_mail);
#endif
Index: mail-storage-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage-private.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- mail-storage-private.h 5 Feb 2005 12:01:49 -0000 1.13
+++ mail-storage-private.h 15 Mar 2005 19:01:51 -0000 1.14
@@ -3,10 +3,11 @@
#include "mail-storage.h"
-struct mail_storage {
- char *name;
- char hierarchy_sep;
+/* Modules should use do "my_id = mail_storage_module_id++" and
+ use objects' module_contexts[id] for their own purposes. */
+extern unsigned int mail_storage_module_id;
+struct mail_storage_vfuncs {
struct mail_storage *(*create)(const char *data, const char *user,
enum mail_storage_flags flags);
void (*destroy)(struct mail_storage *storage);
@@ -44,19 +45,27 @@
const char *(*get_last_error)(struct mail_storage *storage,
int *syntax_error_r);
+};
+
+struct mail_storage {
+ char *name;
+ char hierarchy_sep;
+
+ struct mail_storage_vfuncs v;
/* private: */
+ pool_t pool;
+
char *error;
enum mail_storage_flags flags;
+ /* Module-specific contexts. See mail_storage_module_id. */
+ array_t ARRAY_DEFINE(module_contexts, void);
+
unsigned int syntax_error:1; /* Give a BAD reply instead of NO */
};
-struct mailbox {
- char *name;
-
- struct mail_storage *storage;
-
+struct mailbox_vfuncs {
int (*is_readonly)(struct mailbox *box);
int (*allow_new_keywords)(struct mailbox *box);
@@ -78,7 +87,8 @@
void *context);
struct mailbox_transaction_context *
- (*transaction_begin)(struct mailbox *box, int hide);
+ (*transaction_begin)(struct mailbox *box,
+ enum mailbox_transaction_flags flags);
int (*transaction_commit)(struct mailbox_transaction_context *t,
enum mailbox_sync_flags flags);
void (*transaction_rollback)(struct mailbox_transaction_context *t);
@@ -89,12 +99,14 @@
void (*keywords_free)(struct mailbox_transaction_context *t,
struct mail_keywords *keywords);
- struct mail *(*fetch)(struct mailbox_transaction_context *t,
- uint32_t seq,
- enum mail_fetch_field wanted_fields);
int (*get_uids)(struct mailbox *box, uint32_t uid1, uint32_t uid2,
uint32_t *seq1_r, uint32_t *seq2_r);
+ struct mail *
+ (*mail_alloc)(struct mailbox_transaction_context *t,
+ enum mail_fetch_field wanted_fields,
+ struct mailbox_header_lookup_ctx *wanted_headers);
+
struct mailbox_header_lookup_ctx *
(*header_lookup_init)(struct mailbox *box,
const char *const headers[]);
@@ -105,11 +117,9 @@
struct mail_search_context *
(*search_init)(struct mailbox_transaction_context *t,
const char *charset, struct mail_search_arg *args,
- const enum mail_sort_type *sort_program,
- enum mail_fetch_field wanted_fields,
- struct mailbox_header_lookup_ctx *wanted_headers);
+ const enum mail_sort_type *sort_program);
int (*search_deinit)(struct mail_search_context *ctx);
- struct mail *(*search_next)(struct mail_search_context *ctx);
+ int (*search_next)(struct mail_search_context *ctx, struct mail *mail);
struct mail_save_context *
(*save_init)(struct mailbox_transaction_context *t,
@@ -119,15 +129,68 @@
const char *from_envelope, struct istream *input,
int want_mail);
int (*save_continue)(struct mail_save_context *ctx);
- int (*save_finish)(struct mail_save_context *ctx, struct mail **mail_r);
+ int (*save_finish)(struct mail_save_context *ctx,
+ struct mail *dest_mail);
void (*save_cancel)(struct mail_save_context *ctx);
int (*copy)(struct mailbox_transaction_context *t, struct mail *mail,
- struct mail **dest_mail_r);
+ struct mail *dest_mail);
int (*is_inconsistent)(struct mailbox *box);
};
+struct mailbox {
+ char *name;
+ struct mail_storage *storage;
+
+ struct mailbox_vfuncs v;
+/* private: */
+ pool_t pool;
+
+ /* Module-specific contexts. See mail_storage_module_id. */
+ array_t ARRAY_DEFINE(module_contexts, void);
+};
+
+struct mail_vfuncs {
+ void (*free)(struct mail *mail);
+ int (*set_seq)(struct mail *mail, uint32_t seq);
+
+ enum mail_flags (*get_flags)(struct mail *mail);
+ const char *const *(*get_keywords)(struct mail *mail);
+ const struct message_part *(*get_parts)(struct mail *mail);
+
+ time_t (*get_received_date)(struct mail *mail);
+ time_t (*get_date)(struct mail *mail, int *timezone);
+ uoff_t (*get_virtual_size)(struct mail *mail);
+ uoff_t (*get_physical_size)(struct mail *mail);
+
+ const char *(*get_header)(struct mail *mail, const char *field);
+ struct istream *
+ (*get_headers)(struct mail *mail,
+ struct mailbox_header_lookup_ctx *headers);
+ struct istream *(*get_stream)(struct mail *mail,
+ struct message_size *hdr_size,
+ struct message_size *body_size);
+
+ const char *(*get_special)(struct mail *mail,
+ enum mail_fetch_field field);
+
+ int (*update_flags)(struct mail *mail, enum modify_type modify_type,
+ enum mail_flags flags);
+ int (*update_keywords)(struct mail *mail, enum modify_type modify_type,
+ struct mail_keywords *keywords);
+
+ int (*expunge)(struct mail *mail);
+};
+
+struct mail_private {
+ struct mail mail;
+ struct mail_vfuncs v;
+
+ pool_t pool;
+ array_t ARRAY_DEFINE(module_contexts, void);
+};
+
struct mailbox_list_context {
struct mail_storage *storage;
};
@@ -137,11 +200,11 @@
};
struct mail_search_context {
- struct mailbox *box;
+ struct mailbox_transaction_context *transaction;
};
struct mail_save_context {
- struct mailbox *box;
+ struct mailbox_transaction_context *transaction;
};
struct mailbox_sync_context {
Index: mail-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- mail-storage.c 5 Feb 2005 12:01:49 -0000 1.35
+++ mail-storage.c 15 Mar 2005 19:01:51 -0000 1.36
@@ -18,6 +18,8 @@
struct mail_storage *storage;
};
+unsigned int mail_storage_module_id = 0;
+
static struct mail_storage_list *storages = NULL;
void mail_storage_init(void)
@@ -76,7 +78,7 @@
for (list = storages; list != NULL; list = list->next) {
if (strcasecmp(list->storage->name, name) == 0)
- return list->storage->create(data, user, flags);
+ return list->storage->v.create(data, user, flags);
}
return NULL;
@@ -89,7 +91,7 @@
struct mail_storage *storage;
for (list = storages; list != NULL; list = list->next) {
- storage = list->storage->create(NULL, user, flags);
+ storage = list->storage->v.create(NULL, user, flags);
if (storage != NULL)
return storage;
}
@@ -103,7 +105,7 @@
struct mail_storage_list *list;
for (list = storages; list != NULL; list = list->next) {
- if (list->storage->autodetect(data, flags))
+ if (list->storage->v.autodetect(data, flags))
return list->storage;
}
@@ -131,7 +133,7 @@
} else {
storage = mail_storage_autodetect(data, flags);
if (storage != NULL)
- storage = storage->create(data, user, flags);
+ storage = storage->v.create(data, user, flags);
}
return storage;
@@ -141,7 +143,7 @@
{
i_assert(storage != NULL);
- storage->destroy(storage);
+ storage->v.destroy(storage);
}
void mail_storage_clear_error(struct mail_storage *storage)
@@ -228,24 +230,24 @@
struct mail_storage_callbacks *callbacks,
void *context)
{
- storage->set_callbacks(storage, callbacks, context);
+ storage->v.set_callbacks(storage, callbacks, context);
}
int mail_storage_mailbox_create(struct mail_storage *storage, const char *name,
int directory)
{
- return storage->mailbox_create(storage, name, directory);
+ return storage->v.mailbox_create(storage, name, directory);
}
int mail_storage_mailbox_delete(struct mail_storage *storage, const char *name)
{
- return storage->mailbox_delete(storage, name);
+ return storage->v.mailbox_delete(storage, name);
}
int mail_storage_mailbox_rename(struct mail_storage *storage,
const char *oldname, const char *newname)
{
- return storage->mailbox_rename(storage, oldname, newname);
+ return storage->v.mailbox_rename(storage, oldname, newname);
}
struct mailbox_list_context *
@@ -253,48 +255,48 @@
const char *ref, const char *mask,
enum mailbox_list_flags flags)
{
- return storage->mailbox_list_init(storage, ref, mask, flags);
+ return storage->v.mailbox_list_init(storage, ref, mask, flags);
}
struct mailbox_list *
mail_storage_mailbox_list_next(struct mailbox_list_context *ctx)
{
- return ctx->storage->mailbox_list_next(ctx);
+ return ctx->storage->v.mailbox_list_next(ctx);
}
int mail_storage_mailbox_list_deinit(struct mailbox_list_context *ctx)
{
- return ctx->storage->mailbox_list_deinit(ctx);
+ return ctx->storage->v.mailbox_list_deinit(ctx);
}
int mail_storage_set_subscribed(struct mail_storage *storage,
const char *name, int set)
{
- return storage->set_subscribed(storage, name, set);
+ return storage->v.set_subscribed(storage, name, set);
}
int mail_storage_get_mailbox_name_status(struct mail_storage *storage,
const char *name,
enum mailbox_name_status *status)
{
- return storage->get_mailbox_name_status(storage, name, status);
+ return storage->v.get_mailbox_name_status(storage, name, status);
}
const char *mail_storage_get_last_error(struct mail_storage *storage,
int *syntax_error_r)
{
- return storage->get_last_error(storage, syntax_error_r);
+ return storage->v.get_last_error(storage, syntax_error_r);
}
struct mailbox *mailbox_open(struct mail_storage *storage,
const char *name, enum mailbox_open_flags flags)
{
- return storage->mailbox_open(storage, name, flags);
+ return storage->v.mailbox_open(storage, name, flags);
}
int mailbox_close(struct mailbox *box)
{
- return box->close(box);
+ return box->v.close(box);
}
struct mail_storage *mailbox_get_storage(struct mailbox *box)
@@ -309,123 +311,115 @@
int mailbox_is_readonly(struct mailbox *box)
{
- return box->is_readonly(box);
+ return box->v.is_readonly(box);
}
int mailbox_allow_new_keywords(struct mailbox *box)
{
- return box->allow_new_keywords(box);
+ return box->v.allow_new_keywords(box);
}
int mailbox_get_status(struct mailbox *box,
enum mailbox_status_items items,
struct mailbox_status *status)
{
- return box->get_status(box, items, status);
+ return box->v.get_status(box, items, status);
}
struct mailbox_sync_context *
mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
{
- return box->sync_init(box, flags);
+ return box->v.sync_init(box, flags);
}
int mailbox_sync_next(struct mailbox_sync_context *ctx,
struct mailbox_sync_rec *sync_rec_r)
{
- return ctx->box->sync_next(ctx, sync_rec_r);
+ return ctx->box->v.sync_next(ctx, sync_rec_r);
}
int mailbox_sync_deinit(struct mailbox_sync_context *ctx,
struct mailbox_status *status_r)
{
- return ctx->box->sync_deinit(ctx, status_r);
+ return ctx->box->v.sync_deinit(ctx, status_r);
}
void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval,
mailbox_notify_callback_t *callback, void *context)
{
- box->notify_changes(box, min_interval, callback, context);
+ box->v.notify_changes(box, min_interval, callback, context);
}
struct mail_keywords *
mailbox_keywords_create(struct mailbox_transaction_context *t,
const char *const keywords[])
{
- return t->box->keywords_create(t, keywords);
+ return t->box->v.keywords_create(t, keywords);
}
void mailbox_keywords_free(struct mailbox_transaction_context *t,
struct mail_keywords *keywords)
{
- t->box->keywords_free(t, keywords);
-}
-
-struct mail *mailbox_fetch(struct mailbox_transaction_context *t, uint32_t seq,
- enum mail_fetch_field wanted_fields)
-{
- return t->box->fetch(t, seq, wanted_fields);
+ t->box->v.keywords_free(t, keywords);
}
int mailbox_get_uids(struct mailbox *box, uint32_t uid1, uint32_t uid2,
uint32_t *seq1_r, uint32_t *seq2_r)
{
- return box->get_uids(box, uid1, uid2, seq1_r, seq2_r);
+ return box->v.get_uids(box, uid1, uid2, seq1_r, seq2_r);
}
struct mailbox_header_lookup_ctx *
mailbox_header_lookup_init(struct mailbox *box, const char *const headers[])
{
- return box->header_lookup_init(box, headers);
+ return box->v.header_lookup_init(box, headers);
}
void mailbox_header_lookup_deinit(struct mailbox_header_lookup_ctx *ctx)
{
- ctx->box->header_lookup_deinit(ctx);
+ ctx->box->v.header_lookup_deinit(ctx);
}
int mailbox_search_get_sorting(struct mailbox *box,
enum mail_sort_type *sort_program)
{
- return box->search_get_sorting(box, sort_program);
+ return box->v.search_get_sorting(box, sort_program);
}
struct mail_search_context *
mailbox_search_init(struct mailbox_transaction_context *t,
const char *charset, struct mail_search_arg *args,
- const enum mail_sort_type *sort_program,
- enum mail_fetch_field wanted_fields,
- struct mailbox_header_lookup_ctx *wanted_headers)
+ const enum mail_sort_type *sort_program)
{
- return t->box->search_init(t, charset, args, sort_program,
- wanted_fields, wanted_headers);
+ return t->box->v.search_init(t, charset, args, sort_program);
}
int mailbox_search_deinit(struct mail_search_context *ctx)
{
- return ctx->box->search_deinit(ctx);
+ return ctx->transaction->box->v.search_deinit(ctx);
}
-struct mail *mailbox_search_next(struct mail_search_context *ctx)
+int mailbox_search_next(struct mail_search_context *ctx, struct mail *mail)
{
- return ctx->box->search_next(ctx);
+ return ctx->transaction->box->v.search_next(ctx, mail);
}
struct mailbox_transaction_context *
-mailbox_transaction_begin(struct mailbox *box, int hide)
+mailbox_transaction_begin(struct mailbox *box,
+ enum mailbox_transaction_flags flags)
{
- return box->transaction_begin(box, hide);
+ return box->v.transaction_begin(box, flags);
}
int mailbox_transaction_commit(struct mailbox_transaction_context *t,
enum mailbox_sync_flags flags)
{
- return t->box->transaction_commit(t, flags);
+ return t->box->v.transaction_commit(t, flags);
}
void mailbox_transaction_rollback(struct mailbox_transaction_context *t)
{
- t->box->transaction_rollback(t);
+ t->box->v.transaction_rollback(t);
}
struct mail_save_context *
@@ -435,33 +429,33 @@
const char *from_envelope, struct istream *input,
int want_mail)
{
- return t->box->save_init(t, flags, keywords,
- received_date, timezone_offset,
- from_envelope, input, want_mail);
+ return t->box->v.save_init(t, flags, keywords,
+ received_date, timezone_offset,
+ from_envelope, input, want_mail);
}
int mailbox_save_continue(struct mail_save_context *ctx)
{
- return ctx->box->save_continue(ctx);
+ return ctx->transaction->box->v.save_continue(ctx);
}
-int mailbox_save_finish(struct mail_save_context *ctx, struct mail **mail_r)
+int mailbox_save_finish(struct mail_save_context *ctx, struct mail *dest_mail)
{
- return ctx->box->save_finish(ctx, mail_r);
+ return ctx->transaction->box->v.save_finish(ctx, dest_mail);
}
void mailbox_save_cancel(struct mail_save_context *ctx)
{
- ctx->box->save_cancel(ctx);
+ ctx->transaction->box->v.save_cancel(ctx);
}
int mailbox_copy(struct mailbox_transaction_context *t, struct mail *mail,
- struct mail **dest_mail_r)
+ struct mail *dest_mail)
{
- return t->box->copy(t, mail, dest_mail_r);
+ return t->box->v.copy(t, mail, dest_mail);
}
int mailbox_is_inconsistent(struct mailbox *box)
{
- return box->is_inconsistent(box);
+ return box->v.is_inconsistent(box);
}
Index: mail-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage.h,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- mail-storage.h 15 Mar 2005 11:30:07 -0000 1.90
+++ mail-storage.h 15 Mar 2005 19:01:51 -0000 1.91
@@ -94,6 +94,14 @@
MAIL_FETCH_UIDL_FILE_NAME = 0x00020000
};
+enum mailbox_transaction_flags {
+ /* Hide changes done in this transaction from next view sync */
+ MAILBOX_TRANSACTION_FLAG_HIDE = 0x01,
+ /* External transaction. Should be used for copying and appends,
+ but nothing else. */
+ MAILBOX_TRANSACTION_FLAG_EXTERNAL = 0x02
+};
+
enum mailbox_sync_flags {
/* Make sure we sync all external changes done to mailbox */
MAILBOX_SYNC_FLAG_FULL_READ = 0x01,
@@ -119,7 +127,6 @@
struct mail_storage;
struct mail_search_arg;
struct mail_keywords;
-struct mail;
struct mailbox;
struct mailbox_list_context;
struct mailbox_transaction_context;
@@ -151,6 +158,17 @@
enum mailbox_sync_type type;
};
+struct mail {
+ /* always set */
+ struct mailbox *box;
+ struct mailbox_transaction_context *transaction;
+ uint32_t seq, uid;
+
+ unsigned int expunged:1;
+ unsigned int has_nuls:1; /* message data is known to contain NULs */
+ unsigned int has_no_nuls:1; /* -''- known to not contain NULs */
+};
+
struct mail_storage_callbacks {
/* Alert: Not enough disk space */
void (*alert_no_diskspace)(struct mailbox *mailbox, void *context);
@@ -291,7 +309,8 @@
mailbox_notify_callback_t *callback, void *context);
struct mailbox_transaction_context *
-mailbox_transaction_begin(struct mailbox *box, int hide);
+mailbox_transaction_begin(struct mailbox *box,
+ enum mailbox_transaction_flags flags);
int mailbox_transaction_commit(struct mailbox_transaction_context *t,
enum mailbox_sync_flags flags);
void mailbox_transaction_rollback(struct mailbox_transaction_context *t);
@@ -303,10 +322,6 @@
void mailbox_keywords_free(struct mailbox_transaction_context *t,
struct mail_keywords *keywords);
-/* Simplified fetching for a single sequence. */
-struct mail *mailbox_fetch(struct mailbox_transaction_context *t, uint32_t seq,
- enum mail_fetch_field wanted_fields);
-
/* Convert uid range to sequence range. */
int mailbox_get_uids(struct mailbox *box, uint32_t uid1, uint32_t uid2,
uint32_t *seq1_r, uint32_t *seq2_r);
@@ -326,21 +341,15 @@
If sort_program is non-NULL, it requests that the returned messages
are sorted by the given criteria. sort_program must have gone
- through search_get_sorting().
-
- wanted_fields and wanted_headers aren't required, but they can be
- used for optimizations. */
+ through search_get_sorting(). */
struct mail_search_context *
mailbox_search_init(struct mailbox_transaction_context *t,
const char *charset, struct mail_search_arg *args,
- const enum mail_sort_type *sort_program,
- enum mail_fetch_field wanted_fields,
- struct mailbox_header_lookup_ctx *wanted_headers);
+ const enum mail_sort_type *sort_program);
/* Deinitialize search request. */
int mailbox_search_deinit(struct mail_search_context *ctx);
-/* Search the next message. Returned mail object can be used until
- the next call to search_next() or search_deinit(). */
-struct mail *mailbox_search_next(struct mail_search_context *ctx);
+/* Search the next message. Returns 1 if found, 0 if not, -1 if failure. */
+int mailbox_search_next(struct mail_search_context *ctx, struct mail *mail);
/* Save a mail into mailbox. timezone_offset specifies the timezone in
minutes in which received_date was originally given with. To use
@@ -356,14 +365,14 @@
const char *from_envelope, struct istream *input,
int want_mail);
int mailbox_save_continue(struct mail_save_context *ctx);
-int mailbox_save_finish(struct mail_save_context *ctx, struct mail **mail_r);
+int mailbox_save_finish(struct mail_save_context *ctx, struct mail *dest_mail);
void mailbox_save_cancel(struct mail_save_context *ctx);
-/* Copy given message. If dest_mail_r is non-NULL, the copied message can be
+/* Copy given message. If dest_mail is non-NULL, the copied message can be
accessed using it. Note that setting it non-NULL may require mailbox
syncing, so don't give give it unless you need it. */
int mailbox_copy(struct mailbox_transaction_context *t, struct mail *mail,
- struct mail **dest_mail_r);
+ struct mail *dest_mail);
/* Returns TRUE if mailbox is now in inconsistent state, meaning that
the message IDs etc. may have changed - only way to recover this
@@ -372,60 +381,56 @@
do forced CLOSE. */
int mailbox_is_inconsistent(struct mailbox *box);
-struct mail {
- /* always set */
- struct mailbox *box;
- struct mailbox_transaction_context *transaction;
- uint32_t seq, uid;
-
- unsigned int expunged:1;
- unsigned int has_nuls:1; /* message data is known to contain NULs */
- unsigned int has_no_nuls:1; /* -''- known to not contain NULs */
+/* Returns message's flags */
+enum mail_flags mail_get_flags(struct mail *mail);
+/* Returns message's keywords */
+const char *const *mail_get_keywords(struct mail *mail);
+/* Returns message's MIME parts */
+const struct message_part *mail_get_parts(struct mail *mail);
- enum mail_flags (*get_flags)(struct mail *mail);
- const char *const *(*get_keywords)(struct mail *mail);
- const struct message_part *(*get_parts)(struct mail *mail);
+struct mail *mail_alloc(struct mailbox_transaction_context *t,
+ enum mail_fetch_field wanted_fields,
+ struct mailbox_header_lookup_ctx *wanted_headers);
+void mail_free(struct mail *mail);
+int mail_set_seq(struct mail *mail, uint32_t seq);
- /* Get the time message was received (IMAP INTERNALDATE).
- Returns (time_t)-1 if error occured. */
- time_t (*get_received_date)(struct mail *mail);
- /* Get the Date-header in mail. Timezone is in minutes.
- Returns (time_t)-1 if error occured, 0 if field wasn't found or
- couldn't be parsed. */
- time_t (*get_date)(struct mail *mail, int *timezone);
- /* Get the full virtual size of mail (IMAP RFC822.SIZE).
- Returns (uoff_t)-1 if error occured */
- uoff_t (*get_virtual_size)(struct mail *mail);
- /* Get the full physical size of mail.
- Returns (uoff_t)-1 if error occured */
- uoff_t (*get_physical_size)(struct mail *mail);
+/* Get the time message was received (IMAP INTERNALDATE).
+ Returns (time_t)-1 if error occured. */
+time_t mail_get_received_date(struct mail *mail);
+/* Get the Date-header in mail. Timezone is in minutes.
+ Returns (time_t)-1 if error occured, 0 if field wasn't found or
+ couldn't be parsed. */
+time_t mail_get_date(struct mail *mail, int *timezone);
- /* Get value for single header field */
- const char *(*get_header)(struct mail *mail, const char *field);
- /* Returns stream containing specified headers. */
- struct istream *
- (*get_headers)(struct mail *mail,
- struct mailbox_header_lookup_ctx *headers);
+/* Get the full virtual size of mail (IMAP RFC822.SIZE).
+ Returns (uoff_t)-1 if error occured */
+uoff_t mail_get_virtual_size(struct mail *mail);
+/* Get the full physical size of mail.
+ Returns (uoff_t)-1 if error occured */
+uoff_t mail_get_physical_size(struct mail *mail);
- /* Returns input stream pointing to beginning of message header.
- hdr_size and body_size are updated unless they're NULL. */
- struct istream *(*get_stream)(struct mail *mail,
- struct message_size *hdr_size,
- struct message_size *body_size);
+/* Get value for single header field */
+const char *mail_get_header(struct mail *mail, const char *field);
+/* Returns stream containing specified headers. */
+struct istream *mail_get_headers(struct mail *mail,
+ struct mailbox_header_lookup_ctx *headers);
+/* Returns input stream pointing to beginning of message header.
+ hdr_size and body_size are updated unless they're NULL. */
+struct istream *mail_get_stream(struct mail *mail,
+ struct message_size *hdr_size,
+ struct message_size *body_size);
- /* Get any of the "special" fields. */
- const char *(*get_special)(struct mail *mail,
- enum mail_fetch_field field);
+/* Get any of the "special" fields. */
+const char *mail_get_special(struct mail *mail, enum mail_fetch_field field);
- /* Update message flags. */
- int (*update_flags)(struct mail *mail, enum modify_type modify_type,
- enum mail_flags flags);
- /* Update message keywords. */
- int (*update_keywords)(struct mail *mail, enum modify_type modify_type,
- struct mail_keywords *keywords);
+/* Update message flags. */
+int mail_update_flags(struct mail *mail, enum modify_type modify_type,
+ enum mail_flags flags);
+/* Update message keywords. */
+int mail_update_keywords(struct mail *mail, enum modify_type modify_type,
+ struct mail_keywords *keywords);
- /* Expunge this message. Sequence numbers don't change until commit. */
- int (*expunge)(struct mail *mail);
-};
+/* Expunge this message. Sequence numbers don't change until commit. */
+int mail_expunge(struct mail *mail);
#endif
--- NEW FILE: mail.c ---
/* Copyright (C) 2002-2003 Timo Sirainen */
#include "lib.h"
#include "ioloop.h"
#include "mail-storage-private.h"
struct mail *mail_alloc(struct mailbox_transaction_context *t,
enum mail_fetch_field wanted_fields,
struct mailbox_header_lookup_ctx *wanted_headers)
{
return t->box->v.mail_alloc(t, wanted_fields, wanted_headers);
}
void mail_free(struct mail *mail)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.free(mail);
}
int mail_set_seq(struct mail *mail, uint32_t seq)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.set_seq(mail, seq);
}
enum mail_flags mail_get_flags(struct mail *mail)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_flags(mail);
}
const char *const *mail_get_keywords(struct mail *mail)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_keywords(mail);
}
const struct message_part *mail_get_parts(struct mail *mail)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_parts(mail);
}
time_t mail_get_received_date(struct mail *mail)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_received_date(mail);
}
time_t mail_get_date(struct mail *mail, int *timezone)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_date(mail, timezone);
}
uoff_t mail_get_virtual_size(struct mail *mail)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_virtual_size(mail);
}
uoff_t mail_get_physical_size(struct mail *mail)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_physical_size(mail);
}
const char *mail_get_header(struct mail *mail, const char *field)
{
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_header(mail, field);
}
}
struct istream *mail_get_headers(struct mail *mail,
struct mailbox_header_lookup_ctx *headers)
{
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_headers(mail, headers);
}
}
struct istream *mail_get_stream(struct mail *mail,
struct message_size *hdr_size,
struct message_size *body_size)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_stream(mail, hdr_size, body_size);
}
const char *mail_get_special(struct mail *mail, enum mail_fetch_field field)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.get_special(mail, field);
}
int mail_update_flags(struct mail *mail, enum modify_type modify_type,
enum mail_flags flags)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.update_flags(mail, modify_type, flags);
}
int mail_update_keywords(struct mail *mail, enum modify_type modify_type,
struct mail_keywords *keywords)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.update_keywords(mail, modify_type, keywords);
}
int mail_expunge(struct mail *mail)
{
struct mail_private *p = (struct mail_private *)mail;
return p->v.expunge(mail);
}
--- proxy-mail-storage.c DELETED ---
--- proxy-mail-storage.h DELETED ---
--- proxy-mail.c DELETED ---
--- proxy-mail.h DELETED ---
--- proxy-mailbox.c DELETED ---
--- proxy-mailbox.h DELETED ---
- Previous message: [dovecot-cvs] dovecot/src/deliver deliver.c,1.1,1.2
- Next message: [dovecot-cvs] dovecot/src/imap cmd-append.c, 1.55, 1.56 cmd-copy.c,
1.26, 1.27 cmd-search.c, 1.23, 1.24 cmd-store.c, 1.31,
1.32 common.h, 1.19, 1.20 imap-expunge.c, 1.5,
1.6 imap-fetch-body.c, 1.17, 1.18 imap-fetch.c, 1.37,
1.38 imap-fetch.h, 1.14, 1.15 imap-sort.c, 1.19,
1.20 imap-sync.c, 1.9, 1.10 imap-thread.c, 1.14, 1.15 main.c,
1.61, 1.62 namespace.c, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list