[evolution-kolab/ek-wip-acl] CamelIMAPXExtdServerAcl: first-shot implementation of API functions



commit 37bf2d4b150247d62ee5e9212a7d9f55257c36b9
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Sep 28 15:59:37 2012 +0200

    CamelIMAPXExtdServerAcl: first-shot implementation of API functions
    
    * implemented MYRIGHTS getter
    * implemented ACL getter/setter
    * these functions only issue the IMAP commands for
      MYRIGHTS, GETACL and SETACL
    * the server untagged responses are collected via
      the ACL untagged handler functions, which are not
      exposed via API directly, but get registered with
      the CamelIMAPXServer instance

 src/libekolab/camel-imapx-extd-server-acl.c |   94 ++++++++++++++++++++-------
 src/libekolab/camel-imapx-extd-server-acl.h |    7 +-
 2 files changed, 75 insertions(+), 26 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-extd-server-acl.c b/src/libekolab/camel-imapx-extd-server-acl.c
index b4587ca..f22f691 100644
--- a/src/libekolab/camel-imapx-extd-server-acl.c
+++ b/src/libekolab/camel-imapx-extd-server-acl.c
@@ -34,6 +34,7 @@
 #include "camel-imapx-extd-store.h"
 #include "camel-imapx-extd-store-friend.h"
 #include "camel-imapx-extd-server.h"
+#include "camel-imapx-extd-utils.h"
 
 #include "camel-imapx-extd-server-acl.h"
 
@@ -79,7 +80,7 @@ imapx_extd_server_untagged_acl (CamelIMAPXServer *is,
 
 	(void)stream; /* FIXME */
 	(void)cancellable; /* FIXME */
-	
+
 	/* FIXME implement me */
 	g_assert_not_reached ();
 
@@ -98,7 +99,7 @@ imapx_extd_server_untagged_myrights (CamelIMAPXServer *is,
 
 	(void)stream; /* FIXME */
 	(void)cancellable; /* FIXME */
-	
+
 	/* FIXME implement me */
 	g_assert_not_reached ();
 
@@ -120,59 +121,106 @@ camel_imapx_extd_server_acl_get_handler_descriptors (void)
 
 gboolean
 camel_imapx_extd_server_get_myrights (CamelIMAPXServer *is,
-                                      /* something */
+                                      const gchar *foldername,
                                       GCancellable *cancellable,
                                       GError **err)
 {
+	gchar *cmd = NULL;
+	GError *tmp_err = NULL;
+	gboolean ok = FALSE;
+
 	g_assert (CAMEL_IS_IMAPX_SERVER (is));
-	/* assert something */
+	g_return_val_if_fail (foldername != NULL, FALSE);
 	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
-	(void)cancellable; /* FIXME */
-		
-	/* FIXME implement me */
-	g_assert_not_reached ();
+	/* TODO move MYRIGHTS string to -acl.[hc] */
+	cmd = g_strdup_printf ("%s \"%s\"",
+	                       IMAPX_IMAP_TOKEN_MYRIGHTS,
+	                       foldername);
 
-	return TRUE;
+	/* run MYRIGHTS command */
+	ok = camel_imapx_extd_utils_command_run (is,
+	                                         IMAPX_IMAP_TOKEN_MYRIGHTS,
+	                                         cmd,
+	                                         cancellable,
+	                                         &tmp_err);
+	g_free (cmd);
+
+	if (! ok)
+		g_propagate_error (err, tmp_err);
+
+	return ok;
 }
 
 gboolean
 camel_imapx_extd_server_get_acl (CamelIMAPXServer *is,
-                                 /* something */
+                                 const gchar *foldername,
                                  GCancellable *cancellable,
                                  GError **err)
 {
+	gchar *cmd = NULL;
+	GError *tmp_err = NULL;
+	gboolean ok = FALSE;
+
 	g_assert (CAMEL_IS_IMAPX_SERVER (is));
-	/* assert something */
+	g_return_val_if_fail (foldername != NULL, FALSE);
 	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
-	(void)cancellable; /* FIXME */
-	
-	/* FIXME implement me */
-	g_assert_not_reached ();
+	/* TODO move GETACL string to -acl.[hc] */
+	cmd = g_strdup_printf ("%s \"%s\"",
+	                       IMAPX_IMAP_TOKEN_GETACL,
+	                       foldername);
 
-	return TRUE;
+	/* run GETACL command */
+	ok = camel_imapx_extd_utils_command_run (is,
+	                                         IMAPX_IMAP_TOKEN_GETACL,
+	                                         cmd,
+	                                         cancellable,
+	                                         &tmp_err);
+	g_free (cmd);
+
+	if (! ok)
+		g_propagate_error (err, tmp_err);
+
+	return ok;
 }
 
 gboolean
 camel_imapx_extd_server_set_acl (CamelIMAPXServer *is,
-                                 /* something */
+                                 const gchar *foldername,
+                                 const gchar *acl,
                                  GCancellable *cancellable,
                                  GError **err)
 {
+	gchar *cmd = NULL;
+	GError *tmp_err = NULL;
+	gboolean ok = FALSE;
+
 	g_assert (CAMEL_IS_IMAPX_SERVER (is));
-	/* assert something */
+	g_return_val_if_fail (foldername != NULL, FALSE);
 	/* cancellable may be NULL */
 	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
 
-	(void)cancellable; /* FIXME */
-	
-	/* FIXME implement me */
-	g_assert_not_reached ();
+	/* TODO move SETACL string to -acl.[hc] */
+	cmd = g_strdup_printf ("%s \"%s\" \"%s\"",
+	                       IMAPX_IMAP_TOKEN_SETACL,
+	                       foldername,
+	                       acl);
 
-	return TRUE;
+	/* run SETACL command */
+	ok = camel_imapx_extd_utils_command_run (is,
+	                                         IMAPX_IMAP_TOKEN_SETACL,
+	                                         cmd,
+	                                         cancellable,
+	                                         &tmp_err);
+	g_free (cmd);
+
+	if (! ok)
+		g_propagate_error (err, tmp_err);
+
+	return ok;
 }
 
 /*----------------------------------------------------------------------------*/
diff --git a/src/libekolab/camel-imapx-extd-server-acl.h b/src/libekolab/camel-imapx-extd-server-acl.h
index cee0d32..2749727 100644
--- a/src/libekolab/camel-imapx-extd-server-acl.h
+++ b/src/libekolab/camel-imapx-extd-server-acl.h
@@ -52,19 +52,20 @@ camel_imapx_extd_server_acl_get_handler_descriptors (void);
 
 gboolean
 camel_imapx_extd_server_get_myrights (CamelIMAPXServer *self,
-                                      /* something */
+                                      const gchar *foldername,
                                       GCancellable *cancellable,
                                       GError **err);
 
 gboolean
 camel_imapx_extd_server_get_acl (CamelIMAPXServer *self,
-                                 /* something */
+                                 const gchar *foldername,
                                  GCancellable *cancellable,
                                  GError **err);
 
 gboolean
 camel_imapx_extd_server_set_acl (CamelIMAPXServer *self,
-                                 /* something */
+                                 const gchar *foldername,
+                                 const gchar *acl,
                                  GCancellable *cancellable,
                                  GError **err);
 



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