* mu4e/mu-msg-part: better detection of body / attachments

This commit is contained in:
djcb 2012-08-02 15:48:03 +03:00
parent 99778d1314
commit b71a27b7c0
2 changed files with 17 additions and 4 deletions

View File

@ -362,6 +362,20 @@ handle_encrypted_part (MuMsg *msg,
return TRUE;
}
static gboolean
looks_like_body (GMimeObject *parent, MuMsgPart *msgpart)
{
if (parent &&
!GMIME_IS_MESSAGE_PART(parent) &&
!GMIME_IS_MULTIPART(parent))
return FALSE; /* probably not a body */
if (g_strcmp0 (msgpart->type, "text") != 0)
return FALSE; /* probably not a body */
return TRUE; /* maybe a body part */
}
/* call 'func' with information about this MIME-part */
static gboolean
handle_part (MuMsg *msg, GMimePart *part, GMimeObject *parent,
@ -385,9 +399,7 @@ handle_part (MuMsg *msg, GMimePart *part, GMimeObject *parent,
msgpart.part_type |= get_disposition ((GMimeObject*)part);
/* a top-level non-attachment text part is probably a body */
if ((!parent || GMIME_IS_MESSAGE(parent)) &&
((msgpart.part_type & MU_MSG_PART_TYPE_ATTACHMENT) == 0) &&
g_strcmp0 (msgpart.type, "text") == 0)
if (looks_like_body (parent, &msgpart))
msgpart.part_type |= MU_MSG_PART_TYPE_BODY;
msgpart.data = (gpointer)part;

View File

@ -378,7 +378,8 @@ is nil, and otherwise open it."
;; numbers and the part indices
(remove-if
(lambda (part)
(member 'inline (plist-get part :type)))
(or (member 'body (plist-get part :type))
(member 'inline (plist-get part :type))))
(plist-get msg :parts)))
(attstr
(mapconcat