No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-mail-formatter-quote-text-enriched.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-mail-formatter-quote-text-enriched.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-mail-formatter-quote-text-enriched.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-formatter-extension.h>
26 #include <em-format/e-mail-formatter.h>
27 #include <em-format/e-mail-inline-filter.h>
28 #include <e-util/e-util.h>
29
30 #include <glib/gi18n-lib.h>
31 #include <camel/camel.h>
32
33 static const gchar *formatter_mime_types[] = { "text/enriched",
34 "text/richtext",
35 NULL };
36
37 typedef struct _EMailFormatterQuoteTextEnriched {
38 GObject parent;
39 } EMailFormatterQuoteTextEnriched;
40
41 typedef struct _EMailFormatterQuoteTextEnrichedClass {
42 GObjectClass parent_class;
43 } EMailFormatterQuoteTextEnrichedClass;
44
45 static void e_mail_formatter_quote_formatter_extension_interace_init
46 (EMailFormatterExtensionInterface *iface);
47 static void e_mail_formatter_quote_mail_extension_interface_init
48 (EMailExtensionInterface *iface);
49
50 G_DEFINE_TYPE_EXTENDED (
51 EMailFormatterQuoteTextEnriched,
52 e_mail_formatter_quote_text_enriched,
53 G_TYPE_OBJECT,
54 0,
55 G_IMPLEMENT_INTERFACE (
56 E_TYPE_MAIL_EXTENSION,
57 e_mail_formatter_quote_mail_extension_interface_init)
58 G_IMPLEMENT_INTERFACE (
59 E_TYPE_MAIL_FORMATTER_EXTENSION,
60 e_mail_formatter_quote_formatter_extension_interace_init));
61
62 static gboolean
63 emqfe_text_enriched_format (EMailFormatterExtension *extension,
64 EMailFormatter *formatter,
65 EMailFormatterContext *context,
66 EMailPart *part,
67 CamelStream *stream,
68 GCancellable *cancellable)
69 {
70 CamelStream *filtered_stream;
71 CamelMimeFilter *enriched;
72 guint32 camel_flags = 0;
73
74 if (g_strcmp0 (part->mime_type, "text/richtext") == 0) {
75 camel_flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT;
76 camel_stream_write_string (
77 stream, "\n<!-- text/richtext -->\n",
78 cancellable, NULL);
79 } else {
80 camel_stream_write_string (
81 stream, "\n<!-- text/enriched -->\n",
82 cancellable, NULL);
83 }
84
85 enriched = camel_mime_filter_enriched_new (camel_flags);
86 filtered_stream = camel_stream_filter_new (stream);
87 camel_stream_filter_add (
88 CAMEL_STREAM_FILTER (filtered_stream), enriched);
89 g_object_unref (enriched);
90
91 camel_stream_write_string (stream, "<br><hr><br>", cancellable, NULL);
92 e_mail_formatter_format_text (formatter, part, filtered_stream, cancellable);
93 camel_stream_flush (filtered_stream, cancellable, NULL);
94 g_object_unref (filtered_stream);
95
96 return TRUE;
97 }
98
99 static const gchar *
100 emqfe_text_enriched_get_display_name (EMailFormatterExtension *extension)
101 {
102 return _("Richtext");
103 }
104
105 static const gchar *
106 emqfe_text_enriched_get_description (EMailFormatterExtension *extension)
107 {
108 return _("Display part as enriched text");
109 }
110
111 static const gchar **
112 emqfe_text_enriched_mime_types (EMailExtension *extension)
113 {
114 return formatter_mime_types;
115 }
116
117 static void
118 e_mail_formatter_quote_text_enriched_class_init (EMailFormatterQuoteTextEnrichedClass *class)
119 {
120 }
121
122 static void
123 e_mail_formatter_quote_formatter_extension_interace_init (EMailFormatterExtensionInterface *iface)
124 {
125 iface->format = emqfe_text_enriched_format;
126 iface->get_display_name = emqfe_text_enriched_get_display_name;
127 iface->get_description = emqfe_text_enriched_get_description;
128 }
129
130 static void
131 e_mail_formatter_quote_mail_extension_interface_init (EMailExtensionInterface *iface)
132 {
133 iface->mime_types = emqfe_text_enriched_mime_types;
134 }
135
136 static void
137 e_mail_formatter_quote_text_enriched_init (EMailFormatterQuoteTextEnriched *formatter)
138 {
139
140 }