[evolution-kolab/ek-wip-porting: 2/8] libekolabutil: added type KolabUtilCamelIMAPPath and util functions
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-porting: 2/8] libekolabutil: added type KolabUtilCamelIMAPPath and util functions
- Date: Fri, 31 Aug 2012 16:10:54 +0000 (UTC)
commit 688130fab170b795e221d9fe8f56f629aad191a4
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Aug 31 17:30:18 2012 +0200
libekolabutil: added type KolabUtilCamelIMAPPath and util functions
* holds two strings, an IMAP parent folder name and
an IMAP sub folder name
* added function for splitting an IMAP full path
into the parent path and the folder name (Camel
has functions for the other way around only)
src/libekolabutil/kolab-util-camel.c | 63 ++++++++++++++++++++++++++++++++++
src/libekolabutil/kolab-util-camel.h | 18 ++++++++++
2 files changed, 81 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolabutil/kolab-util-camel.c b/src/libekolabutil/kolab-util-camel.c
index 2c7fd53..dd081f0 100644
--- a/src/libekolabutil/kolab-util-camel.c
+++ b/src/libekolabutil/kolab-util-camel.c
@@ -27,6 +27,7 @@
#include <config.h>
+#include <glib/gprintf.h>
#include <glib/gi18n-lib.h>
#include <libedataserver/libedataserver.h>
@@ -140,4 +141,66 @@ kolab_util_camel_folderlist_from_folderinfo (CamelFolderInfo *fi)
return folders_self;
}
+KolabUtilCamelIMAPPath*
+kolab_util_camel_imap_path_new (void)
+{
+ KolabUtilCamelIMAPPath *path = NULL;
+
+ path = g_new0 (KolabUtilCamelIMAPPath, 1);
+ path->parent_name = NULL;
+ path->folder_name = NULL;
+
+ return path;
+}
+
+void
+kolab_util_camel_imap_path_free (KolabUtilCamelIMAPPath *path)
+{
+ if (path == NULL)
+ return;
+
+ if (path->parent_name != NULL)
+ g_free (path->parent_name);
+ if (path->folder_name != NULL)
+ g_free (path->folder_name);
+
+ g_free (path);
+}
+
+KolabUtilCamelIMAPPath*
+kolab_util_camel_imap_path_split (const gchar *full_path,
+ const gchar *delim)
+{
+ KolabUtilCamelIMAPPath *path = NULL;
+ guint strv_nelem = 0;
+ gchar **strv = NULL;
+ gchar *strv_tmp = NULL;
+
+ if (full_path == NULL)
+ return NULL;
+
+ path = kolab_util_camel_imap_path_new ();
+
+ if (delim == NULL) {
+ path->folder_name = g_strdup (full_path);
+ goto done;
+ }
+
+ strv = g_strsplit (full_path, delim, -1);
+ strv_nelem = g_strv_length (strv);
+
+ strv_tmp = strv[strv_nelem - 1];
+ strv[strv_nelem - 1] = '\0';
+ path->parent_name = g_strjoinv (delim, strv);
+ strv[strv_nelem - 1] = strv_tmp;
+
+ path->folder_name = g_strdup (strv[strv_nelem - 1]);
+
+ g_strfreev (strv);
+
+ done:
+
+ return path;
+}
+
/*----------------------------------------------------------------------------*/
diff --git a/src/libekolabutil/kolab-util-camel.h b/src/libekolabutil/kolab-util-camel.h
index 8e60056..61ac9bc 100644
--- a/src/libekolabutil/kolab-util-camel.h
+++ b/src/libekolabutil/kolab-util-camel.h
@@ -58,6 +58,14 @@
#define KOLAB_SERVER_LDAPS_PORT 636
/*----------------------------------------------------------------------------*/
+
+typedef struct _KolabUtilCamelIMAPPath KolabUtilCamelIMAPPath;
+struct _KolabUtilCamelIMAPPath {
+ gchar *parent_name;
+ gchar *folder_name;
+};
+
+/*----------------------------------------------------------------------------*/
/* Camel init/shutdown */
gboolean kolab_util_camel_init (GError **err);
@@ -77,6 +85,16 @@ kolab_util_camel_imapx_folder_get_uidvalidity (CamelIMAPXFolder *folder);
GList*
kolab_util_camel_folderlist_from_folderinfo (CamelFolderInfo *fi);
+KolabUtilCamelIMAPPath*
+kolab_util_camel_imap_path_new (void);
+
+void
+kolab_util_camel_imap_path_free (KolabUtilCamelIMAPPath *path);
+
+KolabUtilCamelIMAPPath*
+kolab_util_camel_imap_path_split (const gchar *full_path,
+ const gchar *delim);
+
/*----------------------------------------------------------------------------*/
#endif /* _KOLAB_UTIL_CAMEL_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]