implemented multipart/alternative in MIME message viewer
authorHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Wed, 29 Oct 2003 14:17:30 +0000 (14:17 +0000)
committerHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Wed, 29 Oct 2003 14:17:30 +0000 (14:17 +0000)
ChangeLog.claws
configure.ac
src/textview.c

index 7f7e6058451b4cbd0c7b1b1a96efa5e5cbfa80d2..4e06c7e4c0ea400697cf291a703a702310398e28 100644 (file)
@@ -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
 2003-10-28 [christoph] 0.9.6claws57
 
        * configure.ac
index 555d35d87304f72311d254d1b8852ec12e6e4db7..5fb4af6d306497495c4969428388a5a0a2495fca 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
 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
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index b51a452141f851a4884dc112dd211576b0735c94..53a53bdca44ff62b7fd30d861dd6e2de0b2b7bb0 100644 (file)
@@ -463,6 +463,7 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
        gtk_stext_thaw(text);
 }
 
        gtk_stext_thaw(text);
 }
 
+#if 0
 static gboolean add_parts_func(GNode *node, gpointer data)
 {
        MimeInfo *mimeinfo = (MimeInfo *) node->data;
 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);
 }
 
        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)
 
 #define TEXT_INSERT(str) \
        gtk_stext_insert(text, textview->msgfont, NULL, NULL, str, -1)