/* * 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/*", 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 ", part->id, uri); camel_stream_write_string (stream, str, cancellable, NULL); g_free (str); g_free (uri); } return TRUE; } static const gchar * emfe_text_plain_get_display_name (EMailFormatterExtension *extension) { return _("Plain Text"); } static const gchar * emfe_text_plain_get_description (EMailFormatterExtension *extension) { return _("Format part as plain text"); } static const gchar ** emfe_text_plain_mime_types (EMailExtension *extension) { return formatter_mime_types; } static void e_mail_formatter_text_plain_class_init (EMailFormatterTextPlainClass *klass) { e_mail_formatter_text_plain_parent_class = g_type_class_peek_parent (klass); } static void e_mail_formatter_formatter_extension_interface_init (EMailFormatterExtensionInterface *iface) { iface->format = emfe_text_plain_format; iface->get_display_name = emfe_text_plain_get_display_name; iface->get_description = emfe_text_plain_get_description; } static void e_mail_formatter_mail_extension_interface_init (EMailExtensionInterface *iface) { iface->mime_types = emfe_text_plain_mime_types; } static void e_mail_formatter_text_plain_init (EMailFormatterTextPlain *formatter) { }