[evolution-data-server/gnome-2-30] Accept unsolicited CAPABILITY report as part of LOGIN/AUTHENTICATE response



commit 271bbaf03659d4b5dafa2893329617561f98f052
Author: David Woodhouse <David Woodhouse intel com>
Date:   Thu Jun 17 14:47:56 2010 +0100

    Accept unsolicited CAPABILITY report as part of LOGIN/AUTHENTICATE response
    
    Also fix up freeing of cinfo status response.
    (cherry picked from commit ff807993b1eba5c5a83617319dda4587312c8b27)

 camel/providers/imapx/camel-imapx-server.c |   39 +++++++++++++++++----------
 camel/providers/imapx/camel-imapx-utils.c  |    4 +++
 2 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 3c1a1f6..88a22c9 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1436,6 +1436,7 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 				if (imap->cinfo)
 					imapx_free_capability(imap->cinfo);
 				imap->cinfo = sinfo->u.cinfo;
+				sinfo->u.cinfo = NULL;
 				c(printf("got capability flags %08x\n", imap->cinfo->capa));
 			}
 			break;
@@ -2510,9 +2511,21 @@ imapx_reconnect (CamelIMAPXServer *is, CamelException *ex)
 
 		imapx_command_run (is, ic);
 
-		if (!(camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK))
+		if (!(camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK)) {
+			/* Forget old capabilities after login */
+			if (is->cinfo) {
+				imapx_free_capability(is->cinfo);
+				is->cinfo = NULL;
+			}
+
+			if (ic->status->condition == IMAPX_CAPABILITY) {
+				is->cinfo = ic->status->u.cinfo;
+				ic->status->u.cinfo = NULL;
+				c(printf("got capability flags %08x\n", is->cinfo->capa));
+			}
+
 			authenticated = TRUE;
-		else {
+		} else {
 			/* If exception is set, it might be mostly due to cancellation and we would get an
 			   io error, else re-prompt. If authentication fails for other reasons ic->status would be
 			    set with the error message */
@@ -2535,20 +2548,16 @@ imapx_reconnect (CamelIMAPXServer *is, CamelException *ex)
 	if (camel_exception_is_set (ex))
 		goto exception;
 
-	/* After login we re-capa */
-	if (is->cinfo) {
-		imapx_free_capability(is->cinfo);
-		is->cinfo = NULL;
-	}
-	
-
-	ic = camel_imapx_command_new("CAPABILITY", NULL, "CAPABILITY");
-	imapx_command_run (is, ic);
-	camel_exception_xfer (ex, ic->ex);
-	camel_imapx_command_free(ic);
+	/* After login we re-capa unless the server already told us */
+	if (!is->cinfo) {
+		ic = camel_imapx_command_new("CAPABILITY", NULL, "CAPABILITY");
+		imapx_command_run (is, ic);
+		camel_exception_xfer (ex, ic->ex);
+		camel_imapx_command_free(ic);
 
-	if (camel_exception_is_set (ex))
-		goto exception;
+		if (camel_exception_is_set (ex))
+			goto exception;
+	}
 
 	is->state = IMAPX_AUTHENTICATED;
 
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index 72ff198..a2fd5c0 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -1699,6 +1699,10 @@ imapx_free_status(struct _status_info *sinfo)
 		g_ptr_array_free (sinfo->u.copyuid.uids, FALSE);
 		g_ptr_array_free (sinfo->u.copyuid.copied_uids, FALSE);
 		break;
+	case IMAPX_CAPABILITY:
+		if (sinfo->u.cinfo)
+			imapx_free_capability(sinfo->u.cinfo);
+		break;
 	default:
 		break;
 	}



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