[evolution-mapi/gnome-2-32] Bug #633121 - Fetch also Content-class message header



commit 1d17e2606e6ad950c719647727e4ab48edd399f9
Author: Milan Crha <mcrha redhat com>
Date:   Mon Dec 13 11:39:14 2010 +0100

    Bug #633121 - Fetch also Content-class message header

 src/libexchangemapi/exchange-mapi-mail-utils.c |   25 ++++++++++++++++++++++-
 src/libexchangemapi/exchange-mapi-mail-utils.h |    1 +
 2 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/libexchangemapi/exchange-mapi-mail-utils.c b/src/libexchangemapi/exchange-mapi-mail-utils.c
index 081ba5b..deba2d6 100644
--- a/src/libexchangemapi/exchange-mapi-mail-utils.c
+++ b/src/libexchangemapi/exchange-mapi-mail-utils.c
@@ -41,6 +41,8 @@ mail_item_free (MailItem *item)
 	g_free (item->header.references);
 	g_free (item->header.message_id);
 	g_free (item->header.in_reply_to);
+	g_free (item->header.content_class);
+	g_free (item->header.transport_headers);
 
 	exchange_mapi_util_free_attachment_list (&item->attachments);
 	exchange_mapi_util_free_stream_list (&item->generic_streams);
@@ -56,8 +58,9 @@ fetch_props_to_mail_item_cb (FetchItemsCallbackData *item_data, gpointer data)
 {
 	long *flags = NULL;
 	struct FILETIME *delivery_date = NULL;
-	const gchar *msg_class = NULL;
+	const gchar *msg_class = NULL, *content_class = NULL;
 	ExchangeMAPIStream *body = NULL;
+	uint32_t content_class_pid;
 
 	MailItem *item;
 	MailItem **i = (MailItem **)data;
@@ -71,6 +74,10 @@ fetch_props_to_mail_item_cb (FetchItemsCallbackData *item_data, gpointer data)
 		camel_debug_end();
 	}
 
+	content_class_pid = exchange_mapi_connection_resolve_named_prop (item_data->conn, item_data->fid, PidNameContentClass, NULL);
+	if (content_class_pid == MAPI_E_RESERVED)
+		content_class_pid = 0;
+
 	item = g_new0 (MailItem , 1);
 	item->fid = item_data->fid;
 	item->mid = item_data->mid;
@@ -97,11 +104,14 @@ fetch_props_to_mail_item_cb (FetchItemsCallbackData *item_data, gpointer data)
 			flags = (long *) prop_data;
 			break;
 		default:
+			if (content_class_pid != 0 && item_data->properties->lpProps[j].ulPropTag == content_class_pid)
+				content_class = (const gchar *) prop_data;
 			break;
 		}
 	}
 
 	item->msg_class = g_strdup (msg_class);
+	item->header.content_class = g_strdup (content_class);
 
 	item->is_cal = FALSE;
 	if (msg_class && g_str_has_prefix (msg_class, IPM_SCHEDULE_MEETING_PREFIX)) {
@@ -288,9 +298,17 @@ mapi_mail_get_item_prop_list (ExchangeMapiConnection *conn, mapi_id_t fid, TALLO
 		PR_RCVD_REPRESENTING_EMAIL_ADDRESS_UNICODE
 	};
 
+	/* do not make this array static, the function modifies it on run */
+	ResolveNamedIDsData nids[] = {
+		{ PidNameContentClass, 0 }
+	};
+
 	g_return_val_if_fail (props != NULL, FALSE);
 
-	return exchange_mapi_utils_add_props_to_props_array (mem_ctx, props, item_props, G_N_ELEMENTS (item_props));
+	if (!exchange_mapi_utils_add_props_to_props_array (mem_ctx, props, item_props, G_N_ELEMENTS (item_props)))
+		return FALSE;
+
+	return exchange_mapi_utils_add_named_ids_to_props_array (conn, fid, mem_ctx, props, nids, G_N_ELEMENTS (nids));
 }
 
 static void
@@ -408,6 +426,9 @@ mapi_mime_set_msg_headers (ExchangeMapiConnection *conn, CamelMimeMessage *msg,
 		camel_mime_message_set_date (msg, actual_time, offset);
 	}
 
+	if (item->header.content_class)
+		camel_medium_add_header (CAMEL_MEDIUM (msg), "Content-class", item->header.content_class);
+
 	/* Overwrite headers if we have specific properties available*/
 	temp_str = item->header.subject;
 	if (temp_str)
diff --git a/src/libexchangemapi/exchange-mapi-mail-utils.h b/src/libexchangemapi/exchange-mapi-mail-utils.h
index fe4432f..f9d7e3b 100644
--- a/src/libexchangemapi/exchange-mapi-mail-utils.h
+++ b/src/libexchangemapi/exchange-mapi-mail-utils.h
@@ -54,6 +54,7 @@ typedef struct {
 	time_t send_time;
 	guint cpid; /* codepage id */
 	gchar *transport_headers;
+	gchar *content_class;
 } MailItemHeader;
 
 typedef struct {



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