diff src/plugins/trash/trash-plugin.c @ 7642:077bb84e9e77 HEAD

Make mail_search_args an independent structure that can be used for multiple separate searches.
author Timo Sirainen <tss@iki.fi>
date Wed, 04 Jun 2008 00:51:58 +0300
parents 75526c605044
children db66611fd195
line wrap: on
line diff
--- a/src/plugins/trash/trash-plugin.c	Sun Mar 16 12:10:57 2008 +0200
+++ b/src/plugins/trash/trash-plugin.c	Wed Jun 04 00:51:58 2008 +0300
@@ -5,7 +5,7 @@
 #include "istream.h"
 #include "home-expand.h"
 #include "mail-namespace.h"
-#include "mail-search.h"
+#include "mail-search-build.h"
 #include "quota-private.h"
 #include "quota-plugin.h"
 #include "trash-plugin.h"
@@ -26,7 +26,6 @@
 	/* temporarily set while cleaning: */
 	struct mailbox *box;
 	struct mailbox_transaction_context *trans;
-        struct mail_search_arg search_arg;
 	struct mail_search_context *search_ctx;
 	struct mail *mail;
 
@@ -44,6 +43,8 @@
 
 static int trash_clean_mailbox_open(struct trash_mailbox *trash)
 {
+	struct mail_search_args *search_args;
+
 	trash->box = mailbox_open(trash->storage, trash->name, NULL,
 				  MAILBOX_OPEN_KEEP_RECENT);
 	if (trash->box == NULL)
@@ -53,12 +54,15 @@
 		return -1;
 
 	trash->trans = mailbox_transaction_begin(trash->box, 0);
-
-	trash->search_ctx = mailbox_search_init(trash->trans, NULL,
-						&trash->search_arg, NULL);
 	trash->mail = mail_alloc(trash->trans, MAIL_FETCH_PHYSICAL_SIZE |
 				 MAIL_FETCH_RECEIVED_DATE, NULL);
 
+	search_args = mail_search_build_init();
+	mail_search_build_add_all(search_args);
+	trash->search_ctx = mailbox_search_init(trash->trans,
+						search_args, NULL);
+	mail_search_args_unref(&search_args);
+
 	return mailbox_search_next(trash->search_ctx, trash->mail);
 }
 
@@ -259,7 +263,6 @@
 		trash = array_append_space(&trash_boxes);
 		trash->name = p_strdup(config_pool, name+1);
 		trash->priority = atoi(t_strdup_until(line, name));
-		trash->search_arg.type = SEARCH_ALL;
 
 		if (getenv("DEBUG") != NULL) {
 			i_info("trash plugin: Added '%s' with priority %d",