[dovecot-cvs] dovecot/src/lib-storage mail-copy.c, 1.7,
1.8 mail-storage-private.h, 1.25, 1.26 mail-storage.c, 1.50,
1.51 mail-storage.h, 1.107, 1.108
tss-movial at dovecot.org
tss-movial at dovecot.org
Tue May 9 14:57:39 EEST 2006
Update of /var/lib/cvs/dovecot/src/lib-storage
In directory talvi:/tmp/cvs-serv603/lib-storage
Modified Files:
mail-copy.c mail-storage-private.h mail-storage.c
mail-storage.h
Log Message:
Changed mailbox_save_*() API a bit: Moved the struct mail *dest_mail to
save_init() instead of being in save_finish(). This way you can request
wanted fields from the mail while it's being saved.
With maildir the message is being parsed at the same time as it's being
saved, and the results are stored into cache file.
Index: mail-copy.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-copy.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mail-copy.c 22 Feb 2006 16:02:26 -0000 1.7
+++ mail-copy.c 9 May 2006 11:57:36 -0000 1.8
@@ -21,8 +21,7 @@
if (mailbox_save_init(t, flags, keywords,
mail_get_received_date(mail),
- 0, from_envelope, input, dest_mail != NULL,
- &ctx) < 0)
+ 0, from_envelope, input, dest_mail, &ctx) < 0)
return -1;
while (i_stream_read(input) != -1) {
@@ -35,5 +34,5 @@
return -1;
}
- return mailbox_save_finish(&ctx, dest_mail);
+ return mailbox_save_finish(&ctx);
}
Index: mail-storage-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage-private.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- mail-storage-private.h 14 Apr 2006 12:30:22 -0000 1.25
+++ mail-storage-private.h 9 May 2006 11:57:36 -0000 1.26
@@ -147,10 +147,10 @@
struct mail_keywords *keywords,
time_t received_date, int timezone_offset,
const char *from_envelope, struct istream *input,
- bool want_mail, struct mail_save_context **ctx_r);
+ struct mail *dest_mail,
+ struct mail_save_context **ctx_r);
int (*save_continue)(struct mail_save_context *ctx);
- int (*save_finish)(struct mail_save_context *ctx,
- struct mail *dest_mail);
+ int (*save_finish)(struct mail_save_context *ctx);
void (*save_cancel)(struct mail_save_context *ctx);
int (*copy)(struct mailbox_transaction_context *t, struct mail *mail,
@@ -231,6 +231,7 @@
struct mail_save_context {
struct mailbox_transaction_context *transaction;
+ struct mail *dest_mail;
};
struct mailbox_sync_context {
Index: mail-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- mail-storage.c 2 Apr 2006 09:18:53 -0000 1.50
+++ mail-storage.c 9 May 2006 11:57:36 -0000 1.51
@@ -499,11 +499,15 @@
enum mail_flags flags, struct mail_keywords *keywords,
time_t received_date, int timezone_offset,
const char *from_envelope, struct istream *input,
- bool want_mail, struct mail_save_context **ctx_r)
+ struct mail *dest_mail, struct mail_save_context **ctx_r)
{
- return t->box->v.save_init(t, flags, keywords,
- received_date, timezone_offset,
- from_envelope, input, want_mail, ctx_r);
+ if (t->box->v.save_init(t, flags, keywords,
+ received_date, timezone_offset,
+ from_envelope, input, dest_mail, ctx_r) < 0)
+ return -1;
+
+ (*ctx_r)->dest_mail = dest_mail;
+ return 0;
}
int mailbox_save_continue(struct mail_save_context *ctx)
@@ -511,12 +515,12 @@
return ctx->transaction->box->v.save_continue(ctx);
}
-int mailbox_save_finish(struct mail_save_context **_ctx, struct mail *dest_mail)
+int mailbox_save_finish(struct mail_save_context **_ctx)
{
struct mail_save_context *ctx = *_ctx;
*_ctx = NULL;
- return ctx->transaction->box->v.save_finish(ctx, dest_mail);
+ return ctx->transaction->box->v.save_finish(ctx);
}
void mailbox_save_cancel(struct mail_save_context **_ctx)
Index: mail-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage.h,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- mail-storage.h 9 Apr 2006 15:50:22 -0000 1.107
+++ mail-storage.h 9 May 2006 11:57:36 -0000 1.108
@@ -397,16 +397,22 @@
minutes in which received_date was originally given with. To use
current time, set received_date to (time_t)-1.
- If want_mail is TRUE, mail_r will be set in mailbox_save_finish() and
- the saved message can be accessed using it. Note that setting it may
- require mailbox syncing, so don't set it unless you need it. */
+ If dest_mail is set, the saved message can be accessed using it. Note that
+ setting it may require mailbox syncing, so don't set it unless you need
+ it. Also you shouldn't try to access it before mailbox_save_finish() is
+ called.
+
+ The given input stream is never read in these functions, only the data
+ inside it is used. So you should call i_stream_read() yourself and then
+ call mailbox_save_continue() whenever more data is read.
+*/
int mailbox_save_init(struct mailbox_transaction_context *t,
enum mail_flags flags, struct mail_keywords *keywords,
time_t received_date, int timezone_offset,
const char *from_envelope, struct istream *input,
- bool want_mail, struct mail_save_context **ctx_r);
+ struct mail *dest_mail, struct mail_save_context **ctx_r);
int mailbox_save_continue(struct mail_save_context *ctx);
-int mailbox_save_finish(struct mail_save_context **ctx, struct mail *dest_mail);
+int mailbox_save_finish(struct mail_save_context **ctx);
void mailbox_save_cancel(struct mail_save_context **ctx);
/* Copy given message. If dest_mail is non-NULL, the copied message can be
More information about the dovecot-cvs
mailing list