[evolution-kolab] libekolabutil: added CamelIMAPXStream helper function
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] libekolabutil: added CamelIMAPXStream helper function
- Date: Mon, 8 Oct 2012 09:44:25 +0000 (UTC)
commit 76c939a29faf2e793c70949c81a35f0b77398754
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Mon Oct 8 11:36:40 2012 +0200
libekolabutil: added CamelIMAPXStream helper function
* added function to test whether a CamelIMAPXStream
is "at end of stream"
* camel_stream_eos() always returns TRUE for a
CamelIMAPXStream for some reason, so we need
to read a token, check it and write it back
to the stream...
src/libekolabutil/kolab-util-camel.c | 46 ++++++++++++++++++++++++++++------
src/libekolabutil/kolab-util-camel.h | 7 +++++
2 files changed, 45 insertions(+), 8 deletions(-)
---
diff --git a/src/libekolabutil/kolab-util-camel.c b/src/libekolabutil/kolab-util-camel.c
index 7387a3b..703752f 100644
--- a/src/libekolabutil/kolab-util-camel.c
+++ b/src/libekolabutil/kolab-util-camel.c
@@ -25,7 +25,9 @@
/*----------------------------------------------------------------------------*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include <glib/gprintf.h>
#include <glib/gi18n-lib.h>
@@ -136,7 +138,7 @@ kolab_util_camel_folderlist_from_folderinfo (CamelFolderInfo *fi)
GList *folders_self = NULL;
GList *folders_chld = NULL;
GList *folders_next = NULL;
-
+
if (fi == NULL)
return NULL;
@@ -156,7 +158,7 @@ KolabUtilCamelIMAPPath*
kolab_util_camel_imap_path_new (void)
{
KolabUtilCamelIMAPPath *path = NULL;
-
+
path = g_new0 (KolabUtilCamelIMAPPath, 1);
path->parent_name = NULL;
path->folder_name = NULL;
@@ -186,7 +188,7 @@ kolab_util_camel_imap_path_split (const gchar *full_path,
guint strv_nelem = 0;
gchar **strv = NULL;
gchar *strv_tmp = NULL;
-
+
if (full_path == NULL)
return NULL;
@@ -199,19 +201,47 @@ kolab_util_camel_imap_path_split (const gchar *full_path,
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;
+ strv[strv_nelem - 1] = strv_tmp;
path->folder_name = g_strdup (strv[strv_nelem - 1]);
-
+
g_strfreev (strv);
-
+
done:
-
+
return path;
}
+gboolean
+kolab_util_camel_imapx_stream_eos (CamelIMAPXStream *is,
+ GCancellable *cancellable,
+ GError **err)
+{
+ gint tok = 0;
+ guchar *token = NULL;
+ guint len = 0;
+ GError *tmp_err = NULL;
+ gboolean at_end = FALSE;
+
+ g_return_val_if_fail (CAMEL_IS_IMAPX_STREAM (is), FALSE);
+ /* cancellable may be NULL */
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ tok = camel_imapx_stream_token (is, &token, &len, cancellable, &tmp_err);
+
+ if (tmp_err != NULL) {
+ g_propagate_error (err, tmp_err);
+ return TRUE;
+ }
+
+ at_end = (tok == '\n' || tok < 0);
+ camel_imapx_stream_ungettoken (is, tok, token, len);
+
+ return at_end;
+}
+
/*----------------------------------------------------------------------------*/
diff --git a/src/libekolabutil/kolab-util-camel.h b/src/libekolabutil/kolab-util-camel.h
index 61ac9bc..c42b773 100644
--- a/src/libekolabutil/kolab-util-camel.h
+++ b/src/libekolabutil/kolab-util-camel.h
@@ -31,6 +31,8 @@
/*----------------------------------------------------------------------------*/
#include <glib.h>
+#include <gio/gio.h>
+
#include "camel-system-headers.h"
/*----------------------------------------------------------------------------*/
@@ -95,6 +97,11 @@ KolabUtilCamelIMAPPath*
kolab_util_camel_imap_path_split (const gchar *full_path,
const gchar *delim);
+gboolean
+kolab_util_camel_imapx_stream_eos (CamelIMAPXStream *is,
+ GCancellable *cancellable,
+ GError **err);
+
/*----------------------------------------------------------------------------*/
#endif /* _KOLAB_UTIL_CAMEL_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]