[evolution-kolab] libekolabutil: added KolabFolderDescriptor type and util functions



commit 2e78794a403153681b40bf7319649955a0f760e8
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Mon Jul 23 20:07:33 2012 +0200

    libekolabutil: added KolabFolderDescriptor type and util functions
    
    * new type KolabFolderDescriptor to be used with Kolab
      folder info retrieval
    * added new() and free() functions for that type
    * added a free() function for GLists containing
      that type

 src/libekolabutil/kolab-util-folder.c |   42 +++++++++++++++++++++++++++++++++
 src/libekolabutil/kolab-util-folder.h |   16 ++++++++++++
 2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolabutil/kolab-util-folder.c b/src/libekolabutil/kolab-util-folder.c
index 796801f..0439924 100644
--- a/src/libekolabutil/kolab-util-folder.c
+++ b/src/libekolabutil/kolab-util-folder.c
@@ -190,4 +190,46 @@ kolab_util_folder_type_match_with_context_id (KolabFolderTypeID type_id,
 	return TRUE;
 }
 
+KolabFolderDescriptor*
+kolab_util_folder_descriptor_new (const gchar *foldername,
+                                  KolabFolderTypeID type_id)
+{
+	KolabFolderDescriptor *desc = NULL;
+
+	g_assert (foldername != NULL);
+	g_assert ((type_id > KOLAB_FOLDER_TYPE_INVAL) &&
+	          (type_id < KOLAB_FOLDER_LAST_TYPE));
+
+	desc = g_new0 (KolabFolderDescriptor, 1);
+	desc->name = g_strdup (foldername);
+	desc->type_id = type_id;
+
+	return desc;
+}
+
+void
+kolab_util_folder_descriptor_free (KolabFolderDescriptor *desc)
+{
+	if (desc == NULL)
+		return;
+
+	if (desc->name != NULL)
+		g_free (desc->name);
+
+	g_free (desc);
+}
+
+void
+kolab_util_folder_descriptor_glist_free (GList *list)
+{
+	GList *list_ptr = list;
+
+	while (list_ptr != NULL) {
+		kolab_util_folder_descriptor_free (list_ptr->data);
+		list_ptr = g_list_next (list_ptr);
+	}
+	if (list != NULL)
+		g_list_free (list);
+}
+
 /*----------------------------------------------------------------------------*/
diff --git a/src/libekolabutil/kolab-util-folder.h b/src/libekolabutil/kolab-util-folder.h
index 6d78d58..d354138 100644
--- a/src/libekolabutil/kolab-util-folder.h
+++ b/src/libekolabutil/kolab-util-folder.h
@@ -92,6 +92,12 @@ typedef enum {
 	KOLAB_FOLDER_LAST_CONTEXT
 } KolabFolderContextID;
 
+typedef struct _KolabFolderDescriptor KolabFolderDescriptor;
+struct _KolabFolderDescriptor {
+	gchar *name;
+	KolabFolderTypeID type_id;
+};
+
 /*----------------------------------------------------------------------------*/
 
 void
@@ -112,6 +118,16 @@ kolab_util_folder_type_map_to_context_id (KolabFolderTypeID type_id);
 gboolean
 kolab_util_folder_type_match_with_context_id (KolabFolderTypeID type_id, KolabFolderContextID context_id);
 
+KolabFolderDescriptor*
+kolab_util_folder_descriptor_new (const gchar *foldername,
+                                  KolabFolderTypeID type_id);
+
+void
+kolab_util_folder_descriptor_free (KolabFolderDescriptor *desc);
+
+void
+kolab_util_folder_descriptor_glist_free (GList *list);
+
 /*----------------------------------------------------------------------------*/
 
 #endif /* _KOLAB_UTIL_FOLDER_ */



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