No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-mail-config-imap-headers-page.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-mail-config-imap-headers-page.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-mail-config-imap-headers-page.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-config-imap-headers-page.h"
20
21 #include <config.h>
22 #include <glib/gi18n-lib.h>
23
24 #include <mail/e-mail-config-security-page.h>
25
26 #include "e-mail-config-header-manager.h"
27
28 #define E_MAIL_CONFIG_IMAP_HEADERS_PAGE_GET_PRIVATE(obj) \
29 (G_TYPE_INSTANCE_GET_PRIVATE \
30 ((obj), E_TYPE_MAIL_CONFIG_IMAP_HEADERS_PAGE, EMailConfigImapHeadersPagePrivate))
31
32 #define E_MAIL_CONFIG_IMAP_HEADERS_PAGE_SORT_ORDER \
33 (E_MAIL_CONFIG_SECURITY_PAGE_SORT_ORDER + 10)
34
35 struct _EMailConfigImapHeadersPagePrivate {
36 ESource *account_source;
37 CamelSettings *settings;
38
39 GtkToggleButton *fetch_all_headers; /* not referenced */
40 GtkToggleButton *fetch_bas_headers; /* not referenced */
41 GtkToggleButton *fetch_bml_headers; /* not referenced */
42 };
43
44 enum {
45 PROP_0,
46 PROP_ACCOUNT_SOURCE
47 };
48
49 /* Forward Declarations */
50 static void e_mail_config_imap_headers_page_interface_init
51 (EMailConfigPageInterface *interface);
52
53 G_DEFINE_DYNAMIC_TYPE_EXTENDED (
54 EMailConfigImapHeadersPage,
55 e_mail_config_imap_headers_page,
56 GTK_TYPE_BOX,
57 0,
58 G_IMPLEMENT_INTERFACE_DYNAMIC (
59 E_TYPE_MAIL_CONFIG_PAGE,
60 e_mail_config_imap_headers_page_interface_init))
61
62 static void
63 mail_config_imap_headers_page_all_toggled (GtkToggleButton *toggle_button,
64 EMailConfigImapHeadersPage *page)
65 {
66 if (gtk_toggle_button_get_active (toggle_button)) {
67 CamelSettings *settings;
68 CamelFetchHeadersType fetch_headers;
69
70 settings = page->priv->settings;
71 fetch_headers = CAMEL_FETCH_HEADERS_ALL;
72 g_object_set (settings, "fetch-headers", fetch_headers, NULL);
73 }
74 }
75
76 static void
77 mail_config_imap_headers_page_bas_toggled (GtkToggleButton *toggle_button,
78 EMailConfigImapHeadersPage *page)
79 {
80 if (gtk_toggle_button_get_active (toggle_button)) {
81 CamelSettings *settings;
82 CamelFetchHeadersType fetch_headers;
83
84 settings = page->priv->settings;
85 fetch_headers = CAMEL_FETCH_HEADERS_BASIC;
86 g_object_set (settings, "fetch-headers", fetch_headers, NULL);
87 }
88 }
89
90 static void
91 mail_config_imap_headers_page_bml_toggled (GtkToggleButton *toggle_button,
92 EMailConfigImapHeadersPage *page)
93 {
94 if (gtk_toggle_button_get_active (toggle_button)) {
95 CamelSettings *settings;
96 CamelFetchHeadersType fetch_headers;
97
98 settings = page->priv->settings;
99 fetch_headers = CAMEL_FETCH_HEADERS_BASIC_AND_MAILING_LIST;
100 g_object_set (settings, "fetch-headers", fetch_headers, NULL);
101 }
102 }
103
104 static void
105 mail_config_imap_headers_page_set_account_source (EMailConfigImapHeadersPage *page,
106 ESource *account_source)
107 {
108 g_return_if_fail (E_IS_SOURCE (account_source));
109 g_return_if_fail (page->priv->account_source == NULL);
110
111 page->priv->account_source = g_object_ref (account_source);
112 }
113
114 static void
115 mail_config_imap_headers_page_set_property (GObject *object,
116 guint property_id,
117 const GValue *value,
118 GParamSpec *pspec)
119 {
120 switch (property_id) {
121 case PROP_ACCOUNT_SOURCE:
122 mail_config_imap_headers_page_set_account_source (
123 E_MAIL_CONFIG_IMAP_HEADERS_PAGE (object),
124 g_value_get_object (value));
125 return;
126 }
127
128 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
129 }
130
131 static void
132 mail_config_imap_headers_page_get_property (GObject *object,
133 guint property_id,
134 GValue *value,
135 GParamSpec *pspec)
136 {
137 switch (property_id) {
138 case PROP_ACCOUNT_SOURCE:
139 g_value_set_object (
140 value,
141 e_mail_config_imap_headers_page_get_account_source (
142 E_MAIL_CONFIG_IMAP_HEADERS_PAGE (object)));
143 return;
144 }
145
146 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
147 }
148
149 static void
150 mail_config_imap_headers_page_dispose (GObject *object)
151 {
152 EMailConfigImapHeadersPagePrivate *priv;
153
154 priv = E_MAIL_CONFIG_IMAP_HEADERS_PAGE_GET_PRIVATE (object);
155
156 if (priv->account_source != NULL) {
157 g_object_unref (priv->account_source);
158 priv->account_source = NULL;
159 }
160
161 if (priv->settings != NULL) {
162 g_object_unref (priv->settings);
163 priv->settings = NULL;
164 }
165
166 /* Chain up to parent's dispose() method. */
167 G_OBJECT_CLASS (e_mail_config_imap_headers_page_parent_class)->
168 dispose (object);
169 }
170
171 static void
172 mail_config_imap_headers_page_constructed (GObject *object)
173 {
174 EMailConfigImapHeadersPage *page;
175 ESource *source;
176 ESourceCamel *camel_ext;
177 ESourceBackend *backend_ext;
178 CamelSettings *settings;
179 CamelFetchHeadersType fetch_headers;
180 GtkWidget *widget;
181 GtkWidget *container;
182 GtkToggleButton *toggle_button;
183 GSList *group = NULL;
184 const gchar *backend_name;
185 const gchar *extension_name;
186 const gchar *text;
187 gchar *markup;
188
189 page = E_MAIL_CONFIG_IMAP_HEADERS_PAGE (object);
190
191 /* Chain up to parent's constructed() method. */
192 G_OBJECT_CLASS (e_mail_config_imap_headers_page_parent_class)->
193 constructed (object);
194
195 source = e_mail_config_imap_headers_page_get_account_source (page);
196
197 extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
198 backend_ext = e_source_get_extension (source, extension_name);
199 backend_name = e_source_backend_get_backend_name (backend_ext);
200
201 extension_name = e_source_camel_get_extension_name (backend_name);
202 camel_ext = e_source_get_extension (source, extension_name);
203 settings = e_source_camel_get_settings (camel_ext);
204
205 page->priv->settings = g_object_ref (settings);
206
207 gtk_orientable_set_orientation (
208 GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
209
210 gtk_box_set_spacing (GTK_BOX (page), 12);
211
212 /*** IMAP Headers ***/
213
214 /* Use row-spacing=0 so we can pack the "Basic Headers" hint
215 * label closer to its radio button. Unfortunately this means
216 * we have to remember to set a top margin on all the children. */
217 widget = gtk_grid_new ();
218 gtk_grid_set_row_spacing (GTK_GRID (widget), 0);
219 gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
220 gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
221 gtk_widget_show (widget);
222
223 container = widget;
224
225 text = _("IMAP Headers");
226 markup = g_markup_printf_escaped ("<b>%s</b>", text);
227 widget = gtk_label_new (markup);
228 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
229 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
230 gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
231 gtk_widget_show (widget);
232
233 text = _("Select a predefined set of IMAP headers to fetch.\n"
234 "Note, larger sets of headers take longer to download.");
235 widget = gtk_label_new (text);
236 gtk_widget_set_margin_top (widget, 6);
237 gtk_widget_set_margin_left (widget, 12);
238 gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
239 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
240 gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
241 gtk_widget_show (widget);
242
243 text = _("_Fetch All Headers");
244 widget = gtk_radio_button_new_with_mnemonic (group, text);
245 gtk_widget_set_margin_top (widget, 6);
246 gtk_widget_set_margin_left (widget, 12);
247 gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
248 page->priv->fetch_all_headers = GTK_TOGGLE_BUTTON (widget);
249 gtk_widget_show (widget);
250
251 g_signal_connect (
252 widget, "toggled",
253 G_CALLBACK (mail_config_imap_headers_page_all_toggled), page);
254
255 group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
256
257 text = _("_Basic Headers (fastest)");
258 widget = gtk_radio_button_new_with_mnemonic (group, text);
259 gtk_widget_set_margin_top (widget, 6);
260 gtk_widget_set_margin_left (widget, 12);
261 gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 1, 1);
262 page->priv->fetch_bas_headers = GTK_TOGGLE_BUTTON (widget);
263 gtk_widget_show (widget);
264
265 g_signal_connect (
266 widget, "toggled",
267 G_CALLBACK (mail_config_imap_headers_page_bas_toggled), page);
268
269 group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
270
271 text = _("Use this if you are not filtering any mailing lists.");
272 markup = g_markup_printf_escaped ("<small>%s</small>", text);
273 widget = gtk_label_new (markup);
274 gtk_widget_set_margin_left (widget, 36);
275 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
276 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
277 gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 1, 1);
278 gtk_widget_show (widget);
279 g_free (markup);
280
281 text = _("Basic and _Mailing List Headers (default)");
282 widget = gtk_radio_button_new_with_mnemonic (group, text);
283 gtk_widget_set_margin_top (widget, 6);
284 gtk_widget_set_margin_left (widget, 12);
285 gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 1, 1);
286 page->priv->fetch_bml_headers = GTK_TOGGLE_BUTTON (widget);
287 gtk_widget_show (widget);
288
289 g_signal_connect (
290 widget, "toggled",
291 G_CALLBACK (mail_config_imap_headers_page_bml_toggled), page);
292
293 /* Pick an initial radio button. */
294
295 g_object_get (settings, "fetch-headers", &fetch_headers, NULL);
296
297 switch (fetch_headers) {
298 case CAMEL_FETCH_HEADERS_ALL:
299 toggle_button = page->priv->fetch_all_headers;
300 break;
301
302 case CAMEL_FETCH_HEADERS_BASIC:
303 toggle_button = page->priv->fetch_bas_headers;
304 break;
305
306 case CAMEL_FETCH_HEADERS_BASIC_AND_MAILING_LIST:
307 default:
308 toggle_button = page->priv->fetch_bml_headers;
309 break;
310 }
311
312 gtk_toggle_button_set_active (toggle_button, TRUE);
313
314 /*** Custom Headers ***/
315
316 widget = gtk_grid_new ();
317 gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
318 gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
319 gtk_box_pack_start (GTK_BOX (page), widget, TRUE, TRUE, 0);
320 gtk_widget_show (widget);
321
322 g_object_bind_property (
323 page->priv->fetch_all_headers, "active",
324 widget, "sensitive",
325 G_BINDING_SYNC_CREATE |
326 G_BINDING_INVERT_BOOLEAN);
327
328 container = widget;
329
330 text = _("Custom Headers");
331 markup = g_markup_printf_escaped ("<b>%s</b>", text);
332 widget = gtk_label_new (markup);
333 gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
334 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
335 gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
336 gtk_widget_show (widget);
337
338 text = _("Specify any extra headers to fetch in addition "
339 "to the predefined set of headers selected above.");
340 widget = gtk_label_new (text);
341 gtk_widget_set_margin_left (widget, 12);
342 gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
343 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
344 gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
345 gtk_widget_show (widget);
346
347 widget = e_mail_config_header_manager_new ();
348 gtk_widget_set_hexpand (widget, TRUE);
349 gtk_widget_set_vexpand (widget, TRUE);
350 gtk_widget_set_margin_left (widget, 12);
351 gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
352 gtk_widget_show (widget);
353
354 g_object_bind_property (
355 settings, "fetch-headers-extra",
356 widget, "headers",
357 G_BINDING_BIDIRECTIONAL |
358 G_BINDING_SYNC_CREATE);
359 }
360
361 static void
362 e_mail_config_imap_headers_page_class_init (EMailConfigImapHeadersPageClass *class)
363 {
364 GObjectClass *object_class;
365
366 g_type_class_add_private (
367 class, sizeof (EMailConfigImapHeadersPagePrivate));
368
369 object_class = G_OBJECT_CLASS (class);
370 object_class->set_property = mail_config_imap_headers_page_set_property;
371 object_class->get_property = mail_config_imap_headers_page_get_property;
372 object_class->dispose = mail_config_imap_headers_page_dispose;
373 object_class->constructed = mail_config_imap_headers_page_constructed;
374
375 g_object_class_install_property (
376 object_class,
377 PROP_ACCOUNT_SOURCE,
378 g_param_spec_object (
379 "account-source",
380 "Account Source",
381 "Mail account source being edited",
382 E_TYPE_SOURCE,
383 G_PARAM_READWRITE |
384 G_PARAM_CONSTRUCT_ONLY));
385 }
386
387 static void
388 e_mail_config_imap_headers_page_class_finalize (EMailConfigImapHeadersPageClass *class)
389 {
390 }
391
392 static void
393 e_mail_config_imap_headers_page_interface_init (EMailConfigPageInterface *interface)
394 {
395 interface->title = _("IMAP Headers");
396 interface->sort_order = E_MAIL_CONFIG_IMAP_HEADERS_PAGE_SORT_ORDER;
397 }
398
399 static void
400 e_mail_config_imap_headers_page_init (EMailConfigImapHeadersPage *page)
401 {
402 page->priv = E_MAIL_CONFIG_IMAP_HEADERS_PAGE_GET_PRIVATE (page);
403 }
404
405 void
406 e_mail_config_imap_headers_page_type_register (GTypeModule *type_module)
407 {
408 /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
409 * function, so we have to wrap it with a public function in
410 * order to register types from a separate compilation unit. */
411 e_mail_config_imap_headers_page_register_type (type_module);
412 }
413
414 EMailConfigPage *
415 e_mail_config_imap_headers_page_new (ESource *account_source)
416 {
417 g_return_val_if_fail (E_IS_SOURCE (account_source), NULL);
418
419 return g_object_new (
420 E_TYPE_MAIL_CONFIG_IMAP_HEADERS_PAGE,
421 "account-source", account_source, NULL);
422 }
423
424 ESource *
425 e_mail_config_imap_headers_page_get_account_source (EMailConfigImapHeadersPage *page)
426 {
427 g_return_val_if_fail (E_IS_MAIL_CONFIG_IMAP_HEADERS_PAGE (page), NULL);
428
429 return page->priv->account_source;
430 }