Skip to content

Commit

Permalink
mt, chunk: always return text/plain when html == false.
Browse files Browse the repository at this point in the history
  • Loading branch information
gauteh committed Aug 30, 2018
1 parent 5fc72aa commit 9adbb0d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/chunk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 (
Expand Down Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions src/chunk.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/message_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,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<Chunk> c) { return (!c->preferred); })) {
[html](refptr<Chunk> c) { return !c->is_content_type ("text", html ? "html" : "plain"); })) {
use = true;
} else {
use = false;
Expand All @@ -333,7 +333,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);
}

Expand Down

0 comments on commit 9adbb0d

Please sign in to comment.