evolution-3.6.4/em-format/e-mail-formatter-quote-text-plain.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-formatter-quote-text-plain.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-formatter-quote-text-plain.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  1 /*
  2  * e-mail-formatter-quote-text-plain.c
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) version 3.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  */
 18 
 19 #ifdef HAVE_CONFIG_H
 20 #include <config.h>
 21 #endif
 22 
 23 #include "e-mail-format-extensions.h"
 24 
 25 #include <em-format/e-mail-formatter-extension.h>
 26 #include <em-format/e-mail-formatter-quote.h>
 27 #include <em-format/e-mail-part-utils.h>
 28 #include <em-format/e-mail-stripsig-filter.h>
 29 #include <e-util/e-util.h>
 30 
 31 #include <glib/gi18n-lib.h>
 32 #include <camel/camel.h>
 33 
 34 static const gchar *formatter_mime_types[] = { "text/plain", NULL };
 35 
 36 typedef struct _EMailFormatterQuoteTextPlain {
 37 	GObject parent;
 38 } EMailFormatterQuoteTextPlain;
 39 
 40 typedef struct _EMailFormatterQuoteTextPlainClass {
 41 	GObjectClass parent_class;
 42 } EMailFormatterQuoteTextPlainClass;
 43 
 44 static void e_mail_formatter_quote_formatter_extension_interface_init
 45 					(EMailFormatterExtensionInterface *iface);
 46 static void e_mail_formatter_quote_mail_extension_interface_init
 47 					(EMailExtensionInterface *iface);
 48 
 49 G_DEFINE_TYPE_EXTENDED (
 50 	EMailFormatterQuoteTextPlain,
 51 	e_mail_formatter_quote_text_plain,
 52 	G_TYPE_OBJECT,
 53 	0,
 54 	G_IMPLEMENT_INTERFACE (
 55 		E_TYPE_MAIL_EXTENSION,
 56 		e_mail_formatter_quote_mail_extension_interface_init)
 57 	G_IMPLEMENT_INTERFACE (
 58 		E_TYPE_MAIL_FORMATTER_EXTENSION,
 59 		e_mail_formatter_quote_formatter_extension_interface_init));
 60 
 61 static gboolean
 62 emqfe_text_plain_format (EMailFormatterExtension *extension,
 63                          EMailFormatter *formatter,
 64                          EMailFormatterContext *context,
 65                          EMailPart *part,
 66                          CamelStream *stream,
 67                          GCancellable *cancellable)
 68 {
 69 	CamelStream *filtered_stream;
 70 	CamelMimeFilter *html_filter;
 71 	CamelMimeFilter *sig_strip;
 72 	CamelContentType *type;
 73 	EMailFormatterQuoteContext *qf_context;
 74 	const gchar *format;
 75 	guint32 rgb = 0x737373, text_flags;
 76 
 77 	if (!part->part)
 78 		return FALSE;
 79 
 80 	qf_context = (EMailFormatterQuoteContext *) context;
 81 
 82 	text_flags = CAMEL_MIME_FILTER_TOHTML_PRE |
 83 		CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS |
 84 		CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES;
 85 
 86 	if (e_mail_formatter_get_mark_citations (formatter)) {
 87 		text_flags |= CAMEL_MIME_FILTER_TOHTML_MARK_CITATION;
 88 	}
 89 
 90 	/* Check for RFC 2646 flowed text. */
 91 	type = camel_mime_part_get_content_type (part->part);
 92 	if (camel_content_type_is (type, "text", "plain")
 93 	    && (format = camel_content_type_param (type, "format"))
 94 	    && !g_ascii_strcasecmp (format, "flowed"))
 95 		text_flags |= CAMEL_MIME_FILTER_TOHTML_FORMAT_FLOWED;
 96 
 97 	filtered_stream = camel_stream_filter_new (stream);
 98 
 99 	if ((qf_context->qf_flags & E_MAIL_FORMATTER_QUOTE_FLAG_KEEP_SIG) == 0) {
100 		sig_strip = e_mail_stripsig_filter_new (TRUE);
101 		camel_stream_filter_add (
102 			CAMEL_STREAM_FILTER (filtered_stream), sig_strip);
103 		g_object_unref (sig_strip);
104 	}
105 
106 	html_filter = camel_mime_filter_tohtml_new (text_flags, rgb);
107 	camel_stream_filter_add (
108 		CAMEL_STREAM_FILTER (filtered_stream), html_filter);
109 	g_object_unref (html_filter);
110 
111 	e_mail_formatter_format_text (
112 		formatter, part, filtered_stream, cancellable);
113 
114 	camel_stream_flush (filtered_stream, cancellable, NULL);
115 	g_object_unref (filtered_stream);
116 
117 	return TRUE;
118 }
119 
120 static const gchar *
121 emqfe_text_plain_get_display_name (EMailFormatterExtension *extension)
122 {
123 	return _("Plain Text");
124 }
125 
126 static const gchar *
127 emqfe_text_plain_get_description (EMailFormatterExtension *extension)
128 {
129 	return _("Format part as plain text");
130 }
131 
132 static const gchar **
133 emqfe_text_plain_mime_types (EMailExtension *extension)
134 {
135 	return formatter_mime_types;
136 }
137 
138 static void
139 e_mail_formatter_quote_text_plain_class_init (EMailFormatterQuoteTextPlainClass *class)
140 {
141 }
142 
143 static void
144 e_mail_formatter_quote_formatter_extension_interface_init (EMailFormatterExtensionInterface *iface)
145 {
146 	iface->format = emqfe_text_plain_format;
147 	iface->get_display_name = emqfe_text_plain_get_display_name;
148 	iface->get_description = emqfe_text_plain_get_description;
149 }
150 
151 static void
152 e_mail_formatter_quote_mail_extension_interface_init (EMailExtensionInterface *iface)
153 {
154 	iface->mime_types = emqfe_text_plain_mime_types;
155 }
156 
157 static void
158 e_mail_formatter_quote_text_plain_init (EMailFormatterQuoteTextPlain *formatter)
159 {
160 
161 }