[dovecot-cvs] dovecot/src/pop3 client.c, 1.73, 1.74 client.h, 1.14, 1.15 main.c, 1.62, 1.63

tss at dovecot.org tss at dovecot.org
Tue Apr 3 11:34:37 EEST 2007


Update of /var/lib/cvs/dovecot/src/pop3
In directory talvi:/tmp/cvs-serv21629/pop3

Modified Files:
	client.c client.h main.c 
Log Message:
Moved namespace handling to lib-storage. Beginnings of namespace support for
non-IMAP parts of Dovecot.



Index: client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/client.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- client.c	22 Feb 2007 13:30:56 -0000	1.73
+++ client.c	3 Apr 2007 08:34:32 -0000	1.74
@@ -11,6 +11,7 @@
 #include "mail-storage.h"
 #include "commands.h"
 #include "mail-search.h"
+#include "mail-namespace.h"
 
 #include <stdlib.h>
 #include <unistd.h>
@@ -124,8 +125,10 @@
 }
 
 struct client *client_create(int fd_in, int fd_out,
-			     struct mail_storage *storage)
+			     struct mail_namespace *namespaces)
 {
+	struct mail_storage *storage;
+	const char *inbox;
 	struct client *client;
         enum mailbox_open_flags flags;
 	const char *errmsg;
@@ -146,8 +149,18 @@
 
 	client->io = io_add(fd_in, IO_READ, client_input, client);
         client->last_input = ioloop_time;
-	client->storage = storage;
 
+	client->namespaces = namespaces;
+
+	inbox = "INBOX";
+	client->inbox_ns = mail_namespace_find(namespaces, &inbox);
+	if (client->inbox_ns == NULL) {
+		client_send_line(client, "-ERR No INBOX namespace for user.");
+		client_destroy(client, "No INBOX namespace for user.");
+		return NULL;
+	}
+
+	storage = client->inbox_ns->storage;
 	mail_storage_set_callbacks(storage, &mail_storage_callbacks, client);
 
 	flags = 0;
@@ -237,7 +250,7 @@
 	}
 	if (client->mailbox != NULL)
 		mailbox_close(&client->mailbox);
-	mail_storage_destroy(&client->storage);
+	mail_namespaces_deinit(&client->namespaces);
 
 	i_free(client->message_sizes);
 	i_free(client->deleted_bitmask);
@@ -333,7 +346,7 @@
 		return;
 	}
 
-	error = mail_storage_get_last_error(client->storage, &syntax,
+	error = mail_storage_get_last_error(client->inbox_ns->storage, &syntax,
 					    &temporary_error);
 	client_send_line(client, "-ERR %s", error != NULL ? error :
 			 "BUG: Unknown error");

Index: client.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/client.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- client.h	10 Aug 2006 22:32:10 -0000	1.14
+++ client.h	3 Apr 2007 08:34:32 -0000	1.15
@@ -15,7 +15,7 @@
 	command_func_t *cmd;
 	void *cmd_context;
 
-	struct mail_storage *storage;
+	struct mail_namespace *namespaces, *inbox_ns;
 	struct mailbox *mailbox;
 	struct mailbox_transaction_context *trans;
 
@@ -49,7 +49,7 @@
 /* Create new client with specified input/output handles. socket specifies
    if the handle is a socket. */
 struct client *client_create(int fd_in, int fd_out,
-			     struct mail_storage *storage);
+			     struct mail_namespace *namespaces);
 void client_destroy(struct client *client, const char *reason);
 
 /* Disconnect client connection */

Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/main.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- main.c	30 Mar 2007 13:40:22 -0000	1.62
+++ main.c	3 Apr 2007 08:34:32 -0000	1.63
@@ -13,6 +13,7 @@
 #include "var-expand.h"
 #include "dict-client.h"
 #include "mail-storage.h"
+#include "mail-namespace.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -38,6 +39,7 @@
 void (*hook_client_created)(struct client **client) = NULL;
 
 static struct module *modules = NULL;
+static pool_t namespace_pool;
 static char log_prefix[128]; /* syslog() needs this to be permanent */
 static struct io *log_io = NULL;
 
@@ -180,10 +182,7 @@
 
 static int main_init(void)
 {
-        enum mail_storage_flags flags;
-        enum file_lock_method lock_method;
-	struct mail_storage *storage;
-	const char *mail;
+	struct mail_namespace *ns;
 
 	lib_signals_init();
         lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL);
@@ -213,14 +212,6 @@
 
 	module_dir_init(modules);
 
-	mail = getenv("MAIL");
-	if (mail == NULL) {
-		/* support also maildir-specific environment */
-		mail = getenv("MAILDIR");
-		if (mail != NULL)
-			mail = t_strconcat("maildir:", mail, NULL);
-	}
-
 	parse_workarounds();
 	enable_last_command = getenv("POP3_ENABLE_LAST") != NULL;
 	no_flag_updates = getenv("POP3_NO_FLAG_UPDATES") != NULL;
@@ -238,25 +229,10 @@
 		i_fatal("pop3_uidl_format setting doesn't contain any "
 			"%% variables.");
 
-	mail_storage_parse_env(&flags, &lock_method);
-	storage = mail_storage_create(NULL, mail, getenv("USER"),
-				      flags, lock_method);
-	if (storage == NULL) {
-		/* failed */
-		if (mail != NULL && *mail != '\0')
-			i_fatal("Failed to create storage with data: %s", mail);
-		else {
-			const char *home;
-
-			home = getenv("HOME");
-			if (home == NULL) home = "not set";
-
-			i_fatal("MAIL environment missing and "
-				"autodetection failed (home %s)", home);
-		}
-	}
-
-	return client_create(0, 1, storage) != NULL;
+	namespace_pool = pool_alloconly_create("namespaces", 1024);
+	if (mail_namespaces_init(namespace_pool, getenv("USER"), &ns) < 0)
+		exit(FATAL_DEFAULT);
+	return client_create(0, 1, ns) != NULL;
 }
 
 static void main_deinit(void)



More information about the dovecot-cvs mailing list