evolution-3.6.4/em-format/e-mail-parser-message-rfc822.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-parser-message-rfc822.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-parser-message-rfc822.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-message-rfc822.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 #include <glib-object.h>
 27 
 28 #include <em-format/e-mail-parser-extension.h>
 29 #include <em-format/e-mail-parser.h>
 30 #include <em-format/e-mail-part-list.h>
 31 #include <em-format/e-mail-part-utils.h>
 32 #include <e-util/e-util.h>
 33 
 34 #include <camel/camel.h>
 35 
 36 #include <string.h>
 37 
 38 typedef struct _EMailParserMessageRFC822 {
 39 	GObject parent;
 40 } EMailParserMessageRFC822;
 41 
 42 typedef struct _EMailParserMessageRFC822Class {
 43 	GObjectClass parent_class;
 44 } EMailParserMessageRFC822Class;
 45 
 46 static void e_mail_parser_parser_extension_interface_init (EMailParserExtensionInterface *iface);
 47 static void e_mail_parser_mail_extension_interface_init (EMailExtensionInterface *iface);
 48 
 49 G_DEFINE_TYPE_EXTENDED (
 50 	EMailParserMessageRFC822,
 51 	e_mail_parser_message_rfc822,
 52 	G_TYPE_OBJECT,
 53 	0,
 54 	G_IMPLEMENT_INTERFACE (
 55 		E_TYPE_MAIL_EXTENSION,
 56 		e_mail_parser_mail_extension_interface_init)
 57 	G_IMPLEMENT_INTERFACE (
 58 		E_TYPE_MAIL_PARSER_EXTENSION,
 59 		e_mail_parser_parser_extension_interface_init));
 60 
 61 static const gchar * parser_mime_types[] = { "message/rfc822",
 62 					    "message/news",
 63 					    NULL };
 64 
 65 static GSList *
 66 empe_msg_rfc822_parse (EMailParserExtension *extension,
 67                        EMailParser *eparser,
 68                        CamelMimePart *part,
 69                        GString *part_id,
 70                        GCancellable *cancellable)
 71 {
 72 	GSList *parts = NULL;
 73 	EMailPart *mail_part;
 74 	gint len;
 75 	CamelMimePart *message;
 76 	CamelDataWrapper *dw;
 77 	CamelStream *new_stream;
 78 	CamelMimeParser *mime_parser;
 79 	CamelContentType *ct;
 80 
 81 	len = part_id->len;
 82 	g_string_append (part_id, ".rfc822");
 83 
 84         /* Create an empty PURI that will represent start of the RFC message */
 85 	mail_part = e_mail_part_new (part, part_id->str);
 86 	mail_part->mime_type = g_strdup ("message/rfc822");
 87 	parts = g_slist_append (NULL, mail_part);
 88 
 89 	/* Sometime the _actual_ message is encapsulated in another CamelMimePart,
 90 	 * sometimes the CamelMimePart actually represents the RFC822 message */
 91 	ct = camel_mime_part_get_content_type (part);
 92 	if (camel_content_type_is (ct, "message", "rfc822")) {
 93 		new_stream = camel_stream_mem_new ();
 94 		mime_parser = camel_mime_parser_new ();
 95 		message = (CamelMimePart *) camel_mime_message_new ();
 96 
 97 		dw = camel_medium_get_content (CAMEL_MEDIUM (part));
 98 		camel_data_wrapper_decode_to_stream_sync (
 99 			dw, new_stream, cancellable, NULL);
100 		g_seekable_seek (
101 			G_SEEKABLE (new_stream), 0, G_SEEK_SET, cancellable, NULL);
102 		camel_mime_parser_init_with_stream (
103 			mime_parser, new_stream, NULL);
104 		camel_mime_part_construct_from_parser_sync (
105 			message, mime_parser, cancellable, NULL);
106 
107 		g_object_unref (mime_parser);
108 		g_object_unref (new_stream);
109 	} else {
110 		message = g_object_ref (part);
111 	}
112 
113 	parts = g_slist_concat (parts, e_mail_parser_parse_part_as (
114 						eparser, message, part_id,
115 						"application/vnd.evolution.message",
116 						cancellable));
117 
118 	g_object_unref (message);
119 
120         /* Add another generic EMailPart that represents end of the RFC message.
121          * The em_format_write() function will skip all parts between the ".rfc822"
122          * part and ".rfc822.end" part as they will be rendered in an <iframe> */
123 	g_string_append (part_id, ".end");
124 	mail_part = e_mail_part_new (message, part_id->str);
125 	mail_part->is_hidden = TRUE;
126 	parts = g_slist_append (parts, mail_part);
127 	g_string_truncate (part_id, len);
128 
129 	if (e_mail_part_is_attachment (message)) {
130 		return e_mail_parser_wrap_as_attachment (
131 			eparser, message, parts, part_id, cancellable);
132 	}
133 
134 	return parts;
135 }
136 
137 static guint32
138 empe_msg_rfc822_get_flags (EMailParserExtension *extension)
139 {
140 	return E_MAIL_PARSER_EXTENSION_INLINE |
141 		E_MAIL_PARSER_EXTENSION_COMPOUND_TYPE;
142 }
143 
144 static const gchar **
145 empe_msg_rfc822_mime_types (EMailExtension *extension)
146 {
147 	return parser_mime_types;
148 }
149 
150 static void
151 e_mail_parser_message_rfc822_class_init (EMailParserMessageRFC822Class *class)
152 {
153 }
154 
155 static void
156 e_mail_parser_parser_extension_interface_init (EMailParserExtensionInterface *iface)
157 {
158 	iface->parse = empe_msg_rfc822_parse;
159 	iface->get_flags = empe_msg_rfc822_get_flags;
160 }
161 
162 static void
163 e_mail_parser_mail_extension_interface_init (EMailExtensionInterface *iface)
164 {
165 	iface->mime_types = empe_msg_rfc822_mime_types;
166 }
167 
168 static void
169 e_mail_parser_message_rfc822_init (EMailParserMessageRFC822 *parser)
170 {
171 
172 }