diff options
-rw-r--r-- | em-format/em-format.c | 60 | ||||
-rw-r--r-- | em-format/em-format.h | 11 | ||||
-rw-r--r-- | mail/em-format-html-print.c | 14 |
3 files changed, 64 insertions, 21 deletions
diff --git a/em-format/em-format.c b/em-format/em-format.c index a323c56d65..74bcb31e43 100644 --- a/em-format/em-format.c +++ b/em-format/em-format.c @@ -117,6 +117,35 @@ emf_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } +static gboolean +emf_is_inline (EMFormat *emf, + const gchar *part_id, + CamelMimePart *mime_part, + const EMFormatHandler *handle) +{ + struct _EMFormatCache *emfc; + const gchar *disposition; + + if (handle == NULL) + return FALSE; + + emfc = g_hash_table_lookup (emf->inline_table, part_id); + if (emfc && emfc->state != INLINE_UNSET) + return emfc->state & 1; + + /* Some types need to override the disposition. + * e.g. application/x-pkcs7-mime */ + if (handle->flags & EM_FORMAT_HANDLER_INLINE_DISPOSITION) + return TRUE; + + disposition = camel_mime_part_get_disposition (mime_part); + if (disposition != NULL) + return g_ascii_strcasecmp (disposition, "inline") == 0; + + /* Otherwise, use the default for this handler type. */ + return (handle->flags & EM_FORMAT_HANDLER_INLINE) != 0; +} + static void emf_base_init (EMFormatClass *class) { @@ -138,6 +167,7 @@ emf_class_init (EMFormatClass *class) class->format_clone = emf_format_clone; class->format_secure = emf_format_secure; class->busy = emf_busy; + class->is_inline = emf_is_inline; signals[EMF_COMPLETE] = g_signal_new ( "complete", @@ -1040,28 +1070,22 @@ gint em_format_is_attachment(EMFormat *emf, CamelMimePart *part) * * Return value: **/ -gint em_format_is_inline(EMFormat *emf, const gchar *partid, CamelMimePart *part, const EMFormatHandler *handle) +gboolean +em_format_is_inline (EMFormat *emf, + const gchar *part_id, + CamelMimePart *mime_part, + const EMFormatHandler *handle) { - struct _EMFormatCache *emfc; - const gchar *tmp; - - if (handle == NULL) - return FALSE; - - emfc = g_hash_table_lookup(emf->inline_table, partid); - if (emfc && emfc->state != INLINE_UNSET) - return emfc->state & 1; + EMFormatClass *class; - /* some types need to override the disposition, e.g. application/x-pkcs7-mime */ - if (handle->flags & EM_FORMAT_HANDLER_INLINE_DISPOSITION) - return TRUE; + g_return_val_if_fail (EM_IS_FORMAT (emf), FALSE); + g_return_val_if_fail (part_id != NULL, FALSE); + g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), FALSE); - tmp = camel_mime_part_get_disposition(part); - if (tmp) - return g_ascii_strcasecmp(tmp, "inline") == 0; + class = EM_FORMAT_GET_CLASS (emf); + g_return_val_if_fail (class->is_inline != NULL, FALSE); - /* otherwise, use the default for this handler type */ - return (handle->flags & EM_FORMAT_HANDLER_INLINE) != 0; + return class->is_inline (emf, part_id, mime_part, handle); } /** diff --git a/em-format/em-format.h b/em-format/em-format.h index 965ca20399..5ae0e7f2ae 100644 --- a/em-format/em-format.h +++ b/em-format/em-format.h @@ -251,6 +251,11 @@ struct _EMFormatClass { /* Shows optional way to open messages */ void (*format_optional)(EMFormat *, CamelStream *, CamelMimePart *, CamelStream* ); + gboolean (*is_inline) (EMFormat *emf, + const gchar *part_id, + CamelMimePart *mime_part, + const EMFormatHandler *handle); + /* signals */ /* complete, alternative to polling busy, for asynchronous work */ void (*complete)(EMFormat *); @@ -277,9 +282,9 @@ void em_format_add_header (EMFormat *emf, gint em_format_is_attachment (EMFormat *emf, CamelMimePart *part); -gint em_format_is_inline (EMFormat *emf, - const gchar *partid, - CamelMimePart *part, +gboolean em_format_is_inline (EMFormat *emf, + const gchar *part_id, + CamelMimePart *mime_part, const EMFormatHandler *handle); void em_format_set_inline (EMFormat *emf, const gchar *partid, diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c index e660602e46..f7eb288fba 100644 --- a/mail/em-format-html-print.c +++ b/mail/em-format-html-print.c @@ -50,15 +50,29 @@ efhp_finalize (GObject *object) G_OBJECT_CLASS (parent_class)->finalize (object); } +static gboolean +efhp_is_inline (EMFormat *emf, + const gchar *part_id, + CamelMimePart *mime_part, + const EMFormatHandler *handle) +{ + /* When printing, inline any part that has a handler. */ + return (handle != NULL); +} + static void efhp_class_init (EMFormatHTMLPrintClass *class) { GObjectClass *object_class; + EMFormatClass *format_class; parent_class = g_type_class_peek_parent (class); object_class = G_OBJECT_CLASS (class); object_class->finalize = efhp_finalize; + + format_class = EM_FORMAT_CLASS (class); + format_class->is_inline = efhp_is_inline; } static void |