No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-mail-formatter-quote-message-rfc822.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-mail-formatter-quote-message-rfc822.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-mail-formatter-quote-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-formatter-extension.h>
29 #include <em-format/e-mail-formatter-quote.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 static const gchar * formatter_mime_types[] = { "message/rfc822",
39 "application/vnd.evolution.rfc822.end",
40 NULL };
41
42 typedef struct _EMailFormatterQuoteMessageRFC822 {
43 GObject parent;
44 } EMailFormatterQuoteMessageRFC822;
45
46 typedef struct _EMailFormatterQuoteMessageRFC822Class {
47 GObjectClass parent_class;
48 } EMailFormatterQuoteMessageRFC822Class;
49
50 static void e_mail_formatter_quote_formatter_extension_interface_init (EMailFormatterExtensionInterface *iface);
51 static void e_mail_formatter_quote_mail_extension_interface_init (EMailExtensionInterface *iface);
52
53 G_DEFINE_TYPE_EXTENDED (
54 EMailFormatterQuoteMessageRFC822,
55 e_mail_formatter_quote_message_rfc822,
56 G_TYPE_OBJECT,
57 0,
58 G_IMPLEMENT_INTERFACE (
59 E_TYPE_MAIL_EXTENSION,
60 e_mail_formatter_quote_mail_extension_interface_init)
61 G_IMPLEMENT_INTERFACE (
62 E_TYPE_MAIL_FORMATTER_EXTENSION,
63 e_mail_formatter_quote_formatter_extension_interface_init));
64
65 static gboolean
66 emfqe_message_rfc822_format (EMailFormatterExtension *extension,
67 EMailFormatter *formatter,
68 EMailFormatterContext *context,
69 EMailPart *part,
70 CamelStream *stream,
71 GCancellable *cancellable)
72 {
73 GSList *iter;
74 gchar *header, *end;
75 EMailFormatterQuoteContext *qc = (EMailFormatterQuoteContext *) context;
76
77 if (g_cancellable_is_cancelled (cancellable))
78 return FALSE;
79
80 header = e_mail_formatter_get_html_header (formatter);
81 camel_stream_write_string (stream, header, cancellable, NULL);
82 g_free (header);
83
84 iter = e_mail_part_list_get_iter (context->parts, part->id);
85 if (!iter) {
86 return FALSE;
87 }
88
89 end = g_strconcat (part->id, ".end", NULL);
90 for (iter = g_slist_next (iter); iter; iter = g_slist_next (iter)) {
91 EMailPart * p = iter->data;
92 if (!p)
93 continue;
94
95 /* Skip attachment bar */
96 if (g_str_has_suffix (p->id, ".attachment-bar"))
97 continue;
98
99 if (g_str_has_suffix (p->id, ".headers.")) {
100 if (qc->qf_flags & E_MAIL_FORMATTER_QUOTE_FLAG_HEADERS) {
101 e_mail_formatter_format_as (
102 formatter, context, part, stream,
103 "application/vnd.evolution.headers",
104 cancellable);
105 }
106
107 continue;
108 }
109
110 /* Check for nested rfc822 messages */
111 if (g_str_has_suffix (p->id, ".rfc822")) {
112 gchar *sub_end = g_strconcat (p->id, ".end", NULL);
113
114 while (iter) {
115 p = iter->data;
116 if (!p) {
117 iter = g_slist_next (iter);
118 if (!iter) {
119 break;
120 }
121 continue;
122 }
123
124 if (g_strcmp0 (p->id, sub_end) == 0) {
125 break;
126 }
127
128 iter = g_slist_next (iter);
129 if (!iter) {
130 break;
131 }
132 }
133 g_free (sub_end);
134 continue;
135 }
136 if ((g_strcmp0 (p->id, end) == 0))
137 break;
138
139 if (p->is_hidden)
140 continue;
141
142 e_mail_formatter_format_as (
143 formatter, context, p,
144 stream, NULL, cancellable);
145
146 }
147
148 g_free (end);
149
150 camel_stream_write_string (stream, "</body></html>", cancellable, NULL);
151
152 return TRUE;
153 }
154
155 static const gchar *
156 emfqe_message_rfc822_get_display_name (EMailFormatterExtension *extension)
157 {
158 return NULL;
159 }
160
161 static const gchar *
162 emfqe_message_rfc822_get_description (EMailFormatterExtension *extension)
163 {
164 return NULL;
165 }
166
167 static const gchar **
168 emfqe_message_rfc822_mime_types (EMailExtension *extension)
169 {
170 return formatter_mime_types;
171 }
172
173 static void
174 e_mail_formatter_quote_message_rfc822_class_init (EMailFormatterQuoteMessageRFC822Class *class)
175 {
176 }
177
178 static void
179 e_mail_formatter_quote_formatter_extension_interface_init (EMailFormatterExtensionInterface *iface)
180 {
181 iface->format = emfqe_message_rfc822_format;
182 iface->get_display_name = emfqe_message_rfc822_get_display_name;
183 iface->get_description = emfqe_message_rfc822_get_description;
184 }
185
186 static void
187 e_mail_formatter_quote_mail_extension_interface_init (EMailExtensionInterface *iface)
188 {
189 iface->mime_types = emfqe_message_rfc822_mime_types;
190 }
191
192 static void
193 e_mail_formatter_quote_message_rfc822_init (EMailFormatterQuoteMessageRFC822 *formatter)
194 {
195
196 }