Patch: better heuristics for detecting attachments in headers in imap
- From: Jose Dapena Paz <jdapena igalia com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Patch: better heuristics for detecting attachments in headers in imap
- Date: Fri, 29 Feb 2008 09:32:47 +0100
Hi,
This patch improves a bit the heuristics to know if a message has
attachments inside. It retrieves the content type obtained in imap, and,
if it's a multipart/mixed, then we assume the message has attachments.
We also unref the message we use to get information later, to analyse
properly the headers of the message.
Changelog entry:
* libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c:
(message_from_data): improve the heuristics to know if a message has
attachments. First, we don't unref the message too early, so we can
analyse the message headers. Second, we use the content type. If it's
a multipart/mixed, then we assume it has attachments.
--
Jose Dapena Paz <jdapena igalia com>
Igalia
Index: ChangeLog
===================================================================
--- ChangeLog (revision 3437)
+++ ChangeLog (working copy)
@@ -1,3 +1,11 @@
+2008-02-29 Jose Dapena Paz <jdapena igalia com>
+
+ * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c:
+ (message_from_data): improve the heuristics to know if a message has
+ attachments. First, we don't unref the message too early, so we can
+ analyse the message headers. Second, we use the content type. If it's
+ a multipart/mixed, then we assume it has attachments.
+
2008-02-28 Jose Dapena Paz <jdapena igalia com>
* libtinymail-camel/tny-camel-account.c:
Index: libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c (revision 3437)
+++ libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-folder.c (working copy)
@@ -2988,7 +2988,6 @@
}
mi = (CamelImapMessageInfo *)camel_folder_summary_info_new_from_message (folder->summary, msg);
- camel_object_unref (CAMEL_OBJECT (msg));
size = GPOINTER_TO_INT (g_datalist_get_data (&data, "RFC822.SIZE"));
if (size)
@@ -3004,13 +3003,20 @@
} else {
/* TNY TODO: This is a hack! But else we need to parse
* BODYSTRUCTURE (and I'm lazy). It needs fixing though. */
+ const char *content_type;
- if (size > 102400)
+ content_type = camel_header_raw_find (&h, "Content-Type", NULL);
+
+ if (content_type &&
+ (camel_strstrcase (content_type, "multipart/mixed") != NULL) ||
+ size > 102400)
((CamelMessageInfoBase *)mi)->flags |= CAMEL_MESSAGE_ATTACHMENTS;
/* ... it does */
}
+ camel_object_unref (CAMEL_OBJECT (msg));
+
/* This overrides Received: (although it wont be found by the messages
* fed to message_info_new_from_header, as this header is not in the
* query. Leaving them out makes retrieving summary consume a lot less
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]