changeset 5577:1fd9616157e4 HEAD

Updated to support namespaces
author Timo Sirainen <tss@iki.fi>
date Tue, 17 Apr 2007 21:00:48 +0300
parents 36ebd0fe2076
children 9da09dcec39b
files src/plugins/expire/expire-plugin.c src/plugins/trash/trash-plugin.c
diffstat 2 files changed, 22 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/expire/expire-plugin.c	Tue Apr 17 20:59:49 2007 +0300
+++ b/src/plugins/expire/expire-plugin.c	Tue Apr 17 21:00:48 2007 +0300
@@ -4,6 +4,7 @@
 #include "ioloop.h"
 #include "array.h"
 #include "dict.h"
+#include "mail-namespace.h"
 #include "index-mail.h"
 #include "index-storage.h"
 #include "expire-env.h"
@@ -284,10 +285,12 @@
 		EXPIRE_CONTEXT(storage);
 	struct mailbox *box;
 	const struct expire_box *expire_box;
+	const char *full_name;
 
 	box = xpr_storage->super.mailbox_open(storage, name, input, flags);
 	if (box != NULL) {
-		expire_box = expire_box_find(expire.env, name);
+		full_name = t_strconcat(storage->ns->prefix, name, NULL);
+		expire_box = expire_box_find(expire.env, full_name);
 		if (expire_box != NULL)
 			mailbox_expire_hook(box, expire_box->expire_secs);
 	}
--- a/src/plugins/trash/trash-plugin.c	Tue Apr 17 20:59:49 2007 +0300
+++ b/src/plugins/trash/trash-plugin.c	Tue Apr 17 21:00:48 2007 +0300
@@ -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);