[evolution-kolab] CamelKolabIMAPXStore: implemented folder permission getter
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] CamelKolabIMAPXStore: implemented folder permission getter
- Date: Fri, 5 Oct 2012 16:32:31 +0000 (UTC)
commit 4af9ef96987db8d5590fbb429974c9174d830502
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Oct 5 18:24:17 2012 +0200
CamelKolabIMAPXStore: implemented folder permission getter
* implemented query function for reading folder ACL
and MYRIGHTS from the (Kolab) IMAP server
* returns both, ACL and MYRIGHTS, as a GList of
CamelImapxAclEntry instances (for cleaner API)
src/libekolab/camel-kolab-imapx-store.c | 80 +++++++++++++++++++++++++++++-
1 files changed, 77 insertions(+), 3 deletions(-)
---
diff --git a/src/libekolab/camel-kolab-imapx-store.c b/src/libekolab/camel-kolab-imapx-store.c
index 00448a9..ed3a1c0 100644
--- a/src/libekolab/camel-kolab-imapx-store.c
+++ b/src/libekolab/camel-kolab-imapx-store.c
@@ -36,6 +36,7 @@
#include <libekolabutil/kolab-util-error.h>
#include "camel-imapx-extd-server.h"
+#include "camel-kolab-imapx-acl.h"
#include "camel-kolab-imapx-metadata.h"
#include "camel-kolab-imapx-store.h"
@@ -70,6 +71,7 @@ struct _CamelKolabIMAPXStorePrivate {
KolabFolderContextID folder_context;
gboolean folder_types_do_care[KOLAB_FOLDER_LAST_TYPE];
GList *folder_names_do_care;
+ CamelKolabImapxAcl *kacl; /* Kolab acl (mostly identical to IMAPX acl) */
CamelKolabImapxMetadata *kmd; /* Kolab metadata (differs from IMAPX metadata!) */
GList *folder_names_unsubscribe;
@@ -128,6 +130,9 @@ camel_kolab_imapx_store_init (CamelKolabIMAPXStore *self)
priv->folder_names_do_care = NULL;
+ /* acl lookup table (no db yet) */
+ priv->kacl = camel_kolab_imapx_acl_new (FALSE);
+
/* metadata db and lookup table */
priv->kmd = camel_kolab_imapx_metadata_new ();
@@ -169,6 +174,7 @@ camel_kolab_imapx_store_finalize (GObject *object)
__func__, tmp_err->message);
g_error_free (tmp_err);
}
+ camel_kolab_imapx_acl_free (priv->kacl);
camel_kolab_imapx_metadata_free (priv->kmd);
while (! g_mutex_trylock (&(priv->kolab_finfo_lock)));
@@ -1218,15 +1224,75 @@ kolab_imapx_store_get_folder_permissions (CamelKolabIMAPXStore *self,
GCancellable *cancellable,
GError **err)
{
+ CamelKolabIMAPXStorePrivate *priv = NULL;
+ CamelImapxAcl *acl = NULL;
+ CamelImapxAclSpec *spec = NULL;
+ CamelImapxAclType type = 0;
+ GList *perms = NULL;
+ GError *tmp_err = NULL;
+ gboolean ok = TRUE;
+
g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (self));
g_assert (foldername != NULL);
/* cancellable may be NULL */
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
- /* FIXME implement me */
- g_warning ("%s()[%u] FIXME implement me", __func__, __LINE__);
+ priv = CAMEL_KOLAB_IMAPX_STORE_PRIVATE (self);
+
+ g_mutex_lock (&(priv->kolab_finfo_lock));
+
+ /* issue IMAP command */
+
+ if (myrights)
+ type = CAMEL_IMAPX_ACL_TYPE_MYRIGHTS;
+ else
+ type = CAMEL_IMAPX_ACL_TYPE_GENERAL;
+
+ spec = camel_imapx_acl_spec_new (foldername, type);
+ acl = camel_imapx_extd_store_get_acl (CAMEL_IMAPX_EXTD_STORE (self),
+ spec,
+ TRUE, /* resect ACL data */
+ cancellable,
+ &tmp_err);
+ camel_imapx_acl_spec_free (spec);
+ if (tmp_err != NULL)
+ goto exit;
+
+ ok = camel_kolab_imapx_acl_update_from_acl (priv->kacl,
+ acl,
+ &tmp_err);
+ camel_imapx_acl_free (acl);
+ if (! ok)
+ goto exit;
+
+ if (myrights) {
+ CamelImapxAclEntry *entry = NULL;
+ gchar *rights = NULL;
+
+ rights = camel_kolab_imapx_acl_get_myrights (priv->kacl,
+ foldername);
+ /* rights may be NULL */
+ if (rights != NULL) {
+ entry = camel_imapx_acl_entry_new (NULL,
+ rights,
+ NULL);
+ g_free (rights);
+ perms = g_list_prepend (perms, entry);
+ }
+ } else {
+ /* permission list may be empty */
+ perms = camel_kolab_imapx_acl_get_as_list (priv->kacl,
+ foldername);
+ }
- return NULL;
+ exit:
+
+ if (tmp_err != NULL)
+ g_propagate_error (err, tmp_err);
+
+ g_mutex_unlock (&(priv->kolab_finfo_lock));
+
+ return perms;
}
static gboolean
@@ -1236,14 +1302,22 @@ kolab_imapx_store_set_folder_permissions (CamelKolabIMAPXStore *self,
GCancellable *cancellable,
GError **err)
{
+ CamelKolabIMAPXStorePrivate *priv = NULL;
+
g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (self));
/* permissions may be NULL (use to delete all permissions) */
/* cancellable may be NULL */
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+ priv = CAMEL_KOLAB_IMAPX_STORE_PRIVATE (self);
+
+ g_mutex_lock (&(priv->kolab_finfo_lock));
+
/* FIXME implement me */
g_warning ("%s()[%u] FIXME implement me", __func__, __LINE__);
+ g_mutex_unlock (&(priv->kolab_finfo_lock));
+
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]