diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-12-05 21:19:04 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-12-08 03:01:04 +0800 |
commit | 91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8 (patch) | |
tree | 1c06f36fa153eee0779cdfa1be1a24f62e93787d /em-format/e-mail-formatter-print-headers.c | |
parent | 2f0d83cf74b94d5e6272c07179df6e6c7a929789 (diff) | |
download | gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.gz gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.bz2 gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.lz gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.xz gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.tar.zst gsoc2013-evolution-91822b42dc7b5eb64cad2626f9fc620a2ee6a2c8.zip |
Make EMailPartList thread-safe.
Exposing data members in the public struct is unwise, especially when
EMailPartList is used from multiple threads. Instead keep the members
private and provide a set of thread-safe functions to manipulate them.
Diffstat (limited to 'em-format/e-mail-formatter-print-headers.c')
-rw-r--r-- | em-format/e-mail-formatter-print-headers.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/em-format/e-mail-formatter-print-headers.c b/em-format/e-mail-formatter-print-headers.c index 8cda0e598f..03ba7b2ccd 100644 --- a/em-format/e-mail-formatter-print-headers.c +++ b/em-format/e-mail-formatter-print-headers.c @@ -74,11 +74,11 @@ emfpe_headers_format (EMailFormatterExtension *extension, GString *str, *tmp; gchar *subject; const gchar *buf; - GSList *parts_iter; - GList *iter; gint attachments_count; gchar *part_id_prefix; const GQueue *headers; + GQueue queue = G_QUEUE_INIT; + GList *head, *link; buf = camel_medium_get_header (CAMEL_MEDIUM (part->part), "subject"); subject = camel_header_decode_string (buf, "UTF-8"); @@ -92,9 +92,8 @@ emfpe_headers_format (EMailFormatterExtension *extension, "cellpadding=\"0\" class=\"printing-header\">\n"); headers = e_mail_formatter_get_headers (formatter); - for (iter = headers->head; iter; iter = iter->next) { - - EMailFormatterHeader *header = iter->data; + for (link = headers->head; link != NULL; link = g_list_next (link)) { + EMailFormatterHeader *header = link->data; raw_header.name = header->name; /* Skip 'Subject' header, it's already displayed. */ @@ -111,7 +110,7 @@ emfpe_headers_format (EMailFormatterExtension *extension, CamelMimeMessage *message; const gchar *header_value; - message = context->part_list->message; + message = e_mail_part_list_get_message (context->part_list); header_value = camel_medium_get_header ( CAMEL_MEDIUM (message), header->name); @@ -135,12 +134,14 @@ emfpe_headers_format (EMailFormatterExtension *extension, /* Add encryption/signature header */ raw_header.name = _("Security"); tmp = g_string_new (""); - /* Find first secured part. */ - for (parts_iter = context->part_list->list; parts_iter; parts_iter = parts_iter->next) { - EMailPart *mail_part = parts_iter->data; - if (mail_part == NULL) - continue; + e_mail_part_list_queue_parts (context->part_list, NULL, &queue); + + head = g_queue_peek_head_link (&queue); + + /* Find first secured part. */ + for (link = head; link != NULL; link = g_list_next (link)) { + EMailPart *mail_part = link->data; if (!mail_part->validities) continue; @@ -185,11 +186,8 @@ emfpe_headers_format (EMailFormatterExtension *extension, /* Count attachments and display the number as a header */ attachments_count = 0; - for (parts_iter = context->part_list->list; parts_iter; parts_iter = parts_iter->next) { - - EMailPart *mail_part = parts_iter->data; - if (!mail_part) - continue; + for (link = head; link != NULL; link = g_list_next (link)) { + EMailPart *mail_part = link->data; if (!g_str_has_prefix (mail_part->id, part_id_prefix)) continue; @@ -210,6 +208,9 @@ emfpe_headers_format (EMailFormatterExtension *extension, g_free (raw_header.value); } + while (!g_queue_is_empty (&queue)) + e_mail_part_unref (g_queue_pop_head (&queue)); + g_string_append (str, "</table>"); camel_stream_write_string (stream, str->str, cancellable, NULL); |