evolution-3.6.4/modules/mail/e-mail-config-format-html.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-config-format-html.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-config-format-html.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-config-format-html.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-config-format-html.h"
 24 
 25 #include <shell/e-shell.h>
 26 #include <e-util/e-util.h>
 27 #include <em-format/e-mail-formatter.h>
 28 #include <mail/e-mail-reader-utils.h>
 29 
 30 #define E_MAIL_CONFIG_FORMAT_HTML_GET_PRIVATE(obj) \
 31 	(G_TYPE_INSTANCE_GET_PRIVATE \
 32 	((obj), E_TYPE_MAIL_CONFIG_FORMAT_HTML, EMailConfigFormatHTMLPrivate))
 33 
 34 struct _EMailConfigFormatHTMLPrivate {
 35 	GSettings *settings;
 36 	gulong headers_changed_id;
 37 };
 38 
 39 G_DEFINE_DYNAMIC_TYPE (
 40 	EMailConfigFormatHTML,
 41 	e_mail_config_format_html,
 42 	E_TYPE_EXTENSION)
 43 
 44 static EMailFormatter *
 45 mail_config_format_html_get_formatter (EMailConfigFormatHTML *extension)
 46 {
 47 	EExtensible *extensible;
 48 
 49 	extensible = e_extension_get_extensible (E_EXTENSION (extension));
 50 
 51 	return E_MAIL_FORMATTER (extensible);
 52 }
 53 
 54 static void
 55 mail_config_format_html_headers_changed_cb (GSettings *settings,
 56                                             const gchar *key,
 57                                             EMailConfigFormatHTML *extension)
 58 {
 59 	EMailFormatter *formatter;
 60 	gchar **headers;
 61 	gint ii;
 62 
 63 	formatter = mail_config_format_html_get_formatter (extension);
 64 
 65 	headers = g_settings_get_strv (settings, "headers");
 66 
 67 	e_mail_formatter_clear_headers (formatter);
 68 	for (ii = 0; headers && headers[ii]; ii++) {
 69 		EMailReaderHeader *h;
 70 		const gchar *xml = headers[ii];
 71 
 72 		h = e_mail_reader_header_from_xml (xml);
 73 		if (h && h->enabled)
 74 			e_mail_formatter_add_header (
 75 				formatter, h->name, NULL,
 76 				E_MAIL_FORMATTER_HEADER_FLAG_BOLD);
 77 
 78 		e_mail_reader_header_free (h);
 79 	}
 80 
 81 	if (!headers || !headers[0])
 82 		e_mail_formatter_set_default_headers (formatter);
 83 
 84 	g_strfreev (headers);
 85 }
 86 
 87 static void
 88 mail_config_format_html_dispose (GObject *object)
 89 {
 90 	EMailConfigFormatHTMLPrivate *priv;
 91 
 92 	priv = E_MAIL_CONFIG_FORMAT_HTML_GET_PRIVATE (object);
 93 
 94 	if (priv->settings != NULL) {
 95 		g_signal_handler_disconnect (
 96 			priv->settings,
 97 			priv->headers_changed_id);
 98 		g_object_unref (priv->settings);
 99 		priv->settings = NULL;
100 	}
101 
102 	/* Chain up to parent's dispose() method. */
103 	G_OBJECT_CLASS (e_mail_config_format_html_parent_class)->
104 		dispose (object);
105 }
106 
107 static void
108 mail_config_format_html_constructed (GObject *object)
109 {
110 	EMailConfigFormatHTML *extension;
111 	EMailFormatter *formatter;
112 	EShellSettings *shell_settings;
113 	EShell *shell;
114 
115 	extension = E_MAIL_CONFIG_FORMAT_HTML (object);
116 	formatter = mail_config_format_html_get_formatter (extension);
117 
118 	shell = e_shell_get_default ();
119 	shell_settings = e_shell_get_shell_settings (shell);
120 
121 	g_object_bind_property_full (
122 		shell_settings, "mail-citation-color",
123 		formatter, "citation-color",
124 		G_BINDING_SYNC_CREATE,
125 		e_binding_transform_string_to_color,
126 		NULL, NULL, (GDestroyNotify) NULL);
127 
128 	g_object_bind_property (
129 		shell_settings, "mail-mark-citations",
130 		formatter, "mark-citations",
131 		G_BINDING_SYNC_CREATE);
132 
133 	g_object_bind_property (
134 		shell_settings, "mail-image-loading-policy",
135 		formatter, "image-loading-policy",
136 		G_BINDING_SYNC_CREATE);
137 
138 	g_object_bind_property (
139 		shell_settings, "mail-only-local-photos",
140 		formatter, "only-local-photos",
141 		G_BINDING_SYNC_CREATE);
142 
143 	g_object_bind_property (
144 		shell_settings, "mail-show-sender-photo",
145 		formatter, "show-sender-photo",
146 		G_BINDING_SYNC_CREATE);
147 
148 	g_object_bind_property (
149 		shell_settings, "mail-show-real-date",
150 		formatter, "show-real-date",
151 		G_BINDING_SYNC_CREATE);
152 
153 	g_object_bind_property (
154 		shell_settings, "mail-show-animated-images",
155 		formatter, "animate-images",
156 		G_BINDING_SYNC_CREATE);
157 
158 	extension->priv->headers_changed_id = g_signal_connect (
159 		extension->priv->settings, "changed::headers",
160 		G_CALLBACK (mail_config_format_html_headers_changed_cb),
161 		extension);
162 
163 	/* Initial synchronization */
164 	mail_config_format_html_headers_changed_cb (
165 		extension->priv->settings, NULL, extension);
166 
167 	/* Chain up to parent's constructed() method. */
168 	G_OBJECT_CLASS (e_mail_config_format_html_parent_class)->
169 		constructed (object);
170 }
171 
172 static void
173 e_mail_config_format_html_class_init (EMailConfigFormatHTMLClass *class)
174 {
175 	GObjectClass *object_class;
176 	EExtensionClass *extension_class;
177 
178 	g_type_class_add_private (
179 		class, sizeof (EMailConfigFormatHTMLPrivate));
180 
181 	object_class = G_OBJECT_CLASS (class);
182 	object_class->dispose = mail_config_format_html_dispose;
183 	object_class->constructed = mail_config_format_html_constructed;
184 
185 	extension_class = E_EXTENSION_CLASS (class);
186 	extension_class->extensible_type = E_TYPE_MAIL_FORMATTER;
187 }
188 
189 static void
190 e_mail_config_format_html_class_finalize (EMailConfigFormatHTMLClass *class)
191 {
192 }
193 
194 static void
195 e_mail_config_format_html_init (EMailConfigFormatHTML *extension)
196 {
197 	extension->priv = E_MAIL_CONFIG_FORMAT_HTML_GET_PRIVATE (extension);
198 
199 	extension->priv->settings =
200 		g_settings_new ("org.gnome.evolution.mail");
201 }
202 
203 void
204 e_mail_config_format_html_type_register (GTypeModule *type_module)
205 {
206 	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
207 	 *     function, so we have to wrap it with a public function in
208 	 *     order to register types from a separate compilation unit. */
209 	e_mail_config_format_html_register_type (type_module);
210 }