No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-mail-formatter-extension.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-mail-formatter-extension.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-mail-formatter-extension.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 #include "e-mail-formatter-extension.h"
20
21 G_DEFINE_INTERFACE (
22 EMailFormatterExtension,
23 e_mail_formatter_extension,
24 E_TYPE_MAIL_EXTENSION)
25
26 /**
27 * EMailFormatterExtension:
28 *
29 * The #EMailFormatterExtension is an abstract interface for all extensions for
30 * #EmailFormatter.
31 */
32
33 static void
34 e_mail_formatter_extension_default_init (EMailFormatterExtensionInterface *iface)
35 {
36
37 }
38
39 /**
40 * e_mail_formatter_extension_format
41 * @extension: an #EMailFormatterExtension
42 * @formatter: an #EMailFormatter
43 * @context: an #EMailFormatterContext
44 * @part: a #EMailPart to be formatter
45 * @stream: a #CamelStream to which the output should be written
46 * @cancellable: (allow-none) a #GCancellable
47 *
48 * A virtual function reimplemented in all mail formatter extensions. The function
49 * formats @part, generated HTML (or other format that can be displayed to user)
50 * and writes it to the @stream.
51 *
52 * When the function is unable to format the @part (either because it's broken
53 * or because it is a different mimetype then the extension is specialized for), the
54 * function will return @FALSE indicating the #EMailFormatter, that it should pick
55 * another extension.
56 *
57 * Implementation of this function must be thread-safe.
58 *
59 * Return value: Returns @TRUE when the @part was successfully formatted and
60 * data were written to the @stream, @FALSE otherwise.
61 */
62 gboolean
63 e_mail_formatter_extension_format (EMailFormatterExtension *extension,
64 EMailFormatter *formatter,
65 EMailFormatterContext *context,
66 EMailPart *part,
67 CamelStream *stream,
68 GCancellable *cancellable)
69 {
70 EMailFormatterExtensionInterface *interface;
71
72 g_return_val_if_fail (E_IS_MAIL_FORMATTER_EXTENSION (extension), FALSE);
73 g_return_val_if_fail (E_IS_MAIL_FORMATTER (formatter), FALSE);
74 g_return_val_if_fail (context != NULL, FALSE);
75 g_return_val_if_fail (part != NULL, FALSE);
76 g_return_val_if_fail (CAMEL_IS_STREAM (stream), FALSE);
77
78 interface = E_MAIL_FORMATTER_EXTENSION_GET_INTERFACE (extension);
79 g_return_val_if_fail (interface->format != NULL, FALSE);
80
81 return interface->format (extension, formatter, context, part, stream, cancellable);
82 }
83
84 /**
85 * e_mail_formatter_extension_has_widget:
86 * @extension: an #EMailFormatterExtension
87 *
88 * Returns whether the extension can provide a GtkWidget.
89 *
90 * Return value: Returns %TRUE when @extension reimplements get_widget(), %FALSE
91 * otherwise.
92 */
93 gboolean
94 e_mail_formatter_extension_has_widget (EMailFormatterExtension *extension)
95 {
96 EMailFormatterExtensionInterface *interface;
97
98 g_return_val_if_fail (E_IS_MAIL_FORMATTER_EXTENSION (extension), FALSE);
99
100 interface = E_MAIL_FORMATTER_EXTENSION_GET_INTERFACE (extension);
101
102 return (interface->get_widget != NULL);
103 }
104
105 /**
106 * e_mail_formatter_extension_get_widget:
107 * @extension: an #EMailFormatterExtension
108 * @part: an #EMailPart
109 * @params: a #GHashTable
110 *
111 * A virtual function reimplemented in some mail formatter extensions. The function
112 * should construct a #GtkWidget for given @part. The @params hash table can contain
113 * additional parameters listed in the <object> HTML element that has requested
114 * the widget.
115 *
116 * When @bind_dom_func is not %NULL, the callee will set a callback function
117 * which should be called when the webpage is completely rendered to setup
118 * bindings between DOM events and the widget.
119 *
120 * Return value: Returns a #GtkWidget or %NULL, when error occurs or given @extension
121 * does not reimplement this method.
122 */
123 GtkWidget *
124 e_mail_formatter_extension_get_widget (EMailFormatterExtension *extension,
125 EMailPartList *context,
126 EMailPart *part,
127 GHashTable *params)
128 {
129 EMailFormatterExtensionInterface *interface;
130 GtkWidget *widget;
131
132 g_return_val_if_fail (E_IS_MAIL_FORMATTER_EXTENSION (extension), NULL);
133 g_return_val_if_fail (part != NULL, NULL);
134 g_return_val_if_fail (params != NULL, NULL);
135
136 interface = E_MAIL_FORMATTER_EXTENSION_GET_INTERFACE (extension);
137
138 widget = NULL;
139 if (interface->get_widget) {
140 widget = interface->get_widget (
141 extension, context, part, params);
142 }
143
144 return widget;
145 }
146
147 /**
148 * e_mail_formatter_extension_get_display_name:
149 * @extension: an #EMailFormatterExtension
150 *
151 * A virtual function reimplemented in all formatter extensions. It returns a
152 * short name of the extension that can be displayed in user interface.
153 *
154 * Return value: A (localized) string with name of the extension
155 */
156 const gchar *
157 e_mail_formatter_extension_get_display_name (EMailFormatterExtension *extension)
158 {
159 EMailFormatterExtensionInterface *interface;
160
161 g_return_val_if_fail (E_IS_MAIL_FORMATTER_EXTENSION (extension), NULL);
162
163 interface = E_MAIL_FORMATTER_EXTENSION_GET_INTERFACE (extension);
164 g_return_val_if_fail (interface->get_display_name != NULL, NULL);
165
166 return interface->get_display_name (extension);
167 }
168
169 /**
170 * e_mail_formatter_extension_get_description:
171 * @extension: an #EMailFormatterExtension
172 *
173 * A virtual function reimplemented in all formatter extensions. It returns a
174 * longer description of capabilities of the extension.
175 *
176 * Return value: A (localized) string with description of the extension.
177 */
178 const gchar *
179 e_mail_formatter_extension_get_description (EMailFormatterExtension *extension)
180 {
181 EMailFormatterExtensionInterface *interface;
182
183 g_return_val_if_fail (E_IS_MAIL_FORMATTER_EXTENSION (extension), NULL);
184
185 interface = E_MAIL_FORMATTER_EXTENSION_GET_INTERFACE (extension);
186 g_return_val_if_fail (interface->get_description != NULL, NULL);
187
188 return interface->get_description (extension);
189 }