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

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-formatter-text-enriched.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-formatter-text-enriched.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-text-enriched.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.h>
 27 #include <em-format/e-mail-inline-filter.h>
 28 #include <e-util/e-util.h>
 29 
 30 #include <glib/gi18n-lib.h>
 31 #include <camel/camel.h>
 32 
 33 static const gchar *formatter_mime_types[] = { "text/enriched",
 34 					       "text/richtext",
 35 					       NULL };
 36 
 37 typedef struct _EMailFormatterTextEnriched {
 38 	GObject parent;
 39 } EMailFormatterTextEnriched;
 40 
 41 typedef struct _EMailFormatterTextEnrichedClass {
 42 	GObjectClass parent_class;
 43 } EMailFormatterTextEnrichedClass;
 44 
 45 static void e_mail_formatter_formatter_extension_interace_init (EMailFormatterExtensionInterface *iface);
 46 static void e_mail_formatter_mail_extension_interface_init (EMailExtensionInterface *iface);
 47 
 48 G_DEFINE_TYPE_EXTENDED (
 49 	EMailFormatterTextEnriched,
 50 	e_mail_formatter_text_enriched,
 51 	G_TYPE_OBJECT,
 52 	0,
 53 	G_IMPLEMENT_INTERFACE (
 54 		E_TYPE_MAIL_EXTENSION,
 55 		e_mail_formatter_mail_extension_interface_init)
 56 	G_IMPLEMENT_INTERFACE (
 57 		E_TYPE_MAIL_FORMATTER_EXTENSION,
 58 		e_mail_formatter_formatter_extension_interace_init));
 59 
 60 static gboolean
 61 emfe_text_enriched_format (EMailFormatterExtension *extension,
 62                            EMailFormatter *formatter,
 63                            EMailFormatterContext *context,
 64                            EMailPart *part,
 65                            CamelStream *stream,
 66                            GCancellable *cancellable)
 67 {
 68 	CamelStream *filtered_stream;
 69 	CamelMimeFilter *enriched;
 70 	guint32 filter_flags = 0;
 71 	GString *buffer;
 72 
 73 	if (g_cancellable_is_cancelled (cancellable))
 74 		return FALSE;
 75 
 76 	if (!g_strcmp0 (part->mime_type, "text/richtext")) {
 77 		filter_flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT;
 78 	}
 79 
 80 	enriched = camel_mime_filter_enriched_new (filter_flags);
 81 	filtered_stream = camel_stream_filter_new (stream);
 82 	camel_stream_filter_add (
 83 		CAMEL_STREAM_FILTER (filtered_stream), enriched);
 84 	g_object_unref (enriched);
 85 
 86 	buffer = g_string_new ("");
 87 
 88 	g_string_append_printf (
 89 		buffer,
 90 		"<div class=\"part-container\" style=\"border-color: #%06x; "
 91 		"background-color: #%06x; color: #%06x;\">"
 92 		"<div class=\"part-container-inner-margin\">\n",
 93 		e_color_to_value ((GdkColor *)
 94 			e_mail_formatter_get_color (formatter, E_MAIL_FORMATTER_COLOR_FRAME)),
 95 		e_color_to_value ((GdkColor *)
 96 			e_mail_formatter_get_color (formatter, E_MAIL_FORMATTER_COLOR_CONTENT)),
 97 		e_color_to_value ((GdkColor *)
 98 			e_mail_formatter_get_color (formatter, E_MAIL_FORMATTER_COLOR_TEXT)));
 99 
100 	camel_stream_write_string (stream, buffer->str, cancellable, NULL);
101 	g_string_free (buffer, TRUE);
102 
103 	e_mail_formatter_format_text (
104 		formatter, part, filtered_stream, cancellable);
105 	camel_stream_flush (filtered_stream, cancellable, NULL);
106 	g_object_unref (filtered_stream);
107 
108 	camel_stream_write_string (stream, "</div></div>", cancellable, NULL);
109 
110 	return TRUE;
111 }
112 
113 static const gchar *
114 emfe_text_enriched_get_display_name (EMailFormatterExtension *extension)
115 {
116 	return _("Richtext");
117 }
118 
119 static const gchar *
120 emfe_text_enriched_get_description (EMailFormatterExtension *extension)
121 {
122 	return _("Display part as enriched text");
123 }
124 
125 static const gchar **
126 emfe_text_enriched_mime_types (EMailExtension *extension)
127 {
128 	return formatter_mime_types;
129 }
130 
131 static void
132 e_mail_formatter_text_enriched_class_init (EMailFormatterTextEnrichedClass *class)
133 {
134 }
135 
136 static void
137 e_mail_formatter_formatter_extension_interace_init (EMailFormatterExtensionInterface *iface)
138 {
139 	iface->format = emfe_text_enriched_format;
140 	iface->get_display_name = emfe_text_enriched_get_display_name;
141 	iface->get_description = emfe_text_enriched_get_description;
142 }
143 
144 static void
145 e_mail_formatter_mail_extension_interface_init (EMailExtensionInterface *iface)
146 {
147 	iface->mime_types = emfe_text_enriched_mime_types;
148 }
149 
150 static void
151 e_mail_formatter_text_enriched_init (EMailFormatterTextEnriched *formatter)
152 {
153 
154 }