Mercurial > dovecot > core-2.2
changeset 12323:82a1bdac2e4e
zlib: Hook into mail.istream_opened() method rather than mail.get_stream()
This fixes zlib plugin to work with mail attachments.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 20 Oct 2010 18:58:42 +0100 |
parents | d94957cafd3e |
children | d55afae11f89 |
files | src/plugins/zlib/zlib-plugin.c |
diffstat | 1 files changed, 8 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/zlib/zlib-plugin.c Wed Oct 20 18:55:36 2010 +0100 +++ b/src/plugins/zlib/zlib-plugin.c Wed Oct 20 18:58:42 2010 +0100 @@ -129,14 +129,10 @@ return NULL; } -static int zlib_permail_get_stream(struct mail *_mail, - struct message_size *hdr_size, - struct message_size *body_size, - struct istream **stream_r) +static int zlib_istream_opened(struct mail *_mail, struct istream **stream) { struct zlib_user *zuser = ZLIB_USER_CONTEXT(_mail->box->storage->user); struct mail_private *mail = (struct mail_private *)_mail; - struct index_mail *imail = (struct index_mail *)mail; union mail_module_context *zmail = ZLIB_MAIL_CONTEXT(mail); struct istream *input; const struct zlib_handler *handler; @@ -145,17 +141,10 @@ in the middle of saving, and we didn't do the compression ourself. in such situation we're probably checking if the user-given input looks compressed */ - if (imail->data.stream != NULL || - (_mail->saving && zuser->save_handler == NULL)) { - return zmail->super.get_stream(_mail, hdr_size, body_size, - stream_r); - } + if (_mail->saving && zuser->save_handler == NULL) + return zmail->super.istream_opened(_mail, stream); - if (zmail->super.get_stream(_mail, NULL, NULL, &input) < 0) - return -1; - i_assert(input == imail->data.stream); - - handler = zlib_get_zlib_handler(imail->data.stream); + handler = zlib_get_zlib_handler(*stream); if (handler != NULL) { if (handler->create_istream == NULL) { mail_storage_set_critical(_mail->box->storage, @@ -164,11 +153,11 @@ return -1; } - input = imail->data.stream; - imail->data.stream = handler->create_istream(input, TRUE); + input = *stream; + *stream = handler->create_istream(input, TRUE); i_stream_unref(&input); } - return index_mail_init_stream(imail, hdr_size, body_size, stream_r); + return zmail->super.istream_opened(_mail, stream); } static void zlib_mail_allocated(struct mail *_mail) @@ -185,7 +174,7 @@ zmail->super = *v; mail->vlast = &zmail->super; - v->get_stream = zlib_permail_get_stream; + v->istream_opened = zlib_istream_opened; MODULE_CONTEXT_SET_SELF(mail, zlib_mail_module, zmail); }