]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Moved copy() method from struct mail to struct mailbox - the context
authorTimo Sirainen <tss@iki.fi>
Sun, 26 Oct 2003 18:05:42 +0000 (20:05 +0200)
committerTimo Sirainen <tss@iki.fi>
Sun, 26 Oct 2003 18:05:42 +0000 (20:05 +0200)
parameter makes sense only to destination mailbox handler.

--HG--
branch : HEAD

src/imap/cmd-copy.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/mail-storage.h
src/lib-storage/proxy-mail.c

index e8cf4b08087bf40a95090a6533253a751055ef7b..0a1dccd33c1c8c12f510840e6c2275bfba3fb695 100644 (file)
@@ -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;
 
index 682a5f116e9896015003001d46628cd5c642cfcb..ba76509d8fc5374b26df1f603f64232f03c9b882 100644 (file)
@@ -561,7 +561,6 @@ static struct mail index_mail = {
        get_stream,
        get_special,
        index_storage_update_flags,
-       index_storage_copy,
        index_storage_expunge
 };
 
index 94895e8c58b248499c958ddf0de7d01cabcebdf1..afac326951280592b64f28acebb2f61d68fd8506 100644 (file)
@@ -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,
index 091d6212594e4f785f57aeb6c435bc92f3d00ead..1f2794e055f966e39d84d3395c62ffdc93021594 100644 (file)
@@ -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,
index 95c07d4750d6c4b4c5c9e31f04b7670ca2f0b625..7a99ffcd0c3eea76a7e56c58c9694ac775df6865 100644 (file)
@@ -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
index c7aa7fcffdbb3bfdb81cab0385e1b37595a1e152..ef14dc44734f8296c9fc181ef60799b719d30939 100644 (file)
@@ -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;
 }