diff --git a/src/chunk.cc b/src/chunk.cc index 044aa376d..762a8475b 100644 --- a/src/chunk.cc +++ b/src/chunk.cc @@ -238,6 +238,10 @@ namespace Astroid { } + bool Chunk::is_content_type (const char * major, const char * minor) { + return (mime_object != NULL) && g_mime_content_type_is_type (content_type, major, minor); + } + ustring Chunk::viewable_text (bool html = true, bool verbose) { if (isencrypted && !crypt->decrypted) { if (verbose) { @@ -258,7 +262,7 @@ namespace Astroid { LOG (debug) << "chunk: body: part"; - if (g_mime_content_type_is_type (content_type, "text", "plain")) { + if (is_content_type ("text", "plain")) { LOG (debug) << "chunk: plain text (out html: " << html << ")"; GMimeDataWrapper * content = g_mime_part_get_content ( @@ -328,7 +332,7 @@ namespace Astroid { content_stream = filter_stream; - } else if (g_mime_content_type_is_type (content_type, "text", "html")) { + } else if (is_content_type ("text", "html")) { LOG (debug) << "chunk: html text"; GMimeDataWrapper * content = g_mime_part_get_content ( diff --git a/src/chunk.hh b/src/chunk.hh index eaea150d9..30d224b0e 100644 --- a/src/chunk.hh +++ b/src/chunk.hh @@ -30,6 +30,7 @@ namespace Astroid { ustring content_id; ustring get_content_type (); + bool is_content_type (const char* major, const char* minor); ustring viewable_text (bool, bool verbose = false); diff --git a/src/message_thread.cc b/src/message_thread.cc index 589b83044..2366ac348 100644 --- a/src/message_thread.cc +++ b/src/message_thread.cc @@ -324,13 +324,13 @@ namespace Astroid { bool use = false; if (c->siblings.size() >= 1) { - if (c->preferred) { + if (c->is_content_type ("text", html ? "html" : "plain")) { use = true; } else { /* check if there are any other preferred */ if (all_of (c->siblings.begin (), c->siblings.end (), - [](refptr c) { return (!c->preferred); })) { + [html](refptr c) { return !c->is_content_type ("text", html ? "html" : "plain"); })) { use = true; } else { use = false; @@ -341,7 +341,7 @@ namespace Astroid { } if (use) { - if (c->viewable && (c->preferred || html || fallback_html)) { + if (c->viewable && (c->is_content_type ("text", html ? "html" : "plain") || fallback_html)) { body += c->viewable_text (html); }