evolution-3.6.4/em-format/e-mail-parser-headers.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-parser-headers.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-parser-headers.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-parser-headers.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 <glib/gi18n-lib.h>
 26 
 27 #include <em-format/e-mail-parser-extension.h>
 28 #include <em-format/e-mail-parser.h>
 29 #include <libemail-engine/e-mail-utils.h>
 30 #include <e-util/e-util.h>
 31 
 32 #include <camel/camel.h>
 33 
 34 #include <string.h>
 35 
 36 typedef struct _EMailParserHeaders {
 37 	GObject parent;
 38 } EMailParserHeaders;
 39 
 40 typedef struct _EMailParserHeadersClass {
 41 	GObjectClass parent_class;
 42 } EMailParserHeadersClass;
 43 
 44 static void e_mail_parser_parser_extension_interface_init (EMailParserExtensionInterface *iface);
 45 static void e_mail_parser_mail_extension_interface_init (EMailExtensionInterface *iface);
 46 
 47 G_DEFINE_TYPE_EXTENDED (
 48 	EMailParserHeaders,
 49 	e_mail_parser_headers,
 50 	G_TYPE_OBJECT,
 51 	0,
 52 	G_IMPLEMENT_INTERFACE (
 53 		E_TYPE_MAIL_EXTENSION,
 54 		e_mail_parser_mail_extension_interface_init)
 55 	G_IMPLEMENT_INTERFACE (
 56 		E_TYPE_MAIL_PARSER_EXTENSION,
 57 		e_mail_parser_parser_extension_interface_init));
 58 
 59 static const gchar *parser_mime_types[] = { "application/vnd.evolution.headers", NULL };
 60 
 61 static void
 62 empe_headers_bind_dom (EMailPart *part,
 63                        WebKitDOMElement *element)
 64 {
 65 	WebKitDOMDocument *document;
 66 	WebKitDOMElement *photo;
 67 	gchar *addr, *uri;
 68 	gboolean only_local;
 69 
 70 	document = webkit_dom_node_get_owner_document (WEBKIT_DOM_NODE (element));
 71 	photo = webkit_dom_document_get_element_by_id (document, "__evo-contact-photo");
 72 
 73 	/* Contact photos disabled, the <img> tag is not there */
 74 	if (!photo)
 75 		return;
 76 
 77 	addr = webkit_dom_element_get_attribute (photo, "data-mailaddr");
 78 	only_local = webkit_dom_element_has_attribute (photo, "data-onlylocal");
 79 
 80 	uri = g_strdup_printf (
 81 		"mail://contact-photo?mailaddr=%s%s",
 82 		addr, only_local ? "&only-local-photo=1" : "");
 83 
 84 	webkit_dom_html_image_element_set_src (
 85 		WEBKIT_DOM_HTML_IMAGE_ELEMENT (photo), uri);
 86 
 87 	g_free (addr);
 88 	g_free (uri);
 89 }
 90 
 91 static GSList *
 92 empe_headers_parse (EMailParserExtension *extension,
 93                     EMailParser *parser,
 94                     CamelMimePart *part,
 95                     GString *part_id,
 96                     GCancellable *cancellable)
 97 {
 98 	EMailPart *mail_part;
 99 	gint len;
100 
101 	if (g_cancellable_is_cancelled (cancellable))
102 		return NULL;
103 
104 	len = part_id->len;
105 	g_string_append (part_id, ".headers");
106 
107 	mail_part = e_mail_part_new (part, part_id->str);
108 	mail_part->mime_type = g_strdup ("application/vnd.evolution.headers");
109 	mail_part->bind_func = empe_headers_bind_dom;
110 	g_string_truncate (part_id, len);
111 
112 	return g_slist_append (NULL, mail_part);
113 }
114 
115 static const gchar **
116 empe_headers_mime_types (EMailExtension *extension)
117 {
118 	return parser_mime_types;
119 }
120 
121 static void
122 e_mail_parser_headers_class_init (EMailParserHeadersClass *class)
123 {
124 }
125 
126 static void
127 e_mail_parser_parser_extension_interface_init (EMailParserExtensionInterface *iface)
128 {
129 	iface->parse = empe_headers_parse;
130 }
131 
132 static void
133 e_mail_parser_mail_extension_interface_init (EMailExtensionInterface *iface)
134 {
135 	iface->mime_types = empe_headers_mime_types;
136 }
137 
138 static void
139 e_mail_parser_headers_init (EMailParserHeaders *parser)
140 {
141 
142 }