[evolution-kolab] CamelImapxAcl: properly check for "end of stream"



commit 36e6c661c0700a85c0a0c753ff023a3dbde6ed1b
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Mon Oct 8 11:38:54 2012 +0200

    CamelImapxAcl: properly check for "end of stream"
    
    * when reading ACL, we get access_id,rights pairs
      without further tokens which would tell whether
      we read the last pair
    * we therefore need to check whether the current
      CamelIMAPXStream we read from is at its end

 src/libekolab/camel-imapx-acl.c |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/src/libekolab/camel-imapx-acl.c b/src/libekolab/camel-imapx-acl.c
index fabf15c..749473b 100644
--- a/src/libekolab/camel-imapx-acl.c
+++ b/src/libekolab/camel-imapx-acl.c
@@ -34,6 +34,7 @@
 #include <glib/gi18n-lib.h>
 
 #include <libekolabutil/camel-system-headers.h>
+#include <libekolabutil/kolab-util-camel.h>
 
 #include "camel-imapx-acl.h"
 
@@ -546,6 +547,7 @@ camel_imapx_acl_update_acl_from_server_response (CamelImapxAcl *acl,
 	GHashTable *entries_tbl = NULL;
 	GError *tmp_err = NULL;
 	gboolean ok = FALSE;
+	gboolean at_end = FALSE;
 
 	g_return_val_if_fail (acl != NULL, FALSE);
 	g_return_val_if_fail (acl->mboxes != NULL, FALSE);
@@ -563,6 +565,7 @@ camel_imapx_acl_update_acl_from_server_response (CamelImapxAcl *acl,
 		           __func__, __LINE__, tok, tmp_err->message);
 		goto exit;
 	}
+
 	mbox_name = g_strdup ((gchar *) token);
 
 	/* Where to dump the ACL entries into.
@@ -576,12 +579,14 @@ camel_imapx_acl_update_acl_from_server_response (CamelImapxAcl *acl,
 	                      g_strdup (mbox_name),
 	                      entries_tbl);
 
-#if 0 /* FIXME how to tell if we're done reading? CamelIMAPXStream is always at EOS, it seems... */
-	if (camel_stream_eos (CAMEL_STREAM (is))) {
-		g_hash_table_remove_all (entries_tbl);
+	at_end = kolab_util_camel_imapx_stream_eos (is,
+	                                            cancellable,
+	                                            &tmp_err);
+	if (tmp_err != NULL)
+		goto exit;
+	if (at_end)
 		goto skip;
-	}
-#endif
+
 	/* access_id,rights pairs */
 	while (TRUE) {
 		tok = camel_imapx_stream_astring (is, &token, cancellable, &tmp_err);
@@ -608,13 +613,17 @@ camel_imapx_acl_update_acl_from_server_response (CamelImapxAcl *acl,
 		access_id = NULL;
 		rights = NULL;
 
-		/* FIXME CamelIMAPXStream is always EOS??!? */
-		if (camel_stream_eos (CAMEL_STREAM (is)))
+		at_end = kolab_util_camel_imapx_stream_eos (is,
+		                                            cancellable,
+		                                            &tmp_err);
+		if (tmp_err != NULL)
+			goto exit;
+		if (at_end)
 			break;
 	}
-#if 0
+
  skip:
-#endif
+
 	ok = TRUE;
 
  exit:



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