static gboolean empe_msg_deliverystatus_parse (EMailParserExtension *extension, EMailParser *parser, CamelMimePart *part, GString *part_id, GCancellable *cancellable, GQueue *out_mail_parts) { GQueue work_queue = G_QUEUE_INIT; EMailPart *mail_part; gsize len; len = part_id->len; g_string_append (part_id, ".delivery-status"); mail_part = e_mail_part_new (part, part_id->str); e_mail_part_set_mime_type (mail_part, "text/plain"); g_string_truncate (part_id, len); g_queue_push_tail (&work_queue, mail_part); /* The only reason for having a separate parser for * message/delivery-status is to display the part as an attachment */ e_mail_parser_wrap_as_attachment (parser, part, part_id, &work_queue); e_queue_transfer (&work_queue, out_mail_parts); return TRUE; }
static gboolean empe_message_parse (EMailParserExtension *extension, EMailParser *parser, CamelMimePart *part, GString *part_id, GCancellable *cancellable, GQueue *out_mail_parts) { GQueue work_queue = G_QUEUE_INIT; CamelContentType *ct; EMailPart *mail_part; gchar *mime_type; /* Headers */ e_mail_parser_parse_part_as ( parser, part, part_id, "application/vnd.evolution.headers", cancellable, out_mail_parts); ct = camel_mime_part_get_content_type (part); mime_type = camel_content_type_simple (ct); if (camel_content_type_is (ct, "message", "*")) { /* get mime type of the content of the message, * instead of using a generic message/rfc822 */ CamelDataWrapper *content; content = camel_medium_get_content (CAMEL_MEDIUM (part)); if (content) { ct = camel_data_wrapper_get_mime_type_field (content); g_free (mime_type); mime_type = camel_content_type_simple (ct); } } /* Actual message body */ e_mail_parser_parse_part_as ( parser, part, part_id, mime_type, cancellable, &work_queue); /* If the EMailPart representing the message body is marked as an * attachment, wrap it as such so it gets added to the attachment * bar but also set the "force_inline" flag since it doesn't make * sense to collapse the message body if we can render it. */ mail_part = g_queue_peek_head (&work_queue); if (mail_part != NULL && !E_IS_MAIL_PART_ATTACHMENT (mail_part)) { if (e_mail_part_get_is_attachment (mail_part)) { e_mail_parser_wrap_as_attachment ( parser, part, part_id, &work_queue); mail_part = g_queue_peek_head (&work_queue); if (mail_part != NULL) mail_part->force_inline = TRUE; } } e_queue_transfer (&work_queue, out_mail_parts); g_free (mime_type); return TRUE; }
static gboolean empe_mp_digest_parse (EMailParserExtension *extension, EMailParser *parser, CamelMimePart *part, GString *part_id, GCancellable *cancellable, GQueue *out_mail_parts) { CamelMultipart *mp; gint i, nparts, len; mp = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) part); if (!CAMEL_IS_MULTIPART (mp)) return e_mail_parser_parse_part_as ( parser, part, part_id, "application/vnd.evolution.source", cancellable, out_mail_parts); len = part_id->len; nparts = camel_multipart_get_number (mp); for (i = 0; i < nparts; i++) { CamelMimePart *subpart; CamelContentType *ct; gchar *cts; subpart = camel_multipart_get_part (mp, i); if (!subpart) continue; g_string_append_printf (part_id, ".digest.%d", i); ct = camel_mime_part_get_content_type (subpart); /* According to RFC this shouldn't happen, but who knows... */ if (ct && !camel_content_type_is (ct, "message", "rfc822")) { cts = camel_content_type_simple (ct); e_mail_parser_parse_part_as ( parser, subpart, part_id, cts, cancellable, out_mail_parts); g_free (cts); } else { GQueue work_queue = G_QUEUE_INIT; EMailPart *mail_part; gboolean wrap_as_attachment; e_mail_parser_parse_part_as ( parser, subpart, part_id, "message/rfc822", cancellable, &work_queue); mail_part = g_queue_peek_head (&work_queue); wrap_as_attachment = (mail_part != NULL) && !e_mail_part_get_is_attachment (mail_part); /* Force the message to be collapsable */ if (wrap_as_attachment) e_mail_parser_wrap_as_attachment ( parser, subpart, part_id, &work_queue); mail_part = g_queue_peek_head (&work_queue); /* Force the message to be expanded */ if (mail_part != NULL) mail_part->force_inline = TRUE; e_queue_transfer (&work_queue, out_mail_parts); } g_string_truncate (part_id, len); } return TRUE; }