[dovecot-cvs] dovecot/src/plugins/trash trash-plugin.c,1.22,1.23

tss at dovecot.org tss at dovecot.org
Tue Apr 17 21:00:56 EEST 2007


Update of /var/lib/cvs/dovecot/src/plugins/trash
In directory talvi:/tmp/cvs-serv2828/trash

Modified Files:
	trash-plugin.c 
Log Message:
Updated to support namespaces



Index: trash-plugin.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/trash/trash-plugin.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- trash-plugin.c	13 Mar 2007 16:01:49 -0000	1.22
+++ trash-plugin.c	17 Apr 2007 18:00:51 -0000	1.23
@@ -4,6 +4,7 @@
 #include "array.h"
 #include "istream.h"
 #include "home-expand.h"
+#include "mail-namespace.h"
 #include "mail-search.h"
 #include "quota-private.h"
 #include "quota-plugin.h"
@@ -94,6 +95,21 @@
 	return 1;
 }
 
+static void trash_find_storage(struct trash_mailbox *trash)
+{
+	struct mail_storage *const *storages;
+	unsigned int i, count;
+
+	storages = array_get(&quota_set->storages, &count);
+	for (i = 0; i < count; i++) {
+		if (mail_namespace_update_name(storages[i]->ns, &trash->name)) {
+			trash->storage = storages[i];
+			return;
+		}
+	}
+	i_fatal("trash: Namespace not found for mailbox '%s'", trash->name);
+}
+
 static int trash_try_clean_mails(struct quota_transaction_context *ctx,
 				 uint64_t size_needed)
 {
@@ -113,15 +129,8 @@
 			if (trashes[j].priority != trashes[i].priority)
 				break;
 
-			if (trashes[j].storage == NULL) {
-				/* FIXME: this is really ugly. it'll do however
-				   until we get proper namespace support for
-				   lib-storage. */
-				struct mail_storage *const *storage;
-
-				storage = array_idx(&quota_set->storages, 0);
-				trashes[j].storage = *storage;
-			}
+			if (trashes[j].storage == NULL)
+				trash_find_storage(&trashes[j]);
 
 			ret = trash_clean_mailbox_get_next(&trashes[j],
 							   &received);



More information about the dovecot-cvs mailing list