changeset 4400:593523f53500 HEAD

Removed hardcoded trash plugin configuration paths. Added information about it to dovecot-example.conf
author Timo Sirainen <tss@iki.fi>
date Sat, 17 Jun 2006 18:06:20 +0300
parents 932a70c17a48
children 10cdcfe98cfc
files dovecot-example.conf src/plugins/trash/trash-plugin.c
diffstat 2 files changed, 24 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/dovecot-example.conf	Sat Jun 17 17:45:54 2006 +0300
+++ b/dovecot-example.conf	Sat Jun 17 18:06:20 2006 +0300
@@ -977,4 +977,11 @@
   # Convert plugin. If set, specifies the source storage path which is
   # converted to destination storage (default_mail_env).
   #convert_mail = mbox:%h/mail
+
+  # Trash plugin. When saving a message would make user go over quota, this
+  # plugin automatically deletes the oldest mails from configured mailboxes
+  # until the message can be saved within quota limits. The configuration file
+  # is a text file where each line is in format: <priority> <mailbox name>
+  # Mails are first deleted in lowest -> highest priority number order
+  #trash = /etc/dovecot-trash.conf
 }
--- a/src/plugins/trash/trash-plugin.c	Sat Jun 17 17:45:54 2006 +0300
+++ b/src/plugins/trash/trash-plugin.c	Sat Jun 17 18:06:20 2006 +0300
@@ -13,9 +13,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 
-#define LOCAL_CONFIG_FILE "~/.dovecot.trash.conf"
-#define GLOBAL_CONFIG_FILE "/etc/dovecot-trash.conf"
-
 #define MAX_RETRY_COUNT 3
 
 #define TRASH_CONTEXT(obj) \
@@ -233,8 +230,7 @@
 
 	fd = open(path, O_RDONLY);
 	if (fd == -1) {
-		if (errno != ENOENT)
-			i_error("open(%s) failed: %m", path);
+		i_error("open(%s) failed: %m", path);
 		return -1;
 	}
 
@@ -263,19 +259,30 @@
 
 void trash_plugin_init(void)
 {
+	const char *env;
+
 	trash_next_hook_quota_root_created = hook_quota_root_created;
 
+	env = getenv("TRASH");
+	if (env == NULL)
+		return;
+
+	if (quota == NULL) {
+		i_error("trash plugin: quota plugin not initialized");
+		return;
+	}
+
 	config_pool = pool_alloconly_create("trash config", 1024);
-	if (read_configuration(home_expand(LOCAL_CONFIG_FILE)) < 0) {
-		if (read_configuration(GLOBAL_CONFIG_FILE) < 0)
-			return;
-	}
+	if (read_configuration(env) < 0)
+		return;
 
 	hook_quota_root_created = trash_quota_root_created;
 }
 
 void trash_plugin_deinit(void)
 {
-	pool_unref(config_pool);
+	if (config_pool != NULL)
+		pool_unref(config_pool);
+
 	hook_quota_root_created = trash_next_hook_quota_root_created;
 }