Re: Attachements with iso-8859-15
- From: Peter Bloomfield <peterbloomfield bellsouth net>
- To: "Jean-Luc Coulon (f5ibh)" <jean-luc coulon wanadoo fr>
- Cc: Balsa-List <balsa-list gnome org>
- Subject: Re: Attachements with iso-8859-15
- Date: Wed, 26 Jan 2005 14:44:08 +0000
On 01/26/2005 06:26:49 AM, Jean-Luc Coulon (f5ibh) wrote:
Hi,
If I attach a mail with a mime type of text
x-gettext-translation (french translation for a debconf dialog
of translation of a program), I'm asked for the character
encoding. The default value is iso-8859-1.
Is there really the need to ask for the encoding as it s coded
inside the message and even a file command gives the iso8859 ?
Regards
Jean-Luc
Hi Jean-Luc!
The attached patch replaces Balsa's efforts to find an
appropriate charset with GMime's _charset_best method. It works
in a simple test, but I don't run into charset issues very
often. Could you see if it resolves some of these issues?
Thanks!
Peter
? .RData
? .Rhistory
? Changes
? images/16x16
? images/24x24
? src/.sendmsg-window.c.swp
Index: mkinstalldirs
===================================================================
RCS file: /cvs/gnome/balsa/mkinstalldirs,v
retrieving revision 1.1
diff -u -r1.1 mkinstalldirs
--- mkinstalldirs 22 May 2004 21:05:29 -0000 1.1
+++ mkinstalldirs 26 Jan 2005 14:37:01 -0000
@@ -4,37 +4,108 @@
# Created: 1993-05-16
# Public domain
-# $Id: mkinstalldirs,v 1.1 2004/05/22 21:05:29 pawels Exp $
-
errstatus=0
+dirmode=""
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
+
+# process command line arguments
+while test $# -gt 0 ; do
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage" 1>&2
+ exit 0
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
+done
+
+for file
+do
+ if test -d "$file"; then
+ shift
+ else
+ break
+ fi
+done
+
+case $# in
+ 0) exit 0 ;;
+esac
+
+case $dirmode in
+ '')
+ if mkdir -p -- . 2>/dev/null; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ fi
+ ;;
+esac
for file
do
- set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
- shift
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
- pathcomp=
- for d
- do
- pathcomp="$pathcomp$d"
- case "$pathcomp" in
- -* ) pathcomp=./$pathcomp ;;
- esac
-
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp"
-
- mkdir "$pathcomp" || lasterr=$?
-
- if test ! -d "$pathcomp"; then
- errstatus=$lasterr
- fi
- fi
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=""
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
+ fi
+ fi
+ fi
+ fi
- pathcomp="$pathcomp/"
- done
+ pathcomp="$pathcomp/"
+ done
done
exit $errstatus
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# End:
# mkinstalldirs ends here
Index: libbalsa/message.c
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/message.c,v
retrieving revision 1.190
diff -u -r1.190 message.c
--- libbalsa/message.c 17 Jan 2005 18:41:54 -0000 1.190
+++ libbalsa/message.c 26 Jan 2005 14:37:02 -0000
@@ -283,31 +283,6 @@
return charset;
}
-/* Note: libbalsa_message_charset returns a pointer to a newly allocated
- * string containing the canonical form of the charset field, or NULL.
- * When the pointer is nonNULL, the string must be deallocated with
- * g_free. */
-gchar *
-libbalsa_message_charset(LibBalsaMessage * message)
-{
- LibBalsaMessageBody *body;
- const gchar *charset;
- const char *tmp;
- g_return_val_if_fail(message != NULL, NULL);
- body = message->body_list;
- g_return_val_if_fail(body != NULL, NULL);
-
- charset = body->charset;
- if (!charset) {
- charset = libbalsa_message_body_charset(body);
- if (!charset)
- return NULL;
- }
- tmp = g_mime_charset_canon_name(charset);
- return g_strdup(tmp);
-}
-
-
static void
canonize_header_value(gchar *value)
{
Index: libbalsa/message.h
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/message.h,v
retrieving revision 1.81
diff -u -r1.81 message.h
--- libbalsa/message.h 17 Jan 2005 18:41:54 -0000 1.81
+++ libbalsa/message.h 26 Jan 2005 14:37:02 -0000
@@ -309,7 +309,6 @@
gchar **libbalsa_create_hdr_pair(const gchar * name, gchar * value);
const gchar *libbalsa_message_pathname(LibBalsaMessage * message);
-gchar *libbalsa_message_charset(LibBalsaMessage * message);
const gchar *libbalsa_message_body_charset(LibBalsaMessageBody * body);
gboolean libbalsa_message_is_multipart(LibBalsaMessage * message);
gboolean libbalsa_message_is_partial(LibBalsaMessage * message,
Index: libbalsa/send.c
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/send.c,v
retrieving revision 1.242
diff -u -r1.242 send.c
--- libbalsa/send.c 17 Jan 2005 18:41:54 -0000 1.242
+++ libbalsa/send.c 26 Jan 2005 14:37:03 -0000
@@ -281,8 +281,9 @@
stream = g_mime_stream_mem_new();
g_mime_stream_write(stream, content, strlen(content));
- wrapper = g_mime_data_wrapper_new();
- g_mime_data_wrapper_set_stream(wrapper, stream);
+ wrapper =
+ g_mime_data_wrapper_new_with_stream(stream,
+ GMIME_PART_ENCODING_DEFAULT);
g_object_unref(stream);
g_mime_part_set_content_object(mime_part, wrapper);
@@ -300,8 +301,6 @@
charset=body->charset;
- g_return_val_if_fail(charset, NULL);
-
if (body->content_type) {
/* Use the suplied mime type */
gchar *type, *subtype;
@@ -323,7 +322,9 @@
g_mime_part_set_content_disposition(mime_part, GMIME_DISPOSITION_INLINE);
g_mime_part_set_encoding(mime_part, encoding_style);
g_mime_object_set_content_type_parameter(GMIME_OBJECT(mime_part),
- "charset", charset);
+ "charset",
+ charset ? charset :
+ "us-ascii");
if (flow) {
g_mime_object_set_content_type_parameter(GMIME_OBJECT(mime_part),
"DelSp", "Yes");
@@ -331,9 +332,9 @@
"Format", "Flowed");
}
- if (g_ascii_strcasecmp(charset, "UTF-8")!=0 &&
- g_ascii_strcasecmp(charset, "UTF8")!=0 &&
- g_ascii_strcasecmp(charset, "US-ASCII")!=0)
+ if (charset &&
+ g_ascii_strcasecmp(charset, "UTF-8")!=0 &&
+ g_ascii_strcasecmp(charset, "UTF8")!=0)
{
GMimeStream *stream, *filter_stream;
GMimeFilter *filter;
@@ -343,18 +344,18 @@
filter_stream = g_mime_stream_filter_new_with_stream(stream);
filter = g_mime_filter_charset_new("UTF-8", charset);
g_mime_stream_filter_add(GMIME_STREAM_FILTER(filter_stream), filter);
+ g_object_unref(G_OBJECT(filter));
g_mime_stream_write(filter_stream, body->buffer, strlen(body->buffer));
+ g_object_unref(filter_stream);
- wrapper = g_mime_data_wrapper_new();
- g_mime_data_wrapper_set_stream(wrapper, stream);
- g_mime_data_wrapper_set_encoding (wrapper, GMIME_PART_ENCODING_DEFAULT);
- g_mime_part_set_content_object(mime_part, wrapper);
+ wrapper =
+ g_mime_data_wrapper_new_with_stream(stream,
+ GMIME_PART_ENCODING_DEFAULT);
+ g_object_unref(stream);
+ g_mime_part_set_content_object(mime_part, wrapper);
g_object_unref(G_OBJECT(wrapper));
- g_object_unref(G_OBJECT(filter));
- g_object_unref(filter_stream);
- g_object_unref(stream);
} else
lbs_set_content(mime_part, body->buffer);
Index: src/sendmsg-window.c
===================================================================
RCS file: /cvs/gnome/balsa/src/sendmsg-window.c,v
retrieving revision 1.509
diff -u -r1.509 sendmsg-window.c
--- src/sendmsg-window.c 18 Jan 2005 04:02:40 -0000 1.509
+++ src/sendmsg-window.c 26 Jan 2005 14:37:07 -0000
@@ -132,8 +132,6 @@
static void address_book_response(GtkWidget * ab, gint response,
LibBalsaAddressEntry * address_entry);
-static gint set_locale(BalsaSendmsg *, gint);
-
#if !defined(ENABLE_TOUCH_UI)
static void edit_with_gnome(GtkWidget* widget, BalsaSendmsg* bsmsg);
#endif
@@ -939,7 +937,6 @@
g_object_unref(G_OBJECT(bsmsg->bad_address_style));
quit_on_close = bsmsg->quit_on_close;
g_free(bsmsg->fcc_url);
- g_free(bsmsg->charset);
if (bsmsg->spell_checker)
gtk_widget_destroy(bsmsg->spell_checker);
@@ -3540,20 +3537,8 @@
locales_sorted = TRUE;
}
/* find the preferred charset... */
- selected_pos = find_locale_index_by_locale(setlocale(LC_CTYPE, NULL));
- if (bsmsg->charset
- && g_ascii_strcasecmp(locales[selected_pos].charset,
- bsmsg->charset) != 0) {
- for(i=0;
- i<ELEMENTS(locales) &&
- g_ascii_strcasecmp(locales[i].charset, bsmsg->charset) != 0;
- i++)
- ;
- selected_pos = (i == ELEMENTS(locales)) ?
- find_locale_index_by_locale("en_US") : i;
- }
-
- set_locale(bsmsg, selected_pos);
+ bsmsg->locale_index = selected_pos =
+ find_locale_index_by_locale(setlocale(LC_CTYPE, NULL));
for(i=0; i<ELEMENTS(locales); i++) {
GtkWidget *w =
@@ -3683,8 +3668,7 @@
|| (type != SEND_NORMAL && message != NULL));
bsmsg = g_malloc(sizeof(BalsaSendmsg));
- bsmsg->charset = NULL;
- bsmsg->locale = NULL;
+ bsmsg->locale_index = (guint) -1;
bsmsg->fcc_url = NULL;
bsmsg->ident = balsa_app.current_ident;
bsmsg->update_config = FALSE;
@@ -3844,8 +3828,6 @@
gnome_app_set_contents(GNOME_APP(window), main_box);
/* set the menus - and language index */
- if (message && !bsmsg->charset)
- bsmsg->charset = libbalsa_message_charset(message);
init_menus(bsmsg);
/* Connect to "text-changed" here, so that we catch the initial text
@@ -4354,8 +4336,8 @@
/* Disable undo and redo, because buffer2 was changed. */
sw_buffer_set_undo(bsmsg, FALSE, FALSE);
- body->charset = g_strdup(libbalsa_text_attr_string(body->buffer) ?
- bsmsg->charset : "us-ascii");
+ body->charset =
+ g_strdup(g_mime_charset_best(body->buffer, strlen(body->buffer)));
libbalsa_message_append_part(message, body);
/* add attachments */
@@ -4374,35 +4356,6 @@
return message;
}
-static gboolean
-is_charset_ok(BalsaSendmsg *bsmsg)
-{
- gchar *tmp, *res;
- gsize bytes_read, bytes_written;
- GError *err = NULL;
- GtkTextIter start, end;
- GtkTextBuffer *buffer =
- gtk_text_view_get_buffer(GTK_TEXT_VIEW(bsmsg->text));
-
- gtk_text_buffer_get_bounds(buffer, &start, &end);
- tmp = gtk_text_iter_get_text(&start, &end);
- res = g_convert(tmp, strlen(tmp), bsmsg->charset, "UTF-8",
- &bytes_read, &bytes_written, &err);
- g_free(tmp);
- g_free(res);
- if (err) {
- balsa_information_parented
- (GTK_WINDOW(bsmsg->window),
- LIBBALSA_INFORMATION_ERROR,
- _("The message cannot be encoded in charset %s.\n"
- "Please choose a language for this message.\n"
- "For multi-language messages, choose UTF-8."),
- bsmsg->charset);
- g_error_free(err);
- return FALSE;
- }
- return TRUE;
-}
/* "send message" menu and toolbar callback.
* FIXME: automatic charset detection, as libmutt does for strings?
*/
@@ -4419,11 +4372,6 @@
if (!is_ready_to_send(bsmsg))
return FALSE;
- if (balsa_app.debug)
- fprintf(stderr, "sending with charset: %s\n", bsmsg->charset);
-
- if(!is_charset_ok(bsmsg))
- return FALSE;
#ifdef HAVE_GPGME
if ((bsmsg->gpg_mode & LIBBALSA_PROTECT_OPENPGP) != 0 &&
(bsmsg->gpg_mode & LIBBALSA_PROTECT_MODE) != 0 &&
@@ -4547,8 +4495,6 @@
gboolean successp;
LibBalsaMessage *message;
- if(!is_charset_ok(bsmsg))
- return FALSE;
message = bsmsg2message(bsmsg);
if ((bsmsg->type == SEND_REPLY || bsmsg->type == SEND_REPLY_ALL ||
@@ -5041,20 +4987,6 @@
check_readiness(bsmsg);
}
-/* set_locale:
- bsmsg is the compose window,
- idx - corresponding entry index in locales.
-*/
-
-static gint
-set_locale(BalsaSendmsg * bsmsg, gint idx)
-{
- g_free(bsmsg->charset);
- bsmsg->charset = g_strdup(locales[idx].charset);
- bsmsg->locale = locales[idx].locale;
- return FALSE;
-}
-
/* spell_check_cb
*
* Start the spell check
@@ -5083,9 +5015,11 @@
/* configure the spell checker */
balsa_spell_check_set_text(sc, text_view);
- balsa_spell_check_set_language(sc, bsmsg->locale);
-
- balsa_spell_check_set_character_set(sc, bsmsg->charset);
+ balsa_spell_check_set_language(sc,
+ locales[bsmsg->locale_index].locale);
+ balsa_spell_check_set_character_set(sc,
+ locales[bsmsg->locale_index].
+ charset);
balsa_spell_check_set_module(sc,
spell_check_modules_name
[balsa_app.module]);
@@ -5113,11 +5047,10 @@
static void
lang_set_cb(GtkWidget * w, BalsaSendmsg * bsmsg)
{
- if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))) {
- gint i = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),
- GNOMEUIINFO_KEY_UIDATA));
- set_locale(bsmsg, i);
- }
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
+ bsmsg->locale_index =
+ GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),
+ GNOMEUIINFO_KEY_UIDATA));
}
/* sendmsg_window_new_from_list:
Index: src/sendmsg-window.h
===================================================================
RCS file: /cvs/gnome/balsa/src/sendmsg-window.h,v
retrieving revision 1.68
diff -u -r1.68 sendmsg-window.h
--- src/sendmsg-window.h 13 Jan 2005 19:56:59 -0000 1.68
+++ src/sendmsg-window.h 26 Jan 2005 14:37:08 -0000
@@ -67,8 +67,7 @@
LibBalsaMessage *orig_message;
SendType type;
/* language selection related data */
- gchar *charset;
- const gchar *locale;
+ guint locale_index;
GtkWidget *current_language_menu;
/* identity related data */
LibBalsaIdentity* ident;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]