[dovecot-cvs] dovecot/src/lib-storage mail-storage.c,1.16,1.17 mail-storage.h,1.53,1.54

cras at procontrol.fi cras at procontrol.fi
Sun Jul 27 07:12:15 EEST 2003


Update of /home/cvs/dovecot/src/lib-storage
In directory danu:/tmp/cvs-serv23650/lib-storage

Modified Files:
	mail-storage.c mail-storage.h 
Log Message:
Mail storages support now configurable namespace prefix and hierarchy
separator. Subscription file handling needs some more thought.



Index: mail-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-storage.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- mail-storage.c	26 Jul 2003 16:55:11 -0000	1.16
+++ mail-storage.c	27 Jul 2003 03:12:13 -0000	1.17
@@ -101,28 +101,34 @@
 	}
 }
 
-struct mail_storage *mail_storage_create(const char *name, const char *data,
-					 const char *user)
+struct mail_storage *
+mail_storage_create(const char *name, const char *data, const char *user,
+		    const char *namespace, char hierarchy_sep)
 {
 	struct mail_storage_list *list;
 
 	i_assert(name != NULL);
 
 	for (list = storages; list != NULL; list = list->next) {
-		if (strcasecmp(list->storage->name, name) == 0)
-			return list->storage->create(data, user);
+		if (strcasecmp(list->storage->name, name) == 0) {
+			return list->storage->create(data, user,
+						     namespace, hierarchy_sep);
+		}
 	}
 
 	return NULL;
 }
 
-struct mail_storage *mail_storage_create_default(const char *user)
+struct mail_storage *
+mail_storage_create_default(const char *user,
+			    const char *namespace, char hierarchy_sep)
 {
 	struct mail_storage_list *list;
 	struct mail_storage *storage;
 
 	for (list = storages; list != NULL; list = list->next) {
-		storage = list->storage->create(NULL, user);
+		storage = list->storage->create(NULL, user, namespace,
+						hierarchy_sep);
 		if (storage != NULL)
 			return storage;
 	}
@@ -142,14 +148,17 @@
 	return NULL;
 }
 
-struct mail_storage *mail_storage_create_with_data(const char *data,
-						   const char *user)
+struct mail_storage *
+mail_storage_create_with_data(const char *data, const char *user,
+			      const char *namespace, char hierarchy_sep)
 {
 	struct mail_storage *storage;
 	const char *p, *name;
 
-	if (data == NULL || *data == '\0')
-		return mail_storage_create_default(user);
+	if (data == NULL || *data == '\0') {
+		return mail_storage_create_default(user, namespace,
+						   hierarchy_sep);
+	}
 
 	/* check if we're in the form of mailformat:data
 	   (eg. maildir:Maildir) */
@@ -158,11 +167,14 @@
 
 	if (*p == ':') {
 		name = t_strdup_until(data, p);
-		storage = mail_storage_create(name, p+1, user);
+		storage = mail_storage_create(name, p+1, user,
+					      namespace, hierarchy_sep);
 	} else {
 		storage = mail_storage_autodetect(data);
-		if (storage != NULL)
-			storage = storage->create(data, user);
+		if (storage != NULL) {
+			storage = storage->create(data, user,
+						  namespace, hierarchy_sep);
+		}
 	}
 
 	return storage;

Index: mail-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-storage.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- mail-storage.h	26 Jul 2003 23:53:05 -0000	1.53
+++ mail-storage.h	27 Jul 2003 03:12:13 -0000	1.54
@@ -128,11 +128,16 @@
 /* All methods returning int return either TRUE or FALSE. */
 struct mail_storage {
 	char *name;
+	char *namespace;
 
 	char hierarchy_sep;
 
-	/* Create new instance */
-	struct mail_storage *(*create)(const char *data, const char *user);
+	/* Create new instance. If namespace is non-NULL, all mailbox names
+	   are expected to begin with it. hierarchy_sep overrides the default
+	   separator if it's not '\0'. */
+	struct mail_storage *(*create)(const char *data, const char *user,
+				       const char *namespace,
+				       char hierarchy_sep);
 
 	/* Free this instance */
 	void (*free)(struct mail_storage *storage);
@@ -159,7 +164,7 @@
 
 	/* name is allowed to contain multiple new hierarchy levels.
 	   If only_hierarchy is TRUE, the mailbox itself isn't created, just
-	   the hiearchy structure (if needed). */
+	   the hierarchy structure (if needed). */
 	int (*create_mailbox)(struct mail_storage *storage, const char *name,
 			      int only_hierarchy);
 
@@ -484,13 +489,17 @@
 /* Create a new instance of registered mail storage class with given
    storage-specific data. If data is NULL, it tries to use defaults.
    May return NULL if anything fails. */
-struct mail_storage *mail_storage_create(const char *name, const char *data,
-					 const char *user);
+struct mail_storage *
+mail_storage_create(const char *name, const char *data, const char *user,
+		    const char *namespace, char hierarchy_sep);
 void mail_storage_destroy(struct mail_storage *storage);
 
-struct mail_storage *mail_storage_create_default(const char *user);
-struct mail_storage *mail_storage_create_with_data(const char *data,
-						   const char *user);
+struct mail_storage *
+mail_storage_create_default(const char *user,
+			    const char *namespace, char hierarchy_sep);
+struct mail_storage *
+mail_storage_create_with_data(const char *data, const char *user,
+			      const char *namespace, char hierarchy_sep);
 
 /* Set error message in storage. Critical errors are logged with i_error(),
    but user sees only "internal error" message. */



More information about the dovecot-cvs mailing list