Index: camel/providers/imap/ChangeLog
===================================================================
--- camel/providers/imap/ChangeLog	(revision 9058)
+++ camel/providers/imap/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2008-06-27  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #313225
+
+	* camel-imap-folder.c: (CAMEL_MESSAGE_INFO_HEADERS):
+	Transfer always 'CONTENT-CLASS' and 'X-CALENDAR-ATTACHMENT' headers.
+
 2008-06-24  Milan Crha  <mcrha@redhat.com>
 
 	** Fix for bug #531712
Index: camel/providers/imap/camel-imap-folder.c
===================================================================
--- camel/providers/imap/camel-imap-folder.c	(revision 9058)
+++ camel/providers/imap/camel-imap-folder.c	(working copy)
@@ -2798,7 +2798,7 @@ construct_junk_headers (char *header, ch
 	}
 }
 
-#define CAMEL_MESSAGE_INFO_HEADERS "DATE FROM TO CC SUBJECT REFERENCES IN-REPLY-TO MESSAGE-ID MIME-VERSION CONTENT-TYPE "
+#define CAMEL_MESSAGE_INFO_HEADERS "DATE FROM TO CC SUBJECT REFERENCES IN-REPLY-TO MESSAGE-ID MIME-VERSION CONTENT-TYPE CONTENT-CLASS X-CALENDAR-ATTACHMENT "
 
 /* FIXME: this needs to be kept in sync with camel-mime-utils.c's list
    of mailing-list headers and so might be best if this were
Index: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 9058)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2008-06-27  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #313225
+
+	* camel-folder-summary.c: (summary_build_content_info),
+	(summary_build_content_info_message): Check whether message contains
+	headers indicating a calendar attachment and if so, then set the user
+	flag '$has_cal' in the message info.
+
 2008-06-25  Jeffrey Stedfast  <fejj@novell.com>
 
 	* camel-mime-utils.c (camel_header_decode_date): Don't crash if
Index: camel/camel-folder-summary.c
===================================================================
--- camel/camel-folder-summary.c	(revision 9058)
+++ camel/camel-folder-summary.c	(working copy)
@@ -2153,6 +2153,8 @@ summary_build_content_info(CamelFolderSu
 	struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
 	CamelMimeFilterCharset *mfc;
 	CamelMessageContentInfo *part;
+	const char *calendar_header;
+	int calendar_header_offset = -1;
 
 	d(printf("building content info\n"));
 
@@ -2175,6 +2177,21 @@ summary_build_content_info(CamelFolderSu
 			)
 			camel_message_info_set_flags(msginfo, CAMEL_MESSAGE_SECURE, CAMEL_MESSAGE_SECURE);
 
+		calendar_header = camel_mime_parser_header (mp, "Content-class", &calendar_header_offset);
+		if (calendar_header) {
+			while (calendar_header [calendar_header_offset] && isspace (calendar_header [calendar_header_offset]))
+				calendar_header_offset++;
+
+			if (g_ascii_strcasecmp (calendar_header + calendar_header_offset, "urn:content-classes:calendarmessage") != 0)
+				calendar_header = NULL;
+		}
+
+		if (!calendar_header)
+			calendar_header = camel_mime_parser_header (mp, "X-Calendar-Attachment", &calendar_header_offset);
+
+		if (calendar_header)
+			camel_message_info_set_user_flag (msginfo, "$has_cal", TRUE);
+
 		if (p->index && camel_content_type_is(ct, "text", "*")) {
 			char *encoding;
 			const char *charset;
@@ -2304,6 +2321,7 @@ summary_build_content_info_message(Camel
 	struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
 	CamelMessageContentInfo *info = NULL, *child;
 	CamelContentType *ct;
+	const struct _camel_header_raw *header;
 
 	if (s->build_content)
 		info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_new_from_message(s, object);
@@ -2333,6 +2351,22 @@ summary_build_content_info_message(Camel
 		camel_message_info_set_flags(msginfo, CAMEL_MESSAGE_SECURE, CAMEL_MESSAGE_SECURE);
 	}
 
+	for (header = object->headers; header; header = header->next) {
+		const char *value = header->value;
+
+		/* skip preceding spaces in the value */
+		while (value && *value && isspace (*value))
+			value++;
+
+		if (header->name && value && (
+		    (g_ascii_strcasecmp (header->name, "Content-class") == 0 && g_ascii_strcasecmp (value, "urn:content-classes:calendarmessage") == 0) ||
+		    (g_ascii_strcasecmp (header->name, "X-Calendar-Attachment") == 0)))
+			break;
+	}
+
+	if (header)
+		camel_message_info_set_user_flag (msginfo, "$has_cal", TRUE);
+
 	/* using the object types is more accurate than using the mime/types */
 	if (CAMEL_IS_MULTIPART(containee)) {
 		parts = camel_multipart_get_number(CAMEL_MULTIPART(containee));
