[dovecot-cvs] dovecot/src/imap client.c, 1.35, 1.36 client.h, 1.17, 1.18 cmd-append.c, 1.34, 1.35 cmd-select.c, 1.25, 1.26 cmd-store.c, 1.22, 1.23 commands-util.c, 1.30, 1.31 commands-util.h, 1.13, 1.14 common.h, 1.12, 1.13 mail-storage-callbacks.c, 1.8, 1.9 main.c, 1.44, 1.45

cras at procontrol.fi cras at procontrol.fi
Sun May 2 23:32:18 EEST 2004


Update of /home/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv3311/imap

Modified Files:
	client.c client.h cmd-append.c cmd-select.c cmd-store.c 
	commands-util.c commands-util.h common.h 
	mail-storage-callbacks.c main.c 
Log Message:
s/custom flags/keywords/



Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- client.c	27 Apr 2004 20:25:52 -0000	1.35
+++ client.c	2 May 2004 20:32:15 -0000	1.36
@@ -64,8 +64,7 @@
 					    imap_max_line_length);
         client->last_input = ioloop_time;
 
-	client->mailbox_flags.pool =
-		pool_alloconly_create("mailbox_custom_flags", 512);
+	client->keywords.pool = pool_alloconly_create("mailbox_keywords", 512);
 	client->namespaces = namespaces;
 
 	while (namespaces != NULL) {
@@ -99,7 +98,7 @@
 	i_stream_unref(client->input);
 	o_stream_unref(client->output);
 
-	pool_unref(client->mailbox_flags.pool);
+	pool_unref(client->keywords.pool);
 	i_free(client);
 
 	/* quit the program */

Index: client.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- client.h	27 Jul 2003 04:48:32 -0000	1.17
+++ client.h	2 May 2004 20:32:15 -0000	1.18
@@ -8,11 +8,11 @@
 
 typedef int command_func_t(struct client *client);
 
-struct mailbox_custom_flags {
+struct mailbox_keywords {
 	pool_t pool; /* will be p_clear()ed when changed */
 
-	char **custom_flags;
-        unsigned int custom_flags_count;
+	char **keywords;
+        unsigned int keywords_count;
 };
 
 struct client {
@@ -23,7 +23,7 @@
 
         struct namespace *namespaces;
 	struct mailbox *mailbox;
-        struct mailbox_custom_flags mailbox_flags;
+        struct mailbox_keywords keywords;
 	unsigned int select_counter; /* increased when mailbox is changed */
 
 	time_t last_input;

Index: cmd-append.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-append.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- cmd-append.c	28 Apr 2004 00:21:00 -0000	1.34
+++ cmd-append.c	2 May 2004 20:32:15 -0000	1.35
@@ -52,7 +52,7 @@
 	struct imap_parser *save_parser;
 	struct imap_arg *args;
 	struct imap_arg_list *flags_list;
-        struct mailbox_custom_flags old_flags;
+        struct mailbox_keywords old_flags;
 	struct mail_full_flags flags;
 	struct istream *input;
 	time_t internal_date;
@@ -78,15 +78,15 @@
 		return TRUE;
 	}
 
-	if (mailbox_get_status(box, STATUS_CUSTOM_FLAGS, &status) < 0) {
+	if (mailbox_get_status(box, STATUS_KEYWORDS, &status) < 0) {
 		client_send_storage_error(client, storage);
 		mailbox_close(box);
 		return TRUE;
 	}
 	memset(&old_flags, 0, sizeof(old_flags));
         old_flags.pool = pool_datastack_create();
-	client_save_custom_flags(&old_flags, status.custom_flags,
-				 status.custom_flags_count);
+	client_save_keywords(&old_flags, status.keywords,
+			     status.keywords_count);
 
 	t = mailbox_transaction_begin(box, FALSE);
 

Index: cmd-select.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-select.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- cmd-select.c	28 Apr 2004 00:21:00 -0000	1.25
+++ cmd-select.c	2 May 2004 20:32:15 -0000	1.26
@@ -36,23 +36,23 @@
 
 	if (mailbox_get_status(box, STATUS_MESSAGES | STATUS_RECENT |
 			       STATUS_FIRST_UNSEEN_SEQ | STATUS_UIDVALIDITY |
-			       STATUS_UIDNEXT | STATUS_CUSTOM_FLAGS,
+			       STATUS_UIDNEXT | STATUS_KEYWORDS,
 			       &status) < 0) {
 		client_send_storage_error(client, storage);
 		mailbox_close(box);
 		return TRUE;
 	}
 
-	client_save_custom_flags(&client->mailbox_flags, status.custom_flags,
-				 status.custom_flags_count);
+	client_save_keywords(&client->keywords,
+			     status.keywords, status.keywords_count);
 
 	/* set client's mailbox only after getting status to make sure
 	   we're not sending any expunge/exists replies too early to client */
 	client->mailbox = box;
 	client->select_counter++;
 
-	client_send_mailbox_flags(client, box, status.custom_flags,
-				  status.custom_flags_count);
+	client_send_mailbox_flags(client, box, status.keywords,
+				  status.keywords_count);
 
 	client_send_line(client,
 		t_strdup_printf("* %u EXISTS", status.messages));

Index: cmd-store.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-store.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmd-store.c	27 Apr 2004 20:25:52 -0000	1.22
+++ cmd-store.c	2 May 2004 20:32:15 -0000	1.23
@@ -89,11 +89,11 @@
 	if (args[2].type == IMAP_ARG_LIST) {
 		if (!client_parse_mail_flags(client,
 					     IMAP_ARG_LIST(&args[2])->args,
-					     &client->mailbox_flags, &flags))
+					     &client->keywords, &flags))
 			return TRUE;
 	} else {
 		if (!client_parse_mail_flags(client, args+2,
-					     &client->mailbox_flags, &flags))
+					     &client->keywords, &flags))
 			return TRUE;
 	}
 

Index: commands-util.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/commands-util.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- commands-util.c	27 Apr 2004 20:25:52 -0000	1.30
+++ commands-util.c	2 May 2004 20:32:15 -0000	1.31
@@ -1,6 +1,7 @@
 /* Copyright (C) 2002-2003 Timo Sirainen */
 
 #include "common.h"
+#include "buffer.h"
 #include "str.h"
 #include "commands-util.h"
 #include "imap-util.h"
@@ -182,24 +183,24 @@
 			 t_strconcat(syntax ? "* BAD " : "* NO ", error, NULL));
 }
 
-static int is_valid_custom_flag(struct client *client,
-                                const struct mailbox_custom_flags *old_flags,
-				const char *flag)
+static int is_valid_keyword(struct client *client,
+			    const struct mailbox_keywords *old_keywords,
+			    const char *keyword)
 {
 	size_t i;
 
 	/* if it already exists, skip validity checks */
-	for (i = 0; i < old_flags->custom_flags_count; i++) {
-		if (old_flags->custom_flags[i] != NULL &&
-		    strcasecmp(old_flags->custom_flags[i], flag) == 0)
+	for (i = 0; i < old_keywords->keywords_count; i++) {
+		if (old_keywords->keywords[i] != NULL &&
+		    strcasecmp(old_keywords->keywords[i], keyword) == 0)
 			return TRUE;
 	}
 
-	if (strlen(flag) > max_custom_flag_length) {
+	if (strlen(keyword) > max_keyword_length) {
 		client_send_tagline(client,
-			t_strdup_printf("BAD Invalid flag name '%s': "
+			t_strdup_printf("BAD Invalid keyword name '%s': "
 					"Maximum length is %u characters",
-					flag, max_custom_flag_length));
+					keyword, max_keyword_length));
 		return FALSE;
 	}
 
@@ -207,19 +208,18 @@
 }
 
 int client_parse_mail_flags(struct client *client, struct imap_arg *args,
-                            const struct mailbox_custom_flags *old_flags,
+                            const struct mailbox_keywords *old_keywords,
 			    struct mail_full_flags *flags)
 {
-	/* @UNSAFE */
+	const char *const *keywords;
 	char *atom;
-	size_t max_flags, flag_pos, i;
-
-	max_flags = MAIL_CUSTOM_FLAGS_COUNT;
+	buffer_t *buffer;
+	size_t size, i;
 
 	memset(flags, 0, sizeof(*flags));
-	flags->custom_flags = t_new(const char *, max_flags);
+	buffer = buffer_create_dynamic(pool_datastack_create(),
+				       256, (size_t)-1);
 
-	flag_pos = 0;
 	while (args->type != IMAP_ARG_EOL) {
 		if (args->type != IMAP_ARG_ATOM) {
 			client_send_command_error(client,
@@ -248,57 +248,50 @@
 				return FALSE;
 			}
 		} else {
-			/* custom flag - first make sure it's not a duplicate */
-			for (i = 0; i < flag_pos; i++) {
-				if (strcasecmp(flags->custom_flags[i],
-					       atom) == 0)
+			/* keyword - first make sure it's not a duplicate */
+			keywords = buffer_get_data(buffer, &size);
+			size /= sizeof(const char *);
+			for (i = 0; i < size; i++) {
+				if (strcasecmp(keywords[i], atom) == 0)
 					break;
 			}
 
-			if (i == max_flags) {
-				client_send_tagline(client,
-					"Maximum number of different custom "
-					"flags exceeded");
-				return FALSE;
-			}
-
-			if (i == flag_pos) {
-				if (!is_valid_custom_flag(client, old_flags,
-							  atom))
+			if (i == size) {
+				if (!is_valid_keyword(client, old_keywords,
+						      atom))
 					return FALSE;
-				flags->flags |= 1 << (flag_pos +
-						      MAIL_CUSTOM_FLAG_1_BIT);
-				flags->custom_flags[flag_pos++] = atom;
+				buffer_append(buffer, &atom, sizeof(atom));
 			}
 		}
 
 		args++;
 	}
 
-	flags->custom_flags_count = flag_pos;
+	flags->keywords = buffer_get_modifyable_data(buffer, &size);
+	flags->keywords_count = size / sizeof(const char *);
 	return TRUE;
 }
 
-static const char *get_custom_flags_string(const char *custom_flags[],
-					   unsigned int custom_flags_count)
+static const char *
+get_keywords_string(const char *keywords[], unsigned int keywords_count)
 {
 	string_t *str;
 	unsigned int i;
 
-	/* first see if there even is custom flags */
-	for (i = 0; i < custom_flags_count; i++) {
-		if (custom_flags[i] != NULL)
+	/* first see if there even is keywords */
+	for (i = 0; i < keywords_count; i++) {
+		if (keywords[i] != NULL)
 			break;
 	}
 
-	if (i == custom_flags_count)
+	if (i == keywords_count)
 		return "";
 
 	str = t_str_new(256);
-	for (; i < custom_flags_count; i++) {
-		if (custom_flags[i] != NULL) {
+	for (; i < keywords_count; i++) {
+		if (keywords[i] != NULL) {
 			str_append_c(str, ' ');
-			str_append(str, custom_flags[i]);
+			str_append(str, keywords[i]);
 		}
 	}
 	return str_c(str);
@@ -307,12 +300,12 @@
 #define SYSTEM_FLAGS "\\Answered \\Flagged \\Deleted \\Seen \\Draft"
 
 void client_send_mailbox_flags(struct client *client, struct mailbox *box,
-			       const char *custom_flags[],
-			       unsigned int custom_flags_count)
+			       const char *keywords[],
+			       unsigned int keywords_count)
 {
 	const char *str;
 
-	str = get_custom_flags_string(custom_flags, custom_flags_count);
+	str = get_keywords_string(keywords, keywords_count);
 	client_send_line(client,
 		t_strconcat("* FLAGS ("SYSTEM_FLAGS, str, ")", NULL));
 
@@ -322,29 +315,27 @@
 	} else {
 		client_send_line(client,
 			t_strconcat("* OK [PERMANENTFLAGS ("SYSTEM_FLAGS, str,
-				    mailbox_allow_new_custom_flags(box) ?
+				    mailbox_allow_new_keywords(box) ?
 				    " \\*" : "", ")] Flags permitted.", NULL));
 	}
 }
 
-void client_save_custom_flags(struct mailbox_custom_flags *dest,
-			      const char *custom_flags[],
-			      unsigned int custom_flags_count)
+void client_save_keywords(struct mailbox_keywords *dest,
+			  const char *keywords[], unsigned int keywords_count)
 {
 	unsigned int i;
 
 	p_clear(dest->pool);
 
-	if (custom_flags_count == 0) {
-		dest->custom_flags = NULL;
-		dest->custom_flags_count = 0;
+	if (keywords_count == 0) {
+		dest->keywords = NULL;
+		dest->keywords_count = 0;
 		return;
 	}
 
-	dest->custom_flags =
-		p_new(dest->pool, char *, custom_flags_count);
-	dest->custom_flags_count = custom_flags_count;
+	dest->keywords = p_new(dest->pool, char *, keywords_count);
+	dest->keywords_count = keywords_count;
 
-	for (i = 0; i < custom_flags_count; i++)
-		dest->custom_flags[i] = p_strdup(dest->pool, custom_flags[i]);
+	for (i = 0; i < keywords_count; i++)
+		dest->keywords[i] = p_strdup(dest->pool, keywords[i]);
 }

Index: commands-util.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/commands-util.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- commands-util.h	27 Jul 2003 04:48:32 -0000	1.13
+++ commands-util.h	2 May 2004 20:32:15 -0000	1.14
@@ -42,17 +42,16 @@
 /* Parse flags. Returns TRUE if successful, if not sends an error message to
    client. */
 int client_parse_mail_flags(struct client *client, struct imap_arg *args,
-                            const struct mailbox_custom_flags *old_flags,
+                            const struct mailbox_keywords *old_keywords,
 			    struct mail_full_flags *flags);
 
 /* Send FLAGS + PERMANENTFLAGS to client. */
 void client_send_mailbox_flags(struct client *client, struct mailbox *box,
-			       const char *custom_flags[],
-			       unsigned int custom_flags_count);
+			       const char *keywords[],
+			       unsigned int keywords_count);
 
-/* Copy custom flags into dest. dest must have been initialized. */
-void client_save_custom_flags(struct mailbox_custom_flags *dest,
-			      const char *custom_flags[],
-			      unsigned int custom_flags_count);
+/* Copy keywords into dest. dest must have been initialized. */
+void client_save_keywords(struct mailbox_keywords *dest,
+			  const char *keywords[], unsigned int keywords_count);
 
 #endif

Index: common.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/common.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- common.h	28 Apr 2004 00:21:00 -0000	1.12
+++ common.h	2 May 2004 20:32:15 -0000	1.13
@@ -12,10 +12,10 @@
    by default. */
 #define DEFAULT_IMAP_MAX_LINE_LENGTH 65536
 
-#define DEFAULT_MAX_CUSTOM_FLAG_LENGTH 50
+#define DEFAULT_MAX_KEYWORD_LENGTH 50
 
 extern struct ioloop *ioloop;
-extern unsigned int max_custom_flag_length, mailbox_check_interval;
+extern unsigned int max_keyword_length, mailbox_check_interval;
 extern unsigned int imap_max_line_length;
 
 extern string_t *capability_string;

Index: mail-storage-callbacks.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/mail-storage-callbacks.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mail-storage-callbacks.c	27 Apr 2004 20:25:52 -0000	1.8
+++ mail-storage-callbacks.c	2 May 2004 20:32:15 -0000	1.9
@@ -77,20 +77,16 @@
 	client_send_line(client, str);
 }
 
-static void new_custom_flags(struct mailbox *mailbox,
-			     const char *custom_flags[],
-			     unsigned int custom_flags_count, void *context)
+static void new_keywords(struct mailbox *mailbox, const char *keywords[],
+			 unsigned int keywords_count, void *context)
 {
 	struct client *client = context;
 
 	if (client->mailbox != mailbox)
 		return;
 
-	client_save_custom_flags(&client->mailbox_flags, custom_flags,
-				 custom_flags_count);
-
-	client_send_mailbox_flags(client, mailbox, custom_flags,
-				  custom_flags_count);
+	client_save_keywords(&client->keywords, keywords, keywords_count);
+	client_send_mailbox_flags(client, mailbox, keywords, keywords_count);
 }
 
 struct mail_storage_callbacks mail_storage_callbacks = {
@@ -100,5 +96,5 @@
 	expunge,
 	update_flags,
 	new_messages,
-	new_custom_flags
+	new_keywords
 };

Index: main.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/main.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- main.c	28 Apr 2004 00:21:00 -0000	1.44
+++ main.c	2 May 2004 20:32:15 -0000	1.45
@@ -22,7 +22,7 @@
         (getenv("LOGGED_IN") == NULL && getenv("IMAPLOGINTAG") == NULL)
 
 struct ioloop *ioloop;
-unsigned int max_custom_flag_length, mailbox_check_interval;
+unsigned int max_keyword_length, mailbox_check_interval;
 unsigned int imap_max_line_length;
 
 static struct module *modules;
@@ -114,9 +114,9 @@
 		DEFAULT_IMAP_MAX_LINE_LENGTH;
 
 	str = getenv("MAIL_MAX_FLAG_LENGTH");
-	max_custom_flag_length = str != NULL ?
+	max_keyword_length = str != NULL ?
 		(unsigned int)strtoul(str, NULL, 10) :
-		DEFAULT_MAX_CUSTOM_FLAG_LENGTH;
+		DEFAULT_MAX_KEYWORD_LENGTH;
 
 	str = getenv("MAILBOX_CHECK_INTERVAL");
 	mailbox_check_interval = str == NULL ? 0 :



More information about the dovecot-cvs mailing list