/*
* 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 "e-mail-format-extensions.h"
#include
#include
#include
#include
#include
#include
#include
static const gchar *formatter_mime_types[] = { "text/plain",
"text/*",
"message/*",
NULL };
typedef struct _EMailFormatterTextPlain {
GObject parent;
} EMailFormatterTextPlain;
typedef struct _EMailFormatterTextPlainClass {
GObjectClass parent_class;
} EMailFormatterTextPlainClass;
static void e_mail_formatter_formatter_extension_interface_init (EMailFormatterExtensionInterface *iface);
static void e_mail_formatter_mail_extension_interface_init (EMailExtensionInterface *iface);
G_DEFINE_TYPE_EXTENDED (
EMailFormatterTextPlain,
e_mail_formatter_text_plain,
G_TYPE_OBJECT,
0,
G_IMPLEMENT_INTERFACE (
E_TYPE_MAIL_EXTENSION,
e_mail_formatter_mail_extension_interface_init)
G_IMPLEMENT_INTERFACE (
E_TYPE_MAIL_FORMATTER_EXTENSION,
e_mail_formatter_formatter_extension_interface_init));
static gboolean
emfe_text_plain_format (EMailFormatterExtension *extension,
EMailFormatter *formatter,
EMailFormatterContext *context,
EMailPart *part,
CamelStream *stream,
GCancellable *cancellable)
{
CamelDataWrapper *dw;
CamelStream *filtered_stream;
CamelMimeFilter *html_filter;
gchar *content;
const gchar *format;
guint32 filter_flags;
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)) {
if (context->mode == E_MAIL_FORMATTER_MODE_RAW) {
gchar *header;
header = e_mail_formatter_get_html_header (formatter);
camel_stream_write_string (stream, header, cancellable, NULL);
g_free (header);
/* No need for body margins within