aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-05-18 23:24:40 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-05-20 01:07:20 +0800
commitf19058ea7a002e8ebf8351c55a86d3bb17a46cbc (patch)
tree0fdbb2c62ba31e92094ef7da2956f7caedd4840d
parent5ad0b6d8f7ee9244eb328b5951b98f8945e7b3cf (diff)
downloadgsoc2013-evolution-f19058ea7a002e8ebf8351c55a86d3bb17a46cbc.tar.gz
gsoc2013-evolution-f19058ea7a002e8ebf8351c55a86d3bb17a46cbc.tar.zst
gsoc2013-evolution-f19058ea7a002e8ebf8351c55a86d3bb17a46cbc.zip
Add e_mail_part_ref_mime_part().
-rw-r--r--em-format/e-mail-formatter-attachment.c5
-rw-r--r--em-format/e-mail-formatter-error.c6
-rw-r--r--em-format/e-mail-formatter-headers.c10
-rw-r--r--em-format/e-mail-formatter-image.c6
-rw-r--r--em-format/e-mail-formatter-print-headers.c15
-rw-r--r--em-format/e-mail-formatter-quote-attachment.c5
-rw-r--r--em-format/e-mail-formatter-quote-headers.c11
-rw-r--r--em-format/e-mail-formatter-quote-text-plain.c8
-rw-r--r--em-format/e-mail-formatter-source.c14
-rw-r--r--em-format/e-mail-formatter-text-plain.c12
-rw-r--r--em-format/e-mail-formatter.c13
-rw-r--r--em-format/e-mail-part.c25
-rw-r--r--em-format/e-mail-part.h1
-rw-r--r--mail/e-mail-display.c7
-rw-r--r--mail/e-mail-request.c6
-rw-r--r--modules/audio-inline/e-mail-formatter-audio-inline.c5
-rw-r--r--modules/text-highlight/e-mail-formatter-text-highlight.c21
17 files changed, 131 insertions, 39 deletions
diff --git a/em-format/e-mail-formatter-attachment.c b/em-format/e-mail-formatter-attachment.c
index 40eb68c1b3..b7df8aae9b 100644
--- a/em-format/e-mail-formatter-attachment.c
+++ b/em-format/e-mail-formatter-attachment.c
@@ -122,6 +122,7 @@ emfe_attachment_format (EMailFormatterExtension *extension,
EMailExtensionRegistry *reg;
GQueue *extensions;
EMailPartAttachment *empa;
+ CamelMimePart *mime_part;
CamelMimeFilterToHTMLFlags flags;
const gchar *attachment_part_id;
const gchar *part_id;
@@ -250,11 +251,13 @@ emfe_attachment_format (EMailFormatterExtension *extension,
reg, empa->snoop_mime_type);
}
- text = e_mail_part_describe (part->part, empa->snoop_mime_type);
+ mime_part = e_mail_part_ref_mime_part (part);
+ text = e_mail_part_describe (mime_part, empa->snoop_mime_type);
flags = e_mail_formatter_get_text_format_flags (formatter);
html = camel_text_to_html (
text, flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0);
g_free (text);
+ g_object_unref (mime_part);
if (empa->attachment_view_part_id)
attachment_part_id = empa->attachment_view_part_id;
diff --git a/em-format/e-mail-formatter-error.c b/em-format/e-mail-formatter-error.c
index a329abfffd..8669c11ced 100644
--- a/em-format/e-mail-formatter-error.c
+++ b/em-format/e-mail-formatter-error.c
@@ -51,10 +51,12 @@ emfe_error_format (EMailFormatterExtension *extension,
{
CamelStream *filtered_stream;
CamelMimeFilter *filter;
+ CamelMimePart *mime_part;
CamelDataWrapper *dw;
gchar *html;
- dw = camel_medium_get_content (CAMEL_MEDIUM (part->part));
+ mime_part = e_mail_part_ref_mime_part (part);
+ dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
html = g_strdup_printf (
"<div class=\"part-container\" style=\""
@@ -100,6 +102,8 @@ emfe_error_format (EMailFormatterExtension *extension,
"</div>",
cancellable, NULL);
+ g_object_unref (mime_part);
+
return TRUE;
}
diff --git a/em-format/e-mail-formatter-headers.c b/em-format/e-mail-formatter-headers.c
index afe780a4ee..39aceb30c7 100644
--- a/em-format/e-mail-formatter-headers.c
+++ b/em-format/e-mail-formatter-headers.c
@@ -532,6 +532,7 @@ emfe_headers_format (EMailFormatterExtension *extension,
CamelStream *stream,
GCancellable *cancellable)
{
+ CamelMimePart *mime_part;
GString *buffer;
const GdkRGBA white = { 1.0, 1.0, 1.0, 1.0 };
const GdkRGBA *body_rgba = &white;
@@ -543,7 +544,8 @@ emfe_headers_format (EMailFormatterExtension *extension,
if (g_cancellable_is_cancelled (cancellable))
return FALSE;
- if (!part->part)
+ mime_part = e_mail_part_ref_mime_part (part);
+ if (mime_part == NULL)
return FALSE;
switch (gtk_widget_get_default_direction ()) {
@@ -599,13 +601,13 @@ emfe_headers_format (EMailFormatterExtension *extension,
if (is_collapsable)
format_short_headers (
formatter, buffer,
- CAMEL_MEDIUM (part->part),
+ CAMEL_MEDIUM (mime_part),
context->flags,
cancellable);
format_full_headers (
formatter, buffer,
- CAMEL_MEDIUM (part->part),
+ CAMEL_MEDIUM (mime_part),
context->mode,
context->flags,
cancellable);
@@ -618,6 +620,8 @@ emfe_headers_format (EMailFormatterExtension *extension,
g_string_free (buffer, TRUE);
+ g_object_unref (mime_part);
+
return TRUE;
}
diff --git a/em-format/e-mail-formatter-image.c b/em-format/e-mail-formatter-image.c
index f69a59cdba..c504881f27 100644
--- a/em-format/e-mail-formatter-image.c
+++ b/em-format/e-mail-formatter-image.c
@@ -69,6 +69,7 @@ emfe_image_format (EMailFormatterExtension *extension,
GCancellable *cancellable)
{
gchar *content;
+ CamelMimePart *mime_part;
CamelDataWrapper *dw;
GByteArray *ba;
CamelStream *raw_content;
@@ -76,7 +77,8 @@ emfe_image_format (EMailFormatterExtension *extension,
if (g_cancellable_is_cancelled (cancellable))
return FALSE;
- dw = camel_medium_get_content (CAMEL_MEDIUM (part->part));
+ mime_part = e_mail_part_ref_mime_part (part);
+ dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
g_return_val_if_fail (dw, FALSE);
raw_content = camel_stream_mem_new ();
@@ -139,6 +141,8 @@ emfe_image_format (EMailFormatterExtension *extension,
g_object_unref (raw_content);
+ g_object_unref (mime_part);
+
return TRUE;
}
diff --git a/em-format/e-mail-formatter-print-headers.c b/em-format/e-mail-formatter-print-headers.c
index 6eec667463..65515508a5 100644
--- a/em-format/e-mail-formatter-print-headers.c
+++ b/em-format/e-mail-formatter-print-headers.c
@@ -61,12 +61,15 @@ emfpe_headers_format (EMailFormatterExtension *extension,
const gchar *buf;
gint attachments_count;
gchar *part_id_prefix;
+ CamelMimePart *mime_part;
GQueue *headers_queue;
GQueue queue = G_QUEUE_INIT;
GList *head, *link;
const gchar *part_id;
- buf = camel_medium_get_header (CAMEL_MEDIUM (part->part), "subject");
+ mime_part = e_mail_part_ref_mime_part (part);
+
+ buf = camel_medium_get_header (CAMEL_MEDIUM (mime_part), "subject");
subject = camel_header_decode_string (buf, "UTF-8");
str = g_string_new ("");
g_string_append_printf (str, "<h1>%s</h1>\n", subject);
@@ -90,7 +93,7 @@ emfpe_headers_format (EMailFormatterExtension *extension,
raw_header.value = header->value;
e_mail_formatter_format_header (
formatter, str,
- CAMEL_MEDIUM (part->part), &raw_header,
+ CAMEL_MEDIUM (mime_part), &raw_header,
header->flags | E_MAIL_FORMATTER_HEADER_FLAG_NOLINKS,
"UTF-8");
} else {
@@ -106,7 +109,7 @@ emfpe_headers_format (EMailFormatterExtension *extension,
if (raw_header.value && *raw_header.value) {
e_mail_formatter_format_header (
formatter, str,
- CAMEL_MEDIUM (part->part), &raw_header,
+ CAMEL_MEDIUM (mime_part), &raw_header,
header->flags | E_MAIL_FORMATTER_HEADER_FLAG_NOLINKS,
"UTF-8");
}
@@ -169,7 +172,7 @@ emfpe_headers_format (EMailFormatterExtension *extension,
raw_header.value = tmp->str;
e_mail_formatter_format_header (
formatter, str,
- CAMEL_MEDIUM (part->part), &raw_header,
+ CAMEL_MEDIUM (mime_part), &raw_header,
E_MAIL_FORMATTER_HEADER_FLAG_BOLD |
E_MAIL_FORMATTER_HEADER_FLAG_NOLINKS, "UTF-8");
}
@@ -201,7 +204,7 @@ emfpe_headers_format (EMailFormatterExtension *extension,
raw_header.value = g_strdup_printf ("%d", attachments_count);
e_mail_formatter_format_header (
formatter, str,
- CAMEL_MEDIUM (part->part), &raw_header,
+ CAMEL_MEDIUM (mime_part), &raw_header,
E_MAIL_FORMATTER_HEADER_FLAG_BOLD |
E_MAIL_FORMATTER_HEADER_FLAG_NOLINKS, "UTF-8");
g_free (raw_header.value);
@@ -216,6 +219,8 @@ emfpe_headers_format (EMailFormatterExtension *extension,
g_string_free (str, TRUE);
g_free (part_id_prefix);
+ g_object_unref (mime_part);
+
return TRUE;
}
diff --git a/em-format/e-mail-formatter-quote-attachment.c b/em-format/e-mail-formatter-quote-attachment.c
index 6f5068bae1..3443392555 100644
--- a/em-format/e-mail-formatter-quote-attachment.c
+++ b/em-format/e-mail-formatter-quote-attachment.c
@@ -59,6 +59,7 @@ emfqe_attachment_format (EMailFormatterExtension *extension,
EMailPartAttachment *empa;
EMailPart *attachment_view_part;
CamelMimeFilterToHTMLFlags text_format_flags;
+ CamelMimePart *mime_part;
empa = E_MAIL_PART_ATTACHMENT (part);
@@ -74,9 +75,11 @@ emfqe_attachment_format (EMailFormatterExtension *extension,
text_format_flags =
e_mail_formatter_get_text_format_flags (formatter);
+ mime_part = e_mail_part_ref_mime_part (part);
text = e_mail_part_describe (
- part->part,
+ mime_part,
empa ? empa->snoop_mime_type : part->mime_type);
+ g_object_unref (mime_part);
html = camel_text_to_html (
text,
diff --git a/em-format/e-mail-formatter-quote-headers.c b/em-format/e-mail-formatter-quote-headers.c
index fa6c02752b..f23397b3b5 100644
--- a/em-format/e-mail-formatter-quote-headers.c
+++ b/em-format/e-mail-formatter-quote-headers.c
@@ -190,6 +190,7 @@ emqfe_headers_format (EMailFormatterExtension *extension,
GCancellable *cancellable)
{
CamelContentType *ct;
+ CamelMimePart *mime_part;
const gchar *charset;
GList *iter;
GString *buffer;
@@ -198,7 +199,9 @@ emqfe_headers_format (EMailFormatterExtension *extension,
if (!part)
return FALSE;
- ct = camel_mime_part_get_content_type ((CamelMimePart *) part->part);
+ mime_part = e_mail_part_ref_mime_part (part);
+
+ ct = camel_mime_part_get_content_type (mime_part);
charset = camel_content_type_param (ct, "charset");
charset = camel_iconv_charset_name (charset);
@@ -214,13 +217,13 @@ emqfe_headers_format (EMailFormatterExtension *extension,
flags = h->flags & ~E_MAIL_FORMATTER_HEADER_FLAG_HTML;
flags |= E_MAIL_FORMATTER_HEADER_FLAG_NOELIPSIZE;
- for (raw_header = part->part->headers; raw_header; raw_header = raw_header->next) {
+ for (raw_header = mime_part->headers; raw_header; raw_header = raw_header->next) {
if (g_strcmp0 (raw_header->name, h->name) == 0) {
emfqe_format_header (
formatter, buffer,
- (CamelMedium *) part->part,
+ CAMEL_MEDIUM (mime_part),
raw_header, flags, charset);
break;
}
@@ -235,6 +238,8 @@ emqfe_headers_format (EMailFormatterExtension *extension,
g_string_free (buffer, TRUE);
+ g_object_unref (mime_part);
+
return TRUE;
}
diff --git a/em-format/e-mail-formatter-quote-text-plain.c b/em-format/e-mail-formatter-quote-text-plain.c
index 9544a39f96..efe0638e44 100644
--- a/em-format/e-mail-formatter-quote-text-plain.c
+++ b/em-format/e-mail-formatter-quote-text-plain.c
@@ -56,13 +56,15 @@ emqfe_text_plain_format (EMailFormatterExtension *extension,
CamelStream *filtered_stream;
CamelMimeFilter *html_filter;
CamelMimeFilter *sig_strip;
+ CamelMimePart *mime_part;
CamelContentType *type;
EMailFormatterQuoteContext *qf_context;
CamelMimeFilterToHTMLFlags text_flags;
const gchar *format;
guint32 rgb = 0x737373;
- if (!part->part)
+ mime_part = e_mail_part_ref_mime_part (part);
+ if (mime_part == NULL)
return FALSE;
qf_context = (EMailFormatterQuoteContext *) context;
@@ -76,7 +78,7 @@ emqfe_text_plain_format (EMailFormatterExtension *extension,
text_flags |= CAMEL_MIME_FILTER_TOHTML_MARK_CITATION;
/* Check for RFC 2646 flowed text. */
- type = camel_mime_part_get_content_type (part->part);
+ type = camel_mime_part_get_content_type (mime_part);
if (camel_content_type_is (type, "text", "plain")
&& (format = camel_content_type_param (type, "format"))
&& !g_ascii_strcasecmp (format, "flowed"))
@@ -102,6 +104,8 @@ emqfe_text_plain_format (EMailFormatterExtension *extension,
camel_stream_flush (filtered_stream, cancellable, NULL);
g_object_unref (filtered_stream);
+ g_object_unref (mime_part);
+
return TRUE;
}
diff --git a/em-format/e-mail-formatter-source.c b/em-format/e-mail-formatter-source.c
index faa4c76521..944f9a4c14 100644
--- a/em-format/e-mail-formatter-source.c
+++ b/em-format/e-mail-formatter-source.c
@@ -53,7 +53,9 @@ emfe_source_format (EMailFormatterExtension *extension,
GString *buffer;
CamelStream *filtered_stream;
CamelMimeFilter *filter;
- CamelDataWrapper *dw = (CamelDataWrapper *) part->part;
+ CamelMimePart *mime_part;
+
+ mime_part = e_mail_part_ref_mime_part (part);
filtered_stream = camel_stream_filter_new (stream);
@@ -67,7 +69,7 @@ emfe_source_format (EMailFormatterExtension *extension,
buffer = g_string_new ("");
- if (CAMEL_IS_MIME_MESSAGE (part->part)) {
+ if (CAMEL_IS_MIME_MESSAGE (mime_part)) {
g_string_append_printf (
buffer,
"<div class=\"part-container\" "
@@ -101,8 +103,8 @@ emfe_source_format (EMailFormatterExtension *extension,
stream, "<code class=\"pre\">", cancellable, NULL);
camel_data_wrapper_write_to_stream_sync (
- dw, filtered_stream,
- cancellable, NULL);
+ CAMEL_DATA_WRAPPER (mime_part),
+ filtered_stream, cancellable, NULL);
camel_stream_flush (filtered_stream, cancellable, NULL);
g_object_unref (filtered_stream);
@@ -111,12 +113,14 @@ emfe_source_format (EMailFormatterExtension *extension,
g_string_free (buffer, TRUE);
- if (CAMEL_IS_MIME_MESSAGE (part->part)) {
+ if (CAMEL_IS_MIME_MESSAGE (mime_part)) {
camel_stream_write_string (stream, "</div>", cancellable, NULL);
} else {
camel_stream_write_string (stream, "</div></div>", cancellable, NULL);
}
+ g_object_unref (mime_part);
+
return TRUE;
}
diff --git a/em-format/e-mail-formatter-text-plain.c b/em-format/e-mail-formatter-text-plain.c
index 33ede66957..638f0119a1 100644
--- a/em-format/e-mail-formatter-text-plain.c
+++ b/em-format/e-mail-formatter-text-plain.c
@@ -54,7 +54,6 @@ emfe_text_plain_format (EMailFormatterExtension *extension,
CamelStream *stream,
GCancellable *cancellable)
{
- CamelDataWrapper *dw;
CamelStream *filtered_stream;
CamelMimeFilter *html_filter;
gchar *content;
@@ -67,6 +66,8 @@ emfe_text_plain_format (EMailFormatterExtension *extension,
if ((context->mode == E_MAIL_FORMATTER_MODE_RAW) ||
(context->mode == E_MAIL_FORMATTER_MODE_PRINTING)) {
CamelMimeFilterToHTMLFlags flags;
+ CamelMimePart *mime_part;
+ CamelDataWrapper *dw;
if (context->mode == E_MAIL_FORMATTER_MODE_RAW) {
gchar *header;
@@ -83,9 +84,12 @@ emfe_text_plain_format (EMailFormatterExtension *extension,
flags = e_mail_formatter_get_text_format_flags (formatter);
- dw = camel_medium_get_content (CAMEL_MEDIUM (part->part));
- if (!dw)
+ mime_part = e_mail_part_ref_mime_part (part);
+ dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
+ if (dw == NULL) {
+ g_object_unref (mime_part);
return FALSE;
+ }
/* Check for RFC 2646 flowed text. */
if (camel_content_type_is (dw->mime_type, "text", "plain")
@@ -129,6 +133,8 @@ emfe_text_plain_format (EMailFormatterExtension *extension,
cancellable, NULL);
}
+ g_object_unref (mime_part);
+
return TRUE;
} else {
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index e2e6da75a3..4ce93a7db2 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -1037,14 +1037,14 @@ e_mail_formatter_format_text (EMailFormatter *formatter,
const gchar *charset = NULL;
CamelMimeFilter *windows = NULL;
CamelStream *mem_stream = NULL;
- CamelDataWrapper *dw;
+ CamelMimePart *mime_part;
CamelContentType *mime_type;
if (g_cancellable_is_cancelled (cancellable))
return;
- dw = CAMEL_DATA_WRAPPER (part->part);
- mime_type = dw->mime_type;
+ mime_part = e_mail_part_ref_mime_part (part);
+ mime_type = CAMEL_DATA_WRAPPER (mime_part)->mime_type;
if (formatter->priv->charset != NULL) {
charset = formatter->priv->charset;
@@ -1067,7 +1067,8 @@ e_mail_formatter_format_text (EMailFormatter *formatter,
CAMEL_STREAM_FILTER (filter_stream), windows);
camel_data_wrapper_decode_to_stream_sync (
- dw, filter_stream, cancellable, NULL);
+ CAMEL_DATA_WRAPPER (mime_part),
+ filter_stream, cancellable, NULL);
camel_stream_flush (filter_stream, cancellable, NULL);
g_object_unref (filter_stream);
@@ -1088,7 +1089,7 @@ e_mail_formatter_format_text (EMailFormatter *formatter,
}
camel_data_wrapper_decode_to_stream_sync (
- camel_medium_get_content (CAMEL_MEDIUM (dw)),
+ camel_medium_get_content (CAMEL_MEDIUM (mime_part)),
filter_stream, cancellable, NULL);
camel_stream_flush (filter_stream, cancellable, NULL);
g_object_unref (filter_stream);
@@ -1103,6 +1104,8 @@ e_mail_formatter_format_text (EMailFormatter *formatter,
g_object_unref (windows);
g_object_unref (mem_stream);
+
+ g_object_unref (mime_part);
}
gchar *
diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c
index 945175cca2..68434d0ce9 100644
--- a/em-format/e-mail-part.c
+++ b/em-format/e-mail-part.c
@@ -31,6 +31,8 @@
#include "e-mail-part.h"
+#include <string.h>
+
struct _EMailPartPrivate {
guint ref_cnt;
gsize instance_size;
@@ -221,6 +223,29 @@ e_mail_part_id_has_suffix (EMailPart *part,
return g_str_has_suffix (part->id, suffix);
}
+gboolean
+e_mail_part_id_has_substr (EMailPart *part,
+ const gchar *substr)
+{
+ g_return_val_if_fail (part != NULL, FALSE);
+ g_return_val_if_fail (substr != NULL, FALSE);
+
+ return (strstr (part->id, substr) != NULL);
+}
+
+CamelMimePart *
+e_mail_part_ref_mime_part (EMailPart *part)
+{
+ CamelMimePart *mime_part = NULL;
+
+ g_return_val_if_fail (part != NULL, NULL);
+
+ if (part->part != NULL)
+ mime_part = g_object_ref (part->part);
+
+ return mime_part;
+}
+
static EMailPartValidityPair *
mail_part_find_validity_pair (EMailPart *part,
guint32 validity_type)
diff --git a/em-format/e-mail-part.h b/em-format/e-mail-part.h
index c67cb8326f..3e9c7111d7 100644
--- a/em-format/e-mail-part.h
+++ b/em-format/e-mail-part.h
@@ -105,6 +105,7 @@ gboolean e_mail_part_id_has_suffix (EMailPart *part,
const gchar *suffix);
gboolean e_mail_part_id_has_substr (EMailPart *part,
const gchar *substr);
+CamelMimePart * e_mail_part_ref_mime_part (EMailPart *part);
void e_mail_part_update_validity (EMailPart *part,
CamelCipherValidity *validity,
guint32 validity_type);
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index c70e12ece2..3861fbbced 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -941,6 +941,7 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view,
e_attachment_button_set_expandable (
E_ATTACHMENT_BUTTON (widget), FALSE);
} else {
+ CamelMimePart *mime_part;
const CamelContentDisposition *disposition;
e_attachment_button_set_expandable (
@@ -957,11 +958,13 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view,
G_CALLBACK (attachment_button_expanded),
display);
+ mime_part = e_mail_part_ref_mime_part (part);
+
/* Automatically expand attachments that have inline
* disposition or the EMailParts have specific
* force_inline flag set. */
disposition =
- camel_mime_part_get_content_disposition (part->part);
+ camel_mime_part_get_content_disposition (mime_part);
if (!part->force_collapse &&
(part->force_inline ||
(g_strcmp0 (empa->snoop_mime_type, "message/rfc822") == 0) ||
@@ -977,6 +980,8 @@ mail_display_plugin_widget_requested (WebKitWebView *web_view,
attachment_button_expanded (
G_OBJECT (widget), NULL, display);
}
+
+ g_object_unref (mime_part);
}
}
diff --git a/mail/e-mail-request.c b/mail/e-mail-request.c
index 69b9a13533..1c88b74e33 100644
--- a/mail/e-mail-request.c
+++ b/mail/e-mail-request.c
@@ -142,10 +142,12 @@ handle_mail_request (GSimpleAsyncResult *res,
if (part != NULL) {
if (context.mode == E_MAIL_FORMATTER_MODE_CID) {
CamelDataWrapper *dw;
+ CamelMimePart *mime_part;
CamelStream *raw_content;
GByteArray *ba;
- dw = camel_medium_get_content (CAMEL_MEDIUM (part->part));
+ mime_part = e_mail_part_ref_mime_part (part);
+ dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
g_return_if_fail (dw);
raw_content = camel_stream_mem_new ();
@@ -155,6 +157,8 @@ handle_mail_request (GSimpleAsyncResult *res,
camel_stream_write (request->priv->output_stream, (gchar *) ba->data, ba->len, cancellable, NULL);
g_object_unref (raw_content);
+
+ g_object_unref (mime_part);
} else {
if (mime_type == NULL)
mime_type = part->mime_type;
diff --git a/modules/audio-inline/e-mail-formatter-audio-inline.c b/modules/audio-inline/e-mail-formatter-audio-inline.c
index 9c477bd2c8..3545efd3d4 100644
--- a/modules/audio-inline/e-mail-formatter-audio-inline.c
+++ b/modules/audio-inline/e-mail-formatter-audio-inline.c
@@ -176,6 +176,7 @@ play_clicked (GtkWidget *button,
if (!part->filename) {
CamelStream *stream;
CamelDataWrapper *data;
+ CamelMimePart *mime_part;
GError *error = NULL;
gint argc = 1;
const gchar *argv[] = { "org_gnome_audio_inline", NULL };
@@ -187,9 +188,11 @@ play_clicked (GtkWidget *button,
stream = camel_stream_fs_new_with_name (
part->filename, O_RDWR | O_CREAT | O_TRUNC, 0600, NULL);
- data = camel_medium_get_content (CAMEL_MEDIUM (part->parent.part));
+ mime_part = e_mail_part_ref_mime_part (E_MAIL_PART (part));
+ data = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
camel_data_wrapper_decode_to_stream_sync (data, stream, NULL, NULL);
camel_stream_flush (stream, NULL, NULL);
+ g_object_unref (mime_part);
g_object_unref (stream);
d (printf ("audio inline formatter: init gst playbin\n"));
diff --git a/modules/text-highlight/e-mail-formatter-text-highlight.c b/modules/text-highlight/e-mail-formatter-text-highlight.c
index 11fc546d74..de1d89b8e2 100644
--- a/modules/text-highlight/e-mail-formatter-text-highlight.c
+++ b/modules/text-highlight/e-mail-formatter-text-highlight.c
@@ -54,6 +54,9 @@ get_syntax (EMailPart *part,
{
gchar *syntax = NULL;
CamelContentType *ct = NULL;
+ CamelMimePart *mime_part;
+
+ mime_part = e_mail_part_ref_mime_part (part);
if (uri) {
SoupURI *soup_uri = soup_uri_new (uri);
@@ -69,7 +72,7 @@ get_syntax (EMailPart *part,
/* Try to detect syntax by content-type first */
if (syntax == NULL) {
- ct = camel_mime_part_get_content_type (part->part);
+ ct = camel_mime_part_get_content_type (mime_part);
if (ct) {
gchar *mime_type = camel_content_type_simple (ct);
@@ -87,7 +90,7 @@ get_syntax (EMailPart *part,
(camel_content_type_is (ct, "text", "plain"))))) {
const gchar *filename;
- filename = camel_mime_part_get_filename (part->part);
+ filename = camel_mime_part_get_filename (mime_part);
if (filename != NULL) {
gchar *ext = g_strrstr (filename, ".");
if (ext != NULL) {
@@ -102,6 +105,8 @@ get_syntax (EMailPart *part,
syntax = g_strdup ("txt");
}
+ g_object_unref (mime_part);
+
return syntax;
}
@@ -113,16 +118,18 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
CamelStream *stream,
GCancellable *cancellable)
{
+ CamelMimePart *mime_part;
CamelContentType *ct;
gboolean success = FALSE;
- ct = camel_mime_part_get_content_type (part->part);
+ mime_part = e_mail_part_ref_mime_part (part);
+ ct = camel_mime_part_get_content_type (mime_part);
/* Don't format text/html unless it's an attachment */
if (ct && camel_content_type_is (ct, "text", "html")) {
const CamelContentDisposition *disp;
- disp = camel_mime_part_get_content_disposition (part->part);
+ disp = camel_mime_part_get_content_disposition (mime_part);
if (disp == NULL)
goto exit;
@@ -136,7 +143,7 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
CamelStream *filter_stream;
CamelMimeFilter *mime_filter;
- dw = camel_medium_get_content (CAMEL_MEDIUM (part->part));
+ dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
if (dw == NULL)
goto exit;
@@ -181,7 +188,7 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
"--failsafe",
NULL };
- dw = camel_medium_get_content (CAMEL_MEDIUM (part->part));
+ dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
if (dw == NULL)
goto exit;
@@ -349,6 +356,8 @@ emfe_text_highlight_format (EMailFormatterExtension *extension,
success = TRUE;
exit:
+ g_object_unref (mime_part);
+
return success;
}