[evolution-kolab] CamelIMAPXExtdServerAcl: adapt to API changes in CamelImapxAcl



commit 8f591b6001ff3c71ce11e85daefcf1ca1e00f9ee
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Mon Oct 1 18:47:05 2012 +0200

    CamelIMAPXExtdServerAcl: adapt to API changes in CamelImapxAcl

 src/libekolab/camel-imapx-extd-server-acl.c |   73 +++++++++++++++------------
 src/libekolab/camel-imapx-extd-server-acl.h |    3 +-
 2 files changed, 42 insertions(+), 34 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-extd-server-acl.c b/src/libekolab/camel-imapx-extd-server-acl.c
index b84a076..37280a8 100644
--- a/src/libekolab/camel-imapx-extd-server-acl.c
+++ b/src/libekolab/camel-imapx-extd-server-acl.c
@@ -109,10 +109,10 @@ imapx_extd_server_untagged_acl (CamelIMAPXServer *is,
 
 	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);
+		camel_imapx_acl_update_acl_from_server_response (acl,
+		                                                 stream,
+		                                                 cancellable,
+		                                                 &tmp_err);
 
 	if (! parse_and_add_ok) {
 		g_propagate_error (err, tmp_err);
@@ -170,10 +170,10 @@ imapx_extd_server_untagged_myrights (CamelIMAPXServer *is,
 
 	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);
+		camel_imapx_acl_update_myrights_from_server_response (acl,
+		                                                      stream,
+		                                                      cancellable,
+		                                                      &tmp_err);
 
 	if (! parse_and_add_ok) {
 		g_propagate_error (err, tmp_err);
@@ -273,43 +273,52 @@ camel_imapx_extd_server_get_acl (CamelIMAPXServer *is,
 
 gboolean
 camel_imapx_extd_server_set_acl (CamelIMAPXServer *is,
-                                 const gchar *foldername,
-                                 const gchar *imapacl,
+                                 CamelImapxAcl *acl,
                                  GCancellable *cancellable,
                                  GError **err)
 {
-	gchar *cmd = NULL;
+	static GMutex setter_lock;
+	GSList *commands = NULL;
+	GSList *cur_cmd = NULL;
 	GError *tmp_err = NULL;
-	gboolean ok = FALSE;
+	gboolean ok = TRUE;
 
 	g_assert (CAMEL_IS_IMAPX_SERVER (is));
-	g_return_val_if_fail (foldername != NULL, FALSE);
+	g_return_val_if_fail (acl != NULL, FALSE);
 	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
-	ok = camel_imapx_acl_validate_imapacl (imapacl,
-	                                       &tmp_err);
-	if (! ok) {
-		g_propagate_error (err, tmp_err);
-		return FALSE;
-	}
+	g_mutex_lock (&setter_lock);
 
-	/* TODO move SETACL string to -acl.[hc] */
-	cmd = g_strdup_printf ("%s \"%s\" \"%s\"",
-	                       IMAPX_IMAP_TOKEN_SETACL,
-	                       foldername,
-	                       imapacl);
+	commands = camel_imapx_acl_new_commandlist (acl,
+	                                            &tmp_err);
 
-	/* run SETACL command */
-	ok = camel_imapx_extd_utils_command_run (is,
-	                                         IMAPX_IMAP_TOKEN_SETACL,
-	                                         cmd,
-	                                         cancellable,
-	                                         &tmp_err);
-	g_free (cmd);
+	if (commands == NULL)
+		goto exit;
 
-	if (! ok)
+	cur_cmd = commands;
+	while (cur_cmd != NULL) {
+		/* TODO move SETACL string to -acl.[hc] */
+		ok = camel_imapx_extd_utils_command_run (is,
+		                                         IMAPX_IMAP_TOKEN_SETACL,
+		                                         (gchar *) cur_cmd->data,
+		                                         cancellable,
+		                                         &tmp_err);
+		if (! ok)
+			goto exit;
+
+		cur_cmd = g_slist_next (cur_cmd);
+	}
+
+ exit:
+	if (tmp_err != NULL) {
 		g_propagate_error (err, tmp_err);
+		ok = FALSE;
+	}
+	if (commands != NULL)
+		g_slist_free (commands);
+
+	g_mutex_unlock (&setter_lock);
 
 	return ok;
 }
diff --git a/src/libekolab/camel-imapx-extd-server-acl.h b/src/libekolab/camel-imapx-extd-server-acl.h
index 5020288..b6ec3e4 100644
--- a/src/libekolab/camel-imapx-extd-server-acl.h
+++ b/src/libekolab/camel-imapx-extd-server-acl.h
@@ -64,8 +64,7 @@ camel_imapx_extd_server_get_acl (CamelIMAPXServer *self,
 
 gboolean
 camel_imapx_extd_server_set_acl (CamelIMAPXServer *self,
-                                 const gchar *foldername,
-                                 const gchar *imapacl,
+                                 CamelImapxAcl *acl,
                                  GCancellable *cancellable,
                                  GError **err);
 



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