2004-10-02 [colin] 0.9.12cvs119.1
authorColin Leroy <colin@colino.net>
Sat, 2 Oct 2004 16:33:17 +0000 (16:33 +0000)
committerColin Leroy <colin@colino.net>
Sat, 2 Oct 2004 16:33:17 +0000 (16:33 +0000)
* src/mainwindow.c
* src/messageview.c
* src/prefs_common.h
* src/procmime.c
* src/procmime.h
* src/textview.c
Sync with HEAD
* src/gtk/gtksctree.c
Close bug #608

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/gtk/gtksctree.c
src/mainwindow.c
src/messageview.c
src/prefs_common.h
src/procmime.c
src/procmime.h
src/textview.c

index a3ab88734b34d8ec26174742ffbb849714da2345..0191cbf9e8bd3a346442a2f22d0ff70558055311 100644 (file)
@@ -1,3 +1,15 @@
+2004-10-02 [colin]     0.9.12cvs119.1
+
+       * src/mainwindow.c
+       * src/messageview.c
+       * src/prefs_common.h
+       * src/procmime.c
+       * src/procmime.h
+       * src/textview.c
+               Sync with HEAD
+       * src/gtk/gtksctree.c
+               Close bug #608
+
 2004-10-01 [colin]     0.9.12cvs118.1
 
        * src/mimeview.c
index 94dbca2d98ec2796aae8644930eed6e55c00c3cb..5747f9d36f95ebf8967030e47a3d2e5e6e062e14 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.83.2.19 -r 1.83.2.20 src/mimeview.c; ) > 0.9.12cvs117.1.patchset
 ( cvs diff -u -r 1.1.4.4 -r 1.1.4.5 src/gtk/gtksctree.c; ) > 0.9.12cvs117.2.patchset
 ( cvs diff -u -r 1.83.2.20 -r 1.83.2.21 src/mimeview.c; ) > 0.9.12cvs118.1.patchset
+( cvs diff -u -r 1.274.2.20 -r 1.274.2.21 src/mainwindow.c; cvs diff -u -r 1.94.2.30 -r 1.94.2.31 src/messageview.c; cvs diff -u -r 1.103.2.9 -r 1.103.2.10 src/prefs_common.h; cvs diff -u -r 1.49.2.8 -r 1.49.2.9 src/procmime.c; cvs diff -u -r 1.17.2.3 -r 1.17.2.4 src/procmime.h; cvs diff -u -r 1.96.2.18 -r 1.96.2.19 src/textview.c; cvs diff -u -r 1.1.4.5 -r 1.1.4.6 src/gtk/gtksctree.c; ) > 0.9.12cvs119.1.patchset
index 369683340bbff16f89ec9c81dbd538e3185584ba..2007693a1bdcbd9e5d23b324daf18804b3cc4e68 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=118
+EXTRA_VERSION=119
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=.1
 
index b35fd4752961500026a1778ffaebabe62b4b5b3b..445a4b648ba6f6da7b2dc16949315dbe27fb2a39 100644 (file)
@@ -263,6 +263,7 @@ select_row (GtkSCTree *sctree, gint row, gint col, guint state)
        } else
                select_range (sctree, row);
        
+       GTK_CLIST_GET_CLASS(sctree)->refresh(GTK_CLIST(sctree));
        if (additive || range)
                gtk_clist_thaw (GTK_CLIST (sctree));
 }
index 8d02541720d561da09f4c2d50ee55844a9f5e1d8..244b6fbb6fe61e6932c09c032f169da94ee98732 100644 (file)
@@ -260,6 +260,10 @@ static void set_charset_cb         (MainWindow     *mainwin,
                                         guint           action,
                                         GtkWidget      *widget);
 
+static void set_decode_cb              (MainWindow     *mainwin,
+                                        guint           action,
+                                        GtkWidget      *widget);
+
 static void hide_read_messages   (MainWindow   *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
@@ -614,6 +618,22 @@ static GtkItemFactoryEntry mainwin_entries[] =
 #undef CODESET_SEPARATOR
 #undef CODESET_ACTION
 
+#define DECODE_SEPARATOR \
+       {N_("/_View/Decode/---"),               NULL, NULL, 0, "<Separator>"}
+#define DECODE_ACTION(action) \
+        NULL, set_decode_cb, action, "/View/Decode/Auto detect"
+       {N_("/_View/Decode"),           NULL, NULL, 0, "<Branch>"},
+       {N_("/_View/Decode/_Auto detect"),
+        NULL, set_decode_cb, 0, "<RadioItem>"},
+       {N_("/_View/Decode/---"),               NULL, NULL, 0, "<Separator>"},
+       {N_("/_View/Decode/_8bit"),             DECODE_ACTION(ENC_8BIT)},
+       {N_("/_View/Decode/_Quoted printable"), DECODE_ACTION(ENC_QUOTED_PRINTABLE)},
+       {N_("/_View/Decode/_Base64"),           DECODE_ACTION(ENC_BASE64)},
+       {N_("/_View/Decode/_Uuencode"),         DECODE_ACTION(ENC_X_UUENCODE)},
+
+#undef DECODE_SEPARATOR
+#undef DECODE_ACTION
+
        {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
        {N_("/_View/Open in new _window"),      "<control><alt>N", open_msg_cb, 0, NULL},
        {N_("/_View/Mess_age source"),          "<control>U", view_source_cb, 0, NULL},
@@ -2624,15 +2644,31 @@ static void set_charset_cb(MainWindow *mainwin, guint action,
 
        if (GTK_CHECK_MENU_ITEM(widget)->active) {
                str = conv_get_charset_str((CharSet)action);
-               g_free(prefs_common.force_charset);
-               prefs_common.force_charset = str ? g_strdup(str) : NULL;
-
+               
+               g_free(mainwin->messageview->forced_charset);
+               mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
+               procmime_force_charset(str);
+               
                summary_redisplay_msg(mainwin->summaryview);
                
                debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
        }
 }
 
+static void set_decode_cb(MainWindow *mainwin, guint action,
+                          GtkWidget *widget)
+{
+       const gchar *str;
+
+       if (GTK_CHECK_MENU_ITEM(widget)->active) {
+               procmime_force_encoding((EncodingType)action);
+
+               summary_redisplay_msg(mainwin->summaryview);
+               
+               debug_print("forced encoding: %d\n", action);
+       }
+}
+
 static void hide_read_messages (MainWindow *mainwin, guint action,
                                GtkWidget *widget)
 {
index 5ff5894942a0c9e2f86d0e79ea9a102ed0a33774..84b220ee3971865d8c6efe4bfd4549216b561754 100644 (file)
@@ -1289,6 +1289,8 @@ static void set_charset_cb(gpointer data, guint action, GtkWidget *widget)
                charset = conv_get_charset_str((CharSet)action);
                g_free(messageview->forced_charset);
                messageview->forced_charset = g_strdup(charset);
+               procmime_force_charset(charset);
+               
                messageview_show(messageview, messageview->msginfo, FALSE);
        }
 }
index 9a70d2cf4fd042bc8e7c3443aa8fc58dab453b0b..070e4f390aa7d6bf7cb48f1efb23704d0899802c 100644 (file)
@@ -30,6 +30,7 @@
 #include "summaryview.h"
 #include "codeconv.h"
 #include "textview.h"
+#include "procmime.h"
 
 typedef struct _PrefsCommon    PrefsCommon;
 
@@ -230,8 +231,6 @@ struct _PrefsCommon
        gint scroll_step;
        gboolean scroll_halfpage;
 
-       gchar *force_charset;
-
        gboolean show_other_header;
        GSList *disphdr_list;
 
index aa1ff357ae6a7878e1272d365edcbb030d335d12..b89338b28a16de29b73b3766cdf6d76600b35b46 100644 (file)
@@ -73,6 +73,23 @@ static gboolean procmime_mimeinfo_parameters_destroy(gpointer key, gpointer valu
        return TRUE;
 }
 
+static gchar *forced_charset = NULL;
+
+void procmime_force_charset(const gchar *str)
+{
+       g_free(forced_charset);
+       forced_charset = NULL;
+       if (str)
+               forced_charset = g_strdup(str);
+}
+
+static EncodingType forced_encoding = 0;
+
+void procmime_force_encoding(EncodingType encoding)
+{
+       forced_encoding = encoding;
+}
+
 static gboolean free_func(GNode *node, gpointer data)
 {
        MimeInfo *mimeinfo = (MimeInfo *) node->data;
@@ -231,9 +248,15 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
        FILE *outfp, *infp;
        struct stat statbuf;
 
+       EncodingType encoding = forced_encoding 
+                               ? forced_encoding
+                               : mimeinfo->encoding_type;
+                  
        g_return_val_if_fail(mimeinfo != NULL, FALSE);
 
-       if (mimeinfo->encoding_type == ENC_BINARY)
+       if (encoding == ENC_BINARY || 
+           encoding == ENC_7BIT ||
+           encoding == ENC_8BIT)
                return TRUE;
 
        infp = fopen(mimeinfo->filename, "rb");
@@ -251,13 +274,13 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
 
        readend = mimeinfo->offset + mimeinfo->length;
 
-       if (mimeinfo->encoding_type == ENC_QUOTED_PRINTABLE) {
+       if (encoding == ENC_QUOTED_PRINTABLE) {
                while ((ftell(infp) < readend) && (fgets(buf, sizeof(buf), infp) != NULL)) {
                        gint len;
                        len = qp_decode_line(buf);
                        fwrite(buf, len, 1, outfp);
                }
-       } else if (mimeinfo->encoding_type == ENC_BASE64) {
+       } else if (encoding == ENC_BASE64) {
                gchar outbuf[BUFFSIZE];
                gint len;
                Base64Decoder *decoder;
@@ -272,7 +295,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
                        fwrite(outbuf, sizeof(gchar), len, outfp);
                }
                base64_decoder_free(decoder);
-       } else if (mimeinfo->encoding_type == ENC_X_UUENCODE) {
+       } else if (encoding == ENC_X_UUENCODE) {
                gchar outbuf[BUFFSIZE];
                gint len;
                gboolean flag = FALSE;
@@ -489,9 +512,9 @@ FILE *procmime_get_text_content(MimeInfo *mimeinfo)
                return NULL;
        }
 
-       src_codeset = prefs_common.force_charset
-               ? prefs_common.force_charset : 
-               procmime_mimeinfo_get_parameter(mimeinfo, "charset");
+       src_codeset = forced_charset
+                     ? forced_charset : 
+                     procmime_mimeinfo_get_parameter(mimeinfo, "charset");
 
        renderer = NULL;
 
@@ -988,10 +1011,7 @@ void procmime_parse_message_rfc822(MimeInfo *mimeinfo)
        FILE *fp;
        gint mime_major, mime_minor;
 
-       if (mimeinfo->encoding_type != ENC_BINARY && 
-          mimeinfo->encoding_type != ENC_7BIT && 
-          mimeinfo->encoding_type != ENC_8BIT)
-               procmime_decode_content(mimeinfo);
+       procmime_decode_content(mimeinfo);
 
        fp = fopen(mimeinfo->filename, "rb");
        if (fp == NULL) {
@@ -1060,10 +1080,7 @@ void procmime_parse_multipart(MimeInfo *mimeinfo)
                return;
        boundary_len = strlen(boundary);
 
-       if (mimeinfo->encoding_type != ENC_BINARY && 
-           mimeinfo->encoding_type != ENC_7BIT && 
-           mimeinfo->encoding_type != ENC_8BIT)
-               procmime_decode_content(mimeinfo);
+       procmime_decode_content(mimeinfo);
 
        fp = fopen(mimeinfo->filename, "rb");
        if (fp == NULL) {
index d7f84efe1d005b7c1a8d80311a6c6ffb72678780..c628d212e256cec722e3468dcc08960fbf25baea 100644 (file)
@@ -192,9 +192,10 @@ const gchar *procmime_get_encoding_str             (EncodingType    encoding);
 MimeInfo *procmime_scan_file                   (gchar          *filename);
 MimeInfo *procmime_scan_queue_file             (gchar          *filename);
 const gchar *procmime_get_type_str             (MimeMediaType   type);
-gchar *procmime_get_content_type_str           (MimeMediaType type,
-                                                const char *subtype);
-
+gchar *procmime_get_content_type_str           (MimeMediaType   type,
+                                                const char     *subtype);
+void procmime_force_charset                    (const gchar    *str);
+void procmime_force_encoding                   (EncodingType    encoding);
 void renderer_read_config(void);
 void renderer_write_config(void);
 
index 5056b2119a716c407070f9c380662293fca5cccf..beb6f34bcdb5597a0b1329fae771f4454a8de942 100644 (file)
@@ -119,8 +119,7 @@ static void textview_add_part               (TextView       *textview,
 static void textview_add_parts         (TextView       *textview,
                                         MimeInfo       *mimeinfo);
 static void textview_write_body                (TextView       *textview,
-                                        MimeInfo       *mimeinfo,
-                                        const gchar    *charset);
+                                        MimeInfo       *mimeinfo);
 static void textview_show_html         (TextView       *textview,
                                         FILE           *fp,
                                         CodeConverter  *conv);
@@ -310,21 +309,12 @@ void textview_show_message(TextView *textview, MimeInfo *mimeinfo,
                           const gchar *file)
 {
        FILE *fp;
-       const gchar *charset = NULL;
 
        if ((fp = fopen(file, "rb")) == NULL) {
                FILE_OP_ERROR(file, "fopen");
                return;
        }
 
-       if (textview->messageview->forced_charset)
-               charset = textview->messageview->forced_charset;
-       else if (prefs_common.force_charset)
-               charset = prefs_common.force_charset;
-       else
-               charset = procmime_mimeinfo_get_parameter(mimeinfo, "charset");
-
-       textview_set_font(textview, charset);
        textview_clear(textview);
 
        textview_add_parts(textview, mimeinfo);
@@ -337,7 +327,6 @@ void textview_show_message(TextView *textview, MimeInfo *mimeinfo,
 void textview_show_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp)
 {
        GtkTextView *text;
-       const gchar *charset = NULL;
 
        g_return_if_fail(mimeinfo != NULL);
        g_return_if_fail(fp != NULL);
@@ -352,21 +341,12 @@ void textview_show_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp)
        if (fseek(fp, mimeinfo->offset, SEEK_SET) < 0)
                perror("fseek");
 
-       if (textview->messageview->forced_charset)
-               charset = textview->messageview->forced_charset;
-       else if (prefs_common.force_charset)
-               charset = prefs_common.force_charset;
-       else
-               charset = procmime_mimeinfo_get_parameter(mimeinfo, "charset");
-
-       textview_set_font(textview, charset);
-
        textview_clear(textview);
 
        if (mimeinfo->type == MIMETYPE_MULTIPART)
                textview_add_parts(textview, mimeinfo);
        else
-               textview_write_body(textview, mimeinfo, charset);
+               textview_write_body(textview, mimeinfo);
 
 }
 
@@ -376,7 +356,6 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
        GtkTextBuffer *buffer;
        GtkTextIter iter;
        gchar buf[BUFFSIZE];
-       const gchar *charset = NULL;
        GPtrArray *headers = NULL;
        const gchar *name;
        gint charcount;
@@ -423,38 +402,11 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
        } else if (mimeinfo->disposition != DISPOSITIONTYPE_ATTACHMENT) {
                if (prefs_common.display_header && (charcount > 0))
                        gtk_text_buffer_insert(buffer, &iter, "\n", 1);
-               if (textview->messageview->forced_charset)
-                       charset = textview->messageview->forced_charset;
-               else if (prefs_common.force_charset)
-                       charset = prefs_common.force_charset;
-               else
-                       charset = procmime_mimeinfo_get_parameter(mimeinfo, "charset");
 
-               textview_write_body(textview, mimeinfo, charset);
+               textview_write_body(textview, mimeinfo);
        }
 }
 
-#if 0
-static gboolean add_parts_func(GNode *node, gpointer data)
-{
-       MimeInfo *mimeinfo = (MimeInfo *) node->data;
-       TextView *textview = (TextView *) data;
-
-       g_return_val_if_fail(mimeinfo != NULL, FALSE);
-
-       textview_add_part(textview, mimeinfo);
-
-       return FALSE;
-}
-
-static void textview_add_parts(TextView *textview, MimeInfo *mimeinfo)
-{
-       g_return_if_fail(mimeinfo != NULL);
-
-       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;
@@ -571,21 +523,25 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo)
 
 #undef TEXT_INSERT
 
-static void textview_write_body(TextView *textview, MimeInfo *mimeinfo,
-                               const gchar *charset)
+static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
 {
        FILE *tmpfp;
        gchar buf[BUFFSIZE];
        CodeConverter *conv;
+       const gchar *charset;
+       
+       if (textview->messageview->forced_charset)
+               charset = textview->messageview->forced_charset;
+       else
+               charset = procmime_mimeinfo_get_parameter(mimeinfo, "charset");
+
+       textview_set_font(textview, charset);
 
        conv = conv_code_converter_new(charset);
 
        textview->is_in_signature = FALSE;
 
-       if(mimeinfo->encoding_type != ENC_BINARY && 
-          mimeinfo->encoding_type != ENC_7BIT && 
-          mimeinfo->encoding_type != ENC_8BIT)
-               procmime_decode_content(mimeinfo);
+       procmime_decode_content(mimeinfo);
 
        if (!g_strcasecmp(mimeinfo->subtype, "html")) {
                gchar *filename;