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
This commit is contained in:
Colin Leroy 2004-10-02 16:33:17 +00:00
parent d9855da4d9
commit fa436da0b1
10 changed files with 106 additions and 81 deletions

View 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

View file

@ -188,3 +188,4 @@
( 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

View 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

View 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));
}

View 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)
{

View 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);
}
}

View 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;

View 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) {

View 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);

View 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;