[dovecot-cvs] dovecot/src/imap cmd-thread.c,NONE,1.1 Makefile.am,1.9,1.10 cmd-search.c,1.12,1.13 cmd-sort.c,1.7,1.8 cmd-uid.c,1.3,1.4 commands.c,1.4,1.5 commands.h,1.4,1.5

cras at procontrol.fi cras at procontrol.fi
Wed Jan 8 22:49:54 EET 2003


Update of /home/cvs/dovecot/src/imap
In directory danu:/tmp/cvs-serv9871/src/imap

Modified Files:
	Makefile.am cmd-search.c cmd-sort.c cmd-uid.c commands.c 
	commands.h 
Added Files:
	cmd-thread.c 
Log Message:
THREAD=REFERENCES implementation. Doesn't crash, but I'm not sure how
correct replies it produces :)



--- NEW FILE: cmd-thread.c ---
/* Copyright (C) 2002 Timo Sirainen */

#include "common.h"
#include "buffer.h"
#include "commands.h"
#include "mail-search.h"
#include "mail-sort.h"

int cmd_thread(struct client *client)
{
	enum mail_thread_type threading;
	struct mail_search_arg *sargs;
	struct imap_arg *args;
	int args_count;
	pool_t pool;
	const char *error, *charset, *str;

	args_count = imap_parser_read_args(client->parser, 0, 0, &args);
	if (args_count == -2)
		return FALSE;

	if (args_count < 3) {
		client_send_command_error(client, args_count < 0 ? NULL :
					  "Missing or invalid arguments.");
		return TRUE;
	}

	if (!client_verify_open_mailbox(client))
		return TRUE;

	if (args->type != IMAP_ARG_ATOM && args->type != IMAP_ARG_STRING) {
		client_send_command_error(client,
					  "Invalid thread algorithm argument.");
		return TRUE;
	}

	str = IMAP_ARG_STR(args);
	if (strcasecmp(str, "ORDEREDSUBJECT") == 0)
		threading = MAIL_THREAD_ORDEREDSUBJECT;
	else if (strcasecmp(str, "REFERENCES") == 0)
		threading = MAIL_THREAD_REFERENCES;
	else {
		client_send_command_error(client, "Unknown thread algorithm.");
		return TRUE;
	}
	args++;

	/* charset */
	if (args->type != IMAP_ARG_ATOM && args->type != IMAP_ARG_STRING) {
		client_send_command_error(client,
					  "Invalid charset argument.");
		return TRUE;
	}
	charset = IMAP_ARG_STR(args);
	args++;

	pool = pool_alloconly_create("mail_search_args", 2048);

	sargs = mail_search_args_build(pool, args, &error);
	if (sargs == NULL) {
		/* error in search arguments */
		client_send_tagline(client, t_strconcat("NO ", error, NULL));
	} else {
		if (client->mailbox->search(client->mailbox, charset,
					    sargs, NULL, threading,
					    client->output, client->cmd_uid)) {
			/* NOTE: syncing is allowed when returning UIDs */
			if (client->cmd_uid)
				client_sync_full(client);
			else
				client_sync_without_expunges(client);
			client_send_tagline(client, "OK Search completed.");
		} else {
			client_send_storage_error(client);
		}
	}

	pool_unref(pool);
	return TRUE;
}

Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/imap/Makefile.am,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Makefile.am	4 Dec 2002 18:28:37 -0000	1.9
+++ Makefile.am	8 Jan 2003 20:49:52 -0000	1.10
@@ -47,6 +47,7 @@
 	cmd-status.c \
 	cmd-store.c \
 	cmd-subscribe.c \
+	cmd-thread.c \
 	cmd-uid.c \
 	cmd-unsubscribe.c
 

Index: cmd-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-search.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cmd-search.c	5 Jan 2003 13:09:51 -0000	1.12
+++ cmd-search.c	8 Jan 2003 20:49:52 -0000	1.13
@@ -42,7 +42,7 @@
 		charset = NULL;
 	}
 
-	pool = pool_alloconly_create("MailSearchArgs", 2048);
+	pool = pool_alloconly_create("mail_search_args", 2048);
 
 	sargs = mail_search_args_build(pool, args, &error);
 	if (sargs == NULL) {
@@ -50,7 +50,7 @@
 		client_send_tagline(client, t_strconcat("NO ", error, NULL));
 	} else {
 		if (client->mailbox->search(client->mailbox, charset,
-					    sargs, NULL,
+					    sargs, NULL, MAIL_THREAD_NONE,
 					    client->output, client->cmd_uid)) {
 			/* NOTE: syncing is allowed when returning UIDs */
 			if (client->cmd_uid)

Index: cmd-sort.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-sort.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cmd-sort.c	5 Jan 2003 13:09:51 -0000	1.7
+++ cmd-sort.c	8 Jan 2003 20:49:52 -0000	1.8
@@ -103,11 +103,12 @@
 	if (args->type != IMAP_ARG_ATOM && args->type != IMAP_ARG_STRING) {
 		client_send_command_error(client,
 					  "Invalid charset argument.");
+		return TRUE;
 	}
 	charset = IMAP_ARG_STR(args);
 	args++;
 
-	pool = pool_alloconly_create("MailSortArgs", 2048);
+	pool = pool_alloconly_create("mail_search_args", 2048);
 
 	sargs = mail_search_args_build(pool, args, &error);
 	if (sargs == NULL) {
@@ -115,7 +116,7 @@
 		client_send_tagline(client, t_strconcat("NO ", error, NULL));
 	} else {
 		if (client->mailbox->search(client->mailbox, charset,
-					    sargs, sorting,
+					    sargs, sorting, MAIL_THREAD_NONE,
 					    client->output, client->cmd_uid)) {
 			/* NOTE: syncing is allowed when returning UIDs */
 			if (client->cmd_uid)

Index: cmd-uid.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-uid.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cmd-uid.c	5 Jan 2003 13:09:51 -0000	1.3
+++ cmd-uid.c	8 Jan 2003 20:49:52 -0000	1.4
@@ -33,6 +33,11 @@
 		else if (strcasecmp(cmd, "SORT") == 0)
 			client->cmd_func = cmd_sort;
 		break;
+	case 't':
+	case 'T':
+		if (strcasecmp(cmd, "THREAD") == 0)
+			client->cmd_func = cmd_thread;
+		break;
 	}
 
 	if (client->cmd_func != NULL) {

Index: commands.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/commands.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- commands.c	14 Dec 2002 17:47:25 -0000	1.4
+++ commands.c	8 Jan 2003 20:49:52 -0000	1.5
@@ -73,6 +73,10 @@
 		if (strcmp(name, "SUBSCRIBE") == 0)
 			return cmd_subscribe;
 		break;
+	case 'T':
+		if (strcmp(name, "THREAD") == 0)
+			return cmd_thread;
+		break;
 	case 'U':
 		if (strcmp(name, "UID") == 0)
 			return cmd_uid;

Index: commands.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/commands.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- commands.h	5 Jan 2003 13:09:51 -0000	1.4
+++ commands.h	8 Jan 2003 20:49:52 -0000	1.5
@@ -37,6 +37,7 @@
 int cmd_expunge(struct client *client);
 int cmd_search(struct client *client);
 int cmd_sort(struct client *client);
+int cmd_thread(struct client *client);
 int cmd_fetch(struct client *client);
 int cmd_store(struct client *client);
 int cmd_copy(struct client *client);




More information about the dovecot-cvs mailing list