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