parameter makes sense only to destination mailbox handler.
--HG--
branch : HEAD
#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;
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;
get_stream,
get_special,
index_storage_update_flags,
- index_storage_copy,
index_storage_expunge
};
static void maildir_mail_init(struct index_mail *mail)
{
- mail->mail.copy = maildir_storage_copy;
mail->mail.expunge = maildir_storage_expunge;
}
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,
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,
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. */
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
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)
{
pm->get_stream = _get_stream;
pm->get_special = _get_special;
pm->update_flags = _update_flags;
- pm->copy = _copy;
pm->expunge = _expunge;
}