[evolution-kolab] CamelKolabImapxAcl: new layer for ACL handling



commit 54a9af15c299dde20b03a3f8aaf24edcd2a46308
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Fri Oct 5 18:13:01 2012 +0200

    CamelKolabImapxAcl: new layer for ACL handling
    
    * this is the "Kolab" layer on top of CamelImapxAcl
    * since we're not yet persistent with ACL (just online
      for now), this layer is not strictly needed. We still
      implement it for the following reasons:
      - keep symmetry with the metadata implementation
      - provide the proper place to add persistence
        (i.e., storing of ACL in an SQLiteDB, as metadata does),
        once we need that

 src/libekolab/Makefile.am             |    2 +
 src/libekolab/camel-kolab-imapx-acl.c |  168 +++++++++++++++++++++++++++++++++
 src/libekolab/camel-kolab-imapx-acl.h |  117 +++++++++++++++++++++++
 3 files changed, 287 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolab/Makefile.am b/src/libekolab/Makefile.am
index 23446d7..52bdf49 100644
--- a/src/libekolab/Makefile.am
+++ b/src/libekolab/Makefile.am
@@ -32,6 +32,7 @@ ENUM_GENERATED =				\
 
 libekolab_la_SOURCES =				\
 	e-source-kolab-folder.c			\
+	camel-kolab-imapx-acl.c			\
 	camel-kolab-imapx-metadata.c		\
 	camel-kolab-imapx-metadata-db.c		\
 	camel-kolab-imapx-settings.c		\
@@ -52,6 +53,7 @@ libekolab_la_SOURCES =				\
 
 noinst_HEADERS =				\
 	e-source-kolab-folder.h			\
+	camel-kolab-imapx-acl.h			\
 	camel-kolab-imapx-metadata.h		\
 	camel-kolab-imapx-metadata-db.h		\
 	camel-kolab-imapx-settings.h		\
diff --git a/src/libekolab/camel-kolab-imapx-acl.c b/src/libekolab/camel-kolab-imapx-acl.c
new file mode 100644
index 0000000..04c1870
--- /dev/null
+++ b/src/libekolab/camel-kolab-imapx-acl.c
@@ -0,0 +1,168 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ *            camel-kolab-imapx-acl.c
+ *
+ *  Tue Oct 02 17:17:03 2012
+ *  Copyright  2012  Christian Hilberg
+ *  <hilberg kernelconcepts de>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with main.c; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+/*----------------------------------------------------------------------------*/
+
+#include <glib.h>
+
+#include "camel-kolab-imapx-acl.h"
+
+/*----------------------------------------------------------------------------*/
+
+CamelKolabImapxAcl*
+camel_kolab_imapx_acl_new (gboolean locked)
+{
+	CamelKolabImapxAcl *kacl = g_new0 (CamelKolabImapxAcl, 1);
+	kacl->acl = camel_imapx_acl_new (locked);
+	return kacl;
+}
+
+void
+camel_kolab_imapx_acl_free (CamelKolabImapxAcl *kacl)
+{
+	if (kacl == NULL)
+		return;
+
+	camel_imapx_acl_free (kacl->acl);
+
+	g_free (kacl);
+}
+
+GList*
+camel_kolab_imapx_acl_get_as_list (CamelKolabImapxAcl *kacl,
+                                   const gchar *foldername)
+{
+	GList *entries = NULL;
+
+	g_return_val_if_fail (kacl != NULL, NULL);
+	g_return_val_if_fail (foldername != NULL, NULL);
+
+	entries = camel_imapx_acl_get_as_list (kacl->acl,
+	                                       foldername);
+
+	return entries;
+}
+
+GList*
+camel_kolab_imapx_acl_clone_list (GList *entries,
+                                  GError **err)
+{
+	GList *cloned = NULL;
+
+	g_return_val_if_fail (entries != NULL, NULL);
+	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
+
+	cloned = camel_imapx_acl_clone_list (entries,
+	                                     err);
+	return cloned;
+}
+
+void
+camel_kolab_imapx_acl_free_list (GList *entries)
+{
+	if (entries == NULL)
+		return;
+	camel_imapx_acl_free_list (entries);
+}
+
+gboolean
+camel_kolab_imapx_acl_update_from_acl (CamelKolabImapxAcl *kacl,
+                                       CamelImapxAcl *src_acl,
+                                       GError **err)
+{
+	gboolean ok = FALSE;
+
+	g_return_val_if_fail (kacl != NULL, FALSE);
+	/* src_kacl may be NULL */
+	/* entries may be NULL */
+	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+	if (src_acl == NULL)
+		return TRUE;
+
+	ok = camel_imapx_acl_update_from_acl (kacl->acl,
+	                                      src_acl,
+	                                      err);
+	return ok;
+}
+
+gboolean
+camel_kolab_imapx_acl_update_from_list (CamelKolabImapxAcl *kacl,
+                                        const gchar *foldername,
+                                        const GList *entries,
+                                        GError **err)
+{
+	gboolean ok = FALSE;
+
+	g_return_val_if_fail (kacl != NULL, FALSE);
+	g_return_val_if_fail (foldername != NULL, FALSE);
+	/* entries may be NULL */
+	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+	if (entries == NULL)
+		return TRUE;
+
+	ok = camel_imapx_acl_update_from_list (kacl->acl,
+	                                       foldername,
+	                                       entries,
+	                                       err);
+	return ok;
+}
+
+gchar*
+camel_kolab_imapx_acl_get_myrights (CamelKolabImapxAcl *kacl,
+                                    const gchar *foldername)
+{
+	gchar *rights = NULL;
+
+	g_return_val_if_fail (kacl != NULL, NULL);
+	g_return_val_if_fail (foldername != NULL, NULL);
+
+	rights = camel_imapx_acl_get_myrights (kacl->acl,
+	                                       foldername);
+	return rights;
+}
+
+gboolean
+camel_kolab_imapx_acl_update_myrights (CamelKolabImapxAcl *kacl,
+                                       const gchar *foldername,
+                                       const gchar *rights,
+                                       GError **err)
+{
+	gboolean ok = FALSE;
+
+	g_return_val_if_fail (kacl != NULL, FALSE);
+	g_return_val_if_fail (foldername != NULL, FALSE);
+	/* rights may be NULL */
+	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+	ok = camel_imapx_acl_update_myrights (kacl->acl,
+	                                      foldername,
+	                                      rights,
+	                                      err);
+	return ok;
+}
+
+/*----------------------------------------------------------------------------*/
diff --git a/src/libekolab/camel-kolab-imapx-acl.h b/src/libekolab/camel-kolab-imapx-acl.h
new file mode 100644
index 0000000..45748bd
--- /dev/null
+++ b/src/libekolab/camel-kolab-imapx-acl.h
@@ -0,0 +1,117 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ *            camel-kolab-imapx-acl.h
+ *
+ *  Tue Oct 02 17:17:03 2012
+ *  Copyright  2012  Christian Hilberg
+ *  <hilberg kernelconcepts de>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with main.c; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+/*----------------------------------------------------------------------------*/
+/* IMAP ACL (RFC 4314) (Kolab specifics) */
+
+#ifndef _CAMEL_KOLAB_IMAPX_ACL_H_
+#define _CAMEL_KOLAB_IMAPX_ACL_H_
+
+/*----------------------------------------------------------------------------*/
+/* This is just a thin layer on top of camel-imapx-acl.[hc]. Since we're not
+ * yet persistent with ACL (just online for now), this layer is not strictly
+ * needed. We still implement it for the following reasons:
+ *
+ * - keep symmetry with the metadata implementation
+ * - provide the proper place to add persistence
+ *   (i.e., storing of ACL in an SQLiteDB, as
+ *   metadata does), once we need that
+ *
+ * We do not implement persistent storing of ACL in camel-imapx-acl.[hc]
+ * for the very same reason we do not persistently store metadata in
+ * camel-imapx-metadata.[hc] : these files keep the implementation which
+ * is not Kolab-specific, and these implementations may be merged into
+ * upstream IMAPX one day. Since we do not know whether or not persistence
+ * will be needed in upstream (that is, by any other code using IMAPX),
+ * there is no reason to clutter the protocol implementation with SQLite
+ * stuff. Instead, we do it here, if needed.
+ *
+ * Once Evolution-Data-Server becomes more offline-aware (again), we will need
+ * ACL to be stored persistently so we can prevent a user from storing PIM
+ * data into folders which we know she has no folder permissions for (otherwise
+ * we run into the situation of having new/changed PIM objects in our offline
+ * cache which we cannot write to the server due to missing permissions,
+ * and we do not have a good facility to clear our cache (that is, deleting
+ * a PIM folder only locally without deleting it from the server as well)).
+ */
+/*----------------------------------------------------------------------------*/
+
+#include <glib.h>
+
+#include "camel-imapx-acl.h"
+
+/*----------------------------------------------------------------------------*/
+
+typedef struct _CamelKolabImapxAcl CamelKolabImapxAcl;
+struct _CamelKolabImapxAcl {
+	/* SQliteDB here, once we need it */
+	CamelImapxAcl *acl;
+};
+
+/*----------------------------------------------------------------------------*/
+
+CamelKolabImapxAcl*
+camel_kolab_imapx_acl_new (gboolean locked);
+
+void
+camel_kolab_imapx_acl_free (CamelKolabImapxAcl *kacl);
+
+GList*
+camel_kolab_imapx_acl_get_as_list (CamelKolabImapxAcl *kacl,
+                                   const gchar *foldername);
+
+GList*
+camel_kolab_imapx_acl_clone_list (GList *entries,
+                                  GError **err);
+
+void
+camel_kolab_imapx_acl_free_list (GList *entries);
+
+gboolean
+camel_kolab_imapx_acl_update_from_acl (CamelKolabImapxAcl *kacl,
+                                       CamelImapxAcl *src_acl,
+                                       GError **err);
+
+gboolean
+camel_kolab_imapx_acl_update_from_list (CamelKolabImapxAcl *kacl,
+                                        const gchar *foldername,
+                                        const GList *entries,
+                                        GError **err);
+
+gchar*
+camel_kolab_imapx_acl_get_myrights (CamelKolabImapxAcl *kacl,
+                                    const gchar *foldername);
+
+gboolean
+camel_kolab_imapx_acl_update_myrights (CamelKolabImapxAcl *kacl,
+                                       const gchar *foldername,
+                                       const gchar *rights,
+                                       GError **err);
+
+/*----------------------------------------------------------------------------*/
+
+#endif /* _CAMEL_KOLAB_IMAPX_ACL_H_ */
+
+/*----------------------------------------------------------------------------*/



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