No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-mail-parser-image.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-mail-parser-image.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-mail-parser-image.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-part-utils.h>
27 #include <em-format/e-mail-parser.h>
28 #include <e-util/e-util.h>
29
30 #include <glib/gi18n-lib.h>
31 #include <camel/camel.h>
32
33 typedef struct _EMailParserImage {
34 GObject parent;
35 } EMailParserImage;
36
37 typedef struct _EMailParserImageClass {
38 GObjectClass parent_class;
39 } EMailParserImageClass;
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 EMailParserImage,
46 e_mail_parser_image,
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[] = { "image/gif",
57 "image/jpeg",
58 "image/png",
59 "image/x-png",
60 "image/x-bmp",
61 "image/bmp",
62 "image/svg",
63 "image/x-cmu-raster",
64 "image/x-ico",
65 "image/x-portable-anymap",
66 "image/x-portable-bitmap",
67 "image/x-portable-graymap",
68 "image/x-portable-pixmap",
69 "image/x-xpixmap",
70 "image/jpg",
71 "image/pjpeg",
72 NULL };
73
74 static gboolean
75 is_attachment (const gchar *disposition)
76 {
77 return disposition && g_ascii_strcasecmp (disposition, "attachment") == 0;
78 }
79
80 static GSList *
81 empe_image_parse (EMailParserExtension *extension,
82 EMailParser *parser,
83 CamelMimePart *part,
84 GString *part_id,
85 GCancellable *cancellable)
86 {
87 EMailPart *mail_part;
88 const gchar *tmp;
89 gchar *cid;
90 gint len;
91 CamelContentType *ct;
92
93 if (g_cancellable_is_cancelled (cancellable))
94 return NULL;
95
96 tmp = camel_mime_part_get_content_id (part);
97 if (tmp) {
98 cid = g_strdup_printf ("cid:%s", tmp);
99 } else {
100 cid = NULL;
101 }
102
103 len = part_id->len;
104 g_string_append (part_id, ".image");
105
106 ct = camel_mime_part_get_content_type (part);
107
108 mail_part = e_mail_part_new (part, part_id->str);
109 mail_part->is_attachment = TRUE;
110 mail_part->cid = cid;
111 mail_part->mime_type = ct ? camel_content_type_simple (ct) : g_strdup ("image/*");
112 mail_part->is_hidden = cid != NULL && !is_attachment (camel_mime_part_get_disposition (part));
113
114 g_string_truncate (part_id, len);
115
116 if (!mail_part->is_hidden) {
117 return e_mail_parser_wrap_as_attachment (
118 parser, part, g_slist_append (NULL, mail_part),
119 part_id, cancellable);
120 }
121
122 return g_slist_append (NULL, mail_part);
123 }
124
125 static const gchar **
126 empe_image_mime_types (EMailExtension *extension)
127 {
128 return parser_mime_types;
129 }
130
131 static void
132 e_mail_parser_image_class_init (EMailParserImageClass *class)
133 {
134 }
135
136 static void
137 e_mail_parser_parser_extension_interface_init (EMailParserExtensionInterface *iface)
138 {
139 iface->parse = empe_image_parse;
140 }
141
142 static void
143 e_mail_parser_mail_extension_interface_init (EMailExtensionInterface *iface)
144 {
145 iface->mime_types = empe_image_mime_types;
146 }
147
148 static void
149 e_mail_parser_image_init (EMailParserImage *parser)
150 {
151
152 }