From bfc8c1a241ae8c451e5c0c5be4ab48b91ee849ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ho=C3=A0=20Vi=C3=AAt=20Dinh?= Date: Wed, 29 Oct 2003 14:17:30 +0000 Subject: [PATCH] implemented multipart/alternative in MIME message viewer --- ChangeLog.claws | 5 ++++ configure.ac | 2 +- src/textview.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index 7f7e60584..4e06c7e4c 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,8 @@ +2003-10-29 [hoa] 0.9.6claws58 + + * src/textview.c + implemented multipart/alternative in MIME message viewer. + 2003-10-28 [christoph] 0.9.6claws57 * configure.ac diff --git a/configure.ac b/configure.ac index 555d35d87..5fb4af6d3 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=9 MICRO_VERSION=6 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=57 +EXTRA_VERSION=58 if test $EXTRA_VERSION -eq 0; then VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws else diff --git a/src/textview.c b/src/textview.c index b51a45214..53a53bdca 100644 --- a/src/textview.c +++ b/src/textview.c @@ -463,6 +463,7 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo) gtk_stext_thaw(text); } +#if 0 static gboolean add_parts_func(GNode *node, gpointer data) { MimeInfo *mimeinfo = (MimeInfo *) node->data; @@ -481,6 +482,72 @@ static void textview_add_parts(TextView *textview, MimeInfo *mimeinfo) g_node_traverse(mimeinfo->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1, add_parts_func, textview); } +#endif + +static void recursive_add_parts(TextView *textview, GNode *node) +{ + GNode * iter; + MimeInfo *mimeinfo; + + mimeinfo = (MimeInfo *) node->data; + + textview_add_part(textview, mimeinfo); + + if ((mimeinfo->type != MIMETYPE_MULTIPART) && + (mimeinfo->type != MIMETYPE_MESSAGE)) + return; + + if (strcasecmp(mimeinfo->subtype, "alternative") == 0) { + GNode * prefered_body; + int prefered_score; + + /* + text/plain : score 3 + text/* : score 2 + other : score 1 + */ + prefered_body = NULL; + prefered_score = 0; + + for(iter = g_node_first_child(node) ; iter != NULL ; + iter = g_node_next_sibling(iter)) { + int score; + MimeInfo * submime; + + score = 1; + submime = (MimeInfo *) iter->data; + if (submime->type == MIMETYPE_TEXT) + score = 2; + + if (submime->subtype != NULL) { + if (strcasecmp(submime->subtype, "plain") == 0) + score = 3; + } + + if (score > prefered_score) { + prefered_score = score; + prefered_body = iter; + } + } + + if (prefered_body != NULL) { + recursive_add_parts(textview, prefered_body); + } + } + else { + for(iter = g_node_first_child(node) ; iter != NULL ; + iter = g_node_next_sibling(iter)) { + recursive_add_parts(textview, iter); + } + } +} + +static void textview_add_parts(TextView *textview, MimeInfo *mimeinfo) +{ + g_return_if_fail(mimeinfo != NULL); + + recursive_add_parts(textview, mimeinfo->node); +} #define TEXT_INSERT(str) \ gtk_stext_insert(text, textview->msgfont, NULL, NULL, str, -1) -- 2.25.1