From: Timo Sirainen Date: Sun, 26 Oct 2003 18:05:42 +0000 (+0200) Subject: Moved copy() method from struct mail to struct mailbox - the context X-Git-Tag: 1.1.alpha1~4264 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df1db5e1dde18b87fa78bd846b736c67c46406fd;p=thirdparty%2Fdovecot%2Fcore.git Moved copy() method from struct mail to struct mailbox - the context parameter makes sense only to destination mailbox handler. --HG-- branch : HEAD --- diff --git a/src/imap/cmd-copy.c b/src/imap/cmd-copy.c index e8cf4b0808..0a1dccd33c 100644 --- a/src/imap/cmd-copy.c +++ b/src/imap/cmd-copy.c @@ -4,27 +4,27 @@ #include "commands.h" static int fetch_and_copy(struct mail_copy_context *copy_ctx, - struct mailbox *box, const char *messageset, - int uidset, int *all_found) + struct mailbox *srcbox, struct mailbox *destbox, + const char *messageset, int uidset, int *all_found) { struct mail_fetch_context *fetch_ctx; struct mail *mail; int failed = FALSE; - fetch_ctx = box->fetch_init(box, MAIL_FETCH_STREAM_HEADER | - MAIL_FETCH_STREAM_BODY, NULL, - messageset, uidset); + fetch_ctx = srcbox->fetch_init(srcbox, MAIL_FETCH_STREAM_HEADER | + MAIL_FETCH_STREAM_BODY, NULL, + messageset, uidset); if (fetch_ctx == NULL) return FALSE; - while ((mail = box->fetch_next(fetch_ctx)) != NULL) { - if (!mail->copy(mail, copy_ctx)) { + while ((mail = srcbox->fetch_next(fetch_ctx)) != NULL) { + if (!destbox->copy(mail, copy_ctx)) { failed = TRUE; break; } } - if (!box->fetch_deinit(fetch_ctx, all_found)) + if (!srcbox->fetch_deinit(fetch_ctx, all_found)) return FALSE; return !failed; @@ -75,7 +75,7 @@ int cmd_copy(struct client *client) if (copy_ctx == NULL) failed = TRUE; else { - if (!fetch_and_copy(copy_ctx, client->mailbox, + if (!fetch_and_copy(copy_ctx, client->mailbox, destbox, messageset, client->cmd_uid, &all_found)) failed = TRUE; diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 682a5f116e..ba76509d8f 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -561,7 +561,6 @@ static struct mail index_mail = { get_stream, get_special, index_storage_update_flags, - index_storage_copy, index_storage_expunge }; diff --git a/src/lib-storage/index/maildir/maildir-storage.c b/src/lib-storage/index/maildir/maildir-storage.c index 94895e8c58..afac326951 100644 --- a/src/lib-storage/index/maildir/maildir-storage.c +++ b/src/lib-storage/index/maildir/maildir-storage.c @@ -387,7 +387,6 @@ static int verify_inbox(struct mail_storage *storage) static void maildir_mail_init(struct index_mail *mail) { - mail->mail.copy = maildir_storage_copy; mail->mail.expunge = maildir_storage_expunge; } @@ -872,6 +871,7 @@ struct mailbox maildir_mailbox = { maildir_storage_save_next, maildir_storage_copy_init, maildir_storage_copy_deinit, + maildir_storage_copy, maildir_storage_expunge_init, maildir_storage_expunge_deinit, maildir_storage_expunge_fetch_next, diff --git a/src/lib-storage/index/mbox/mbox-storage.c b/src/lib-storage/index/mbox/mbox-storage.c index 091d621259..1f2794e055 100644 --- a/src/lib-storage/index/mbox/mbox-storage.c +++ b/src/lib-storage/index/mbox/mbox-storage.c @@ -871,6 +871,7 @@ struct mailbox mbox_mailbox = { mbox_storage_save_next, index_storage_copy_init, index_storage_copy_deinit, + index_storage_copy, mbox_storage_expunge_init, mbox_storage_expunge_deinit, mbox_storage_expunge_fetch_next, diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index 95c07d4750..7a99ffcd0c 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -325,6 +325,8 @@ struct mailbox { struct mail_copy_context *(*copy_init)(struct mailbox *box); /* Finish copying. */ int (*copy_deinit)(struct mail_copy_context *ctx, int rollback); + /* Copy given message. */ + int (*copy)(struct mail *mail, struct mail_copy_context *ctx); /* Initialize expunging operation to this mailbox. If expunge_all is TRUE, all messages are returned rather than just deleted. */ @@ -390,9 +392,6 @@ struct mail { const struct mail_full_flags *flags, enum modify_type modify_type); - /* Copy this message to another mailbox. */ - int (*copy)(struct mail *mail, struct mail_copy_context *ctx); - /* Expunge this message. Note that the actual message may or may not be really expunged until expunge_deinit() is called. In any case, after this call you must not try to access this mail, or any other diff --git a/src/lib-storage/proxy-mail.c b/src/lib-storage/proxy-mail.c index c7aa7fcffd..ef14dc4473 100644 --- a/src/lib-storage/proxy-mail.c +++ b/src/lib-storage/proxy-mail.c @@ -69,13 +69,6 @@ static int _update_flags(struct mail *mail, const struct mail_full_flags *flags, return p->mail->update_flags(p->mail, flags, modify_type); } -static int _copy(struct mail *mail, struct mail_copy_context *ctx) -{ - struct proxy_mail *p = (struct proxy_mail *) mail; - - return p->mail->copy(p->mail, ctx); -} - static int _expunge(struct mail *mail, struct mail_expunge_context *ctx, unsigned int *seq_r, int notify) { @@ -101,7 +94,6 @@ void proxy_mail_init(struct proxy_mail *proxy, struct mail *mail) pm->get_stream = _get_stream; pm->get_special = _get_special; pm->update_flags = _update_flags; - pm->copy = _copy; pm->expunge = _expunge; }