[dovecot-cvs] dovecot/src/plugins/quota quota-plugin.c, 1.6, 1.7 quota-plugin.h, 1.2, 1.3 quota-storage.c, 1.12, 1.13 quota.c, 1.19, 1.20

tss at dovecot.org tss at dovecot.org
Thu Mar 29 10:59:17 EEST 2007


Update of /var/lib/cvs/dovecot/src/plugins/quota
In directory talvi:/tmp/cvs-serv11000/plugins/quota

Modified Files:
	quota-plugin.c quota-plugin.h quota-storage.c quota.c 
Log Message:
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
work with either fs/maildir++ directory layout. They can be changed by
appending :LAYOUT=fs|maildir++ to mail_location.



Index: quota-plugin.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-plugin.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- quota-plugin.c	22 Feb 2007 14:27:43 -0000	1.6
+++ quota-plugin.c	29 Mar 2007 07:59:14 -0000	1.7
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "mail-storage.h"
+#include "mailbox-list-private.h"
 #include "quota.h"
 #include "quota-plugin.h"
 
@@ -11,6 +12,7 @@
 extern void (*hook_mail_storage_created)(struct mail_storage *storage);
 
 void (*quota_next_hook_mail_storage_created)(struct mail_storage *storage);
+void (*quota_next_hook_mailbox_list_created)(struct mailbox_list *list);
 
 const char *quota_plugin_version = PACKAGE_VERSION;
 struct quota *quota_set;
@@ -74,9 +76,11 @@
 	}
 	t_pop();
 
-	quota_next_hook_mail_storage_created =
-		hook_mail_storage_created;
+	quota_next_hook_mail_storage_created = hook_mail_storage_created;
 	hook_mail_storage_created = quota_mail_storage_created;
+
+	quota_next_hook_mailbox_list_created = hook_mailbox_list_created;
+	hook_mailbox_list_created = quota_mailbox_list_created;
 }
 
 void quota_plugin_deinit(void)
@@ -84,6 +88,8 @@
 	if (quota_set != NULL) {
 		hook_mail_storage_created =
 			quota_next_hook_mail_storage_created;
+		hook_mailbox_list_created =
+			quota_next_hook_mailbox_list_created;
 		quota_deinit(quota_set);
 	}
 }

Index: quota-plugin.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-plugin.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- quota-plugin.h	12 Nov 2006 18:48:33 -0000	1.2
+++ quota-plugin.h	29 Mar 2007 07:59:14 -0000	1.3
@@ -5,11 +5,14 @@
 
 extern void (*quota_next_hook_mail_storage_created)
 	(struct mail_storage *storage);
+extern void (*quota_next_hook_mailbox_list_created)(struct mailbox_list *list);
+
 /* "quota" symbol already exists in OSX, so we'll use this slightly uglier
    name. */
 extern struct quota *quota_set;
 
 void quota_mail_storage_created(struct mail_storage *storage);
+void quota_mailbox_list_created(struct mailbox_list *list);
 
 void quota_plugin_init(void);
 void quota_plugin_deinit(void);

Index: quota-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota-storage.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- quota-storage.c	12 Nov 2006 18:48:33 -0000	1.12
+++ quota-storage.c	29 Mar 2007 07:59:14 -0000	1.13
@@ -5,6 +5,7 @@
 #include "istream.h"
 #include "mail-search.h"
 #include "mail-storage-private.h"
+#include "mailbox-list-private.h"
 #include "quota-private.h"
 #include "quota-plugin.h"
 
@@ -13,6 +14,15 @@
 #define QUOTA_CONTEXT(obj) \
 	*((void **)array_idx_modifiable(&(obj)->module_contexts, \
 					quota_storage_module_id))
+#define QUOTA_LIST_CONTEXT(obj) \
+	*((void **)array_idx_modifiable(&(obj)->module_contexts, \
+					quota_mailbox_list_module_id))
+
+struct quota_mailbox_list {
+	struct mailbox_list_vfuncs super;
+
+	struct mail_storage *storage;
+};
 
 struct quota_mail_storage {
 	struct mail_storage_vfuncs super;
@@ -31,6 +41,9 @@
 static unsigned int quota_storage_module_id = 0;
 static bool quota_storage_module_id_set = FALSE;
 
+static unsigned int quota_mailbox_list_module_id = 0;
+static bool quota_mailbox_list_module_id_set = FALSE;
+
 static int quota_mail_expunge(struct mail *_mail)
 {
 	struct mail_private *mail = (struct mail_private *)_mail;
@@ -247,9 +260,10 @@
 	return box;
 }
 
-static int quota_mailbox_delete(struct mail_storage *storage, const char *name)
+static int
+quota_mailbox_list_delete(struct mailbox_list *list, const char *name)
 {
-	struct quota_mail_storage *qstorage = QUOTA_CONTEXT(storage);
+	struct quota_mailbox_list *qlist = QUOTA_LIST_CONTEXT(list);
 	struct mailbox *box;
 	struct mail_search_context *ctx;
         struct mailbox_transaction_context *t;
@@ -262,7 +276,7 @@
 	   and free the quota for all the messages existing in it. Open the
 	   mailbox locked so that other processes can't mess up the quota
 	   calculations by adding/removing mails while we're doing this. */
-	box = mailbox_open(storage, name, NULL, MAILBOX_OPEN_FAST |
+	box = mailbox_open(qlist->storage, name, NULL, MAILBOX_OPEN_FAST |
 			   MAILBOX_OPEN_KEEP_RECENT | MAILBOX_OPEN_KEEP_LOCKED);
 	if (box == NULL)
 		return -1;
@@ -287,7 +301,7 @@
 	mailbox_close(&box);
 	/* FIXME: here's an unfortunate race condition */
 	return ret < 0 ? -1 :
-		qstorage->super.mailbox_delete(storage, name);
+		qlist->super.delete_mailbox(list, name);
 }
 
 static void quota_storage_destroy(struct mail_storage *storage)
@@ -301,16 +315,18 @@
 
 void quota_mail_storage_created(struct mail_storage *storage)
 {
+	struct quota_mailbox_list *qlist = QUOTA_LIST_CONTEXT(storage->list);
 	struct quota_mail_storage *qstorage;
 
 	if (quota_next_hook_mail_storage_created != NULL)
 		quota_next_hook_mail_storage_created(storage);
 
+	qlist->storage = storage;
+
 	qstorage = p_new(storage->pool, struct quota_mail_storage, 1);
 	qstorage->super = storage->v;
 	storage->v.destroy = quota_storage_destroy;
 	storage->v.mailbox_open = quota_mailbox_open;
-	storage->v.mailbox_delete = quota_mailbox_delete;
 
 	if (!quota_storage_module_id_set) {
 		quota_storage_module_id = mail_storage_module_id++;
@@ -325,3 +341,23 @@
 		quota_add_user_storage(quota_set, storage);
 	}
 }
+
+void quota_mailbox_list_created(struct mailbox_list *list)
+{
+	struct quota_mailbox_list *qlist;
+
+	if (quota_next_hook_mailbox_list_created != NULL)
+		quota_next_hook_mailbox_list_created(list);
+
+	qlist = p_new(list->pool, struct quota_mailbox_list, 1);
+	qlist->super = list->v;
+	list->v.delete_mailbox = quota_mailbox_list_delete;
+
+	if (!quota_mailbox_list_module_id_set) {
+		quota_mailbox_list_module_id = mailbox_list_module_id++;
+		quota_mailbox_list_module_id_set = TRUE;
+	}
+
+	array_idx_set(&list->module_contexts,
+		      quota_mailbox_list_module_id, &qlist);
+}

Index: quota.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/quota/quota.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- quota.c	16 Feb 2007 20:22:36 -0000	1.19
+++ quota.c	29 Mar 2007 07:59:14 -0000	1.20
@@ -3,6 +3,7 @@
 #include "lib.h"
 #include "array.h"
 #include "hash.h"
+#include "mailbox-list-private.h"
 #include "quota-private.h"
 #include "quota-fs.h"
 #include <stdlib.h>
@@ -410,7 +411,7 @@
 	/* the quota information comes from userdb (or even config file),
 	   so there's really no way to support this until some major changes
 	   are done */
-	*error_r = MAIL_STORAGE_ERR_NO_PERMISSION;
+	*error_r = MAILBOX_LIST_ERR_NO_PERMISSION;
 	return -1;
 }
 



More information about the dovecot-cvs mailing list