[evolution-mapi] BUGFIX: 578287 - Fix for garbled headers.



commit 6e742b965f2b479af210483b2b5540e6f6a86b1d
Author: Bharath Acharya <abharath novell com>
Date:   Wed Jun 10 09:13:17 2009 +0530

    BUGFIX: 578287 - Fix for garbled headers.
    
    MAPI now sort of works, but some information is garbled and hangs occur.
---
 src/addressbook/e-book-backend-mapi.c          |    3 +++
 src/camel/camel-mapi-folder.c                  |    2 ++
 src/libexchangemapi/exchange-mapi-cal-utils.c  |    2 ++
 src/libexchangemapi/exchange-mapi-connection.c |   18 +++++++-----------
 src/libexchangemapi/exchange-mapi-connection.h |    1 +
 src/libexchangemapi/exchange-mapi-utils.c      |    2 ++
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index 77c45fd..3b8866a 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -743,6 +743,7 @@ create_contact_item (FetchItemsCallbackData *item_data, gpointer data)
 {
 	EContact *contact;
 	char *suid;
+	GSList *recipients = item_data->recipients;
 	
 	contact = emapidump_contact (item_data->properties);
 	suid = exchange_mapi_util_mapi_ids_to_uid (item_data->fid, item_data->mid);
@@ -753,6 +754,8 @@ create_contact_item (FetchItemsCallbackData *item_data, gpointer data)
 		data = contact;
 	}
 
+	exchange_mapi_util_free_recipient_list (&recipients);
+
 	g_free (suid);
 
 	return TRUE;
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 5e20aba..4c9a383 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -1375,6 +1375,8 @@ mapi_folder_get_message( CamelFolder *folder, const char *uid, CamelException *e
 
 	msg = mapi_folder_item_to_msg (folder, item, ex);
 
+	exchange_mapi_util_free_recipient_list (&item->recipients);
+
 	g_free (item);
 
 	if (!msg) {
diff --git a/src/libexchangemapi/exchange-mapi-cal-utils.c b/src/libexchangemapi/exchange-mapi-cal-utils.c
index 9d31be8..4af8657 100644
--- a/src/libexchangemapi/exchange-mapi-cal-utils.c
+++ b/src/libexchangemapi/exchange-mapi-cal-utils.c
@@ -1022,6 +1022,8 @@ fetch_server_data_cb (FetchItemsCallbackData *item_data, gpointer data)
 
 	cbdata->comp = comp; 
 
+	exchange_mapi_util_free_recipient_list (&recipients);
+	
 	g_free (smid);
 	g_free (fileuri);
 	g_free (filename);
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index e1d53f9..a7cf929 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -713,16 +713,13 @@ static gboolean
 exchange_mapi_util_get_recipients (mapi_object_t *obj_message, GSList **recip_list)
 {
 	enum MAPISTATUS		retval;
-//	TALLOC_CTX 		*mem_ctx;
 	struct SPropTagArray	proptags;
 	struct SRowSet		rows_recip;
 	uint32_t		i_row_recip;
 	gboolean 		status = TRUE;
 
 	d(g_print("\n%s: Entering %s ", G_STRLOC, G_STRFUNC));
-
-//	mem_ctx = talloc_init ("ExchangeMAPI_GetRecipients");
-
+	
 	/* fetch recipient table */
 	retval = GetRecipientTable(obj_message, &rows_recip, &proptags);
 	if (retval != MAPI_E_SUCCESS) {
@@ -733,12 +730,14 @@ exchange_mapi_util_get_recipients (mapi_object_t *obj_message, GSList **recip_li
 	for (i_row_recip = 0; i_row_recip < rows_recip.cRows; i_row_recip++) {
 		ExchangeMAPIRecipient 	*recipient = g_new0 (ExchangeMAPIRecipient, 1);
 
-		recipient->email_id = (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_SMTP_ADDRESS);
+		recipient->mem_ctx = talloc_init ("ExchangeMAPI_GetRecipients");
+
+		recipient->email_id = talloc_steal (recipient->mem_ctx, (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_SMTP_ADDRESS));
 		/* fallback */
 		if (!recipient->email_id) {
-			const char *addrtype = (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_ADDRTYPE);
+			const char *addrtype = talloc_steal (recipient->mem_ctx, (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_ADDRTYPE));
 			if (addrtype && !g_ascii_strcasecmp(addrtype, "SMTP"))
-				recipient->email_id = (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_EMAIL_ADDRESS);
+				recipient->email_id = talloc_steal (recipient->mem_ctx, (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_EMAIL_ADDRESS));
 		}
 		/* fail */
 		if (!recipient->email_id) {
@@ -746,7 +745,7 @@ exchange_mapi_util_get_recipients (mapi_object_t *obj_message, GSList **recip_li
 			mapidump_SRow (&(rows_recip.aRow[i_row_recip]), " ");
 		}
 
-		recipient->out.all_lpProps = rows_recip.aRow[i_row_recip].lpProps;
+		recipient->out.all_lpProps = talloc_steal ((TALLOC_CTX *)recipient->mem_ctx, rows_recip.aRow[i_row_recip].lpProps);
 		recipient->out.all_cValues = rows_recip.aRow[i_row_recip].cValues;
 
 		*recip_list = g_slist_append (*recip_list, recipient);
@@ -755,7 +754,6 @@ exchange_mapi_util_get_recipients (mapi_object_t *obj_message, GSList **recip_li
 cleanup:
 	if (retval != MAPI_E_SUCCESS)
 		status = FALSE;
-//	talloc_free (mem_ctx);
 
 	d(g_print("\n%s: Leaving %s ", G_STRLOC, G_STRFUNC));
 
@@ -1176,7 +1174,6 @@ exchange_mapi_connection_fetch_items   (mapi_id_t fid,
 				for (k=0; k < prop_count; k++)
 					cast_mapi_SPropValue(&properties_array.lpProps[k], &lpProps[k]);
 
-				MAPIFreeBuffer(lpProps);
 			} else
 				retval = GetPropsAll (&obj_message, &properties_array);
 
@@ -1353,7 +1350,6 @@ exchange_mapi_connection_fetch_item (mapi_id_t fid, mapi_id_t mid,
 		for (k=0; k < prop_count; k++)
 			cast_mapi_SPropValue(&properties_array.lpProps[k], &lpProps[k]);
 
-		MAPIFreeBuffer(lpProps);
 	} else
 		retval = GetPropsAll (&obj_message, &properties_array);
 
diff --git a/src/libexchangemapi/exchange-mapi-connection.h b/src/libexchangemapi/exchange-mapi-connection.h
index bdd8bf3..ca13543 100644
--- a/src/libexchangemapi/exchange-mapi-connection.h
+++ b/src/libexchangemapi/exchange-mapi-connection.h
@@ -58,6 +58,7 @@ typedef struct {
 typedef struct {
 	/* MANDATORY */
 	const char *email_id;
+	TALLOC_CTX *mem_ctx;
 
 	/* It is ideal to set all these properties on all recipients 
 	 * as we never know if a recipient would be resolved or not. */ 
diff --git a/src/libexchangemapi/exchange-mapi-utils.c b/src/libexchangemapi/exchange-mapi-utils.c
index 2b47d73..4805a8b 100644
--- a/src/libexchangemapi/exchange-mapi-utils.c
+++ b/src/libexchangemapi/exchange-mapi-utils.c
@@ -262,6 +262,8 @@ exchange_mapi_util_free_recipient_list (GSList **recip_list)
 
 	for (; l != NULL; l = l->next) {
 		ExchangeMAPIRecipient *recipient = (ExchangeMAPIRecipient *) (l->data);
+
+		talloc_free (recipient->mem_ctx);
 		if (recipient->in.ext_cValues)
 			g_free (recipient->in.ext_lpProps);
 		if (recipient->in.req_cValues)



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