changeset 8125:81967ad7098f HEAD

deliver: Added -s parameter to autosubscribe to autocreated mailboxes.
author Timo Sirainen <tss@iki.fi>
date Sat, 30 Aug 2008 13:32:14 +0300
parents 744f9dbff89c
children cf2c4f3c636f
files src/deliver/deliver.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/deliver/deliver.c	Sat Aug 30 13:21:18 2008 +0300
+++ b/src/deliver/deliver.c	Sat Aug 30 13:32:14 2008 +0300
@@ -61,6 +61,7 @@
 static bool saved_mail = FALSE;
 static bool tried_default_save = FALSE;
 static bool no_mailbox_autocreate = FALSE;
+static bool mailbox_autosubscribe = FALSE;
 static char *explicit_envelope_sender = NULL;
 
 static struct module *modules;
@@ -175,6 +176,10 @@
 	/* try creating it. */
 	if (mail_storage_mailbox_create(ns->storage, name, FALSE) < 0)
 		return NULL;
+	if (mailbox_autosubscribe) {
+		/* (try to) subscribe to it */
+		(void)mailbox_list_set_subscribed(ns->list, name, TRUE);
+	}
 
 	/* and try opening again */
 	box = mailbox_open(ns->storage, name, NULL, MAILBOX_OPEN_FAST |
@@ -694,7 +699,7 @@
 {
 	printf(
 "Usage: deliver [-c <config file>] [-a <address>] [-d <username>] [-p <path>]\n"
-"               [-f <envelope sender>] [-m <mailbox>] [-n] [-e] [-k]\n");
+"               [-f <envelope sender>] [-m <mailbox>] [-n] [-s] [-e] [-k]\n");
 }
 
 void deliver_env_clean(void)
@@ -860,8 +865,9 @@
 			if (*argv[i] != '\0')
 				mailbox = argv[i];
 		} else if (strcmp(argv[i], "-n") == 0) {
-			/* destination mailbox */
 			no_mailbox_autocreate = TRUE;
+		} else if (strcmp(argv[i], "-s") == 0) {
+			mailbox_autosubscribe = TRUE;
 		} else if (strcmp(argv[i], "-f") == 0) {
 			/* envelope sender address */
 			i++;