[evolution-mapi] Bug #607384 - Replying causes the message to appear as garbage
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Bug #607384 - Replying causes the message to appear as garbage
- Date: Mon, 24 May 2010 16:18:47 +0000 (UTC)
commit 3b86ec45e4e4d399f0737f2fd045f08534f96108
Author: Milan Crha <mcrha redhat com>
Date: Mon May 24 18:17:41 2010 +0200
Bug #607384 - Replying causes the message to appear as garbage
src/camel/camel-mapi-utils.c | 8 ++++-
src/libexchangemapi/exchange-mapi-connection.c | 38 ++++++++++++++++++-----
2 files changed, 36 insertions(+), 10 deletions(-)
---
diff --git a/src/camel/camel-mapi-utils.c b/src/camel/camel-mapi-utils.c
index 95d7ff3..586f8ed 100644
--- a/src/camel/camel-mapi-utils.c
+++ b/src/camel/camel-mapi-utils.c
@@ -155,6 +155,12 @@ mail_item_set_body_stream (MailItem *item, CamelStream *body, MailItemPartType p
g_byte_array_append (stream->value, (const guint8 *)"", 1);
item->msg.body_parts = g_slist_append (item->msg.body_parts, stream);
+ } else if (stream->proptag == PR_HTML) {
+ /* PR_HTML shouldn't be in UTF-16 */
+ if (!is_null_terminated)
+ g_byte_array_append (stream->value, (const guint8 *)"", 1);
+
+ item->generic_streams = g_slist_append (item->generic_streams, stream);
} else {
gsize written = 0;
gchar *in_unicode;
@@ -400,7 +406,7 @@ camel_mapi_utils_create_item_build_props (ExchangeMapiConnection *conn, mapi_id_
return FALSE; \
} G_STMT_END
- cpid = 65001; /* UTF8 */
+ cpid = 65001; /* UTF8 - also used with PR_HTML */
set_value (PR_INTERNET_CPID, &cpid);
set_value (PR_SUBJECT_UNICODE, item->header.subject);
/* PR_CONVERSATION_TOPIC_UNICODE and PR_NORMALIZED_SUBJECT_UNICODE, together with PR_SUBJECT_PREFIX_UNICODE
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index 9a64ffb..684864e 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -367,7 +367,7 @@ exchange_mapi_connection_connected (ExchangeMapiConnection *conn)
}
static gboolean
-exchange_mapi_util_read_generic_stream (mapi_object_t *obj_message, uint32_t proptag, GSList **stream_list)
+exchange_mapi_util_read_generic_stream (mapi_object_t *obj_message, const uint32_t *cpid, uint32_t proptag, GSList **stream_list)
{
enum MAPISTATUS retval;
TALLOC_CTX *mem_ctx;
@@ -432,8 +432,27 @@ exchange_mapi_util_read_generic_stream (mapi_object_t *obj_message, uint32_t pro
ExchangeMAPIStream *stream = g_new0 (ExchangeMAPIStream, 1);
struct mapi_SPropValue_array properties_array;
- stream->value = g_byte_array_sized_new (off_data);
- stream->value = g_byte_array_append (stream->value, buf_data, off_data);
+ stream->value = NULL;
+
+ if (proptag == PR_HTML && ((cpid && (*cpid == 1200 || *cpid == 1201)) || (off_data > 5 && buf_data[3] == '\0'))) {
+ /* this is special, get the CPID and transform to utf8 when it's utf16 */
+ gsize written = 0;
+ gchar *in_utf8;
+
+ in_utf8 = g_convert ((const gchar *) buf_data, off_data, "UTF-8", "UTF-16", NULL, &written, NULL);
+ if (in_utf8 && written > 0) {
+ stream->value = g_byte_array_sized_new (written + 1);
+ g_byte_array_append (stream->value, (const guint8 *) in_utf8, written);
+
+ if (in_utf8[written] != '\0')
+ g_byte_array_append (stream->value, (const guint8 *) "", 1);
+ }
+ }
+
+ if (!stream->value) {
+ stream->value = g_byte_array_sized_new (off_data);
+ g_byte_array_append (stream->value, buf_data, off_data);
+ }
/* Build a mapi_SPropValue_array structure */
properties_array.cValues = 1;
@@ -480,7 +499,8 @@ exchange_mapi_util_read_body_stream (mapi_object_t *obj_message, GSList **stream
mem_ctx = talloc_init ("ExchangeMAPI_ReadBodyStream");
/* Build the array of properties we want to fetch */
- SPropTagArray = set_SPropTagArray(mem_ctx, 0x6,
+ SPropTagArray = set_SPropTagArray(mem_ctx, 0x7,
+ PR_INTERNET_CPID,
PR_MSG_EDITOR_FORMAT,
PR_BODY,
PR_BODY_UNICODE,
@@ -545,7 +565,7 @@ exchange_mapi_util_read_body_stream (mapi_object_t *obj_message, GSList **stream
body.data = talloc_memdup(mem_ctx, data, size);
body.length = size;
retval = MAPI_E_SUCCESS;
- } else if (exchange_mapi_util_read_generic_stream (obj_message, PR_HTML, stream_list)) {
+ } else if (exchange_mapi_util_read_generic_stream (obj_message, exchange_mapi_util_find_SPropVal_array_propval (lpProps, PR_INTERNET_CPID), PR_HTML, stream_list)) {
retval = MAPI_E_SUCCESS;
}
break;
@@ -944,12 +964,12 @@ exchange_mapi_util_get_attachments (ExchangeMapiConnection *conn, mapi_id_t fid,
/* just to get all the other streams */
for (z=0; z < properties.cValues; z++) {
if ((properties.lpProps[z].ulPropTag & 0xFFFF) == PT_BINARY)
- exchange_mapi_util_read_generic_stream (&obj_attach, properties.lpProps[z].ulPropTag, &(attachment->streams));
+ exchange_mapi_util_read_generic_stream (&obj_attach, exchange_mapi_util_find_array_propval (&properties, PR_INTERNET_CPID), properties.lpProps[z].ulPropTag, &(attachment->streams));
}
ui32 = (const uint32_t *) get_SPropValue_SRow_data(&rows_attach.aRow[i_row_attach], PR_ATTACH_METHOD);
if (ui32 && *ui32 == ATTACH_BY_VALUE) {
- exchange_mapi_util_read_generic_stream (&obj_attach, PR_ATTACH_DATA_BIN, &(attachment->streams));
+ exchange_mapi_util_read_generic_stream (&obj_attach, exchange_mapi_util_find_array_propval (&properties, PR_INTERNET_CPID), PR_ATTACH_DATA_BIN, &(attachment->streams));
} else if (ui32 && *ui32 == ATTACH_EMBEDDED_MSG) {
mapi_object_t obj_emb_msg;
@@ -1532,7 +1552,7 @@ exchange_mapi_connection_fetch_items (ExchangeMapiConnection *conn, mapi_id_t
for (z=0; z < properties_array.cValues; z++) {
if ((properties_array.lpProps[z].ulPropTag & 0xFFFF) == PT_BINARY &&
(options & MAPI_OPTIONS_FETCH_GENERIC_STREAMS))
- exchange_mapi_util_read_generic_stream (&obj_message, properties_array.lpProps[z].ulPropTag, &stream_list);
+ exchange_mapi_util_read_generic_stream (&obj_message, exchange_mapi_util_find_array_propval (&properties_array, PR_INTERNET_CPID), properties_array.lpProps[z].ulPropTag, &stream_list);
}
mapi_SPropValue_array_named(&obj_message, &properties_array);
@@ -1654,7 +1674,7 @@ exchange_mapi_connection_fetch_object_props (ExchangeMapiConnection *conn, mapi_
/* just to get all the other streams */
for (z=0; z < properties_array.cValues; z++)
if ((properties_array.lpProps[z].ulPropTag & 0xFFFF) == PT_BINARY && (options & MAPI_OPTIONS_FETCH_GENERIC_STREAMS))
- exchange_mapi_util_read_generic_stream (obj_message, properties_array.lpProps[z].ulPropTag, &stream_list);
+ exchange_mapi_util_read_generic_stream (obj_message, exchange_mapi_util_find_array_propval (&properties_array, PR_INTERNET_CPID), properties_array.lpProps[z].ulPropTag, &stream_list);
mapi_SPropValue_array_named (obj_message, &properties_array);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]