[evolution-mapi] Fix mail fetching with exchange 2010
- From: Jonathon Jongsma <jjongsma src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Fix mail fetching with exchange 2010
- Date: Mon, 1 Feb 2010 18:17:27 +0000 (UTC)
commit 0b1dfc9ee9f3231117aeb595da7f4a46cd78729a
Author: Jonathon Jongsma <jonathon dunnart localdomain>
Date: Thu Jan 28 16:09:01 2010 -0500
Fix mail fetching with exchange 2010
When testing against exchange 2010, evolution-mapi was displaying the first
mail in my inbox but was failing to download any further mails. The root cause
of the bug can be illustrated by the following pseudo-code:
rowset = QueryRows;
struct SPropTagArray tags = set_SPropTagArray(...);
for (i = 0 to rowset.numRows) {
msg = OpenMessage(rowset[i]);
GetProps (msg, tags,..)
}
so we re-use the 'tags' variable between calls to GetProps(). But the problem
is that it seems that GetProps() modifies 'tags', so subsequent calls will fail.
Creating a copy of 'tags' for each loop iteration fixes the problem and allows
me to see all messages in my inbox.
https://bugzilla.gnome.org/show_bug.cgi?id=608379
src/libexchangemapi/exchange-mapi-connection.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index 72c52cc..642ad6d 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -1105,6 +1105,19 @@ cleanup:
return mids;
}
+static struct SPropTagArray*
+copy_tag_array (TALLOC_CTX *mem_ctx, struct SPropTagArray *array)
+{
+ struct SPropTagArray *tags_copy = NULL;
+ if (array->cValues) {
+ tags_copy = talloc_zero(mem_ctx, struct SPropTagArray);
+ tags_copy->aulPropTag = talloc_memdup(mem_ctx, array->aulPropTag,
+ sizeof (array->aulPropTag[0]) * array->cValues);
+ tags_copy->cValues = array->cValues;
+ }
+ return tags_copy;
+}
+
gboolean
exchange_mapi_connection_fetch_items (mapi_id_t fid,
struct mapi_SRestriction *res, struct SSortOrderSet *sort_order,
@@ -1286,8 +1299,12 @@ exchange_mapi_connection_fetch_items (mapi_id_t fid,
if (GetPropsTagArray->cValues) {
struct SPropValue *lpProps;
uint32_t prop_count = 0, k;
-
- retval = GetProps (&obj_message, GetPropsTagArray, &lpProps, &prop_count);
+ // create a copy of the props tag for every
+ // request because it might be modified by
+ // GetProps() and cause later calls to fail
+ struct SPropTagArray *tags = copy_tag_array (mem_ctx, GetPropsTagArray);
+ retval = GetProps (&obj_message, tags, &lpProps, &prop_count);
+ MAPIFreeBuffer (tags);
/* Conversion from SPropValue to mapi_SPropValue. (no padding here) */
properties_array.cValues = prop_count;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]