From c025ffbb296501d2da8cba78aa6a14008055cf87 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 16 May 2013 13:10:26 -0400 Subject: Add e_mail_part_get_id(). --- em-format/e-mail-formatter-attachment-bar.c | 3 +- em-format/e-mail-formatter-attachment.c | 20 +++++++++---- em-format/e-mail-formatter-headers.c | 2 +- em-format/e-mail-formatter-message-rfc822.c | 36 +++++++++++++++-------- em-format/e-mail-formatter-print-headers.c | 4 ++- em-format/e-mail-formatter-quote-message-rfc822.c | 16 ++++++---- em-format/e-mail-formatter-secure-button.c | 3 +- em-format/e-mail-formatter-text-html.c | 6 ++-- em-format/e-mail-formatter-text-plain.c | 6 ++-- em-format/e-mail-formatter-utils.c | 13 +++++--- em-format/e-mail-formatter.c | 5 +++- em-format/e-mail-parser.c | 4 +-- em-format/e-mail-part-list.c | 4 +-- em-format/e-mail-part.c | 8 +++++ em-format/e-mail-part.h | 1 + 15 files changed, 89 insertions(+), 42 deletions(-) (limited to 'em-format') diff --git a/em-format/e-mail-formatter-attachment-bar.c b/em-format/e-mail-formatter-attachment-bar.c index 61c1509cd1..b18ce067e5 100644 --- a/em-format/e-mail-formatter-attachment-bar.c +++ b/em-format/e-mail-formatter-attachment-bar.c @@ -59,7 +59,8 @@ emfe_attachment_bar_format (EMailFormatterExtension *extension, str = g_strdup_printf ( "", - part->id, part->id); + e_mail_part_get_id (part), + e_mail_part_get_id (part)); camel_stream_write_string (stream, str, cancellable, NULL); diff --git a/em-format/e-mail-formatter-attachment.c b/em-format/e-mail-formatter-attachment.c index 08b0da2042..40eb68c1b3 100644 --- a/em-format/e-mail-formatter-attachment.c +++ b/em-format/e-mail-formatter-attachment.c @@ -61,7 +61,7 @@ find_attachment_store (EMailPartList *part_list, EMailPart *part; gchar *id; - start_id = start->id; + start_id = e_mail_part_get_id (start); e_mail_part_list_queue_parts (part_list, NULL, &queue); @@ -75,8 +75,11 @@ find_attachment_store (EMailPartList *part_list, for (link = head; link != NULL; link = g_list_next (link)) { EMailPart *p = link->data; + const gchar *p_id; - if (g_strcmp0 (p->id, id) == 0) { + p_id = e_mail_part_get_id (p); + + if (g_strcmp0 (p_id, id) == 0) { part = p; break; } @@ -121,10 +124,12 @@ emfe_attachment_format (EMailFormatterExtension *extension, EMailPartAttachment *empa; CamelMimeFilterToHTMLFlags flags; const gchar *attachment_part_id; + const gchar *part_id; g_return_val_if_fail (E_IS_MAIL_PART_ATTACHMENT (part), FALSE); empa = (EMailPartAttachment *) part; + part_id = e_mail_part_get_id (part); if ((context->mode == E_MAIL_FORMATTER_MODE_NORMAL) || (context->mode == E_MAIL_FORMATTER_MODE_PRINTING) || @@ -163,7 +168,7 @@ emfe_attachment_format (EMailFormatterExtension *extension, } g_list_free (attachments); } else { - g_warning ("Failed to locate attachment-bar for %s", part->id); + g_warning ("Failed to locate attachment-bar for %s", part_id); } g_object_unref (attachment); @@ -254,7 +259,7 @@ emfe_attachment_format (EMailFormatterExtension *extension, if (empa->attachment_view_part_id) attachment_part_id = empa->attachment_view_part_id; else - attachment_part_id = part->id; + attachment_part_id = part_id; button_id = g_strconcat (attachment_part_id, ".attachment_button", NULL); @@ -267,7 +272,7 @@ emfe_attachment_format (EMailFormatterExtension *extension, "height=\"20\" width=\"100\" data=\"%s\" id=\"%s\">" "" "%s" - "", part->id, button_id, html); + "", part_id, button_id, html); camel_stream_write_string (stream, str, cancellable, NULL); g_free (button_id); @@ -362,17 +367,20 @@ emfe_attachment_get_widget (EMailFormatterExtension *extension, EAttachmentStore *store; EAttachmentView *view; GtkWidget *widget; + const gchar *part_id; g_return_val_if_fail (E_IS_MAIL_PART_ATTACHMENT (part), NULL); attachment = g_object_ref ( E_MAIL_PART_ATTACHMENT (part)->attachment); + part_id = e_mail_part_get_id (part); + store = find_attachment_store (context, part); widget = e_attachment_button_new (); g_object_set_data_full ( G_OBJECT (widget), - "uri", g_strdup (part->id), + "uri", g_strdup (part_id), (GDestroyNotify) g_free); e_attachment_button_set_attachment ( E_ATTACHMENT_BUTTON (widget), attachment); diff --git a/em-format/e-mail-formatter-headers.c b/em-format/e-mail-formatter-headers.c index a3d7b20680..afe780a4ee 100644 --- a/em-format/e-mail-formatter-headers.c +++ b/em-format/e-mail-formatter-headers.c @@ -580,7 +580,7 @@ emfe_headers_format (EMailFormatterExtension *extension, "style=\"color: #%06x; direction: %s\">" "", e_rgba_to_value (body_rgba), - part->id, + e_mail_part_get_id (part), e_rgba_to_value (header_rgba), direction); diff --git a/em-format/e-mail-formatter-message-rfc822.c b/em-format/e-mail-formatter-message-rfc822.c index 8059e55e76..8e7b1cee8b 100644 --- a/em-format/e-mail-formatter-message-rfc822.c +++ b/em-format/e-mail-formatter-message-rfc822.c @@ -53,6 +53,10 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, CamelStream *stream, GCancellable *cancellable) { + const gchar *part_id; + + part_id = e_mail_part_get_id (part); + if (g_cancellable_is_cancelled (cancellable)) return FALSE; @@ -69,7 +73,7 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, context->mode = E_MAIL_FORMATTER_MODE_NORMAL; e_mail_part_list_queue_parts ( - context->part_list, part->id, &queue); + context->part_list, part_id, &queue); /* Discard the first EMailPart. */ if (!g_queue_is_empty (&queue)) @@ -77,19 +81,22 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, head = g_queue_peek_head_link (&queue); - end = g_strconcat (part->id, ".end", NULL); + end = g_strconcat (part_id, ".end", NULL); for (link = head; link != NULL; link = g_list_next (link)) { EMailPart *p = link->data; + const gchar *p_id; + + p_id = e_mail_part_get_id (p); /* Check for nested rfc822 messages */ if (g_str_has_suffix (p->id, ".rfc822")) { - gchar *sub_end = g_strconcat (p->id, ".end", NULL); + gchar *sub_end = g_strconcat (p_id, ".end", NULL); while (link != NULL) { p = link->data; - if (g_strcmp0 (p->id, sub_end) == 0) + if (g_strcmp0 (p_id, sub_end) == 0) break; link = g_list_next (link); @@ -98,7 +105,7 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, continue; } - if ((g_strcmp0 (p->id, end) == 0)) + if ((g_strcmp0 (p_id, end) == 0)) break; if (p->is_hidden) @@ -125,7 +132,7 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, /* Part is EMailPartAttachment */ e_mail_part_list_queue_parts ( - context->part_list, part->id, &queue); + context->part_list, part_id, &queue); /* Discard the first EMailPart. */ if (!g_queue_is_empty (&queue)) @@ -135,26 +142,29 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, return FALSE; part = g_queue_pop_head (&queue); - end = g_strconcat (part->id, ".end", NULL); + end = g_strconcat (part_id, ".end", NULL); e_mail_part_unref (part); head = g_queue_peek_head_link (&queue); for (link = head; link != NULL; link = g_list_next (link)) { EMailPart *p = link->data; + const gchar *p_id; /* Skip attachment bar */ if (g_str_has_suffix (part->id, ".attachment-bar")) continue; + p_id = e_mail_part_get_id (p); + /* Check for nested rfc822 messages */ if (g_str_has_suffix (p->id, ".rfc822")) { - gchar *sub_end = g_strconcat (p->id, ".end", NULL); + gchar *sub_end = g_strconcat (p_id, ".end", NULL); while (link != NULL) { p = link->data; - if (g_strcmp0 (p->id, sub_end) == 0) + if (g_strcmp0 (p_id, sub_end) == 0) break; link = g_list_next (link); @@ -163,7 +173,7 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, continue; } - if ((g_strcmp0 (p->id, end) == 0)) + if ((g_strcmp0 (p_id, end) == 0)) break; if (p->is_hidden) @@ -187,7 +197,7 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, gchar *str; gchar *uri; - p = e_mail_part_list_ref_part (context->part_list, part->id); + p = e_mail_part_list_ref_part (context->part_list, part_id); if (p == NULL) return FALSE; @@ -203,7 +213,7 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, uri = e_mail_part_build_uri ( folder, message_uid, - "part_id", G_TYPE_STRING, p->id, + "part_id", G_TYPE_STRING, e_mail_part_get_id (p), "mode", G_TYPE_INT, E_MAIL_FORMATTER_MODE_RAW, "headers_collapsable", G_TYPE_INT, 0, "formatter_default_charset", G_TYPE_STRING, default_charset, @@ -223,7 +233,7 @@ emfe_message_rfc822_format (EMailFormatterExtension *extension, e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_BODY)), - part->id, uri, part->id); + part_id, uri, part_id); camel_stream_write_string (stream, str, cancellable, NULL); diff --git a/em-format/e-mail-formatter-print-headers.c b/em-format/e-mail-formatter-print-headers.c index b739d6ce96..30d7a2827d 100644 --- a/em-format/e-mail-formatter-print-headers.c +++ b/em-format/e-mail-formatter-print-headers.c @@ -64,6 +64,7 @@ emfpe_headers_format (EMailFormatterExtension *extension, 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"); subject = camel_header_decode_string (buf, "UTF-8"); @@ -118,7 +119,8 @@ emfpe_headers_format (EMailFormatterExtension *extension, g_queue_free_full (headers_queue, (GDestroyNotify) e_mail_formatter_header_free); /* Get prefix of this PURI */ - part_id_prefix = g_strndup (part->id, g_strrstr (part->id, ".") - part->id); + part_id = e_mail_part_get_id (part); + part_id_prefix = g_strndup (part_id, g_strrstr (part_id, ".") - part_id); /* Add encryption/signature header */ raw_header.name = _("Security"); diff --git a/em-format/e-mail-formatter-quote-message-rfc822.c b/em-format/e-mail-formatter-quote-message-rfc822.c index 710ee9f18c..ae09a0285b 100644 --- a/em-format/e-mail-formatter-quote-message-rfc822.c +++ b/em-format/e-mail-formatter-quote-message-rfc822.c @@ -59,6 +59,9 @@ emfqe_message_rfc822_format (EMailFormatterExtension *extension, GList *head, *link; gchar *header, *end; EMailFormatterQuoteContext *qc = (EMailFormatterQuoteContext *) context; + const gchar *part_id; + + part_id = e_mail_part_get_id (part); if (g_cancellable_is_cancelled (cancellable)) return FALSE; @@ -67,7 +70,7 @@ emfqe_message_rfc822_format (EMailFormatterExtension *extension, camel_stream_write_string (stream, header, cancellable, NULL); g_free (header); - e_mail_part_list_queue_parts (context->part_list, part->id, &queue); + e_mail_part_list_queue_parts (context->part_list, part_id, &queue); if (g_queue_is_empty (&queue)) return FALSE; @@ -77,10 +80,13 @@ emfqe_message_rfc822_format (EMailFormatterExtension *extension, head = g_queue_peek_head (&queue); - end = g_strconcat (part->id, ".end", NULL); + end = g_strconcat (part_id, ".end", NULL); for (link = head; link != NULL; link = g_list_next (link)) { EMailPart *p = link->data; + const gchar *p_id; + + p_id = e_mail_part_get_id (p); /* Skip attachment bar */ if (g_str_has_suffix (p->id, ".attachment-bar")) @@ -99,12 +105,12 @@ emfqe_message_rfc822_format (EMailFormatterExtension *extension, /* Check for nested rfc822 messages */ if (g_str_has_suffix (p->id, ".rfc822")) { - gchar *sub_end = g_strconcat (p->id, ".end", NULL); + gchar *sub_end = g_strconcat (p_id, ".end", NULL); while (link != NULL) { p = link->data; - if (g_strcmp0 (p->id, sub_end) == 0) + if (g_strcmp0 (p_id, sub_end) == 0) break; link = g_list_next (link); @@ -113,7 +119,7 @@ emfqe_message_rfc822_format (EMailFormatterExtension *extension, continue; } - if ((g_strcmp0 (p->id, end) == 0)) + if ((g_strcmp0 (p_id, end) == 0)) break; if (p->is_hidden) diff --git a/em-format/e-mail-formatter-secure-button.c b/em-format/e-mail-formatter-secure-button.c index 83e88d5752..91a330348f 100644 --- a/em-format/e-mail-formatter-secure-button.c +++ b/em-format/e-mail-formatter-secure-button.c @@ -88,7 +88,8 @@ emfe_secure_button_format (EMailFormatterExtension *extension, str = g_strdup_printf ( "", - part->id, part->id); + e_mail_part_get_id (part), + e_mail_part_get_id (part)); camel_stream_write_string (stream, str, cancellable, NULL); diff --git a/em-format/e-mail-formatter-text-html.c b/em-format/e-mail-formatter-text-html.c index f730f1217b..0a581117a6 100644 --- a/em-format/e-mail-formatter-text-html.c +++ b/em-format/e-mail-formatter-text-html.c @@ -312,7 +312,7 @@ emfe_text_html_format (EMailFormatterExtension *extension, uri = e_mail_part_build_uri ( folder, message_uid, - "part_id", G_TYPE_STRING, part->id, + "part_id", G_TYPE_STRING, e_mail_part_get_id (part), "mode", G_TYPE_INT, E_MAIL_FORMATTER_MODE_RAW, "formatter_default_charset", G_TYPE_STRING, default_charset, "formatter_charset", G_TYPE_STRING, charset, @@ -332,8 +332,8 @@ emfe_text_html_format (EMailFormatterExtension *extension, "" "", uri, - part->id, - part->id, + e_mail_part_get_id (part), + e_mail_part_get_id (part), e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_FRAME))); diff --git a/em-format/e-mail-formatter-text-plain.c b/em-format/e-mail-formatter-text-plain.c index 122c566cf0..33ede66957 100644 --- a/em-format/e-mail-formatter-text-plain.c +++ b/em-format/e-mail-formatter-text-plain.c @@ -149,7 +149,7 @@ emfe_text_plain_format (EMailFormatterExtension *extension, uri = e_mail_part_build_uri ( folder, message_uid, - "part_id", G_TYPE_STRING, part->id, + "part_id", G_TYPE_STRING, e_mail_part_get_id (part), "mode", G_TYPE_INT, E_MAIL_FORMATTER_MODE_RAW, "formatter_default_charset", G_TYPE_STRING, default_charset, "formatter_charset", G_TYPE_STRING, charset, @@ -163,7 +163,9 @@ emfe_text_plain_format (EMailFormatterExtension *extension, " style=\"border: 1px solid #%06x; background-color: #%06x;\">" "" "", - part->id, part->id, uri, + e_mail_part_get_id (part), + e_mail_part_get_id (part), + uri, e_rgba_to_value ( e_mail_formatter_get_color ( formatter, E_MAIL_FORMATTER_COLOR_FRAME)), diff --git a/em-format/e-mail-formatter-utils.c b/em-format/e-mail-formatter-utils.c index 775ef1d6cc..fe4c887756 100644 --- a/em-format/e-mail-formatter-utils.c +++ b/em-format/e-mail-formatter-utils.c @@ -470,20 +470,25 @@ e_mail_formatter_find_rfc822_end_iter (GList *rfc822_start_iter) { GList *link = rfc822_start_iter; EMailPart *part; + const gchar *part_id; gchar *end; g_return_val_if_fail (rfc822_start_iter != NULL, NULL); part = E_MAIL_PART (link->data); - g_return_val_if_fail (part != NULL, NULL); - end = g_strconcat (part->id, ".end", NULL); + part_id = e_mail_part_get_id (part); + g_return_val_if_fail (part_id != NULL, NULL); + + end = g_strconcat (part_id, ".end", NULL); while (link != NULL) { part = E_MAIL_PART (link->data); - g_return_val_if_fail (part != NULL, NULL); - if (g_strcmp0 (part->id, end) == 0) + part_id = e_mail_part_get_id (part); + g_return_val_if_fail (part_id != NULL, NULL); + + if (g_strcmp0 (part_id, end) == 0) break; link = g_list_next (link); diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c index ad203d83ad..fb1c069ffa 100644 --- a/em-format/e-mail-formatter.c +++ b/em-format/e-mail-formatter.c @@ -396,8 +396,11 @@ mail_formatter_run (EMailFormatter *formatter, for (link = head; link != NULL; link = g_list_next (link)) { EMailPart *part = link->data; + const gchar *part_id; gboolean ok; + part_id = e_mail_part_get_id (part); + if (g_cancellable_is_cancelled (cancellable)) break; @@ -451,7 +454,7 @@ mail_formatter_run (EMailFormatter *formatter, /* .message is the entire message. There's nothing more * to be written. */ - if (g_strcmp0 (part->id, ".message") == 0) + if (g_strcmp0 (part_id, ".message") == 0) break; /* If we just wrote source of a rfc822 message, then jump diff --git a/em-format/e-mail-parser.c b/em-format/e-mail-parser.c index 174d88ca69..39ffba8085 100644 --- a/em-format/e-mail-parser.c +++ b/em-format/e-mail-parser.c @@ -363,7 +363,7 @@ e_mail_parser_parse_sync (EMailParser *parser, printf ( " id: %s | cid: %s | mime_type: %s | " "is_hidden: %d | is_attachment: %d\n", - part->id, + e_mail_part_get_id (part), part->cid, part->mime_type, part->is_hidden ? 1 : 0, @@ -467,7 +467,7 @@ e_mail_parser_parse_finish (EMailParser *parser, printf ( " id: %s | cid: %s | mime_type: %s | " "is_hidden: %d | is_attachment: %d\n", - part->id, + e_mail_part_get_id (part), part->cid, part->mime_type, part->is_hidden ? 1 : 0, diff --git a/em-format/e-mail-part-list.c b/em-format/e-mail-part-list.c index e6ccc5733b..c3ace21fa7 100644 --- a/em-format/e-mail-part-list.c +++ b/em-format/e-mail-part-list.c @@ -324,7 +324,7 @@ e_mail_part_list_ref_part (EMailPartList *part_list, if (by_cid) candidate_id = candidate->cid; else - candidate_id = candidate->id; + candidate_id = e_mail_part_get_id (candidate); if (g_strcmp0 (candidate_id, part_id) == 0) { match = e_mail_part_ref (candidate); @@ -372,7 +372,7 @@ e_mail_part_list_queue_parts (EMailPartList *part_list, EMailPart *candidate = E_MAIL_PART (link->data); const gchar *candidate_id; - candidate_id = candidate->id; + candidate_id = e_mail_part_get_id (candidate); if (g_strcmp0 (candidate_id, part_id) == 0) break; diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c index 5b39e0a8f5..e6b0576d2e 100644 --- a/em-format/e-mail-part.c +++ b/em-format/e-mail-part.c @@ -175,6 +175,14 @@ e_mail_part_get_instance_size (EMailPart *part) return part->priv->instance_size; } +const gchar * +e_mail_part_get_id (EMailPart *part) +{ + g_return_val_if_fail (part != NULL, NULL); + + return part->id; +} + 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 9131e7fbdb..f1e48051f8 100644 --- a/em-format/e-mail-part.h +++ b/em-format/e-mail-part.h @@ -95,6 +95,7 @@ void e_mail_part_unref (EMailPart *part); gsize e_mail_part_get_instance_size (EMailPart *part); +const gchar * e_mail_part_get_id (EMailPart *part); void e_mail_part_update_validity (EMailPart *part, CamelCipherValidity *validity, guint32 validity_type); -- cgit v1.2.3