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



commit ff807993b1eba5c5a83617319dda4587312c8b27
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.

 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 7eceb1e..6389d41 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1433,6 +1433,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;
@@ -2533,9 +2534,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 */
@@ -2558,20 +2571,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 ea0c983..6369d09 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -1698,6 +1698,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]