evolution-3.6.4/em-format/e-mail-formatter-error.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-formatter-error.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-formatter-error.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-error.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 #include "e-mail-format-extensions.h"
 23 
 24 #include <glib/gi18n-lib.h>
 25 
 26 #include <em-format/e-mail-formatter-extension.h>
 27 #include <em-format/e-mail-formatter.h>
 28 #include <e-util/e-util.h>
 29 
 30 #include <camel/camel.h>
 31 
 32 typedef struct _EMailFormatterError {
 33 	GObject parent;
 34 } EMailFormatterError;
 35 
 36 typedef struct _EMailFormatterErrorClass {
 37 	GObjectClass parent_class;
 38 } EMailFormatterErrorClass;
 39 
 40 static void e_mail_formatter_formatter_extension_interface_init (EMailFormatterExtensionInterface *iface);
 41 static void e_mail_formatter_mail_extension_interface_init (EMailExtensionInterface *iface);
 42 
 43 G_DEFINE_TYPE_EXTENDED (
 44 	EMailFormatterError,
 45 	e_mail_formatter_error,
 46 	G_TYPE_OBJECT,
 47 	0,
 48 	G_IMPLEMENT_INTERFACE (
 49 		E_TYPE_MAIL_EXTENSION,
 50 		e_mail_formatter_mail_extension_interface_init)
 51 	G_IMPLEMENT_INTERFACE (
 52 		E_TYPE_MAIL_FORMATTER_EXTENSION,
 53 		e_mail_formatter_formatter_extension_interface_init));
 54 
 55 static const gchar *formatter_mime_types[] = { "application/vnd.evolution.error", NULL };
 56 
 57 static gboolean
 58 emfe_error_format (EMailFormatterExtension *extension,
 59                    EMailFormatter *formatter,
 60                    EMailFormatterContext *context,
 61                    EMailPart *part,
 62                    CamelStream *stream,
 63                    GCancellable *cancellable)
 64 {
 65 	CamelStream *filtered_stream;
 66 	CamelMimeFilter *filter;
 67 	CamelDataWrapper *dw;
 68 	gchar *html;
 69 
 70 	dw = camel_medium_get_content ((CamelMedium *) part->part);
 71 
 72 	html = g_strdup_printf (
 73 		"<div class=\"part-container\" style=\""
 74 		"border-color: #%06x;"
 75 		"background-color: #%06x; color: #%06x;\">"
 76 		"<div class=\"part-container-inner-margin pre\">\n"
 77 		"<table border=\"0\" cellspacing=\"10\" "
 78 		"cellpadding=\"0\" width=\"100%%\">\n"
 79 		"<tr valign=\"top\"><td width=50>"
 80 		"<img src=\"gtk-stock://%s/?size=%d\" /></td>\n"
 81 		"<td style=\"color: red;\">",
 82 		e_color_to_value ((GdkColor *)
 83 			e_mail_formatter_get_color (
 84 				formatter, E_MAIL_FORMATTER_COLOR_FRAME)),
 85 		e_color_to_value ((GdkColor *)
 86 			e_mail_formatter_get_color (
 87 				formatter, E_MAIL_FORMATTER_COLOR_BODY)),
 88 		e_color_to_value ((GdkColor *)
 89 			e_mail_formatter_get_color (
 90 				formatter, E_MAIL_FORMATTER_COLOR_TEXT)),
 91 		GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
 92 
 93 	camel_stream_write_string (stream, html, cancellable, NULL);
 94 	g_free (html);
 95 
 96 	filtered_stream = camel_stream_filter_new (stream);
 97 	filter = camel_mime_filter_tohtml_new (
 98 		CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
 99 		CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0);
100 	camel_stream_filter_add (CAMEL_STREAM_FILTER (filtered_stream), filter);
101 	g_object_unref (filter);
102 
103 	camel_data_wrapper_decode_to_stream_sync (dw, filtered_stream, cancellable, NULL);
104 	camel_stream_flush (filtered_stream, cancellable, NULL);
105 	g_object_unref (filtered_stream);
106 
107 	camel_stream_write_string (
108 		stream,
109 		"</td>\n"
110 		"</tr>\n"
111 		"</table>\n"
112 		"</div>\n"
113 		"</div>",
114 		cancellable, NULL);
115 
116 	return TRUE;
117 }
118 
119 static const gchar *
120 emfe_error_get_display_name (EMailFormatterExtension *extension)
121 {
122 	return NULL;
123 }
124 
125 static const gchar *
126 emfe_error_get_description (EMailFormatterExtension *extension)
127 {
128 	return NULL;
129 }
130 
131 static const gchar **
132 emfe_error_mime_types (EMailExtension *extension)
133 {
134 	return formatter_mime_types;
135 }
136 
137 static void
138 e_mail_formatter_error_class_init (EMailFormatterErrorClass *class)
139 {
140 }
141 
142 static void
143 e_mail_formatter_formatter_extension_interface_init (EMailFormatterExtensionInterface *iface)
144 {
145 	iface->format = emfe_error_format;
146 	iface->get_display_name = emfe_error_get_display_name;
147 	iface->get_description = emfe_error_get_description;
148 }
149 
150 static void
151 e_mail_formatter_mail_extension_interface_init (EMailExtensionInterface *iface)
152 {
153 	iface->mime_types = emfe_error_mime_types;
154 }
155 
156 static void
157 e_mail_formatter_error_init (EMailFormatterError *formatter)
158 {
159 
160 }