[dovecot-cvs] dovecot/src/imap cmd-copy.c,1.15,1.16 cmd-search.c,1.17,1.18 cmd-store.c,1.19,1.20 imap-fetch.c,1.16,1.17 imap-fetch.h,1.4,1.5 imap-search.c,1.4,1.5 imap-search.h,1.1,1.2 imap-sort.c,1.8,1.9 imap-thread.c,1.5,1.6

cras at procontrol.fi cras at procontrol.fi
Sun Oct 26 22:13:18 EET 2003


Update of /home/cvs/dovecot/src/imap
In directory danu:/tmp/cvs-serv11799/imap

Modified Files:
	cmd-copy.c cmd-search.c cmd-store.c imap-fetch.c imap-fetch.h 
	imap-search.c imap-search.h imap-sort.c imap-thread.c 
Log Message:
Removed fetch_init/fetch_next from mail-storage. search_* makes it
unnecessary



Index: cmd-copy.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-copy.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- cmd-copy.c	26 Oct 2003 18:05:42 -0000	1.15
+++ cmd-copy.c	26 Oct 2003 20:13:15 -0000	1.16
@@ -2,29 +2,32 @@
 
 #include "common.h"
 #include "commands.h"
+#include "imap-search.h"
 
 static int fetch_and_copy(struct mail_copy_context *copy_ctx,
 			  struct mailbox *srcbox, struct mailbox *destbox,
 			  const char *messageset, int uidset, int *all_found)
 {
-	struct mail_fetch_context *fetch_ctx;
+	struct mail_search_arg *search_arg;
+	struct mail_search_context *search_ctx;
 	struct mail *mail;
 	int failed = FALSE;
 
-	fetch_ctx = srcbox->fetch_init(srcbox, MAIL_FETCH_STREAM_HEADER |
-				       MAIL_FETCH_STREAM_BODY, NULL,
-				       messageset, uidset);
-	if (fetch_ctx == NULL)
+	search_arg = imap_search_get_msgset_arg(messageset, uidset);
+	search_ctx = srcbox->search_init(srcbox, NULL, search_arg, NULL,
+					 MAIL_FETCH_STREAM_HEADER |
+					 MAIL_FETCH_STREAM_BODY, NULL);
+	if (search_ctx == NULL)
 		return FALSE;
 
-	while ((mail = srcbox->fetch_next(fetch_ctx)) != NULL) {
+	while ((mail = srcbox->search_next(search_ctx)) != NULL) {
 		if (!destbox->copy(mail, copy_ctx)) {
 			failed = TRUE;
 			break;
 		}
 	}
 
-	if (!srcbox->fetch_deinit(fetch_ctx, all_found))
+	if (!srcbox->search_deinit(search_ctx, all_found))
 		return FALSE;
 
 	return !failed;

Index: cmd-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-search.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- cmd-search.c	27 Jul 2003 04:48:32 -0000	1.17
+++ cmd-search.c	26 Oct 2003 20:13:15 -0000	1.18
@@ -37,7 +37,7 @@
 		str_printfa(str, " %u", uid ? mail->uid : mail->seq);
 	}
 
-	ret = client->mailbox->search_deinit(ctx);
+	ret = client->mailbox->search_deinit(ctx, NULL);
 
 	if (!first || ret) {
 		str_append(str, "\r\n");

Index: cmd-store.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-store.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- cmd-store.c	10 Aug 2003 18:14:39 -0000	1.19
+++ cmd-store.c	26 Oct 2003 20:13:15 -0000	1.20
@@ -2,6 +2,7 @@
 
 #include "common.h"
 #include "commands.h"
+#include "imap-search.h"
 
 static int get_modify_type(struct client *client, const char *item,
 			   enum modify_type *modify_type, int *silent)
@@ -59,7 +60,8 @@
 	struct mail_full_flags flags;
 	enum modify_type modify_type;
 	struct mailbox *box;
-	struct mail_fetch_context *fetch_ctx;
+	struct mail_search_arg *search_arg;
+	struct mail_search_context *search_ctx;
 	struct mail *mail;
 	const char *messageset, *item;
 	int silent, all_found, failed;
@@ -104,14 +106,16 @@
 				    MAILBOX_LOCK_READ);
 	}
 
-	fetch_ctx = failed ? NULL :
-		box->fetch_init(box, MAIL_FETCH_FLAGS, NULL,
-				messageset, client->cmd_uid);
-	if (fetch_ctx == NULL)
+	search_arg = imap_search_get_msgset_arg(messageset, client->cmd_uid);
+	search_ctx = failed ? NULL :
+		box->search_init(box, NULL, search_arg, NULL,
+				 MAIL_FETCH_FLAGS, NULL);
+
+	if (search_ctx == NULL)
 		failed = TRUE;
 	else {
 		failed = FALSE;
-		while ((mail = box->fetch_next(fetch_ctx)) != NULL) {
+		while ((mail = box->search_next(search_ctx)) != NULL) {
 			if (!mail->update_flags(mail, &flags, modify_type)) {
 				failed = TRUE;
 				break;
@@ -126,7 +130,7 @@
 		}
 	}
 
-	if (!box->fetch_deinit(fetch_ctx, &all_found))
+	if (!box->search_deinit(search_ctx, &all_found))
 		failed = TRUE;
 
 	(void)box->lock(box, MAILBOX_LOCK_UNLOCK);

Index: imap-fetch.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-fetch.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- imap-fetch.c	21 Oct 2003 14:14:56 -0000	1.16
+++ imap-fetch.c	26 Oct 2003 20:13:15 -0000	1.17
@@ -10,6 +10,7 @@
 #include "imap-date.h"
 #include "commands.h"
 #include "imap-fetch.h"
+#include "imap-search.h"
 
 #include <unistd.h>
 
@@ -330,6 +331,7 @@
 	       const char *messageset, int uidset)
 {
 	struct mailbox *box = client->mailbox;
+	struct mail_search_arg *search_arg;
 	struct imap_fetch_context ctx;
 	struct mail *mail;
 	struct imap_fetch_body_data *body;
@@ -386,13 +388,14 @@
 			return -1;
 	}
 
-	ctx.fetch_ctx = box->fetch_init(box, fetch_data, wanted_headers,
-					messageset, uidset);
-	if (ctx.fetch_ctx == NULL)
+	search_arg = imap_search_get_msgset_arg(messageset, uidset);
+	ctx.search_ctx = box->search_init(box, NULL, search_arg, NULL,
+					  fetch_data, wanted_headers);
+	if (ctx.search_ctx == NULL)
 		ctx.failed = TRUE;
 	else {
 		ctx.str = str_new(default_pool, 8192);
-		while ((mail = box->fetch_next(ctx.fetch_ctx)) != NULL) {
+		while ((mail = box->search_next(ctx.search_ctx)) != NULL) {
 			if (!fetch_mail(&ctx, mail)) {
 				ctx.failed = TRUE;
 				break;
@@ -400,7 +403,7 @@
 		}
 		str_free(ctx.str);
 
-		if (!box->fetch_deinit(ctx.fetch_ctx, &all_found))
+		if (!box->search_deinit(ctx.search_ctx, &all_found))
 			ctx.failed = TRUE;
 	}
 

Index: imap-fetch.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-fetch.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- imap-fetch.h	6 Aug 2003 20:15:30 -0000	1.4
+++ imap-fetch.h	26 Oct 2003 20:13:15 -0000	1.5
@@ -19,7 +19,7 @@
 };
 
 struct imap_fetch_context {
-	struct mail_fetch_context *fetch_ctx;
+	struct mail_search_context *search_ctx;
 
 	enum mail_fetch_field fetch_data;
 	enum imap_fetch_field imap_data;

Index: imap-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-search.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- imap-search.c	6 Aug 2003 20:15:30 -0000	1.4
+++ imap-search.c	26 Oct 2003 20:13:15 -0000	1.5
@@ -349,3 +349,13 @@
 	return first_sarg;
 }
 
+struct mail_search_arg *
+imap_search_get_msgset_arg(const char *messageset, int uidset)
+{
+	struct mail_search_arg *arg;
+
+	arg = t_new(struct mail_search_arg, 1);
+	arg->type = uidset ? SEARCH_UID : SEARCH_SET;
+	arg->value.str = t_strdup(messageset);
+	return arg;
+}

Index: imap-search.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-search.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- imap-search.h	20 Jan 2003 14:52:51 -0000	1.1
+++ imap-search.h	26 Oct 2003 20:13:15 -0000	1.2
@@ -5,4 +5,7 @@
 struct mail_search_arg *
 imap_search_args_build(pool_t pool, struct imap_arg *args, const char **error);
 
+struct mail_search_arg *
+imap_search_get_msgset_arg(const char *messageset, int uidset);
+
 #endif

Index: imap-sort.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-sort.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- imap-sort.c	3 Oct 2003 16:20:58 -0000	1.8
+++ imap-sort.c	26 Oct 2003 20:13:15 -0000	1.9
@@ -244,7 +244,7 @@
 		mail_sort_input(ctx, mail);
 
 	mail_sort_flush(ctx);
-	ret = client->mailbox->search_deinit(ctx->search_ctx);
+	ret = client->mailbox->search_deinit(ctx->search_ctx, NULL);
 
 	if (ctx->written || ret) {
 		str_append(ctx->str, "\r\n");

Index: imap-thread.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-thread.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- imap-thread.c	21 Sep 2003 16:21:36 -0000	1.5
+++ imap-thread.c	26 Oct 2003 20:13:15 -0000	1.6
@@ -142,7 +142,7 @@
 	mail_thread_finish(ctx);
 	o_stream_send_str(client->output, "\r\n");
 
-	ret = client->mailbox->search_deinit(ctx->search_ctx);
+	ret = client->mailbox->search_deinit(ctx->search_ctx, NULL);
         mail_thread_deinit(ctx);
 	return ret;
 }



More information about the dovecot-cvs mailing list