[evolution-kolab] CamelKolabIMAPXStore: implemented setter for ACL



commit 2875e4e2410dc0bf807505cde88efc09c5f4f94d
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Mon Oct 15 20:09:40 2012 +0200

    CamelKolabIMAPXStore: implemented setter for ACL
    
    * implemented the folder permissions setter
    * changed API for subordinate CamelIMAPXExtdStore:
      We supply ACL as GList instead of a hash table,
      since we need the list representation anyways
      for generating the IMAP command list

 src/libekolab/camel-imapx-extd-store.c  |   14 ++++--
 src/libekolab/camel-imapx-extd-store.h  |    6 ++-
 src/libekolab/camel-kolab-imapx-store.c |   70 +++++++++++++++++++++++++++++-
 3 files changed, 80 insertions(+), 10 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-extd-store.c b/src/libekolab/camel-imapx-extd-store.c
index ce6d98d..594d955 100644
--- a/src/libekolab/camel-imapx-extd-store.c
+++ b/src/libekolab/camel-imapx-extd-store.c
@@ -615,19 +615,21 @@ imapx_extd_store_get_acl (CamelIMAPXExtdStore *self,
 
 static gboolean
 imapx_extd_store_set_acl (CamelIMAPXExtdStore *self,
-                          CamelImapxAcl *acl,
+                          const gchar *foldername,
+                          const GList *entries,
                           GCancellable *cancellable,
                           GError **err)
 {
 	g_assert (CAMEL_IS_IMAPX_EXTD_STORE (self));
-	g_assert (acl != NULL);
+	g_assert (foldername != NULL);
+	/* entries may be 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__);
 
-	return FALSE;
+	return TRUE;
 }
 
 /*----------------------------------------------------------------------------*/
@@ -902,7 +904,8 @@ camel_imapx_extd_store_get_acl (CamelIMAPXExtdStore *self,
 
 gboolean
 camel_imapx_extd_store_set_acl (CamelIMAPXExtdStore *self,
-                                CamelImapxAcl *acl,
+                                const gchar *foldername,
+                                const GList *entries,
                                 GCancellable *cancellable,
                                 GError **err)
 {
@@ -912,7 +915,8 @@ camel_imapx_extd_store_set_acl (CamelIMAPXExtdStore *self,
 
 	klass = CAMEL_IMAPX_EXTD_STORE_GET_CLASS (self);
 	return klass->set_acl (self,
-	                       acl,
+	                       foldername,
+	                       entries,
 	                       cancellable,
 	                       err);
 }
diff --git a/src/libekolab/camel-imapx-extd-store.h b/src/libekolab/camel-imapx-extd-store.h
index 39b315b..7fb8c2f 100644
--- a/src/libekolab/camel-imapx-extd-store.h
+++ b/src/libekolab/camel-imapx-extd-store.h
@@ -96,7 +96,8 @@ struct _CamelIMAPXExtdStoreClass {
 	                           GError **err);
 
 	gboolean (*set_acl) (CamelIMAPXExtdStore *self,
-	                     CamelImapxAcl *acl,
+	                     const gchar *foldername,
+	                     const GList *entries,
 	                     GCancellable *cancellable,
 	                     GError **err);
 };
@@ -135,7 +136,8 @@ camel_imapx_extd_store_get_acl (CamelIMAPXExtdStore *self,
 
 gboolean
 camel_imapx_extd_store_set_acl (CamelIMAPXExtdStore *self,
-                                CamelImapxAcl *acl,
+                                const gchar *foldername,
+                                const GList *entries,
                                 GCancellable *cancellable,
                                 GError **err);
 
diff --git a/src/libekolab/camel-kolab-imapx-store.c b/src/libekolab/camel-kolab-imapx-store.c
index 145b4b7..46523ae 100644
--- a/src/libekolab/camel-kolab-imapx-store.c
+++ b/src/libekolab/camel-kolab-imapx-store.c
@@ -444,6 +444,63 @@ imapx_store_set_foldertype (CamelKolabIMAPXStore *self,
 	return TRUE;
 }
 
+static gboolean
+imapx_store_set_folder_permissions (CamelKolabIMAPXStore *self,
+                                    const gchar *foldername,
+                                    const GList *permissions,
+                                    GCancellable *cancellable,
+                                    GError **err)
+{
+	CamelKolabIMAPXStorePrivate *priv = NULL;
+	CamelIMAPXExtdStore *es = NULL;
+	GError *tmp_err = NULL;
+	gboolean perms_ok = FALSE;
+
+	g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (self));
+	g_assert (foldername != NULL);
+	/* permissions may be NULL */
+	/* cancellable may be NULL */
+	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+	priv = CAMEL_KOLAB_IMAPX_STORE_PRIVATE (self);
+	es = CAMEL_IMAPX_EXTD_STORE (self);
+
+	/* check whether we are online and get server */
+	if (! camel_offline_store_get_online (CAMEL_OFFLINE_STORE (self))) {
+		/* If we're here, we're trying to set the
+		 * permissions of the folder in offline mode -
+		 * to be sure the folder permissions can be set,
+		 * we must be online
+		 */
+		g_set_error (err,
+		             KOLAB_CAMEL_KOLAB_ERROR,
+		             KOLAB_CAMEL_KOLAB_ERROR_SERVER,
+		             _("Must be online to complete this operation"));
+		return FALSE;
+	}
+
+	/* set folder perms on the server */
+	perms_ok = camel_imapx_extd_store_set_acl (es,
+	                                           foldername,
+	                                           permissions,
+	                                           cancellable,
+	                                           &tmp_err);
+	if (! perms_ok) {
+		g_propagate_error (err, tmp_err);
+		return FALSE;
+	}
+
+	/* create kolab "flat" data structure */
+	(void) camel_kolab_imapx_acl_update_from_list (priv->kacl,
+	                                               foldername,
+	                                               permissions,
+	                                               NULL);
+
+	/* persistence to be added here, if needed */
+
+	return TRUE;
+}
+
 static CamelFolderInfo*
 imapx_store_folder_info_build_restricted (CamelKolabIMAPXStore *self,
                                           const CamelFolderInfo *fi,
@@ -1329,6 +1386,8 @@ kolab_imapx_store_set_folder_permissions (CamelKolabIMAPXStore *self,
                                           GError **err)
 {
 	CamelKolabIMAPXStorePrivate *priv = NULL;
+	GError *tmp_err = NULL;
+	gboolean ok = FALSE;
 
 	g_assert (CAMEL_IS_KOLAB_IMAPX_STORE (self));
 	/* permissions may be NULL (use to delete all permissions) */
@@ -1339,12 +1398,17 @@ kolab_imapx_store_set_folder_permissions (CamelKolabIMAPXStore *self,
 
 	g_mutex_lock (&(priv->kolab_finfo_lock));
 
-	/* FIXME implement me */
-	g_warning ("%s()[%u] FIXME implement me", __func__, __LINE__);
+	ok = imapx_store_set_folder_permissions (self,
+	                                         foldername,
+	                                         permissions,
+	                                         cancellable,
+	                                         &tmp_err);
+	if (! ok)
+		g_propagate_error (err, tmp_err);
 
 	g_mutex_unlock (&(priv->kolab_finfo_lock));
 
-	return FALSE;
+	return ok;
 }
 
 /*----------------------------------------------------------------------------*/



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