[evolution-kolab] CamelImapxAcl: new entry / list cloning functions



commit e84c8f970af1a0ffee4374748701f61c0c54a478
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Tue Oct 2 15:34:21 2012 +0200

    CamelImapxAcl: new entry / list cloning functions
    
    * added function for cloning a CamelImapxAclEntry
      (convenience function for new())
    * added function for cloning a list of
      CamelImapxAclEntry instances

 src/libekolab/camel-imapx-acl.c |   42 +++++++++++++++++++++++++++++++++++++++
 src/libekolab/camel-imapx-acl.h |    8 +++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-acl.c b/src/libekolab/camel-imapx-acl.c
index 11b1778..3f6e5c1 100644
--- a/src/libekolab/camel-imapx-acl.c
+++ b/src/libekolab/camel-imapx-acl.c
@@ -143,6 +143,21 @@ camel_imapx_acl_entry_new (const gchar *access_id,
 	return entry;
 }
 
+CamelImapxAclEntry*
+camel_imapx_acl_entry_clone (const CamelImapxAclEntry *entry,
+                             GError **err)
+{
+	CamelImapxAclEntry *new_entry = NULL;
+
+	if (entry == NULL)
+		return NULL;
+
+	new_entry = camel_imapx_acl_entry_new (entry->access_id,
+	                                       entry->rights,
+	                                       err);
+	return new_entry;
+}
+
 void
 camel_imapx_acl_entry_free (CamelImapxAclEntry *entry)
 {
@@ -267,6 +282,33 @@ camel_imapx_acl_get_as_list (CamelImapxAcl *acl,
 	return NULL;
 }
 
+GList*
+camel_imapx_acl_clone_list (GList *entries,
+                            GError **err)
+{
+	CamelImapxAclEntry *entry = NULL;
+	GList *new_lst = NULL;
+	GList *entries_ptr = NULL;
+	GError *tmp_err = NULL;
+
+	entries_ptr = entries;
+	while (entries_ptr != NULL) {
+		entry = camel_imapx_acl_entry_clone ((CamelImapxAclEntry *) entries_ptr->data,
+		                                     &tmp_err);
+		if (tmp_err != NULL) {
+			g_propagate_error (err, tmp_err);
+			camel_imapx_acl_free_list (new_lst);
+			return NULL;
+		}
+
+		new_lst = g_list_prepend (new_lst, entry);
+		entries_ptr = g_list_next (entries_ptr);
+	}
+
+	new_lst = g_list_reverse (new_lst);
+	return new_lst;
+}
+
 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 eaf4f27..56d89db 100644
--- a/src/libekolab/camel-imapx-acl.h
+++ b/src/libekolab/camel-imapx-acl.h
@@ -79,6 +79,10 @@ camel_imapx_acl_entry_new (const gchar *access_id,
                            const gchar *rights,
                            GError **err);
 
+CamelImapxAclEntry*
+camel_imapx_acl_entry_clone (const CamelImapxAclEntry *entry,
+                             GError **err);
+
 void
 camel_imapx_acl_entry_free (CamelImapxAclEntry *entry);
 
@@ -99,6 +103,10 @@ GList*
 camel_imapx_acl_get_as_list (CamelImapxAcl *acl,
                              const gchar *mbox_name);
 
+GList*
+camel_imapx_acl_clone_list (GList *entries,
+                            GError **err);
+
 void
 camel_imapx_acl_free_list (GList *entries);
 



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