[evolution-kolab/ek-wip-acl] CamelIMAPXExtdServerAcl: implemented untagged response handlers



commit 307ef857dd0b5044b9508e5e46fbc1d3fd9940b2
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Sep 28 18:06:29 2012 +0200

    CamelIMAPXExtdServerAcl: implemented untagged response handlers
    
    * implemented untagged response handler for ACL response
    * implemented untagged response handler for MYRIGHTS response

 src/libekolab/camel-imapx-extd-server-acl.c |  104 ++++++++++++++++++++++++---
 1 files changed, 94 insertions(+), 10 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-extd-server-acl.c b/src/libekolab/camel-imapx-extd-server-acl.c
index e5033fb..b84a076 100644
--- a/src/libekolab/camel-imapx-extd-server-acl.c
+++ b/src/libekolab/camel-imapx-extd-server-acl.c
@@ -74,17 +74,59 @@ imapx_extd_server_untagged_acl (CamelIMAPXServer *is,
                                 GCancellable *cancellable,
                                 GError **err)
 {
+	static GMutex handler_lock;
+	CamelIMAPXStore *store = NULL;
+	CamelIMAPXExtdStore *estore = NULL;
+	CamelImapxAcl *acl = NULL;
+	guint32 capa = 0;
+	guint32 capa_flag_id = 0;
+	GError *tmp_err = NULL;
+	gboolean parse_and_add_ok = FALSE;
+	gboolean success = FALSE;
+
 	g_assert (CAMEL_IS_IMAPX_SERVER (is));
+	g_return_val_if_fail (CAMEL_IS_IMAPX_STREAM (stream), FALSE);
 	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
-	(void)stream; /* FIXME */
-	(void)cancellable; /* FIXME */
+	g_mutex_lock (&handler_lock);
+
+	store = camel_imapx_server_ref_store (is);
+	estore = CAMEL_IMAPX_EXTD_STORE (store);
+
+	/* capability check */
+	capa_flag_id =
+		camel_imapx_extd_store_get_capa_flag_id (estore,
+		                                         CAMEL_IMAPX_EXTD_STORE_CAPA_FLAG_ACL);
+	capa = is->cinfo->capa & capa_flag_id;
+	if (! capa) {
+		g_set_error (err,
+		             CAMEL_IMAPX_ERROR,
+		             1, /* FIXME define and add a sensible code here */
+		             _("Got ACL response but server did not advertise ACL capability"));
+		goto exit;
+	}
+
+	acl = camel_imapx_extd_store_get_acl_table (estore);
+	parse_and_add_ok =
+		camel_imapx_acl_add_acl_from_server_response (acl,
+		                                              stream,
+		                                              cancellable,
+		                                              &tmp_err);
+
+	if (! parse_and_add_ok) {
+		g_propagate_error (err, tmp_err);
+		goto exit;
+	}
+
+	success = TRUE;
+
+ exit:
+	g_object_unref (store);
 
-	/* FIXME implement me */
-	g_assert_not_reached ();
+	g_mutex_unlock (&handler_lock);
 
-	return TRUE;
+	return success;
 }
 
 static gboolean
@@ -93,17 +135,59 @@ imapx_extd_server_untagged_myrights (CamelIMAPXServer *is,
                                      GCancellable *cancellable,
                                      GError **err)
 {
+	static GMutex handler_lock;
+	CamelIMAPXStore *store = NULL;
+	CamelIMAPXExtdStore *estore = NULL;
+	CamelImapxAcl *acl = NULL;
+	guint32 capa = 0;
+	guint32 capa_flag_id = 0;
+	GError *tmp_err = NULL;
+	gboolean parse_and_add_ok = FALSE;
+	gboolean success = FALSE;
+
 	g_assert (CAMEL_IS_IMAPX_SERVER (is));
+	g_return_val_if_fail (CAMEL_IS_IMAPX_STREAM (stream), FALSE);
 	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
-	(void)stream; /* FIXME */
-	(void)cancellable; /* FIXME */
+	g_mutex_lock (&handler_lock);
+
+	store = camel_imapx_server_ref_store (is);
+	estore = CAMEL_IMAPX_EXTD_STORE (store);
+
+	/* capability check */
+	capa_flag_id =
+		camel_imapx_extd_store_get_capa_flag_id (estore,
+		                                         CAMEL_IMAPX_EXTD_STORE_CAPA_FLAG_ACL);
+	capa = is->cinfo->capa & capa_flag_id;
+	if (! capa) {
+		g_set_error (err,
+		             CAMEL_IMAPX_ERROR,
+		             1, /* FIXME define and add a sensible code here */
+		             _("Got MYRIGHTS response but server did not advertise ACL capability"));
+		goto exit;
+	}
+
+	acl = camel_imapx_extd_store_get_acl_table (estore);
+	parse_and_add_ok =
+		camel_imapx_acl_add_myrights_from_server_response (acl,
+		                                                   stream,
+		                                                   cancellable,
+		                                                   &tmp_err);
+
+	if (! parse_and_add_ok) {
+		g_propagate_error (err, tmp_err);
+		goto exit;
+	}
+
+	success = TRUE;
+
+ exit:
+	g_object_unref (store);
 
-	/* FIXME implement me */
-	g_assert_not_reached ();
+	g_mutex_unlock (&handler_lock);
 
-	return TRUE;
+	return success;
 }
 
 /*----------------------------------------------------------------------------*/



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