[evolution-kolab/ek-wip-porting] CamelIMAPXExtdServer: annotation/metadata fixups



commit 3953271472086afec388914c180d0a288cebffd2
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Sat Mar 10 20:13:11 2012 +0100

    CamelIMAPXExtdServer: annotation/metadata fixups
    
    * initialize the metadata data structures
    * fixups in the metadata getter/setter functions
      for Camel changes (need a CamelIMAPXJob now
      for submitting IMAPX jobs)

 .../providers/imapx/camel-imapx-extd-server.c      |   60 +++++++++++++------
 1 files changed, 41 insertions(+), 19 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-extd-server.c b/src/camel/providers/imapx/camel-imapx-extd-server.c
index d2a551e..8e6ecc1 100644
--- a/src/camel/providers/imapx/camel-imapx-extd-server.c
+++ b/src/camel/providers/imapx/camel-imapx-extd-server.c
@@ -79,7 +79,8 @@ camel_imapx_extd_server_init (CamelIMAPXExtdServer *self)
 	g_assert (CAMEL_IS_IMAPX_EXTD_SERVER (self));
 	priv = CAMEL_IMAPX_EXTD_SERVER_PRIVATE (self);
 
-	priv->md = NULL;
+	priv->md = camel_imapx_metadata_new (CAMEL_IMAPX_METADATA_PROTO_INVAL,
+	                                     FALSE);
 }
 
 static void
@@ -186,8 +187,7 @@ extd_server_untagged (CamelIMAPXExtdServer *self,
 	service = CAMEL_SERVICE (is->store);
 	settings = camel_service_get_settings (service);
 
-	fetch_order = camel_imapx_settings_get_fetch_order (
-	                                                    CAMEL_IMAPX_SETTINGS (settings));
+	fetch_order = camel_imapx_settings_get_fetch_order (CAMEL_IMAPX_SETTINGS (settings));
 
 	e(is->tagprefix, "got untagged response\n");
 	id = 0;
@@ -203,8 +203,7 @@ extd_server_untagged (CamelIMAPXExtdServer *self,
 	}
 
 	if (tok == '\n') {
-		g_set_error (
-		             error, CAMEL_IMAPX_ERROR, 1,
+		g_set_error (error, CAMEL_IMAPX_ERROR, 1,
 		             "truncated server response");
 		return FALSE;
 	}
@@ -897,8 +896,7 @@ extd_server_connect_to_server (CamelIMAPXExtdServer *self,
 	}
 
 	if (!is->cinfo) {
-		ic = camel_imapx_command_new (
-		                              is, "CAPABILITY", NULL, "CAPABILITY");
+		ic = camel_imapx_command_new (is, "CAPABILITY", NULL, "CAPABILITY");
 		if (!extd_server_command_run (self, ic, cancellable, error)) {
 			camel_imapx_command_unref (ic);
 			success = FALSE;
@@ -1008,6 +1006,7 @@ extd_server_reconnect (CamelIMAPXExtdServer *self,
 {
 	/* modified dupe of imapx_reconnect() */
 
+	CamelIMAPXExtdServerPrivate *priv = NULL;
 	CamelIMAPXServer *is = NULL;
 	CamelIMAPXCommand *ic = NULL;
 	CamelService *service = NULL;
@@ -1021,6 +1020,7 @@ extd_server_reconnect (CamelIMAPXExtdServer *self,
 	/* cancellable may be NULL */
 	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
+	priv = CAMEL_IMAPX_EXTD_SERVER_PRIVATE (self);
 	is = CAMEL_IMAPX_SERVER (self);
 	service = CAMEL_SERVICE (is->store);
 	session = camel_service_get_session (service);
@@ -1109,6 +1109,22 @@ extd_server_reconnect (CamelIMAPXExtdServer *self,
 		imapx_store->dir_sep = ns->sep;
 	}
 
+	/* set annotation protocol, depending on server capability */
+
+	if (is->cinfo->capa & IMAPX_ANNOTATEMORE) {
+		/* IMAP ANNOTATEMORE (draft 05) */
+		g_mutex_lock (priv->md->md_lock);
+		priv->md->proto = CAMEL_IMAPX_METADATA_PROTO_ANNOTATEMORE;
+		g_mutex_unlock (priv->md->md_lock);
+	}
+#if 0
+	if (is->cinfo->capa & IMAPX_METADATA) {
+		/* IMAP METADATA not yet supported */
+		g_mutex_lock (priv->md->md_lock);
+		priv->md->proto = CAMEL_IMAPX_METADATA_PROTO_METADATA;
+		g_mutex_unlock (priv->md->md_lock);
+	}
+#endif
 	is->state = IMAPX_INITIALISED;
 
 	g_free (mechanism);
@@ -1731,8 +1747,8 @@ imapx_extd_server_metadata_get_proto (CamelIMAPXExtdServer *self)
 		 *      (decide the protocol here, depending on
 		 *      the IMAP server's untagged response)
 		 */
-		g_error ("%s: FIXME implement online annotation protocol query",
-		         __func__);
+		g_warning ("%s: FIXME implement online annotation protocol query",
+		           __func__);
 		return CAMEL_IMAPX_METADATA_PROTO_INVAL; /* FIXME */
 	}
 
@@ -1754,6 +1770,7 @@ imapx_extd_server_get_metadata (CamelIMAPXExtdServer *self,
 	CamelImapxMetadata *md = NULL;
 	gchar *cmd = NULL;
 	GError *tmp_err = NULL;
+	gboolean ok = FALSE;
 
 	g_assert (CAMEL_IS_IMAPX_EXTD_SERVER (self));
 	g_assert (spec != NULL);
@@ -1775,19 +1792,21 @@ imapx_extd_server_get_metadata (CamelIMAPXExtdServer *self,
 	                              "GETANNOTATION",
 	                              NULL,
 	                              cmd);
+	ic->job = camel_imapx_job_new (cancellable);
+	/* TODO set more job details like priority? */
 
 	/* run GETANNOTATION command synchronously
 	 * (TODO can we change this to async operation?)
-	 *
-	 * FIXME: do we need to use extd_server_command_run()
-	 *        instead?
 	 */
-	camel_imapx_server_command_run_sync (is, ic, cancellable, &tmp_err);
+	ok = camel_imapx_server_command_run_sync (is, ic, cancellable, &tmp_err);
 
 	g_free (cmd);
+	camel_imapx_job_unref (ic->job);
+	ic->job = NULL;
+	camel_imapx_command_done (ic);
 	camel_imapx_command_unref (ic);
 
-	if (tmp_err != NULL) {
+	if (! ok) {
 		g_propagate_error (err, tmp_err);
 		return NULL;
 	}
@@ -1813,6 +1832,7 @@ imapx_extd_server_set_metadata (CamelIMAPXExtdServer *self,
 	GSList *commands = NULL;
 	GSList *cur_cmd = NULL;
 	GError *tmp_err = NULL;
+	gboolean ok = FALSE;
 
 	g_assert (CAMEL_IS_IMAPX_EXTD_SERVER (self));
 	g_assert (md != NULL);
@@ -1835,18 +1855,20 @@ imapx_extd_server_set_metadata (CamelIMAPXExtdServer *self,
 				              "SETANNOTATION",
 				              NULL,
 				              (gchar *) cur_cmd->data);
+		ic->job = camel_imapx_job_new (cancellable);
+		/* TODO set more job details like priority? */
 
 		/* run SETANNOTATION command synchronously
 		 * (TODO can we change this to async operation?)
-		 *
-		 * FIXME: do we need to use extd_server_command_run()
-		 *        instead?
 		 */
-		camel_imapx_server_command_run_sync (is, ic, cancellable, &tmp_err);
+		ok = camel_imapx_server_command_run_sync (is, ic, cancellable, &tmp_err);
 
+		camel_imapx_job_unref (ic->job);
+		ic->job = NULL;
+		camel_imapx_command_done (ic);
 		camel_imapx_command_unref (ic);
 
-		if (tmp_err != NULL) {
+		if (! ok) {
 			g_slist_free (commands);
 			g_propagate_error (err, tmp_err);
 			return FALSE;



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