aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-08-10 18:01:18 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-08-10 18:03:19 +0800
commit221c841d423c567f3bfb8b12ea039d7e932fdefa (patch)
tree2f505fd3231fd264d6c7cefe347881c060978542 /em-format
parent4b92f70a49aeaf7d097a3be9aeccd82ebba4966d (diff)
downloadgsoc2013-evolution-221c841d423c567f3bfb8b12ea039d7e932fdefa.tar.gz
gsoc2013-evolution-221c841d423c567f3bfb8b12ea039d7e932fdefa.tar.zst
gsoc2013-evolution-221c841d423c567f3bfb8b12ea039d7e932fdefa.zip
Bug 626453 - Show attachments inline when printing
Diffstat (limited to 'em-format')
-rw-r--r--em-format/em-format.c60
-rw-r--r--em-format/em-format.h11
2 files changed, 50 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,