aboutsummaryrefslogtreecommitdiffstats
path: root/composer
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2004-04-16 02:55:33 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-04-16 02:55:33 +0800
commitf57b228500d5511f3985c6986a26d2aaa732d42c (patch)
treecedf9cbca4252083794fc7c55666cc2a38431386 /composer
parent6313647810adb53640b429819dbd50a98aa78fe2 (diff)
downloadgsoc2013-evolution-f57b228500d5511f3985c6986a26d2aaa732d42c.tar.gz
gsoc2013-evolution-f57b228500d5511f3985c6986a26d2aaa732d42c.tar.zst
gsoc2013-evolution-f57b228500d5511f3985c6986a26d2aaa732d42c.zip
Same idea here as with build_mesage(), don't convert th gconf charset
2004-04-15 Jeffrey Stedfast <fejj@ximian.com> * e-msg-composer-attachment-bar.c (attach_to_multipart): Same idea here as with build_mesage(), don't convert th gconf charset setting to the iconv name before setting it on the mime part. * e-msg-composer.c (best_charset): Now returns a malloc'd string bufefr containing the charset that has NOT been converted to the iconv name. This is important in order to avoid using the iconv charset name which may or may not necessarily be the IANA blessed name. (composer_get_default_charset_setting): Changed to always return the actual value in the settings (eg. don't return the iconv name). (build_message): Updated for changes to best_charset(). Set the actual charset name as the charset param and then get the iconv_charset from that. Use iconv_charset everywhere else. (get_file_content): Updated for changes to get_default_charset_setting(). (setup_ui): Same. svn path=/trunk/; revision=25487
Diffstat (limited to 'composer')
-rw-r--r--composer/ChangeLog21
-rw-r--r--composer/e-msg-composer-attachment-bar.c32
-rw-r--r--composer/e-msg-composer.c81
3 files changed, 82 insertions, 52 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index b4c712c175..39441ef567 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,24 @@
+2004-04-15 Jeffrey Stedfast <fejj@ximian.com>
+
+ * e-msg-composer-attachment-bar.c (attach_to_multipart): Same idea
+ here as with build_mesage(), don't convert th gconf charset
+ setting to the iconv name before setting it on the mime part.
+
+ * e-msg-composer.c (best_charset): Now returns a malloc'd string
+ bufefr containing the charset that has NOT been converted to the
+ iconv name. This is important in order to avoid using the iconv
+ charset name which may or may not necessarily be the IANA blessed
+ name.
+ (composer_get_default_charset_setting): Changed to always return
+ the actual value in the settings (eg. don't return the iconv
+ name).
+ (build_message): Updated for changes to best_charset(). Set the
+ actual charset name as the charset param and then get the
+ iconv_charset from that. Use iconv_charset everywhere else.
+ (get_file_content): Updated for changes to
+ get_default_charset_setting().
+ (setup_ui): Same.
+
2004-04-13 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer.c (get_file_content): To be on the safe side
diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c
index 5f035ec410..d2f0ff4d48 100644
--- a/composer/e-msg-composer-attachment-bar.c
+++ b/composer/e-msg-composer-attachment-bar.c
@@ -743,29 +743,31 @@ e_msg_composer_attachment_bar_new (GtkAdjustment *adj)
return GTK_WIDGET (new);
}
-static const char *
+static char *
get_default_charset (void)
{
GConfClient *gconf;
- const char *charset;
- char *buf;
+ const char *locale;
+ char *charset;
gconf = gconf_client_get_default ();
- buf = gconf_client_get_string (gconf, "/apps/evolution/mail/composer/charset", NULL);
- if (buf && buf[0] == '\0') {
- g_free (buf);
- buf = NULL;
+ charset = gconf_client_get_string (gconf, "/apps/evolution/mail/composer/charset", NULL);
+
+ if (!charset || charset[0] == '\0') {
+ g_free (charset);
+ charset = gconf_client_get_string (gconf, "/apps/evolution/mail/format/charset", NULL);
+ if (charset && charset[0] == '\0') {
+ g_free (charset);
+ charset = NULL;
+ }
}
g_object_unref (gconf);
- if (buf != NULL) {
- charset = e_iconv_charset_name (buf);
- g_free (buf);
- } else
- charset = e_iconv_locale_charset ();
+ if (!charset && (locale = e_iconv_locale_charset ()))
+ charset = g_strdup (locale);
- return charset;
+ return charset ? charset : g_strdup ("us-ascii");
}
static void
@@ -786,6 +788,7 @@ attach_to_multipart (CamelMultipart *multipart,
CamelMimeFilterBestenc *bestenc;
CamelStream *stream;
const char *charset;
+ char *buf = NULL;
char *type;
charset = camel_content_type_param (content_type, "charset");
@@ -808,7 +811,7 @@ attach_to_multipart (CamelMultipart *multipart,
default_charset = "us-ascii";
} else if (!charset) {
if (!default_charset)
- default_charset = get_default_charset ();
+ default_charset = buf = get_default_charset ();
/* FIXME: We should really check that this fits within the
default_charset and if not find one that does and/or
@@ -821,6 +824,7 @@ attach_to_multipart (CamelMultipart *multipart,
type = camel_content_type_format (content_type);
camel_mime_part_set_content_type (attachment->body, type);
g_free (type);
+ g_free (buf);
}
camel_object_unref (bestenc);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 8161f59f5b..c73ab320f0 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -280,40 +280,37 @@ best_encoding (GByteArray *buf, const char *charset)
return CAMEL_TRANSFER_ENCODING_BASE64;
}
-static const char *
+static char *
composer_get_default_charset_setting (void)
{
GConfClient *gconf;
- const char *charset;
- char *buf;
+ const char *locale;
+ char *charset;
gconf = gconf_client_get_default ();
- buf = gconf_client_get_string (gconf, "/apps/evolution/mail/composer/charset", NULL);
-
- if (buf == NULL || buf[0] == '\0') {
- g_free (buf);
- buf = gconf_client_get_string (gconf, "/apps/evolution/mail/format/charset", NULL);
- if (buf && buf[0] == '\0') {
- g_free (buf);
- buf = NULL;
+ charset = gconf_client_get_string (gconf, "/apps/evolution/mail/composer/charset", NULL);
+
+ if (!charset || charset[0] == '\0') {
+ g_free (charset);
+ charset = gconf_client_get_string (gconf, "/apps/evolution/mail/format/charset", NULL);
+ if (charset && charset[0] == '\0') {
+ g_free (charset);
+ charset = NULL;
}
}
g_object_unref (gconf);
- if (buf != NULL) {
- charset = e_iconv_charset_name (buf);
- g_free (buf);
- } else
- charset = e_iconv_locale_charset ();
+ if (!charset && (locale = e_iconv_locale_charset ()))
+ charset = g_strdup (locale);
- return charset ? charset : "us-ascii";
+ return charset ? charset : g_strdup ("us-ascii");
}
-static const char *
+static char *
best_charset (GByteArray *buf, const char *default_charset, CamelTransferEncoding *encoding)
{
- const char *charset;
+ char *charset;
/* First try US-ASCII */
*encoding = best_encoding (buf, "US-ASCII");
@@ -321,10 +318,9 @@ best_charset (GByteArray *buf, const char *default_charset, CamelTransferEncodin
return NULL;
/* Next try the user-specified charset for this message */
- charset = default_charset;
- *encoding = best_encoding (buf, charset);
+ *encoding = best_encoding (buf, default_charset);
if (*encoding != -1)
- return charset;
+ return g_strdup (default_charset);
/* Now try the user's default charset from the mail config */
charset = composer_get_default_charset_setting ();
@@ -333,13 +329,14 @@ best_charset (GByteArray *buf, const char *default_charset, CamelTransferEncodin
return charset;
/* Try to find something that will work */
- charset = camel_charset_best (buf->data, buf->len);
- if (!charset)
+ if (!(charset = (char *) camel_charset_best (buf->data, buf->len))) {
*encoding = CAMEL_TRANSFER_ENCODING_7BIT;
- else
- *encoding = best_encoding (buf, charset);
+ return NULL;
+ }
+
+ *encoding = best_encoding (buf, charset);
- return charset;
+ return g_strdup (charset);
}
static gboolean
@@ -403,15 +400,16 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
EMsgComposerHdrs *hdrs = E_MSG_COMPOSER_HDRS (composer->hdrs);
CamelDataWrapper *plain, *html, *current;
CamelTransferEncoding plain_encoding;
+ const char *iconv_charset = NULL;
GPtrArray *recipients = NULL;
CamelMultipart *body = NULL;
CamelContentType *type;
CamelMimeMessage *new;
- const char *charset = NULL;
CamelStream *stream;
CamelMimePart *part;
CamelException ex;
GByteArray *data;
+ char *charset;
int i;
if (composer->persist_stream_interface == CORBA_OBJECT_NIL)
@@ -454,14 +452,17 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
/* FIXME: we may want to do better than this... */
charset = best_charset (data, composer->charset, &plain_encoding);
type = camel_content_type_new ("text", "plain");
- if (charset)
+ if ((charset = best_charset (data, composer->charset, &plain_encoding))) {
camel_content_type_set_param (type, "charset", charset);
+ iconv_charset = e_iconv_charset_name (charset);
+ g_free (charset);
+ }
}
stream = camel_stream_mem_new_with_byte_array (data);
/* convert the stream to the appropriate charset */
- if (charset && strcasecmp (charset, "UTF-8") != 0) {
+ if (iconv_charset && g_ascii_strcasecmp (iconv_charset, "UTF-8") != 0) {
CamelStreamFilter *filter_stream;
CamelMimeFilterCharset *filter;
@@ -469,7 +470,7 @@ build_message (EMsgComposer *composer, gboolean save_html_object_data)
camel_object_unref (stream);
stream = (CamelStream *) filter_stream;
- filter = camel_mime_filter_charset_new_convert ("UTF-8", charset);
+ filter = camel_mime_filter_charset_new_convert ("UTF-8", iconv_charset);
camel_stream_filter_add (filter_stream, (CamelMimeFilter *) filter);
camel_object_unref (filter);
}
@@ -816,7 +817,7 @@ get_file_content (EMsgComposer *composer, const char *file_name, gboolean want_h
CamelMimeFilter *html, *charenc;
CamelStream *stream;
GByteArray *buffer;
- const char *charset;
+ char *charset;
char *content;
int fd;
@@ -824,7 +825,7 @@ get_file_content (EMsgComposer *composer, const char *file_name, gboolean want_h
if (fd == -1) {
if (warn) {
GtkWidget *dialog;
-
+
dialog = gtk_message_dialog_new(GTK_WINDOW(composer),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
@@ -869,12 +870,15 @@ get_file_content (EMsgComposer *composer, const char *file_name, gboolean want_h
filtered_stream = camel_stream_filter_new_with_stream (stream);
camel_object_unref (stream);
- charset = composer ? composer->charset : composer_get_default_charset_setting ();
- if ((charenc = (CamelMimeFilter *) camel_mime_filter_charset_new_convert (charset, "utf-8"))) {
+ charset = composer && composer->charset ? composer->charset : NULL;
+ charset = charset ? g_strdup (charset) : composer_get_default_charset_setting ();
+ if ((charenc = (CamelMimeFilter *) camel_mime_filter_charset_new_convert (charset, "UTF-8"))) {
camel_stream_filter_add (filtered_stream, charenc);
camel_object_unref (charenc);
}
+ g_free (charset);
+
camel_stream_write_to_stream ((CamelStream *) filtered_stream, (CamelStream *) memstream);
camel_object_unref (filtered_stream);
g_byte_array_free (buffer, TRUE);
@@ -2194,8 +2198,8 @@ static void
setup_ui (EMsgComposer *composer)
{
BonoboUIContainer *container;
- const char *default_charset;
gboolean hide_smime;
+ char *charset;
container = bonobo_window_get_ui_container (BONOBO_WINDOW (composer));
@@ -2215,11 +2219,12 @@ setup_ui (EMsgComposer *composer)
/* Populate the Charset Encoding menu and default it to whatever the user
chose as his default charset in the mailer */
- default_charset = composer_get_default_charset_setting ();
+ charset = composer_get_default_charset_setting ();
e_charset_picker_bonobo_ui_populate (composer->uic, "/menu/Edit/EncodingPlaceholder",
- default_charset,
+ charset,
menu_changed_charset_cb,
composer);
+ g_free (charset);
/* Format -> HTML */
bonobo_ui_component_set_prop (