[evolution-kolab/ek-wip-acl] CamelImapxAcl: added updater for ACL GList representation
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-acl] CamelImapxAcl: added updater for ACL GList representation
- Date: Fri, 12 Oct 2012 15:21:36 +0000 (UTC)
commit 6f5b0e5dc142febbbc96cf3e1e3538567f6a5b6c
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Oct 12 15:41:56 2012 +0200
CamelImapxAcl: added updater for ACL GList representation
* new function for updating an ACL in GList
form from a CamelImapxAclEntry instance
src/libekolab/camel-imapx-acl.c | 47 +++++++++++++++++++++++++++++++++++++++
src/libekolab/camel-imapx-acl.h | 5 ++++
2 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-acl.c b/src/libekolab/camel-imapx-acl.c
index 0c020a0..c62fd9b 100644
--- a/src/libekolab/camel-imapx-acl.c
+++ b/src/libekolab/camel-imapx-acl.c
@@ -562,6 +562,53 @@ camel_imapx_acl_get_rights_from_list (const GList *entries,
return rights;
}
+gboolean
+camel_imapx_acl_update_list_from_entry (GList **entries,
+ const CamelImapxAclEntry *entry,
+ GError **err)
+{
+ CamelImapxAclEntry *tmp_entry = NULL;
+ GList *entries_ptr = NULL;
+ GError *tmp_err = NULL;
+ gboolean found = FALSE;
+ gboolean ok = FALSE;
+
+ g_return_val_if_fail (entries != NULL, FALSE);
+ /* entry may be NULL */
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ if (entry == NULL)
+ return TRUE;
+
+ ok = imapx_acl_entry_validate (entry, &tmp_err);
+ if (! ok) {
+ g_propagate_error (err, tmp_err);
+ return FALSE;
+ }
+
+ /* find matching entry, if any */
+ entries_ptr = *entries;
+ while (entries_ptr != NULL) {
+ tmp_entry = (CamelImapxAclEntry *) entries_ptr->data;
+ found = (g_strcmp0 (tmp_entry->access_id, entry->access_id) == 0);
+ if (found) {
+ if (tmp_entry->rights)
+ g_free (tmp_entry->rights);
+ tmp_entry->rights = g_strdup (entry->rights);
+ break;
+ }
+ entries_ptr = g_list_next (entries_ptr);
+ }
+
+ if (! found) {
+ tmp_entry = camel_imapx_acl_entry_clone (entry,
+ NULL);
+ *entries = g_list_append (*entries, tmp_entry);
+ }
+
+ return TRUE;
+}
+
void
camel_imapx_acl_free_list (GList *entries)
{
diff --git a/src/libekolab/camel-imapx-acl.h b/src/libekolab/camel-imapx-acl.h
index 578adb4..839b2fc 100644
--- a/src/libekolab/camel-imapx-acl.h
+++ b/src/libekolab/camel-imapx-acl.h
@@ -112,6 +112,11 @@ camel_imapx_acl_get_rights_from_list (const GList *entries,
const gchar *access_id,
GError **err);
+gboolean
+camel_imapx_acl_update_list_from_entry (GList **entries,
+ const CamelImapxAclEntry *entry,
+ GError **err);
+
void
camel_imapx_acl_free_list (GList *entries);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]