[evolution-patches] XGWMOVE for imap4



I've had this sitting in my tree for almost 2 weeks now...

-- 
Jeffrey Stedfast
Evolution Hacker - Novell, Inc.
fejj ximian com  - www.novell.com
? imap4-XGWMOVE.patch
? imap4.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/imap4/ChangeLog,v
retrieving revision 1.11
diff -u -r1.11 ChangeLog
--- ChangeLog	15 Feb 2005 21:11:52 -0000	1.11
+++ ChangeLog	15 Feb 2005 21:12:38 -0000
@@ -1,3 +1,14 @@
+2005-02-03  Jeffrey Stedfast  <fejj novell com>
+
+	* camel-imap4-engine.c (camel_imap4_engine_handle_untagged_1):
+	Handle XGWMOVE untagged events as EXPUNGE events.
+
+	* camel-imap4-folder.c (imap4_transfer_messages_to): Optionally
+	use XGWMOVE if the extension is available.
+
+	* camel-imap4-engine.c (camel_imap4_engine_capability): Query for
+	the XGWEXTENSIONS as well if the server supports it.
+
 2005-02-14  Jeffrey Stedfast  <fejj novell com>
 
 	* camel-imap4-store-summary.c (store_info_to_folder_info):
Index: camel-imap4-engine.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/imap4/camel-imap4-engine.c,v
retrieving revision 1.21
diff -u -r1.21 camel-imap4-engine.c
--- camel-imap4-engine.c	1 Feb 2005 16:30:04 -0000	1.21
+++ camel-imap4-engine.c	15 Feb 2005 21:12:38 -0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*  Camel
- *  Copyright (C) 1999-2004 Jeffrey Stedfast
+/*
+ *  Authors: Jeffrey Stedfast <fejj novell com>
+ *
+ *  Copyright 2005 Novell, Inc. (www.novell.com)
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -15,6 +17,7 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
  */
 
 
@@ -45,6 +48,9 @@
 static void camel_imap4_engine_init (CamelIMAP4Engine *engine, CamelIMAP4EngineClass *klass);
 static void camel_imap4_engine_finalize (CamelObject *object);
 
+static int parse_xgwextensions (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index,
+				camel_imap4_token_t *token, CamelException *ex);
+
 
 static CamelObjectClass *parent_class = NULL;
 
@@ -260,6 +266,22 @@
 	
 	camel_imap4_command_unref (ic);
 	
+	if (retval == -1 || !(engine->capa & CAMEL_IMAP4_CAPABILITY_XGWEXTENSIONS))
+		return retval;
+	
+	ic = camel_imap4_engine_prequeue (engine, NULL, "XGWEXTENSIONS\r\n");
+	camel_imap4_command_register_untagged (ic, "XGWEXTENSIONS", parse_xgwextensions);
+	
+	while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
+		;
+	
+	if (id == -1 || ic->status != CAMEL_IMAP4_COMMAND_COMPLETE) {
+		camel_exception_xfer (ex, &ic->ex);
+		retval = -1;
+	}
+	
+	camel_imap4_command_unref (ic);
+	
 	return retval;
 }
 
@@ -439,14 +461,56 @@
 	{ "UIDPLUS",       CAMEL_IMAP4_CAPABILITY_UIDPLUS       }, /* rfc2359 */
 	{ "LITERAL+",      CAMEL_IMAP4_CAPABILITY_LITERALPLUS   }, /* rfc2088 */
 	{ "LOGINDISABLED", CAMEL_IMAP4_CAPABILITY_LOGINDISABLED },
-	{ "STARTTLS",      CAMEL_IMAP4_CAPABILITY_STARTTLS      },
+	{ "STARTTLS",      CAMEL_IMAP4_CAPABILITY_STARTTLS      }, /* rfc3501 */
 	{ "QUOTA",         CAMEL_IMAP4_CAPABILITY_QUOTA         }, /* rfc2087 */
 	{ "ACL",           CAMEL_IMAP4_CAPABILITY_ACL           }, /* rfc2086 */
 	{ "IDLE",          CAMEL_IMAP4_CAPABILITY_IDLE          }, /* rfc2177 */
 	{ "MULTIAPPEND",   CAMEL_IMAP4_CAPABILITY_MULTIAPPEND   }, /* rfc3502 */
+	{ "UNSELECT",      CAMEL_IMAP4_CAPABILITY_UNSELECT      },
+	{ "XGWEXTENSIONS", CAMEL_IMAP4_CAPABILITY_XGWEXTENSIONS }, /* GroupWise extensions */
 	{ NULL,            0                                    }
 };
 
+static struct {
+	const char *name;
+	guint32 flag;
+} imap4_xgwextensions[] = {
+	{ "XGWMOVE",       CAMEL_IMAP4_CAPABILITY_XGWMOVE       }, /* GroupWise MOVE command */
+	{ NULL,            0                                    }
+};
+
+static int
+parse_xgwextensions (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
+{
+	int i;
+	
+	if (camel_imap4_engine_next_token (engine, token, ex) == -1)
+		return -1;
+	
+	while (token->token == CAMEL_IMAP4_TOKEN_ATOM) {
+		for (i = 0; imap4_xgwextensions[i].name; i++) {
+			if (!g_ascii_strcasecmp (imap4_xgwextensions[i].name, token->v.atom))
+				engine->capa |= imap4_xgwextensions[i].flag;
+		}
+		
+		if (camel_imap4_engine_next_token (engine, token, ex) == -1)
+			return -1;
+	}
+	
+	if (token->token != '\n') {
+		d(fprintf (stderr, "expected ')' to close untagged FETCH response\n"));
+		goto unexpected;
+	}
+	
+	return 0;
+	
+ unexpected:
+	
+	camel_imap4_utils_set_unexpected_token_error (ex, engine, token);
+	
+	return -1;
+}
+
 static gboolean
 auth_free (gpointer key, gpointer value, gpointer user_data)
 {
@@ -460,6 +524,7 @@
 	camel_imap4_token_t token;
 	int i;
 	
+	/* we assume UTF8 searches work until proven otherwise */
 	engine->capa = CAMEL_IMAP4_CAPABILITY_utf8_search;
 	engine->level = 0;
 	
@@ -1132,7 +1197,7 @@
 		/* NOTE: these can be over-ridden by a registered untagged response handler */
 		if (!strcmp ("EXISTS", token->v.atom)) {
 			camel_imap4_summary_set_exists (folder->summary, v);
-		} else if (!strcmp ("EXPUNGE", token->v.atom)) {
+		} else if (!strcmp ("EXPUNGE", token->v.atom) || !strcmp ("XGWMOVE", token->v.atom)) {
 			camel_imap4_summary_expunge (folder->summary, (int) v);
 		} else if (!strcmp ("RECENT", token->v.atom)) {
 			camel_imap4_summary_set_recent (folder->summary, v);
Index: camel-imap4-engine.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/imap4/camel-imap4-engine.h,v
retrieving revision 1.8
diff -u -r1.8 camel-imap4-engine.h
--- camel-imap4-engine.h	2 Dec 2004 08:03:30 -0000	1.8
+++ camel-imap4-engine.h	15 Feb 2005 21:12:38 -0000
@@ -1,6 +1,8 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*  Camel
- *  Copyright (C) 1999-2004 Jeffrey Stedfast
+/*
+ *  Authors: Jeffrey Stedfast <fejj novell com>
+ *
+ *  Copyright 2005 Novell, Inc. (www.novell.com)
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -15,6 +17,7 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
  */
 
 
@@ -78,8 +81,11 @@
 	CAMEL_IMAP4_CAPABILITY_QUOTA            = (1 << 9),
 	CAMEL_IMAP4_CAPABILITY_ACL              = (1 << 10),
 	CAMEL_IMAP4_CAPABILITY_MULTIAPPEND      = (1 << 11),
-	CAMEL_IMAP4_CAPABILITY_useful_lsub      = (1 << 12),
-	CAMEL_IMAP4_CAPABILITY_utf8_search      = (1 << 13),
+	CAMEL_IMAP4_CAPABILITY_UNSELECT         = (1 << 12),
+	CAMEL_IMAP4_CAPABILITY_XGWEXTENSIONS    = (1 << 13),
+	CAMEL_IMAP4_CAPABILITY_XGWMOVE          = (1 << 14),
+	CAMEL_IMAP4_CAPABILITY_useful_lsub      = (1 << 15),
+	CAMEL_IMAP4_CAPABILITY_utf8_search      = (1 << 16),
 };
 
 typedef enum {
Index: camel-imap4-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/imap4/camel-imap4-folder.c,v
retrieving revision 1.39
diff -u -r1.39 camel-imap4-folder.c
--- camel-imap4-folder.c	25 Jan 2005 16:57:19 -0000	1.39
+++ camel-imap4-folder.c	15 Feb 2005 21:12:38 -0000
@@ -1119,7 +1119,11 @@
 	for (i = 0; i < infos->len; i += n) {
 		n = camel_imap4_get_uid_set (engine, src->summary, infos, i, 10 + dest_namelen, &set);
 		
-		ic = camel_imap4_engine_queue (engine, src, "UID COPY %s %F\r\n", set, dest);
+		if (move && (engine->capa & CAMEL_IMAP4_CAPABILITY_XGWMOVE))
+			ic = camel_imap4_engine_queue (engine, src, "UID XGWMOVE %s %F\r\n", set, dest);
+		else
+			ic = camel_imap4_engine_queue (engine, src, "UID COPY %s %F\r\n", set, dest);
+		
 		while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1)
 			;
 		
@@ -1162,7 +1166,7 @@
 		
 		camel_imap4_command_unref (ic);
 		
-		if (move) {
+		if (move && !(engine->capa & CAMEL_IMAP4_CAPABILITY_XGWMOVE)) {
 			for (j = i; j < n; j++) {
 				info = infos->pdata[j];
 				camel_folder_set_message_flags (src, camel_message_info_uid (info),

Attachment: smime.p7s
Description: S/MIME cryptographic signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]