From c1381b02bc61009814dbbbb842c34d094ed74add Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 10 Aug 2010 07:40:46 -0400 Subject: EMFormat cleanups. --- em-format/em-format-quote.c | 323 +++++++++++++++++++--------------- em-format/em-format-quote.h | 15 +- em-format/em-format.c | 415 +++++++++++++++++++++++++------------------- em-format/em-format.h | 96 ++++++---- mail/e-mail-reader.c | 11 +- mail/em-format-html.c | 4 +- 6 files changed, 498 insertions(+), 366 deletions(-) diff --git a/em-format/em-format-quote.c b/em-format/em-format-quote.c index aa666b22f1..eadaf7d2b4 100644 --- a/em-format/em-format-quote.c +++ b/em-format/em-format-quote.c @@ -37,26 +37,10 @@ struct _EMFormatQuotePrivate { gint dummy; }; -static void emfq_format_clone(EMFormat *, CamelFolder *, const gchar *, CamelMimeMessage *, EMFormat *); -static void emfq_format_error(EMFormat *emf, CamelStream *stream, const gchar *txt); -static void emfq_format_message(EMFormat *, CamelStream *, CamelMimePart *, const EMFormatHandler *); -static void emfq_format_source(EMFormat *, CamelStream *, CamelMimePart *); -static void emfq_format_attachment(EMFormat *, CamelStream *, CamelMimePart *, const gchar *, const EMFormatHandler *); - static void emfq_builtin_init(EMFormatQuoteClass *efhc); static gpointer parent_class; -static void -emfq_init(GObject *o) -{ - EMFormatQuote *emfq =(EMFormatQuote *) o; - - /* we want to convert url's etc */ - emfq->text_html_flags = CAMEL_MIME_FILTER_TOHTML_PRE | CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS - | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; -} - static void emfq_finalize (GObject *object) { @@ -64,16 +48,109 @@ emfq_finalize (GObject *object) if (emfq->stream) g_object_unref (emfq->stream); - g_free(emfq->credits); + g_free (emfq->credits); /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (parent_class)->finalize (object); } static void -emfq_base_init(EMFormatQuoteClass *emfqclass) +emfq_format_clone (EMFormat *emf, + CamelFolder *folder, + const gchar *uid, + CamelMimeMessage *msg, + EMFormat *src) +{ + EMFormatQuote *emfq = (EMFormatQuote *) emf; + const EMFormatHandler *handle; + GConfClient *gconf; + + /* Chain up to parent's format_clone() method. */ + EM_FORMAT_CLASS (parent_class)->format_clone (emf, folder, uid, msg, src); + + gconf = gconf_client_get_default (); + camel_stream_reset(emfq->stream, NULL); + if (gconf_client_get_bool(gconf, "/apps/evolution/mail/composer/top_signature", NULL)) + camel_stream_printf (emfq->stream, "
\n"); + g_object_unref (gconf); + handle = em_format_find_handler(emf, "x-evolution/message/prefix"); + if (handle) + handle->handler(emf, emfq->stream, (CamelMimePart *)msg, handle, FALSE); + handle = em_format_find_handler(emf, "x-evolution/message/rfc822"); + if (handle) + handle->handler(emf, emfq->stream, (CamelMimePart *)msg, handle, FALSE); + + camel_stream_flush(emfq->stream, NULL); + + g_signal_emit_by_name(emf, "complete"); +} + +static void +emfq_format_error (EMFormat *emf, + CamelStream *stream, + const gchar *errmsg) { - emfq_builtin_init(emfqclass); + /* Nothing to do. */ +} + +static void +emfq_format_source (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part) +{ + CamelStream *filtered_stream; + CamelMimeFilter *html_filter; + + filtered_stream = camel_stream_filter_new (stream); + html_filter = camel_mime_filter_tohtml_new ( + CAMEL_MIME_FILTER_TOHTML_CONVERT_NL | + CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES | + CAMEL_MIME_FILTER_TOHTML_ESCAPE_8BIT, 0); + camel_stream_filter_add ( + CAMEL_STREAM_FILTER (filtered_stream), html_filter); + g_object_unref (html_filter); + + em_format_format_text ( + emf, filtered_stream, CAMEL_DATA_WRAPPER (part)); + + g_object_unref (filtered_stream); +} + +static void +emfq_format_attachment (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const gchar *mime_type, + const EMFormatHandler *handle) +{ + EMFormatQuote *emfq = EM_FORMAT_QUOTE (emf); + gchar *text, *html; + + if (!em_format_is_inline (emf, emf->part_id->str, part, handle)) + return; + + camel_stream_write_string ( + stream, "" + "
\n", NULL); + + /* output some info about it */ + text = em_format_describe_part (part, mime_type); + html = camel_text_to_html ( + text, emfq->text_html_flags & + CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); + camel_stream_write_string (stream, html, NULL); + g_free (html); + g_free (text); + + camel_stream_write_string (stream, "
", NULL); + + handle->handler (emf, stream, part, handle, FALSE); +} + +static void +emfq_base_init (EMFormatQuoteClass *class) +{ + emfq_builtin_init (class); } static void @@ -95,6 +172,16 @@ emfq_class_init (EMFormatQuoteClass *class) format_class->format_attachment = emfq_format_attachment; } +static void +emfq_init (EMFormatQuote *emfq) +{ + /* we want to convert url's etc */ + emfq->text_html_flags = + CAMEL_MIME_FILTER_TOHTML_PRE | + CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | + CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; +} + GType em_format_quote_get_type (void) { @@ -124,61 +211,28 @@ em_format_quote_get_type (void) EMFormatQuote * em_format_quote_new (const gchar *credits, CamelStream *stream, - guint32 flags) + EMFormatQuoteFlags flags) { EMFormatQuote *emfq; + g_return_val_if_fail (CAMEL_IS_STREAM (stream), NULL); + emfq = g_object_new (EM_TYPE_FORMAT_QUOTE, NULL); emfq->credits = g_strdup (credits); - emfq->stream = stream; - g_object_ref (stream); + emfq->stream = g_object_ref (stream); emfq->flags = flags; return emfq; } static void -emfq_format_empty_line(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) -{ - camel_stream_printf(stream, "
\n"); -} - -static void -emfq_format_clone(EMFormat *emf, CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, EMFormat *src) -{ - EMFormatQuote *emfq = (EMFormatQuote *) emf; - const EMFormatHandler *handle; - GConfClient *gconf; - - /* Chain up to parent's format_clone() method. */ - EM_FORMAT_CLASS (parent_class)->format_clone (emf, folder, uid, msg, src); - - gconf = gconf_client_get_default (); - camel_stream_reset(emfq->stream, NULL); - if (gconf_client_get_bool(gconf, "/apps/evolution/mail/composer/top_signature", NULL)) - emfq_format_empty_line(emf, emfq->stream, (CamelMimePart *)msg, NULL); - g_object_unref (gconf); - handle = em_format_find_handler(emf, "x-evolution/message/prefix"); - if (handle) - handle->handler(emf, emfq->stream, (CamelMimePart *)msg, handle, FALSE); - handle = em_format_find_handler(emf, "x-evolution/message/rfc822"); - if (handle) - handle->handler(emf, emfq->stream, (CamelMimePart *)msg, handle, FALSE); - - camel_stream_flush(emfq->stream, NULL); - - g_signal_emit_by_name(emf, "complete"); -} - -static void -emfq_format_error(EMFormat *emf, CamelStream *stream, const gchar *txt) -{ - /* FIXME: should we even bother writing error text for quoting? probably not... */ -} - -static void -emfq_format_text_header (EMFormatQuote *emfq, CamelStream *stream, const gchar *label, const gchar *value, guint32 flags, gint is_html) +emfq_format_text_header (EMFormatQuote *emfq, + CamelStream *stream, + const gchar *label, + const gchar *value, + guint32 flags, + gint is_html) { const gchar *html; gchar *mhtml = NULL; @@ -281,23 +335,28 @@ canon_header_name (gchar *name) * capitalised and any letter following a '-' also gets * capitalised */ - if (*inptr >= 'a' && *inptr <= 'z') - *inptr -= 0x20; + if (g_ascii_islower (*inptr)) + *inptr = g_ascii_toupper (*inptr); inptr++; while (*inptr) { - if (inptr[-1] == '-' && *inptr >= 'a' && *inptr <= 'z') - *inptr -= 0x20; - else if (*inptr >= 'A' && *inptr <= 'Z') - *inptr += 0x20; + if (inptr[-1] == '-' && g_ascii_islower (*inptr)) + *inptr = g_ascii_toupper (*inptr); + else if (g_ascii_isupper (*inptr)) + *inptr = g_ascii_tolower (*inptr); inptr++; } } static void -emfq_format_header (EMFormat *emf, CamelStream *stream, CamelMedium *part, const gchar *namein, guint32 flags, const gchar *charset) +emfq_format_header (EMFormat *emf, + CamelStream *stream, + CamelMedium *part, + const gchar *namein, + guint32 flags, + const gchar *charset) { CamelMimeMessage *msg = (CamelMimeMessage *) part; EMFormatQuote *emfq = (EMFormatQuote *) emf; @@ -375,7 +434,9 @@ emfq_format_header (EMFormat *emf, CamelStream *stream, CamelMedium *part, const } static void -emfq_format_headers (EMFormatQuote *emfq, CamelStream *stream, CamelMedium *part) +emfq_format_headers (EMFormatQuote *emfq, + CamelStream *stream, + CamelMedium *part) { EMFormat *emf = (EMFormat *) emfq; CamelContentType *ct; @@ -402,7 +463,11 @@ emfq_format_headers (EMFormatQuote *emfq, CamelStream *stream, CamelMedium *part } static void -emfq_format_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) +emfq_format_message_prefix (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + gboolean is_fallback) { EMFormatQuote *emfq = (EMFormatQuote *) emf; @@ -411,7 +476,11 @@ emfq_format_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *pa } static void -emfq_format_message(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) +emfq_format_message (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + gboolean is_fallback) { EMFormatQuote *emfq = (EMFormatQuote *) emf; @@ -432,48 +501,13 @@ emfq_format_message(EMFormat *emf, CamelStream *stream, CamelMimePart *part, con } static void -emfq_format_source(EMFormat *emf, CamelStream *stream, CamelMimePart *part) -{ - CamelStream *filtered_stream; - CamelMimeFilter *html_filter; - - filtered_stream = camel_stream_filter_new ((CamelStream *) stream); - html_filter = camel_mime_filter_tohtml_new (CAMEL_MIME_FILTER_TOHTML_CONVERT_NL - | CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES - | CAMEL_MIME_FILTER_TOHTML_ESCAPE_8BIT, 0); - camel_stream_filter_add ( - CAMEL_STREAM_FILTER (filtered_stream), html_filter); - g_object_unref (html_filter); - - em_format_format_text(emf, (CamelStream *)filtered_stream, (CamelDataWrapper *)part); - g_object_unref (filtered_stream); -} - -static void -emfq_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const gchar *mime_type, const EMFormatHandler *handle) -{ - if (handle && em_format_is_inline(emf, emf->part_id->str, part, handle)) { - gchar *text, *html; - - camel_stream_write_string(stream, - "
\n", NULL); - - /* output some info about it */ - text = em_format_describe_part(part, mime_type); - html = camel_text_to_html(text, ((EMFormatQuote *)emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - camel_stream_write_string(stream, html, NULL); - g_free(html); - g_free(text); - - camel_stream_write_string(stream, "
", NULL); - - handle->handler(emf, stream, part, handle, FALSE); - } -} - -static void -emfq_text_plain(EMFormatQuote *emfq, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +emfq_text_plain (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + gboolean is_fallback) { + EMFormatQuote *emfq = EM_FORMAT_QUOTE (emf); CamelStream *filtered_stream; CamelMimeFilter *html_filter; CamelMimeFilter *sig_strip; @@ -513,64 +547,79 @@ emfq_text_plain(EMFormatQuote *emfq, CamelStream *stream, CamelMimePart *part, E } static void -emfq_text_enriched(EMFormatQuote *emfq, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +emfq_text_enriched (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + gboolean is_fallback) { CamelStream *filtered_stream; CamelMimeFilter *enriched; guint32 flags = 0; - if (!strcmp(info->mime_type, "text/richtext")) { + if (g_strcmp0 (info->mime_type, "text/richtext") == 0) { flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT; - camel_stream_write_string(stream, "\n\n", NULL); + camel_stream_write_string ( + stream, "\n\n", NULL); } else { - camel_stream_write_string(stream, "\n\n", NULL); + camel_stream_write_string ( + stream, "\n\n", NULL); } - enriched = camel_mime_filter_enriched_new(flags); + enriched = camel_mime_filter_enriched_new (flags); filtered_stream = camel_stream_filter_new (stream); camel_stream_filter_add ( CAMEL_STREAM_FILTER (filtered_stream), enriched); g_object_unref (enriched); - camel_stream_write_string(stream, "


", NULL); - em_format_format_text((EMFormat *)emfq, (CamelStream *)filtered_stream, (CamelDataWrapper *)part); + camel_stream_write_string (stream, "


", NULL); + em_format_format_text ( + emf, filtered_stream, CAMEL_DATA_WRAPPER (part)); g_object_unref (filtered_stream); } static void -emfq_text_html(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +emfq_text_html (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + gboolean is_fallback) { camel_stream_write_string(stream, "\n\n", NULL); em_format_format_text(emf, stream, (CamelDataWrapper *)part); } static void -emfq_ignore(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +emfq_ignore (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + gboolean is_fallback) { /* NOOP */ } static EMFormatHandler type_builtin_table[] = { - { (gchar *) "text/plain", (EMFormatFunc)emfq_text_plain }, - { (gchar *) "text/enriched", (EMFormatFunc)emfq_text_enriched }, - { (gchar *) "text/richtext", (EMFormatFunc)emfq_text_enriched }, - { (gchar *) "text/html", (EMFormatFunc)emfq_text_html }, - { (gchar *) "text/*", (EMFormatFunc)emfq_text_plain }, -/* { (gchar *) "multipart/related",(EMFormatFunc)emfq_multipart_related },*/ - { (gchar *) "message/external-body", (EMFormatFunc)emfq_ignore }, - { (gchar *) "multipart/appledouble", (EMFormatFunc)emfq_ignore }, + { (gchar *) "text/plain", emfq_text_plain }, + { (gchar *) "text/enriched", emfq_text_enriched }, + { (gchar *) "text/richtext", emfq_text_enriched }, + { (gchar *) "text/html", emfq_text_html }, + { (gchar *) "text/*", emfq_text_plain }, + { (gchar *) "message/external-body", emfq_ignore }, + { (gchar *) "multipart/appledouble", emfq_ignore }, /* internal evolution types */ - { (gchar *) "x-evolution/evolution-rss-feed", (EMFormatFunc)emfq_text_html }, - { (gchar *) "x-evolution/message/rfc822", (EMFormatFunc)emfq_format_message }, - { (gchar *) "x-evolution/message/prefix", (EMFormatFunc)emfq_format_message_prefix }, + { (gchar *) "x-evolution/evolution-rss-feed", emfq_text_html }, + { (gchar *) "x-evolution/message/rfc822", emfq_format_message }, + { (gchar *) "x-evolution/message/prefix", emfq_format_message_prefix }, }; static void -emfq_builtin_init(EMFormatQuoteClass *efhc) +emfq_builtin_init (EMFormatQuoteClass *efhc) { - gint i; + gint ii; - for (i = 0; i < G_N_ELEMENTS (type_builtin_table); i++) - em_format_class_add_handler((EMFormatClass *)efhc, &type_builtin_table[i]); + for (ii = 0; ii < G_N_ELEMENTS (type_builtin_table); ii++) + em_format_class_add_handler ( + EM_FORMAT_CLASS (efhc), &type_builtin_table[ii]); } diff --git a/em-format/em-format-quote.h b/em-format/em-format-quote.h index 5ea841cfdb..c95615366e 100644 --- a/em-format/em-format-quote.h +++ b/em-format/em-format-quote.h @@ -44,24 +44,25 @@ (G_TYPE_INSTANCE_GET_CLASS \ ((obj), EM_TYPE_FORMAT_QUOTE, EMFormatQuoteClass)) -#define EM_FORMAT_QUOTE_CITE (1<<0) -#define EM_FORMAT_QUOTE_HEADERS (1<<1) -#define EM_FORMAT_QUOTE_KEEP_SIG (1<<2) /* do not strip signature */ - G_BEGIN_DECLS typedef struct _EMFormatQuote EMFormatQuote; typedef struct _EMFormatQuoteClass EMFormatQuoteClass; typedef struct _EMFormatQuotePrivate EMFormatQuotePrivate; +typedef enum { + EM_FORMAT_QUOTE_CITE = 1 << 0, + EM_FORMAT_QUOTE_HEADERS = 1 << 1, + EM_FORMAT_QUOTE_KEEP_SIG = 1 << 2 /* do not strip signature */ +} EMFormatQuoteFlags; + struct _EMFormatQuote { EMFormat format; - EMFormatQuotePrivate *priv; gchar *credits; CamelStream *stream; - guint32 flags; + EMFormatQuoteFlags flags; guint32 text_html_flags; }; @@ -73,7 +74,7 @@ struct _EMFormatQuoteClass { GType em_format_quote_get_type (void); EMFormatQuote * em_format_quote_new (const gchar *credits, CamelStream *stream, - guint32 flags); + EMFormatQuoteFlags flags); G_END_DECLS diff --git a/em-format/em-format.c b/em-format/em-format.c index 74bcb31e43..5892bd772d 100644 --- a/em-format/em-format.c +++ b/em-format/em-format.c @@ -58,10 +58,6 @@ struct _EMFormatCache { static void emf_builtin_init(EMFormatClass *); -static const EMFormatHandler *emf_find_handler(EMFormat *emf, const gchar *mime_type); -static void emf_format_clone(EMFormat *emf, CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, EMFormat *emfsource); -static void emf_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid); -static gboolean emf_busy(EMFormat *emf); enum { EMF_COMPLETE, EMF_LAST_SIGNAL @@ -92,6 +88,19 @@ emf_insert_cache(EMFormat *emf, const gchar *partid) return new; } +static void +emf_clone_inlines (gpointer key, gpointer val, gpointer data) +{ + struct _EMFormatCache *emfc = val, *new; + + new = emf_insert_cache((EMFormat *)data, emfc->partid); + new->state = emfc->state; + if (emfc->valid) + new->valid = camel_cipher_validity_clone(emfc->valid); + if (emfc->secured) + g_object_ref ((new->secured = emfc->secured)); +} + static void emf_finalize (GObject *object) { @@ -117,6 +126,114 @@ emf_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } +static const EMFormatHandler * +emf_find_handler (EMFormat *emf, + const gchar *mime_type) +{ + EMFormatClass *emfc = (EMFormatClass *)G_OBJECT_GET_CLASS(emf); + + return g_hash_table_lookup (emfc->type_handlers, mime_type); +} + +static void +emf_format_clone (EMFormat *emf, + CamelFolder *folder, + const gchar *uid, + CamelMimeMessage *msg, + EMFormat *emfsource) +{ + em_format_clear_puri_tree(emf); + + if (emf != emfsource) { + g_hash_table_remove_all(emf->inline_table); + if (emfsource) { + GList *link; + + /* We clone the current state here */ + g_hash_table_foreach(emfsource->inline_table, emf_clone_inlines, emf); + emf->mode = emfsource->mode; + g_free(emf->charset); + emf->charset = g_strdup(emfsource->charset); + g_free (emf->default_charset); + emf->default_charset = g_strdup (emfsource->default_charset); + + em_format_clear_headers(emf); + + link = g_queue_peek_head_link (&emfsource->header_list); + while (link != NULL) { + struct _EMFormatHeader *h = link->data; + em_format_add_header (emf, h->name, h->flags); + link = g_list_next (link); + } + } + } + + /* what a mess */ + if (folder != emf->folder) { + if (emf->folder) + g_object_unref (emf->folder); + if (folder) + g_object_ref (folder); + emf->folder = folder; + } + + if (uid != emf->uid) { + g_free(emf->uid); + emf->uid = g_strdup(uid); + } + + if (msg != emf->message) { + if (emf->message) + g_object_unref (emf->message); + if (msg) + g_object_ref (msg); + emf->message = msg; + } + + g_string_truncate(emf->part_id, 0); + if (folder != NULL) + /* TODO build some string based on the folder name/location? */ + g_string_append_printf(emf->part_id, ".%p", (gpointer) folder); + if (uid != NULL) + g_string_append_printf(emf->part_id, ".%s", uid); +} + +static void +emf_format_secure (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + CamelCipherValidity *valid) +{ + CamelCipherValidity *save = emf->valid_parent; + gint len; + + /* Note that this also requires support from higher up in the class chain + - validity needs to be cleared when you start output + - also needs to be cleared (but saved) whenever you start a new message. */ + + if (emf->valid == NULL) { + emf->valid = valid; + } else { + camel_dlist_addtail(&emf->valid_parent->children, (CamelDListNode *)valid); + camel_cipher_validity_envelope(emf->valid_parent, valid); + } + + emf->valid_parent = valid; + + len = emf->part_id->len; + g_string_append_printf(emf->part_id, ".secured"); + em_format_part(emf, stream, part); + g_string_truncate(emf->part_id, len); + + emf->valid_parent = save; +} + +static gboolean +emf_busy (EMFormat *emf) +{ + return FALSE; +} + static gboolean emf_is_inline (EMFormat *emf, const gchar *part_id, @@ -251,7 +368,8 @@ em_format_get_type (void) * Use a mime type of "foo/ *" to insert a fallback handler for type "foo". **/ void -em_format_class_add_handler(EMFormatClass *emfc, EMFormatHandler *info) +em_format_class_add_handler (EMFormatClass *emfc, + EMFormatHandler *info) { d(printf("adding format handler to '%s' '%s'\n", g_type_name_from_class((GTypeClass *)emfc), info->mime_type)); info->old = g_hash_table_lookup(emfc->type_handlers, info->mime_type); @@ -262,6 +380,7 @@ struct _class_handlers { EMFormatClass *old; EMFormatClass *new; }; + static void merge_missing (gpointer key, gpointer value, gpointer userdata) { @@ -299,7 +418,8 @@ em_format_merge_handler(EMFormat *new, EMFormat *old) * added. **/ void -em_format_class_remove_handler(EMFormatClass *emfc, EMFormatHandler *info) +em_format_class_remove_handler (EMFormatClass *emfc, + EMFormatHandler *info) { EMFormatHandler *current; @@ -320,6 +440,15 @@ em_format_class_remove_handler(EMFormatClass *emfc, EMFormatHandler *info) } } +/** + * em_format_find_handler: + * @emf: + * @mime_type: + * + * Find a format handler by @mime_type. + * + * Return value: NULL if no handler is available. + **/ const EMFormatHandler * em_format_find_handler (EMFormat *emf, const gchar *mime_type) @@ -331,24 +460,8 @@ em_format_find_handler (EMFormat *emf, class = EM_FORMAT_GET_CLASS (emf); g_return_val_if_fail (class->find_handler != NULL, NULL); - return class->find_handler (emf, mime_type); -} -/** - * em_format_find_handler: - * @emf: - * @mime_type: - * - * Find a format handler by @mime_type. - * - * Return value: NULL if no handler is available. - **/ -static const EMFormatHandler * -emf_find_handler(EMFormat *emf, const gchar *mime_type) -{ - EMFormatClass *emfc = (EMFormatClass *)G_OBJECT_GET_CLASS(emf); - - return g_hash_table_lookup(emfc->type_handlers, mime_type); + return class->find_handler (emf, mime_type); } /** @@ -363,7 +476,8 @@ emf_find_handler(EMFormat *emf, const gchar *mime_type) * Return value: **/ const EMFormatHandler * -em_format_fallback_handler(EMFormat *emf, const gchar *mime_type) +em_format_fallback_handler (EMFormat *emf, + const gchar *mime_type) { gchar *mime, *s; @@ -616,7 +730,7 @@ emf_clear_puri_node (GNode *node) * data. **/ void -em_format_clear_puri_tree(EMFormat *emf) +em_format_clear_puri_tree (EMFormat *emf) { if (emf->pending_uri_table == NULL) emf->pending_uri_table = @@ -640,7 +754,10 @@ em_format_clear_puri_tree(EMFormat *emf) /* use mime_type == NULL to force showing as application/octet-stream */ void -em_format_part_as(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const gchar *mime_type) +em_format_part_as (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const gchar *mime_type) { const EMFormatHandler *handle = NULL; const gchar *snoop_save = emf->snoop_mime_type, *tmp; @@ -704,124 +821,21 @@ finish: } void -em_format_part(EMFormat *emf, CamelStream *stream, CamelMimePart *part) +em_format_part (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part) { gchar *mime_type; CamelDataWrapper *dw; - dw = camel_medium_get_content ((CamelMedium *)part); - mime_type = camel_data_wrapper_get_mime_type(dw); - if (mime_type) { - camel_strdown(mime_type); - em_format_part_as(emf, stream, part, mime_type); - g_free(mime_type); + dw = camel_medium_get_content (CAMEL_MEDIUM (part)); + mime_type = camel_data_wrapper_get_mime_type (dw); + if (mime_type != NULL) { + camel_strdown (mime_type); + em_format_part_as (emf, stream, part, mime_type); + g_free (mime_type); } else - em_format_part_as(emf, stream, part, "text/plain"); -} - -static void -emf_clone_inlines(gpointer key, gpointer val, gpointer data) -{ - struct _EMFormatCache *emfc = val, *new; - - new = emf_insert_cache((EMFormat *)data, emfc->partid); - new->state = emfc->state; - if (emfc->valid) - new->valid = camel_cipher_validity_clone(emfc->valid); - if (emfc->secured) - g_object_ref ((new->secured = emfc->secured)); -} - -static void -emf_format_clone(EMFormat *emf, CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, EMFormat *emfsource) -{ - em_format_clear_puri_tree(emf); - - if (emf != emfsource) { - g_hash_table_remove_all(emf->inline_table); - if (emfsource) { - GList *link; - - /* We clone the current state here */ - g_hash_table_foreach(emfsource->inline_table, emf_clone_inlines, emf); - emf->mode = emfsource->mode; - g_free(emf->charset); - emf->charset = g_strdup(emfsource->charset); - g_free (emf->default_charset); - emf->default_charset = g_strdup (emfsource->default_charset); - - em_format_clear_headers(emf); - - link = g_queue_peek_head_link (&emfsource->header_list); - while (link != NULL) { - struct _EMFormatHeader *h = link->data; - em_format_add_header (emf, h->name, h->flags); - link = g_list_next (link); - } - } - } - - /* what a mess */ - if (folder != emf->folder) { - if (emf->folder) - g_object_unref (emf->folder); - if (folder) - g_object_ref (folder); - emf->folder = folder; - } - - if (uid != emf->uid) { - g_free(emf->uid); - emf->uid = g_strdup(uid); - } - - if (msg != emf->message) { - if (emf->message) - g_object_unref (emf->message); - if (msg) - g_object_ref (msg); - emf->message = msg; - } - - g_string_truncate(emf->part_id, 0); - if (folder != NULL) - /* TODO build some string based on the folder name/location? */ - g_string_append_printf(emf->part_id, ".%p", (gpointer) folder); - if (uid != NULL) - g_string_append_printf(emf->part_id, ".%s", uid); -} - -static void -emf_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid) -{ - CamelCipherValidity *save = emf->valid_parent; - gint len; - - /* Note that this also requires support from higher up in the class chain - - validity needs to be cleared when you start output - - also needs to be cleared (but saved) whenever you start a new message. */ - - if (emf->valid == NULL) { - emf->valid = valid; - } else { - camel_dlist_addtail(&emf->valid_parent->children, (CamelDListNode *)valid); - camel_cipher_validity_envelope(emf->valid_parent, valid); - } - - emf->valid_parent = valid; - - len = emf->part_id->len; - g_string_append_printf(emf->part_id, ".secured"); - em_format_part(emf, stream, part); - g_string_truncate(emf->part_id, len); - - emf->valid_parent = save; -} - -static gboolean -emf_busy(EMFormat *emf) -{ - return FALSE; + em_format_part_as (emf, stream, part, "text/plain"); } /** @@ -856,6 +870,7 @@ em_format_format_clone (EMFormat *emf, class = EM_FORMAT_GET_CLASS (emf); g_return_if_fail (class->format_clone != NULL); + class->format_clone (emf, folder, uid, message, source); } @@ -883,22 +898,23 @@ em_format_redraw (EMFormat *emf) * @emf: * @type: * - * Set display mode, EM_FORMAT_SOURCE, EM_FORMAT_ALLHEADERS, or - * EM_FORMAT_NORMAL. + * Set display mode, EM_FORMAT_MODE_SOURCE, EM_FORMAT_MODE_ALLHEADERS, + * or EM_FORMAT_MODE_NORMAL. **/ void -em_format_set_mode(EMFormat *emf, em_format_mode_t type) +em_format_set_mode (EMFormat *emf, + EMFormatMode mode) { g_return_if_fail (EM_IS_FORMAT (emf)); - if (emf->mode == type) + if (emf->mode == mode) return; - emf->mode = type; + emf->mode = mode; /* force redraw if type changed afterwards */ - if (emf->message) - em_format_redraw(emf); + if (emf->message != NULL) + em_format_redraw (emf); } /** @@ -910,7 +926,8 @@ em_format_set_mode(EMFormat *emf, em_format_mode_t type) * required. **/ void -em_format_set_charset(EMFormat *emf, const gchar *charset) +em_format_set_charset (EMFormat *emf, + const gchar *charset) { if ((emf->charset && charset && g_ascii_strcasecmp(emf->charset, charset) == 0) || (emf->charset == NULL && charset == NULL) @@ -930,11 +947,12 @@ em_format_set_charset(EMFormat *emf, const gchar *charset) * @charset: * * Set the fallback, default system charset to use when no other charsets - * are present. Message will be redisplayed if required (and sometimes redisplayed - * when it isn't). + * are present. Message will be redisplayed if required (and sometimes + * redisplayed when it isn't). **/ void -em_format_set_default_charset(EMFormat *emf, const gchar *charset) +em_format_set_default_charset (EMFormat *emf, + const gchar *charset) { if ((emf->default_charset && charset && g_ascii_strcasecmp(emf->default_charset, charset) == 0) || (emf->default_charset == NULL && charset == NULL) @@ -989,13 +1007,16 @@ static const struct { * From, Reply-To, To, Cc, Bcc, Subject and Date. **/ void -em_format_default_headers(EMFormat *emf) +em_format_default_headers (EMFormat *emf) { - gint i; + gint ii; - em_format_clear_headers(emf); - for (i = 0; i < G_N_ELEMENTS (default_headers); i++) - em_format_add_header(emf, default_headers[i].name, default_headers[i].flags); + em_format_clear_headers (emf); + + for (ii = 0; ii < G_N_ELEMENTS (default_headers); ii++) + em_format_add_header ( + emf, default_headers[ii].name, + default_headers[ii].flags); } /** @@ -1009,7 +1030,10 @@ em_format_default_headers(EMFormat *emf) * headers included in this list will be shown using special * formatting routines. **/ -void em_format_add_header(EMFormat *emf, const gchar *name, guint32 flags) +void +em_format_add_header (EMFormat *emf, + const gchar *name, + guint32 flags) { EMFormatHeader *h; @@ -1035,7 +1059,9 @@ void em_format_add_header(EMFormat *emf, const gchar *name, guint32 flags) * * Return value: TRUE/FALSE **/ -gint em_format_is_attachment(EMFormat *emf, CamelMimePart *part) +gint +em_format_is_attachment (EMFormat *emf, + CamelMimePart *part) { /*CamelContentType *ct = camel_mime_part_get_content_type(part);*/ CamelDataWrapper *dw = camel_medium_get_content ((CamelMedium *)part); @@ -1058,7 +1084,7 @@ gint em_format_is_attachment(EMFormat *emf, CamelMimePart *part) * em_format_is_inline: * @emf: * @part: - * @partid: format->part_id part id of this part. + * @part_id: format->part_id part id of this part. * @handle: handler for this part * * Returns true if the part should be displayed inline. Any part with @@ -1091,20 +1117,26 @@ em_format_is_inline (EMFormat *emf, /** * em_format_set_inline: * @emf: - * @partid: id of part + * @part_id: id of part * @state: * * Force the attachment @part to be expanded or hidden explictly to match * @state. This is used only to record the change for a redraw or * cloned layout render and does not force a redraw. **/ -void em_format_set_inline(EMFormat *emf, const gchar *partid, gint state) +void +em_format_set_inline (EMFormat *emf, + const gchar *part_id, + gint state) { struct _EMFormatCache *emfc; - emfc = g_hash_table_lookup(emf->inline_table, partid); + g_return_if_fail (EM_IS_FORMAT (emf)); + g_return_if_fail (part_id != NULL); + + emfc = g_hash_table_lookup(emf->inline_table, part_id); if (emfc == NULL) { - emfc = emf_insert_cache(emf, partid); + emfc = emf_insert_cache(emf, part_id); } else if (emfc->state != INLINE_UNSET && (emfc->state & 1) == state) return; @@ -1119,7 +1151,7 @@ em_format_format_attachment (EMFormat *emf, CamelStream *stream, CamelMimePart *mime_part, const gchar *mime_type, - const struct _EMFormatHandler *info) + const EMFormatHandler *info) { EMFormatClass *class; @@ -1131,6 +1163,7 @@ em_format_format_attachment (EMFormat *emf, class = EM_FORMAT_GET_CLASS (emf); g_return_if_fail (class->format_attachment != NULL); + class->format_attachment (emf, stream, mime_part, mime_type, info); } @@ -1173,6 +1206,7 @@ em_format_format_secure (EMFormat *emf, class = EM_FORMAT_GET_CLASS (emf); g_return_if_fail (class->format_secure != NULL); + class->format_secure (emf, stream, mime_part, valid); if (emf->valid_parent == NULL && emf->valid != NULL) { @@ -1194,6 +1228,7 @@ em_format_format_source (EMFormat *emf, class = EM_FORMAT_GET_CLASS (emf); g_return_if_fail (class->format_source != NULL); + class->format_source (emf, stream, mime_part); } @@ -1206,12 +1241,15 @@ em_format_busy (EMFormat *emf) class = EM_FORMAT_GET_CLASS (emf); g_return_val_if_fail (class->busy != NULL, FALSE); + return class->busy (emf); } /* should this be virtual? */ void -em_format_format_content(EMFormat *emf, CamelStream *stream, CamelMimePart *part) +em_format_format_content (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part) { CamelDataWrapper *dw = camel_medium_get_content ((CamelMedium *)part); @@ -1230,7 +1268,9 @@ em_format_format_content(EMFormat *emf, CamelStream *stream, CamelMimePart *part * Decode/output a part's content to @stream. **/ void -em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw) +em_format_format_text (EMFormat *emf, + CamelStream *stream, + CamelDataWrapper *dw) { CamelStream *filter_stream; CamelMimeFilter *filter; @@ -1293,7 +1333,7 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw) g_object_unref (gconf); size = camel_data_wrapper_decode_to_stream ( - emf->mode == EM_FORMAT_SOURCE ? + emf->mode == EM_FORMAT_MODE_SOURCE ? (CamelDataWrapper *) dw : camel_medium_get_content ((CamelMedium *)dw), (CamelStream *)filter_stream, NULL); @@ -1323,7 +1363,8 @@ em_format_format_text(EMFormat *emf, CamelStream *stream, CamelDataWrapper *dw) * Return value: **/ gchar * -em_format_describe_part(CamelMimePart *part, const gchar *mime_type) +em_format_describe_part (CamelMimePart *part, + const gchar *mime_type) { GString *stext; const gchar *filename, *description; @@ -1346,7 +1387,8 @@ em_format_describe_part(CamelMimePart *part, const gchar *mime_type) } static void -add_validity_found (EMFormat *emf, CamelCipherValidity *valid) +add_validity_found (EMFormat *emf, + CamelCipherValidity *valid) { g_return_if_fail (emf != NULL); @@ -1594,10 +1636,12 @@ emf_multipart_encrypted (EMFormat *emf, } static void -emf_write_related(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) +emf_write_related (EMFormat *emf, + CamelStream *stream, + EMFormatPURI *puri) { - em_format_format_content(emf, stream, puri->part); - camel_stream_close(stream, NULL); + em_format_format_content (emf, stream, puri->part); + camel_stream_close (stream, NULL); } /* RFC 2387 */ @@ -1882,11 +1926,15 @@ emf_message_deliverystatus (EMFormat *emf, const EMFormatHandler *info, gboolean is_fallback) { - em_format_format_text(emf, stream, (CamelDataWrapper *)part); + em_format_format_text (emf, stream, (CamelDataWrapper *)part); } static void -emf_inlinepgp_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, EMFormatHandler *info) +emf_inlinepgp_signed (EMFormat *emf, + CamelStream *stream, + CamelMimePart *ipart, + const EMFormatHandler *info, + gboolean is_fallback) { CamelStream *filtered_stream; CamelMimeFilterPgp *pgp_filter; @@ -1976,7 +2024,11 @@ emf_inlinepgp_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, E } static void -emf_inlinepgp_encrypted(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, EMFormatHandler *info) +emf_inlinepgp_encrypted (EMFormat *emf, + CamelStream *stream, + CamelMimePart *ipart, + const EMFormatHandler *info, + gboolean is_fallback) { CamelCipherContext *cipher; CamelCipherValidity *valid; @@ -2054,17 +2106,20 @@ static EMFormatHandler type_builtin_table[] = { #endif /* internal types */ - { (gchar *) "application/x-inlinepgp-signed", (EMFormatFunc)emf_inlinepgp_signed }, - { (gchar *) "application/x-inlinepgp-encrypted", (EMFormatFunc)emf_inlinepgp_encrypted }, + { (gchar *) "application/x-inlinepgp-signed", emf_inlinepgp_signed }, + { (gchar *) "application/x-inlinepgp-encrypted", emf_inlinepgp_encrypted }, }; static void -emf_builtin_init(EMFormatClass *class) +emf_builtin_init (EMFormatClass *class) { - gint i; + gint ii; - for (i = 0; i < G_N_ELEMENTS (type_builtin_table); i++) - g_hash_table_insert(class->type_handlers, type_builtin_table[i].mime_type, &type_builtin_table[i]); + for (ii = 0; ii < G_N_ELEMENTS (type_builtin_table); ii++) + g_hash_table_insert ( + class->type_handlers, + type_builtin_table[ii].mime_type, + &type_builtin_table[ii]); } /** diff --git a/em-format/em-format.h b/em-format/em-format.h index 5ae0e7f2ae..ec805e7cd8 100644 --- a/em-format/em-format.h +++ b/em-format/em-format.h @@ -59,20 +59,38 @@ typedef struct _EMFormatPrivate EMFormatPrivate; typedef struct _EMFormatHandler EMFormatHandler; typedef struct _EMFormatHeader EMFormatHeader; -typedef void (*EMFormatFunc) (EMFormat *md, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info, gboolean is_fallback); +typedef void (*EMFormatFunc) (EMFormat *emf, + CamelStream *stream, + CamelMimePart *mime_part, + const EMFormatHandler *info, + gboolean is_fallback); -typedef enum _em_format_mode_t { - EM_FORMAT_NORMAL, - EM_FORMAT_ALLHEADERS, - EM_FORMAT_SOURCE -} em_format_mode_t; +typedef enum { + EM_FORMAT_MODE_NORMAL, + EM_FORMAT_MODE_ALLHEADERS, + EM_FORMAT_MODE_SOURCE +} EMFormatMode; + +/** + * EMFormatHandlerFlags - Format handler flags. + * + * @EM_FORMAT_HANDLER_INLINE: This type should be shown expanded + * inline by default. + * @EM_FORMAT_HANDLER_INLINE_DISPOSITION: This type should always be + * shown inline, despite what the Content-Disposition suggests. + * + **/ +typedef enum { + EM_FORMAT_HANDLER_INLINE = 1<<0, + EM_FORMAT_HANDLER_INLINE_DISPOSITION = 1<<1 +} EMFormatHandlerFlags; /** * struct _EMFormatHandler - MIME type handler. * * @mime_type: Type this handler handles. * @handler: The handler callback. - * @flags: Handling flags, see enum _em_format_handler_t. + * @flags: Handler flags * @old: The last handler set on this type. Allows overrides to * fallback to previous implementation. * @@ -80,27 +98,15 @@ typedef enum _em_format_mode_t { struct _EMFormatHandler { gchar *mime_type; EMFormatFunc handler; - guint32 flags; + EMFormatHandlerFlags flags; EMFormatHandler *old; }; -/** - * enum _em_format_handler_t - Format handler flags. - * - * @EM_FORMAT_HANDLER_INLINE: This type should be shown expanded - * inline by default. - * @EM_FORMAT_HANDLER_INLINE_DISPOSITION: This type should always be - * shown inline, despite what the Content-Disposition suggests. - * - **/ -enum _em_format_handler_t { - EM_FORMAT_HANDLER_INLINE = 1<<0, - EM_FORMAT_HANDLER_INLINE_DISPOSITION = 1<<1 -}; - typedef struct _EMFormatPURI EMFormatPURI; -typedef void (*EMFormatPURIFunc)(EMFormat *md, CamelStream *stream, EMFormatPURI *puri); +typedef void (*EMFormatPURIFunc) (EMFormat *emf, + CamelStream *stream, + EMFormatPURI *puri); /** * struct _EMFormatPURI - Pending URI object. @@ -216,7 +222,7 @@ struct _EMFormat { /* current level to search from */ GNode *pending_uri_level; - em_format_mode_t mode; /* source/headers/etc */ + EMFormatMode mode; /* source/headers/etc */ gchar *charset; /* charset override */ gchar *default_charset; /* charset fallback */ gboolean composer; /* Formatting from composer ?*/ @@ -229,27 +235,47 @@ struct _EMFormatClass { GHashTable *type_handlers; /* lookup handler, default falls back to hashtable above */ - const EMFormatHandler *(*find_handler)(EMFormat *, const gchar *mime_type); + const EMFormatHandler * + (*find_handler) (EMFormat *emf, + const gchar *mime_type); /* start formatting a message */ - void (*format_clone)(EMFormat *, CamelFolder *, const gchar *uid, CamelMimeMessage *, EMFormat *); + void (*format_clone) (EMFormat *emf, + CamelFolder *folder, + const gchar *uid, + CamelMimeMessage *message, + EMFormat *source); /* some internel error/inconsistency */ - void (*format_error)(EMFormat *, CamelStream *, const gchar *msg); + void (*format_error) (EMFormat *emf, + CamelStream *stream, + const gchar *errmsg); /* use for external structured parts */ - void (*format_attachment)(EMFormat *, CamelStream *, CamelMimePart *, const gchar *mime_type, const EMFormatHandler *info); + void (*format_attachment) (EMFormat *emf, + CamelStream *stream, + CamelMimePart *mime_part, + const gchar *mime_type, + const EMFormatHandler *info); /* use for unparsable content */ - void (*format_source)(EMFormat *, CamelStream *, CamelMimePart *); + void (*format_source) (EMFormat *emf, + CamelStream *stream, + CamelMimePart *mime_part); /* for outputing secure(d) content */ - void (*format_secure)(EMFormat *, CamelStream *, CamelMimePart *, CamelCipherValidity *); + void (*format_secure) (EMFormat *emf, + CamelStream *stream, + CamelMimePart *mime_part, + CamelCipherValidity *validity); /* returns true if the formatter is still busy with pending stuff */ - gboolean (*busy)(EMFormat *); + gboolean (*busy) (EMFormat *); /* Shows optional way to open messages */ - void (*format_optional)(EMFormat *, CamelStream *, CamelMimePart *, CamelStream* ); + void (*format_optional) (EMFormat *emf, + CamelStream *filter_stream, + CamelMimePart *mime_part, + CamelStream *mem_stream); gboolean (*is_inline) (EMFormat *emf, const gchar *part_id, @@ -258,11 +284,11 @@ struct _EMFormatClass { /* signals */ /* complete, alternative to polling busy, for asynchronous work */ - void (*complete)(EMFormat *); + void (*complete) (EMFormat *emf); }; void em_format_set_mode (EMFormat *emf, - em_format_mode_t type); + EMFormatMode mode); void em_format_set_charset (EMFormat *emf, const gchar *charset); void em_format_set_default_charset (EMFormat *emf, @@ -373,7 +399,7 @@ void em_format_part (EMFormat *emf, void em_format_merge_handler (EMFormat *new, EMFormat *old); -const gchar * em_format_snoop_type (CamelMimePart *part); +const gchar * em_format_snoop_type (CamelMimePart *part); G_END_DECLS diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index f60a3d44c0..3675b5209b 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -1198,7 +1198,7 @@ action_mail_show_all_headers_cb (GtkToggleAction *action, EMailReader *reader) { EMFormatHTML *formatter; - em_format_mode_t mode; + EMFormatMode mode; formatter = e_mail_reader_get_formatter (reader); @@ -1206,9 +1206,9 @@ action_mail_show_all_headers_cb (GtkToggleAction *action, return; if (gtk_toggle_action_get_active (action)) - mode = EM_FORMAT_ALLHEADERS; + mode = EM_FORMAT_MODE_ALLHEADERS; else - mode = EM_FORMAT_NORMAL; + mode = EM_FORMAT_MODE_NORMAL; em_format_set_mode (EM_FORMAT (formatter), mode); } @@ -1235,8 +1235,9 @@ action_mail_show_source_cb (GtkAction *action, reader = E_MAIL_READER (browser); formatter = e_mail_reader_get_formatter (reader); - if (formatter) - em_format_set_mode (EM_FORMAT (formatter), EM_FORMAT_SOURCE); + if (formatter != NULL) + em_format_set_mode ( + EM_FORMAT (formatter), EM_FORMAT_MODE_SOURCE); e_mail_reader_set_folder (reader, folder, folder_uri); e_mail_reader_set_message (reader, uids->pdata[0]); diff --git a/mail/em-format-html.c b/mail/em-format-html.c index a7e4c03ab5..5818ad2a35 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -181,7 +181,7 @@ efh_format_exec (struct _format_msg *m) /* */ - if (format->mode == EM_FORMAT_SOURCE) { + if (format->mode == EM_FORMAT_MODE_SOURCE) { em_format_format_source ( format, (CamelStream *) m->estream, (CamelMimePart *) m->message); @@ -2659,7 +2659,7 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) camel_stream_printf (stream, "\n"); /* dump selected headers */ - if (emf->mode == EM_FORMAT_ALLHEADERS) { + if (emf->mode == EM_FORMAT_MODE_ALLHEADERS) { header = ((CamelMimePart *)part)->headers; while (header) { efh_format_header(emf, stream, part, header, EM_FORMAT_HTML_HEADER_NOCOLUMNS, charset); -- cgit v1.2.3