From 84682bfe2cd440b12773805b5c78391e3909cdce Mon Sep 17 00:00:00 2001 From: djcb Date: Tue, 24 Jul 2012 23:38:57 +0300 Subject: [PATCH] * mu-msg-view: better detection of signed/encrypted parts --- lib/mu-msg-file.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/lib/mu-msg-file.c b/lib/mu-msg-file.c index 298ced54..31c7d89a 100644 --- a/lib/mu-msg-file.c +++ b/lib/mu-msg-file.c @@ -259,6 +259,12 @@ looks_like_attachment (GMimeObject *part) static void msg_cflags_cb (GMimeObject *parent, GMimeObject *part, MuFlags *flags) { + if (GMIME_IS_MULTIPART_SIGNED(part)) + *flags |= MU_FLAG_SIGNED; + + if (GMIME_IS_MULTIPART_ENCRYPTED(part)) + *flags |= MU_FLAG_ENCRYPTED; + if (*flags & MU_FLAG_HAS_ATTACH) return; @@ -274,40 +280,14 @@ msg_cflags_cb (GMimeObject *parent, GMimeObject *part, MuFlags *flags) static MuFlags get_content_flags (MuMsgFile *self) { - GMimeContentType *ctype; MuFlags flags; - GMimeObject *part; - if (!GMIME_IS_MESSAGE(self->_mime_msg)) - return MU_FLAG_NONE; - - flags = 0; - g_mime_message_foreach (self->_mime_msg, - (GMimeObjectForeachFunc)msg_cflags_cb, - &flags); - - /* note: signed or encrypted status for a message is determined by - * the top-level mime-part - */ - if ((part = g_mime_message_get_mime_part(self->_mime_msg))) { - ctype = g_mime_object_get_content_type - (GMIME_OBJECT(part)); - if (!ctype) { - g_warning ("not a content type!"); - return 0; - } - - if (ctype) { - if (g_mime_content_type_is_type - (ctype,"*", "signed")) - flags |= MU_FLAG_SIGNED; - if (g_mime_content_type_is_type - (ctype,"*", "encrypted")) - flags |= MU_FLAG_ENCRYPTED; - } - } else - g_warning ("no top level mime part found"); + flags = MU_FLAG_NONE; + if (GMIME_IS_MESSAGE(self->_mime_msg)) + g_mime_message_foreach (self->_mime_msg, + (GMimeObjectForeachFunc)msg_cflags_cb, + &flags); return flags; }