/*
* e-mail-formatter-text-plain.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see
*
*/
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#include
#include "e-mail-formatter-extension.h"
#include "e-mail-inline-filter.h"
#include "e-mail-part-utils.h"
typedef EMailFormatterExtension EMailFormatterTextPlain;
typedef EMailFormatterExtensionClass EMailFormatterTextPlainClass;
GType e_mail_formatter_text_plain_get_type (void);
G_DEFINE_TYPE (
EMailFormatterTextPlain,
e_mail_formatter_text_plain,
E_TYPE_MAIL_FORMATTER_EXTENSION)
static const gchar *formatter_mime_types[] = {
"text/plain",
"text/*",
"message/*",
"application/vnd.evolution.plaintext",
NULL
};
static gboolean
emfe_text_plain_format (EMailFormatterExtension *extension,
EMailFormatter *formatter,
EMailFormatterContext *context,
EMailPart *part,
CamelStream *stream,
GCancellable *cancellable)
{
CamelStream *filtered_stream;
CamelMimeFilter *html_filter;
gchar *content;
const gchar *format;
guint32 rgb;
if (g_cancellable_is_cancelled (cancellable))
return FALSE;
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) {
camel_stream_write_string (
stream,
e_mail_formatter_get_sub_html_header (formatter),
cancellable,
NULL);
/* No need for body margins within