evolution-3.6.4/em-format/e-mail-parser-multipart-digest.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-parser-multipart-digest.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-parser-multipart-digest.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-multipart-digest.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-parser-extension.h>
 26 #include <em-format/e-mail-parser.h>
 27 #include <e-util/e-util.h>
 28 
 29 #include <camel/camel.h>
 30 
 31 #include <string.h>
 32 
 33 typedef struct _EMailParserMultipartDigest {
 34 	GObject parent;
 35 } EMailParserMultipartDigest;
 36 
 37 typedef struct _EMailParserMultipartDigestClass {
 38 	GObjectClass parent_class;
 39 } EMailParserMultipartDigestClass;
 40 
 41 static void e_mail_parser_parser_extension_interface_init (EMailParserExtensionInterface *iface);
 42 static void e_mail_parser_mail_extension_interface_init (EMailExtensionInterface *iface);
 43 
 44 G_DEFINE_TYPE_EXTENDED (
 45 	EMailParserMultipartDigest,
 46 	e_mail_parser_multipart_digest,
 47 	G_TYPE_OBJECT,
 48 	0,
 49 	G_IMPLEMENT_INTERFACE (
 50 		E_TYPE_MAIL_EXTENSION,
 51 		e_mail_parser_mail_extension_interface_init)
 52 	G_IMPLEMENT_INTERFACE (
 53 		E_TYPE_MAIL_PARSER_EXTENSION,
 54 		e_mail_parser_parser_extension_interface_init));
 55 
 56 static const gchar * parser_mime_types[] = { "multipart/digest",
 57 					    NULL };
 58 
 59 static GSList *
 60 empe_mp_digest_parse (EMailParserExtension *extension,
 61                       EMailParser *parser,
 62                       CamelMimePart *part,
 63                       GString *part_id,
 64                       GCancellable *cancellable)
 65 {
 66 	CamelMultipart *mp;
 67 	gint i, nparts, len;
 68 	GSList *parts;
 69 
 70 	if (g_cancellable_is_cancelled (cancellable))
 71 		return NULL;
 72 
 73 	mp = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) part);
 74 
 75 	if (!CAMEL_IS_MULTIPART (mp)) {
 76 		return e_mail_parser_parse_part_as (
 77 				parser, part, part_id,
 78 				"application/vnd.evolution.source", cancellable);
 79 	}
 80 
 81 	len = part_id->len;
 82 	nparts = camel_multipart_get_number (mp);
 83 	parts = NULL;
 84 	for (i = 0; i < nparts; i++) {
 85 		CamelMimePart *subpart;
 86 		CamelContentType *ct;
 87 		gchar *cts;
 88 
 89 		subpart = camel_multipart_get_part (mp, i);
 90 
 91 		if (!subpart)
 92 			continue;
 93 
 94 		g_string_append_printf (part_id, ".digest.%d", i);
 95 
 96 		ct = camel_mime_part_get_content_type (subpart);
 97 
 98 		/* According to RFC this shouldn't happen, but who knows... */
 99 		if (ct && !camel_content_type_is (ct, "message", "rfc822")) {
100 			cts = camel_content_type_simple (ct);
101 
102 			parts = g_slist_concat (
103 				parts,
104 				e_mail_parser_parse_part_as (
105 					parser, subpart, part_id,
106 					cts, cancellable));
107 
108 			g_free (cts);
109 		} else {
110 			GSList *new_parts;
111 
112 			new_parts = e_mail_parser_parse_part_as (
113 					parser, subpart, part_id,
114 					"message/rfc822", cancellable);
115 
116 			/* Force the message to be collapsable */
117 			if (new_parts && new_parts->data &&
118 			    !E_MAIL_PART (new_parts->data)->is_attachment) {
119 				new_parts = e_mail_parser_wrap_as_attachment (
120 					parser, subpart, new_parts, part_id,
121 					cancellable);
122 			}
123 
124 			/* Force the message to be expanded */
125 			if (new_parts) {
126 				EMailPart *p = new_parts->data;
127 				if (p) {
128 					p->force_inline = TRUE;
129 				}
130 			}
131 
132 			parts = g_slist_concat (parts, new_parts);
133 		}
134 
135 		g_string_truncate (part_id, len);
136 	}
137 
138 	return parts;
139 }
140 
141 static guint32
142 empe_mp_digest_get_flags (EMailParserExtension *extension)
143 {
144 	return E_MAIL_PARSER_EXTENSION_COMPOUND_TYPE;
145 }
146 
147 static const gchar **
148 empe_mp_digest_mime_types (EMailExtension *extension)
149 {
150 	return parser_mime_types;
151 }
152 
153 static void
154 e_mail_parser_multipart_digest_class_init (EMailParserMultipartDigestClass *class)
155 {
156 }
157 
158 static void
159 e_mail_parser_parser_extension_interface_init (EMailParserExtensionInterface *iface)
160 {
161 	iface->parse = empe_mp_digest_parse;
162 	iface->get_flags = empe_mp_digest_get_flags;
163 }
164 
165 static void
166 e_mail_parser_mail_extension_interface_init (EMailExtensionInterface *iface)
167 {
168 	iface->mime_types = empe_mp_digest_mime_types;
169 }
170 
171 static void
172 e_mail_parser_multipart_digest_init (EMailParserMultipartDigest *parser)
173 {
174 
175 }