[dovecot-cvs]
dovecot/src/lib-storage/index/maildir maildir-expunge.c,1.12,1.13
maildir-storage.c,1.48,1.49 maildir-storage.h,1.16,1.17
cras at procontrol.fi
cras at procontrol.fi
Sat Jul 26 20:33:24 EEST 2003
- Previous message: [dovecot-cvs]
dovecot/src/lib-storage/index index-expunge.c,1.17,1.18
index-mail.c,1.12,1.13 index-mail.h,1.4,1.5
index-storage.c,1.36,1.37 index-storage.h,1.44,1.45
index-update-flags.c,1.23,1.24
- Next message: [dovecot-cvs]
dovecot/src/pop3 client.c,1.11,1.12 commands.c,1.8,1.9
mail-storage-callbacks.c,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib-storage/index/maildir
In directory danu:/tmp/cvs-serv28560/lib-storage/index/maildir
Modified Files:
maildir-expunge.c maildir-storage.c maildir-storage.h
Log Message:
API change for expunging messages. Not exactly what I wanted, but good
enough.
Index: maildir-expunge.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-expunge.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- maildir-expunge.c 21 Jul 2003 14:35:39 -0000 1.12
+++ maildir-expunge.c 26 Jul 2003 16:33:22 -0000 1.13
@@ -1,67 +1,83 @@
-/* Copyright (C) 2002 Timo Sirainen */
+/* Copyright (C) 2002-2003 Timo Sirainen */
#include "lib.h"
+#include "index-expunge.h"
#include "maildir-index.h"
#include "maildir-storage.h"
-int maildir_expunge_locked(struct index_mailbox *ibox, int notify)
+struct maildir_expunge_context {
+ struct mail_expunge_context *ctx;
+ int sent_access_warning;
+};
+
+struct mail_expunge_context *
+maildir_storage_expunge_init(struct mailbox *box,
+ enum mail_fetch_field wanted_fields,
+ int expunge_all)
{
- struct mail_index_record *rec, *first_rec, *last_rec;
- unsigned int seq, first_seq, last_seq;
- int ret, no_permission = FALSE;
+ struct maildir_expunge_context *ctx;
+ struct mail_expunge_context *mctx;
- if (!index_expunge_seek_first(ibox, &seq, &rec))
- return FALSE;
+ mctx = index_storage_expunge_init(box, wanted_fields, expunge_all);
+ if (mctx == NULL)
+ return NULL;
- first_rec = last_rec = NULL;
- first_seq = last_seq = 0;
- while (rec != NULL) {
- if ((rec->msg_flags & MAIL_DELETED) == 0)
- ret = FALSE;
- else {
- t_push();
- ret = maildir_expunge_mail(ibox->index, rec);
- t_pop();
+ ctx = i_new(struct maildir_expunge_context, 1);
+ ctx->ctx = mctx;
+ return (struct mail_expunge_context *) ctx;
+}
- if (!ret) {
- if (errno != EACCES)
- return FALSE;
- no_permission = TRUE;
- } else {
- if (first_rec == NULL) {
- first_rec = rec;
- first_seq = seq;
- }
- last_rec = rec;
- last_seq = seq;
- }
- }
+int maildir_storage_expunge_deinit(struct mail_expunge_context *_ctx)
+{
+ struct maildir_expunge_context *ctx =
+ (struct maildir_expunge_context *) _ctx;
+ struct mail_expunge_context *mctx;
- if (!ret && first_rec != NULL) {
- if (!index_expunge_mails(ibox, first_rec, last_rec,
- first_seq, last_seq, notify))
- return FALSE;
- first_rec = NULL;
+ mctx = ctx->ctx;
+ i_free(ctx);
+ return index_storage_expunge_deinit(mctx);
+}
- seq = first_seq;
- rec = ibox->index->lookup(ibox->index, seq);
- } else {
- seq++;
- rec = ibox->index->next(ibox->index, rec);
- }
+struct mail *
+maildir_storage_expunge_fetch_next(struct mail_expunge_context *_ctx)
+{
+ struct maildir_expunge_context *ctx =
+ (struct maildir_expunge_context *) _ctx;
+
+ return index_storage_expunge_fetch_next(ctx->ctx);
+}
+
+int maildir_storage_expunge(struct mail *mail,
+ struct mail_expunge_context *_ctx,
+ unsigned int *seq_r, int notify)
+{
+ struct maildir_expunge_context *ctx =
+ (struct maildir_expunge_context *) _ctx;
+ struct index_mail *imail = (struct index_mail *) mail;
+ int ret;
+
+ if (mail->box->readonly) {
+ /* send warning */
+ return index_storage_expunge(mail, ctx->ctx, seq_r, notify);
}
- if (first_rec != NULL) {
- if (!index_expunge_mails(ibox, first_rec, last_rec,
- first_seq, last_seq, notify))
+ t_push();
+ ret = maildir_expunge_mail(imail->ibox->index, imail->data.rec);
+ t_pop();
+
+ if (!ret) {
+ if (errno != EACCES)
return FALSE;
- }
- if (no_permission) {
- ibox->box.storage->callbacks->notify_no(&ibox->box,
+ if (ctx->sent_access_warning)
+ return TRUE;
+ ctx->sent_access_warning = TRUE;
+
+ mail->box->storage->callbacks->notify_no(mail->box,
"We didn't have permission to expunge all the mails",
- ibox->box.storage->callback_context);
+ mail->box->storage->callback_context);
+ return TRUE;
}
- return TRUE;
+ return index_storage_expunge(mail, ctx->ctx, seq_r, notify);
}
Index: maildir-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- maildir-storage.c 23 Jul 2003 02:55:12 -0000 1.48
+++ maildir-storage.c 26 Jul 2003 16:33:22 -0000 1.49
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Timo Sirainen */
+/* Copyright (C) 2002-2003 Timo Sirainen */
#include "lib.h"
#include "home-expand.h"
@@ -322,6 +322,7 @@
static void maildir_mail_init(struct index_mail *mail)
{
mail->mail.copy = maildir_storage_copy;
+ mail->mail.expunge = maildir_storage_expunge;
}
static struct mailbox *
@@ -344,10 +345,8 @@
ibox = index_storage_mailbox_init(storage, &maildir_mailbox,
index, name, flags);
- if (ibox != NULL) {
- ibox->expunge_locked = maildir_expunge_locked;
+ if (ibox != NULL)
ibox->mail_init = maildir_mail_init;
- }
return (struct mailbox *) ibox;
}
@@ -770,7 +769,6 @@
index_storage_get_status,
index_storage_sync,
maildir_storage_auto_sync,
- index_storage_expunge,
index_storage_fetch_init,
index_storage_fetch_deinit,
index_storage_fetch_next,
@@ -785,6 +783,9 @@
maildir_storage_save_next,
maildir_storage_copy_init,
maildir_storage_copy_deinit,
+ maildir_storage_expunge_init,
+ maildir_storage_expunge_deinit,
+ maildir_storage_expunge_fetch_next,
mail_storage_is_inconsistency_error,
FALSE,
Index: maildir-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- maildir-storage.h 23 Jul 2003 00:40:50 -0000 1.16
+++ maildir-storage.h 26 Jul 2003 16:33:22 -0000 1.17
@@ -23,7 +23,15 @@
struct mailbox_list *
maildir_list_mailbox_next(struct mailbox_list_context *ctx);
-int maildir_expunge_locked(struct index_mailbox *ibox, int notify);
+struct mail_expunge_context *
+maildir_storage_expunge_init(struct mailbox *box,
+ enum mail_fetch_field wanted_fields,
+ int expunge_all);
+int maildir_storage_expunge_deinit(struct mail_expunge_context *ctx);
+struct mail *
+maildir_storage_expunge_fetch_next(struct mail_expunge_context *ctx);
+int maildir_storage_expunge(struct mail *mail, struct mail_expunge_context *ctx,
+ unsigned int *seq_r, int notify);
const char *maildir_get_path(struct mail_storage *storage, const char *name);
- Previous message: [dovecot-cvs]
dovecot/src/lib-storage/index index-expunge.c,1.17,1.18
index-mail.c,1.12,1.13 index-mail.h,1.4,1.5
index-storage.c,1.36,1.37 index-storage.h,1.44,1.45
index-update-flags.c,1.23,1.24
- Next message: [dovecot-cvs]
dovecot/src/pop3 client.c,1.11,1.12 commands.c,1.8,1.9
mail-storage-callbacks.c,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list