evolution-mapi r32 - trunk/src/camel



Author: jjohnny
Date: Mon Dec 15 11:19:03 2008
New Revision: 32
URL: http://svn.gnome.org/viewvc/evolution-mapi?rev=32&view=rev

Log:
Patch for #563945. These issues should be fixed once the mimewriter is complete.

Modified:
   trunk/src/camel/ChangeLog
   trunk/src/camel/camel-mapi-folder.c
   trunk/src/camel/camel-mapi-transport.c

Modified: trunk/src/camel/camel-mapi-folder.c
==============================================================================
--- trunk/src/camel/camel-mapi-folder.c	(original)
+++ trunk/src/camel/camel-mapi-folder.c	Mon Dec 15 11:19:03 2008
@@ -335,7 +335,7 @@
 			mi = (CamelMapiMessageInfo *)camel_message_info_new (folder->summary); 
 			if (mi->info.content == NULL) {
 				mi->info.content = camel_folder_summary_content_info_new (folder->summary);
-				mi->info.content->type = camel_content_type_new ("multipart", "mixed");	
+				mi->info.content->type = camel_content_type_new ("multipart", "related");      
 			}
 		}
 		
@@ -1023,7 +1023,6 @@
 	} else
 		camel_mime_part_set_content(part, " ", strlen(" "), "text/html");
 
-	camel_multipart_set_boundary (multipart, NULL);
 	camel_multipart_add_part (multipart, part);
 	camel_object_unref (part);
 }
@@ -1036,6 +1035,7 @@
 {
 	CamelMimeMessage *msg = NULL;
 	CamelMultipart *multipart = NULL;
+	CamelContentType *content_type = NULL;
 
 	GSList *attach_list = NULL;
 	int errno;
@@ -1050,6 +1050,14 @@
 
 	multipart = camel_multipart_new ();
 
+	/*FIXME : Using set of default. Fix it during mimewriter*/
+	camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart),
+					  "multipart/related");
+
+	camel_content_type_set_param (multipart, "type", "multipart/alternative");
+
+	camel_multipart_set_boundary (multipart, NULL);
+
 	camel_mime_message_set_message_id (msg, uid);
 	body_part_list = item->msg.body_parts;
 	while (body_part_list){
@@ -1068,29 +1076,41 @@
 		for (al = attach_list; al != NULL; al = al->next) {
 			ExchangeMAPIAttachment *attach = (ExchangeMAPIAttachment *)al->data;
 			ExchangeMAPIStream *stream = NULL;
-			const char *filename, *mime_type; 
+			const char *filename, *mime_type, *content_id = NULL; 
 			CamelMimePart *part;
 
-			filename = (const char *) exchange_mapi_util_find_SPropVal_array_propval(attach->lpProps, PR_ATTACH_LONG_FILENAME);
-			if (!(filename && *filename))
-				filename = (const char *) exchange_mapi_util_find_SPropVal_array_propval(attach->lpProps, PR_ATTACH_FILENAME);
-
-			mime_type = (const char *) exchange_mapi_util_find_SPropVal_array_propval(attach->lpProps, PR_ATTACH_MIME_TAG);
-
 			stream = exchange_mapi_util_find_stream (attach->streams, PR_ATTACH_DATA_BIN);
 
 			if (!stream || stream->value->len <= 0) {
 				continue;
 			}
+
 			part = camel_mime_part_new ();
 
+			filename = (const char *) exchange_mapi_util_find_SPropVal_array_propval(attach->lpProps, 
+												 PR_ATTACH_LONG_FILENAME);
+
+			if (!(filename && *filename))
+				filename = (const char *) exchange_mapi_util_find_SPropVal_array_propval(attach->lpProps, 
+													 PR_ATTACH_FILENAME);
 			camel_mime_part_set_filename(part, g_strdup(filename));
-			//Auto generate content-id
-			camel_mime_part_set_content_id (part, NULL);
-			camel_mime_part_set_content(part, stream->value->data, stream->value->len, mime_type);
 			camel_content_type_set_param (((CamelDataWrapper *) part)->mime_type, "name", filename);
 
-			camel_multipart_set_boundary(multipart, NULL);
+			/*Content-Type*/
+			mime_type = (const char *) exchange_mapi_util_find_SPropVal_array_propval(attach->lpProps, 
+												  PR_ATTACH_MIME_TAG);
+
+			camel_mime_part_set_content(part, stream->value->data, stream->value->len, mime_type);
+
+			/*Content-ID*/
+			content_id = (const char *) exchange_mapi_util_find_SPropVal_array_propval(attach->lpProps, 
+												   PR_ATTACH_CONTENT_ID);
+
+			camel_mime_part_set_content_id (part, content_id);
+
+			/*Fall back to default*/
+			camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_BASE64);
+
 			camel_multipart_add_part (multipart, part);
 			camel_object_unref (part);
 			

Modified: trunk/src/camel/camel-mapi-transport.c
==============================================================================
--- trunk/src/camel/camel-mapi-transport.c	(original)
+++ trunk/src/camel/camel-mapi-transport.c	Mon Dec 15 11:19:03 2008
@@ -107,7 +107,7 @@
 	if (item->header.subject)
 		free(item->header.subject);
 
-	item->header.subject = strdup(subject);
+	item->header.subject = g_strdup(subject);
 }
 
 #define MAX_READ_SIZE 0x1000
@@ -135,7 +135,7 @@
 		stream->proptag = PR_HTML;
 		break;
 	case PART_TYPE_PLAIN_TEXT:
-		stream->proptag = PR_BODY;
+		stream->proptag = PR_BODY_UNICODE;
 		break;
 	}
 
@@ -147,21 +147,23 @@
 }
 
 static gboolean
-mapi_item_add_attach(MapiItem *item, const gchar *filename, const char *description, 
-		     CamelStream *content_stream, int content_size)
+mapi_item_add_attach (MapiItem *item, CamelMimePart *part, CamelStream *content_stream)
 {
 	guint8 *buf = g_new0 (guint8 , STREAM_SIZE);
-	guint32	read_size, flag;
+	gchar *content_id = NULL;
+	guint32	read_size, flag, i = 0;
+
 	ExchangeMAPIAttachment *item_attach;
 	ExchangeMAPIStream *stream; 
 
+	const gchar *filename = camel_mime_part_get_filename (part);
+	
 	item_attach = g_new0 (ExchangeMAPIAttachment, 1);
 
-	item_attach->cValues = 4; 
-	item_attach->lpProps = g_new0 (struct SPropValue, 4); 
+	item_attach->lpProps = g_new0 (struct SPropValue, 5);
 
 	flag = ATTACH_BY_VALUE; 
-	set_SPropValue_proptag(&(item_attach->lpProps[0]), PR_ATTACH_METHOD, (const void *) (&flag));
+	set_SPropValue_proptag(&(item_attach->lpProps[i++]), PR_ATTACH_METHOD, (const void *) (&flag));
 
 	/* MSDN Documentation: When the supplied offset is -1 (0xFFFFFFFF), the 
 	 * attachment is not rendered using the PR_RENDERING_POSITION property. 
@@ -169,22 +171,38 @@
 	 * the attachment is to be rendered. 
 	 */
 	flag = 0xFFFFFFFF;
-	set_SPropValue_proptag(&(item_attach->lpProps[1]), PR_RENDERING_POSITION, (const void *) (&flag));
+	set_SPropValue_proptag(&(item_attach->lpProps[i++]), PR_RENDERING_POSITION, (const void *) (&flag));
 
 	if (filename) {
-		set_SPropValue_proptag(&(item_attach->lpProps[2]), PR_ATTACH_FILENAME, (const void *) g_strdup(filename));
-		set_SPropValue_proptag(&(item_attach->lpProps[3]), PR_ATTACH_LONG_FILENAME, (const void *) g_strdup(filename));
+		set_SPropValue_proptag(&(item_attach->lpProps[i++]), 
+				       PR_ATTACH_FILENAME,
+				       (const void *) g_strdup(filename));
+
+		set_SPropValue_proptag(&(item_attach->lpProps[i++]), 
+				       PR_ATTACH_LONG_FILENAME, 
+				       (const void *) g_strdup(filename));
+	}
+
+	/* mime type : multipart/related */
+	content_id = camel_mime_part_get_content_id (part);
+	if (content_id) {
+		set_SPropValue_proptag(&(item_attach->lpProps[i++]), 
+				       PR_ATTACH_CONTENT_ID,
+				       (const void *) g_strdup(content_id));
 	}
 
+	item_attach->cValues = i;
+
 	stream = g_new0 (ExchangeMAPIStream, 1);
 	stream->proptag = PR_ATTACH_DATA_BIN; 
 	stream->value = g_byte_array_new ();
+
 	camel_seekable_stream_seek((CamelSeekableStream *)content_stream, 0, CAMEL_STREAM_SET);
 	while((read_size = camel_stream_read(content_stream, (char *)buf, STREAM_SIZE))){
 		stream->value = g_byte_array_append (stream->value, buf, read_size);
 	}
-	item_attach->streams = g_slist_append (item_attach->streams, stream); 
 
+	item_attach->streams = g_slist_append (item_attach->streams, stream); 
 	item->attachments = g_slist_append(item->attachments, item_attach);
 
 	return TRUE;
@@ -217,7 +235,6 @@
 		/* filename */
 		filename = camel_mime_part_get_filename(part);
 
-		dw = camel_medium_get_content_object(CAMEL_MEDIUM(part));
 		content_stream = camel_stream_mem_new();
 		content_size = camel_data_wrapper_decode_to_stream (dw, (CamelStream *) content_stream);
 		camel_stream_write ((CamelStream *) content_stream, "", 1);
@@ -234,8 +251,7 @@
 		} else if (camel_content_type_is (type, "text", "html")) {
 			mapi_item_set_body_stream (item, content_stream, PART_TYPE_TEXT_HTML);
 		} else {
-			mapi_item_add_attach(item, filename, description, 
-					     content_stream, content_size);
+			mapi_item_add_attach (item, part, content_stream);
 		}
 	}
 
@@ -385,8 +401,8 @@
 
 	props = g_new0 (struct SPropValue, 6);
 
-	set_SPropValue_proptag(&props[i++], PR_CONVERSATION_TOPIC, g_strdup (item->header.subject));
-	set_SPropValue_proptag(&props[i++], PR_NORMALIZED_SUBJECT, g_strdup (item->header.subject));
+	set_SPropValue_proptag(&props[i++], PR_CONVERSATION_TOPIC_UNICODE, g_strdup (item->header.subject));
+	set_SPropValue_proptag(&props[i++], PR_NORMALIZED_SUBJECT_UNICODE, g_strdup (item->header.subject));
 
 	*msgflag = MSGFLAG_UNSENT;
 	set_SPropValue_proptag(&props[i++], PR_MESSAGE_FLAGS, (void *)msgflag);
@@ -399,7 +415,7 @@
 		bin->lpb = (uint8_t *)stream->value->data;
 		if (stream->proptag == PR_HTML)
 			set_SPropValue_proptag(&props[i++], stream->proptag, (void *)bin);
-		else if (stream->proptag == PR_BODY)
+		else if (stream->proptag == PR_BODY_UNICODE)
 			set_SPropValue_proptag(&props[i++], stream->proptag, (void *)stream->value->data);
 	}
 



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