Fix for bug #48791 (and also fixes a FIXME)
2003-09-23 Jeffrey Stedfast <fejj@ximian.com> Fix for bug #48791 (and also fixes a FIXME) * em-format.c (emf_init): Setup a gconf listener for changes to the charset setting. (gconf_charset_changed): Update the cached gconf charset value. (emf_finalise): Free the EMFormatPrivate data, unref the gconf client, disconnect the charset notify id, and free the cached gconf charset value. (em_format_format_text): Use the cached gconf charset value. svn path=/trunk/; revision=22675
This commit is contained in:

committed by
Jeffrey Stedfast

parent
b0cf774e78
commit
8db4001828
@ -1,3 +1,15 @@
|
|||||||
|
2003-09-23 Jeffrey Stedfast <fejj@ximian.com>
|
||||||
|
|
||||||
|
Fix for bug #48791 (and also fixes a FIXME)
|
||||||
|
|
||||||
|
* em-format.c (emf_init): Setup a gconf listener for changes to
|
||||||
|
the charset setting.
|
||||||
|
(gconf_charset_changed): Update the cached gconf charset value.
|
||||||
|
(emf_finalise): Free the EMFormatPrivate data, unref the gconf
|
||||||
|
client, disconnect the charset notify id, and free the cached
|
||||||
|
gconf charset value.
|
||||||
|
(em_format_format_text): Use the cached gconf charset value.
|
||||||
|
|
||||||
2003-09-22 Not Zed <NotZed@Ximian.com>
|
2003-09-22 Not Zed <NotZed@Ximian.com>
|
||||||
|
|
||||||
** See bug #32996
|
** See bug #32996
|
||||||
|
@ -55,6 +55,12 @@
|
|||||||
|
|
||||||
#define d(x)
|
#define d(x)
|
||||||
|
|
||||||
|
struct _EMFormatPrivate {
|
||||||
|
GConfClient *gconf;
|
||||||
|
guint charset_id;
|
||||||
|
char *gconf_charset;
|
||||||
|
};
|
||||||
|
|
||||||
static void emf_builtin_init(EMFormatClass *);
|
static void emf_builtin_init(EMFormatClass *);
|
||||||
static const char *emf_snoop_part(CamelMimePart *part);
|
static const char *emf_snoop_part(CamelMimePart *part);
|
||||||
|
|
||||||
@ -69,11 +75,30 @@ enum {
|
|||||||
static guint emf_signals[EMF_LAST_SIGNAL];
|
static guint emf_signals[EMF_LAST_SIGNAL];
|
||||||
static GObjectClass *emf_parent;
|
static GObjectClass *emf_parent;
|
||||||
|
|
||||||
|
static void
|
||||||
|
gconf_charset_changed (GConfClient *client, guint cnxn_id,
|
||||||
|
GConfEntry *entry, gpointer user_data)
|
||||||
|
{
|
||||||
|
struct _EMFormatPrivate *priv = ((EMFormat *) user_data)->priv;
|
||||||
|
|
||||||
|
g_free (priv->gconf_charset);
|
||||||
|
priv->gconf_charset = gconf_client_get_string (priv->gconf, "/apps/evolution/mail/format/charset", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emf_init(GObject *o)
|
emf_init(GObject *o)
|
||||||
{
|
{
|
||||||
|
struct _EMFormatPrivate *priv;
|
||||||
EMFormat *emf = (EMFormat *)o;
|
EMFormat *emf = (EMFormat *)o;
|
||||||
|
|
||||||
|
priv = emf->priv = g_new (struct _EMFormatPrivate, 1);
|
||||||
|
priv->gconf = gconf_client_get_default ();
|
||||||
|
gconf_client_add_dir (priv->gconf, "/apps/evolution/mail/format/charset",
|
||||||
|
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
||||||
|
priv->charset_id = gconf_client_notify_add (priv->gconf, "/apps/evolution/mail/format/charset",
|
||||||
|
gconf_charset_changed, NULL, NULL, emf);
|
||||||
|
priv->gconf_charset = gconf_client_get_string (priv->gconf, "/apps/evolution/mail/format/charset", NULL);
|
||||||
|
|
||||||
emf->inline_table = g_hash_table_new(NULL, NULL);
|
emf->inline_table = g_hash_table_new(NULL, NULL);
|
||||||
e_dlist_init(&emf->header_list);
|
e_dlist_init(&emf->header_list);
|
||||||
em_format_default_headers(emf);
|
em_format_default_headers(emf);
|
||||||
@ -82,8 +107,15 @@ emf_init(GObject *o)
|
|||||||
static void
|
static void
|
||||||
emf_finalise(GObject *o)
|
emf_finalise(GObject *o)
|
||||||
{
|
{
|
||||||
|
struct _EMFormatPrivate *priv = ((EMFormat *) o)->priv;
|
||||||
EMFormat *emf = (EMFormat *)o;
|
EMFormat *emf = (EMFormat *)o;
|
||||||
|
|
||||||
|
gconf_client_notify_remove (priv->gconf, priv->charset_id);
|
||||||
|
priv->charset_id = 0;
|
||||||
|
g_object_unref (priv->gconf);
|
||||||
|
g_free (priv->gconf_charset);
|
||||||
|
g_free (priv);
|
||||||
|
|
||||||
if (emf->session)
|
if (emf->session)
|
||||||
camel_object_unref(emf->session);
|
camel_object_unref(emf->session);
|
||||||
|
|
||||||
@ -92,9 +124,9 @@ emf_finalise(GObject *o)
|
|||||||
|
|
||||||
em_format_clear_headers(emf);
|
em_format_clear_headers(emf);
|
||||||
g_free(emf->charset);
|
g_free(emf->charset);
|
||||||
|
|
||||||
/* FIXME: check pending jobs */
|
/* FIXME: check pending jobs */
|
||||||
|
|
||||||
((GObjectClass *)emf_parent)->finalize(o);
|
((GObjectClass *)emf_parent)->finalize(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -798,8 +830,7 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw)
|
|||||||
CamelStreamFilter *filter_stream;
|
CamelStreamFilter *filter_stream;
|
||||||
CamelMimeFilterCharset *filter;
|
CamelMimeFilterCharset *filter;
|
||||||
const char *charset = NULL;
|
const char *charset = NULL;
|
||||||
char *fallback_charset = NULL;
|
|
||||||
|
|
||||||
if (emf->charset) {
|
if (emf->charset) {
|
||||||
charset = emf->charset;
|
charset = emf->charset;
|
||||||
} else if (dw->mime_type
|
} else if (dw->mime_type
|
||||||
@ -824,16 +855,12 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw)
|
|||||||
camel_stream_flush((CamelStream *)filter_stream);
|
camel_stream_flush((CamelStream *)filter_stream);
|
||||||
camel_object_unref(filter_stream);
|
camel_object_unref(filter_stream);
|
||||||
|
|
||||||
charset = fallback_charset = g_strdup(camel_mime_filter_windows_real_charset(windows));
|
charset = camel_mime_filter_windows_real_charset (windows);
|
||||||
camel_object_unref(windows);
|
camel_object_unref(windows);
|
||||||
} else if (charset == NULL) {
|
} else if (charset == NULL) {
|
||||||
/* FIXME: remove gconf query every time */
|
charset = emf->priv->gconf_charset;
|
||||||
GConfClient *gconf = gconf_client_get_default();
|
|
||||||
|
|
||||||
charset = fallback_charset = gconf_client_get_string(gconf, "/apps/evolution/mail/format/charset", NULL);
|
|
||||||
g_object_unref(gconf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_stream = camel_stream_filter_new_with_stream(stream);
|
filter_stream = camel_stream_filter_new_with_stream(stream);
|
||||||
|
|
||||||
if ((filter = camel_mime_filter_charset_new_convert(charset, "UTF-8"))) {
|
if ((filter = camel_mime_filter_charset_new_convert(charset, "UTF-8"))) {
|
||||||
@ -841,8 +868,6 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw)
|
|||||||
camel_object_unref(filter);
|
camel_object_unref(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(fallback_charset);
|
|
||||||
|
|
||||||
camel_data_wrapper_decode_to_stream(dw, (CamelStream *)filter_stream);
|
camel_data_wrapper_decode_to_stream(dw, (CamelStream *)filter_stream);
|
||||||
camel_stream_flush((CamelStream *)filter_stream);
|
camel_stream_flush((CamelStream *)filter_stream);
|
||||||
camel_object_unref(filter_stream);
|
camel_object_unref(filter_stream);
|
||||||
|
@ -95,7 +95,9 @@ struct _EMFormatHeader {
|
|||||||
|
|
||||||
struct _EMFormat {
|
struct _EMFormat {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
|
struct _EMFormatPrivate *priv;
|
||||||
|
|
||||||
struct _CamelMedium *message; /* the current message */
|
struct _CamelMedium *message; /* the current message */
|
||||||
|
|
||||||
EDList header_list; /* if empty, then all */
|
EDList header_list; /* if empty, then all */
|
||||||
|
Reference in New Issue
Block a user