evolution-3.6.4/mail/e-mail-config-security-page.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-config-security-page.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-config-security-page.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  1 /*
  2  * e-mail-config-security-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-security-page.h"
 20 
 21 #include <config.h>
 22 #include <glib/gi18n-lib.h>
 23 
 24 #include <libebackend/libebackend.h>
 25 
 26 #if defined (HAVE_NSS)
 27 #include <smime/gui/e-cert-selector.h>
 28 #endif /* HAVE_NSS */
 29 
 30 #define E_MAIL_CONFIG_SECURITY_PAGE_GET_PRIVATE(obj) \
 31 	(G_TYPE_INSTANCE_GET_PRIVATE \
 32 	((obj), E_TYPE_MAIL_CONFIG_SECURITY_PAGE, EMailConfigSecurityPagePrivate))
 33 
 34 struct _EMailConfigSecurityPagePrivate {
 35 	ESource *identity_source;
 36 };
 37 
 38 enum {
 39 	PROP_0,
 40 	PROP_IDENTITY_SOURCE
 41 };
 42 
 43 /* Forward Declarations */
 44 static void	e_mail_config_security_page_interface_init
 45 					(EMailConfigPageInterface *interface);
 46 
 47 G_DEFINE_TYPE_WITH_CODE (
 48 	EMailConfigSecurityPage,
 49 	e_mail_config_security_page,
 50 	GTK_TYPE_BOX,
 51 	G_IMPLEMENT_INTERFACE (
 52 		E_TYPE_EXTENSIBLE, NULL)
 53 	G_IMPLEMENT_INTERFACE (
 54 		E_TYPE_MAIL_CONFIG_PAGE,
 55 		e_mail_config_security_page_interface_init))
 56 
 57 static gboolean
 58 mail_config_security_page_string_has_text (GBinding *binding,
 59                                            const GValue *source_value,
 60                                            GValue *target_value,
 61                                            gpointer unused)
 62 {
 63 	const gchar *string;
 64 	gchar *stripped;
 65 
 66 	string = g_value_get_string (source_value);
 67 
 68 	if (string == NULL)
 69 		string = "";
 70 
 71 	stripped = g_strstrip (g_strdup (string));
 72 	g_value_set_boolean (target_value, *stripped != '\0');
 73 	g_free (stripped);
 74 
 75 	return TRUE;
 76 }
 77 
 78 static void
 79 mail_config_security_page_cert_selected (ECertSelector *selector,
 80                                          const gchar *key,
 81                                          GtkEntry *entry)
 82 {
 83 	if (key != NULL)
 84 		gtk_entry_set_text (entry, key);
 85 
 86 	gtk_widget_destroy (GTK_WIDGET (selector));
 87 }
 88 
 89 static void
 90 mail_config_security_page_select_encrypt_cert (GtkButton *button,
 91                                                GtkEntry *entry)
 92 {
 93 	GtkWidget *selector;
 94 	gpointer parent;
 95 
 96 	parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
 97 	parent = GTK_IS_WIDGET (parent) ? parent : NULL;
 98 
 99 	selector = e_cert_selector_new (
100 		E_CERT_SELECTOR_RECIPIENT,
101 		gtk_entry_get_text (entry));
102 	gtk_window_set_transient_for (
103 		GTK_WINDOW (selector), parent);
104 	gtk_widget_show (selector);
105 
106 	g_signal_connect (
107 		selector, "selected",
108 		G_CALLBACK (mail_config_security_page_cert_selected),
109 		entry);
110 }
111 
112 static void
113 mail_config_security_page_select_sign_cert (GtkButton *button,
114                                             GtkEntry *entry)
115 {
116 	GtkWidget *selector;
117 	gpointer parent;
118 
119 	parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
120 	parent = GTK_IS_WIDGET (parent) ? parent : NULL;
121 
122 	selector = e_cert_selector_new (
123 		E_CERT_SELECTOR_SIGNER,
124 		gtk_entry_get_text (entry));
125 	gtk_window_set_transient_for (
126 		GTK_WINDOW (selector), parent);
127 	gtk_widget_show (selector);
128 
129 	g_signal_connect (
130 		selector, "selected",
131 		G_CALLBACK (mail_config_security_page_cert_selected),
132 		entry);
133 }
134 
135 static void
136 mail_config_security_page_clear_cert (GtkButton *button,
137                                       GtkEntry *entry)
138 {
139 	gtk_entry_set_text (entry, "");
140 }
141 
142 static void
143 mail_config_security_page_set_identity_source (EMailConfigSecurityPage *page,
144                                                ESource *identity_source)
145 {
146 	g_return_if_fail (E_IS_SOURCE (identity_source));
147 	g_return_if_fail (page->priv->identity_source == NULL);
148 
149 	page->priv->identity_source = g_object_ref (identity_source);
150 }
151 
152 static void
153 mail_config_security_page_set_property (GObject *object,
154                                         guint property_id,
155                                         const GValue *value,
156                                         GParamSpec *pspec)
157 {
158 	switch (property_id) {
159 		case PROP_IDENTITY_SOURCE:
160 			mail_config_security_page_set_identity_source (
161 				E_MAIL_CONFIG_SECURITY_PAGE (object),
162 				g_value_get_object (value));
163 			return;
164 	}
165 
166 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
167 }
168 
169 static void
170 mail_config_security_page_get_property (GObject *object,
171                                         guint property_id,
172                                         GValue *value,
173                                         GParamSpec *pspec)
174 {
175 	switch (property_id) {
176 		case PROP_IDENTITY_SOURCE:
177 			g_value_set_object (
178 				value,
179 				e_mail_config_security_page_get_identity_source (
180 				E_MAIL_CONFIG_SECURITY_PAGE (object)));
181 			return;
182 	}
183 
184 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
185 }
186 
187 static void
188 mail_config_security_page_dispose (GObject *object)
189 {
190 	EMailConfigSecurityPagePrivate *priv;
191 
192 	priv = E_MAIL_CONFIG_SECURITY_PAGE_GET_PRIVATE (object);
193 
194 	if (priv->identity_source != NULL) {
195 		g_object_unref (priv->identity_source);
196 		priv->identity_source = NULL;
197 	}
198 
199 	/* Chain up to parent's dispose() method. */
200 	G_OBJECT_CLASS (e_mail_config_security_page_parent_class)->
201 		dispose (object);
202 }
203 
204 static void
205 mail_config_security_page_constructed (GObject *object)
206 {
207 	EMailConfigSecurityPage *page;
208 	ESource *source;
209 	ESourceMailComposition *composition_ext;
210 	ESourceOpenPGP *openpgp_ext;
211 	GtkEntry *entry;
212 	GtkLabel *label;
213 	GtkWidget *widget;
214 	GtkWidget *container;
215 	GtkSizeGroup *size_group;
216 	const gchar *extension_name;
217 	const gchar *text;
218 	gchar *markup;
219 
220 #if defined (HAVE_NSS)
221 	ESourceSMIME *smime_ext;
222 #endif /* HAVE_NSS */
223 
224 	page = E_MAIL_CONFIG_SECURITY_PAGE (object);
225 
226 	/* Chain up to parent's constructed() method. */
227 	G_OBJECT_CLASS (e_mail_config_security_page_parent_class)->
228 		constructed (object);
229 
230 	source = e_mail_config_security_page_get_identity_source (page);
231 
232 	extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
233 	composition_ext = e_source_get_extension (source, extension_name);
234 
235 	extension_name = E_SOURCE_EXTENSION_OPENPGP;
236 	openpgp_ext = e_source_get_extension (source, extension_name);
237 
238 #if defined (HAVE_NSS)
239 	extension_name = E_SOURCE_EXTENSION_SMIME;
240 	smime_ext = e_source_get_extension (source, extension_name);
241 #endif /* HAVE_NSS */
242 
243 	gtk_orientable_set_orientation (
244 		GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
245 
246 	gtk_box_set_spacing (GTK_BOX (page), 12);
247 
248 	size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
249 
250 	/*** General ***/
251 
252 	widget = gtk_grid_new ();
253 	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
254 	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
255 	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
256 	gtk_widget_show (widget);
257 
258 	container = widget;
259 
260 	text = _("General");
261 	markup = g_markup_printf_escaped ("<b>%s</b>", text);
262 	widget = gtk_label_new (markup);
263 	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
264 	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
265 	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
266 	gtk_widget_show (widget);
267 
268 	text = _("_Do not sign meeting requests (for Outlook compatibility)");
269 	widget = gtk_check_button_new_with_mnemonic (text);
270 	gtk_widget_set_margin_left (widget, 12);
271 	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
272 	gtk_widget_show (widget);
273 
274 	g_object_bind_property (
275 		composition_ext, "sign-imip",
276 		widget, "active",
277 		G_BINDING_BIDIRECTIONAL |
278 		G_BINDING_SYNC_CREATE);
279 
280 	/*** Pretty Good Privacy (OpenPGP) ***/
281 
282 	widget = gtk_grid_new ();
283 	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
284 	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
285 	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
286 	gtk_widget_show (widget);
287 
288 	container = widget;
289 
290 	text = _("Pretty Good Privacy (OpenPGP)");
291 	markup = g_markup_printf_escaped ("<b>%s</b>", text);
292 	widget = gtk_label_new (markup);
293 	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
294 	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
295 	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
296 	gtk_widget_show (widget);
297 
298 	text = _("OpenPGP _Key ID:");
299 	widget = gtk_label_new_with_mnemonic (text);
300 	gtk_widget_set_margin_left (widget, 12);
301 	gtk_size_group_add_widget (size_group, widget);
302 	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
303 	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
304 	gtk_widget_show (widget);
305 
306 	label = GTK_LABEL (widget);
307 
308 	widget = gtk_entry_new ();
309 	gtk_widget_set_hexpand (widget, TRUE);
310 	gtk_label_set_mnemonic_widget (label, widget);
311 	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
312 	gtk_widget_show (widget);
313 
314 	g_object_bind_property (
315 		openpgp_ext, "key-id",
316 		widget, "text",
317 		G_BINDING_SYNC_CREATE |
318 		G_BINDING_BIDIRECTIONAL);
319 
320 	text = _("Si_gning algorithm:");
321 	widget = gtk_label_new_with_mnemonic (text);
322 	gtk_widget_set_margin_left (widget, 12);
323 	gtk_size_group_add_widget (size_group, widget);
324 	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
325 	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
326 	gtk_widget_show (widget);
327 
328 	label = GTK_LABEL (widget);
329 
330 	widget = gtk_combo_box_text_new ();
331 	gtk_combo_box_text_append (
332 		GTK_COMBO_BOX_TEXT (widget),
333 		"", _("Default"));
334 	gtk_combo_box_text_append (
335 		GTK_COMBO_BOX_TEXT (widget),
336 		"sha1", _("SHA1"));
337 	gtk_combo_box_text_append (
338 		GTK_COMBO_BOX_TEXT (widget),
339 		"sha256", _("SHA256"));
340 	gtk_combo_box_text_append (
341 		GTK_COMBO_BOX_TEXT (widget),
342 		"sha384", _("SHA384"));
343 	gtk_combo_box_text_append (
344 		GTK_COMBO_BOX_TEXT (widget),
345 		"sha512", _("SHA512"));
346 	gtk_widget_set_halign (widget, GTK_ALIGN_START);
347 	gtk_label_set_mnemonic_widget (label, widget);
348 	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
349 	gtk_widget_show (widget);
350 
351 	g_object_bind_property (
352 		openpgp_ext, "signing-algorithm",
353 		widget, "active-id",
354 		G_BINDING_SYNC_CREATE |
355 		G_BINDING_BIDIRECTIONAL);
356 
357 	/* Make sure the combo box has an active item. */
358 	if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (widget)) == NULL)
359 		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
360 
361 	text = _("Al_ways sign outgoing messages when using this account");
362 	widget = gtk_check_button_new_with_mnemonic (text);
363 	gtk_widget_set_margin_left (widget, 12);
364 	gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 2, 1);
365 	gtk_widget_show (widget);
366 
367 	g_object_bind_property (
368 		openpgp_ext, "sign-by-default",
369 		widget, "active",
370 		G_BINDING_SYNC_CREATE |
371 		G_BINDING_BIDIRECTIONAL);
372 
373 	text = _("Always encrypt to _myself when sending encrypted messages");
374 	widget = gtk_check_button_new_with_mnemonic (text);
375 	gtk_widget_set_margin_left (widget, 12);
376 	gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 2, 1);
377 	gtk_widget_show (widget);
378 
379 	g_object_bind_property (
380 		openpgp_ext, "encrypt-to-self",
381 		widget, "active",
382 		G_BINDING_SYNC_CREATE |
383 		G_BINDING_BIDIRECTIONAL);
384 
385 	text = _("Always _trust keys in my keyring when encrypting");
386 	widget = gtk_check_button_new_with_mnemonic (text);
387 	gtk_widget_set_margin_left (widget, 12);
388 	gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 2, 1);
389 	gtk_widget_show (widget);
390 
391 	g_object_bind_property (
392 		openpgp_ext, "always-trust",
393 		widget, "active",
394 		G_BINDING_SYNC_CREATE |
395 		G_BINDING_BIDIRECTIONAL);
396 
397 #if defined (HAVE_NSS)
398 
399 	/*** Security MIME (S/MIME) ***/
400 
401 	widget = gtk_grid_new ();
402 	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
403 	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
404 	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
405 	gtk_widget_show (widget);
406 
407 	container = widget;
408 
409 	text = _("Secure MIME (S/MIME)");
410 	markup = g_markup_printf_escaped ("<b>%s</b>", text);
411 	widget = gtk_label_new (markup);
412 	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
413 	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
414 	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 4, 1);
415 	gtk_widget_show (widget);
416 
417 	text = _("Sig_ning certificate:");
418 	widget = gtk_label_new_with_mnemonic (text);
419 	gtk_widget_set_margin_left (widget, 12);
420 	gtk_size_group_add_widget (size_group, widget);
421 	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
422 	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
423 	gtk_widget_show (widget);
424 
425 	label = GTK_LABEL (widget);
426 
427 	widget = gtk_entry_new ();
428 	gtk_widget_set_hexpand (widget, TRUE);
429 	gtk_label_set_mnemonic_widget (label, widget);
430 	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
431 	gtk_widget_show (widget);
432 
433 	g_object_bind_property (
434 		smime_ext, "signing-certificate",
435 		widget, "text",
436 		G_BINDING_BIDIRECTIONAL |
437 		G_BINDING_SYNC_CREATE);
438 
439 	entry = GTK_ENTRY (widget);
440 
441 	widget = gtk_button_new_with_label (_("Select"));
442 	gtk_grid_attach (GTK_GRID (container), widget, 2, 1, 1, 1);
443 	gtk_widget_show (widget);
444 
445 	g_signal_connect (
446 		widget, "clicked",
447 		G_CALLBACK (mail_config_security_page_select_sign_cert),
448 		entry);
449 
450 	widget = gtk_button_new_from_stock (GTK_STOCK_CLEAR);
451 	gtk_grid_attach (GTK_GRID (container), widget, 3, 1, 1, 1);
452 	gtk_widget_show (widget);
453 
454 	g_signal_connect (
455 		widget, "clicked",
456 		G_CALLBACK (mail_config_security_page_clear_cert),
457 		entry);
458 
459 	text = _("Signing _algorithm:");
460 	widget = gtk_label_new_with_mnemonic (text);
461 	gtk_widget_set_margin_left (widget, 12);
462 	gtk_size_group_add_widget (size_group, widget);
463 	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
464 	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
465 	gtk_widget_show (widget);
466 
467 	label = GTK_LABEL (widget);
468 
469 	widget = gtk_combo_box_text_new ();
470 	gtk_combo_box_text_append (
471 		GTK_COMBO_BOX_TEXT (widget),
472 		"", _("Default"));
473 	gtk_combo_box_text_append (
474 		GTK_COMBO_BOX_TEXT (widget),
475 		"sha1", _("SHA1"));
476 	gtk_combo_box_text_append (
477 		GTK_COMBO_BOX_TEXT (widget),
478 		"sha256", _("SHA256"));
479 	gtk_combo_box_text_append (
480 		GTK_COMBO_BOX_TEXT (widget),
481 		"sha384", _("SHA384"));
482 	gtk_combo_box_text_append (
483 		GTK_COMBO_BOX_TEXT (widget),
484 		"sha512", _("SHA512"));
485 	gtk_widget_set_halign (widget, GTK_ALIGN_START);
486 	gtk_label_set_mnemonic_widget (label, widget);
487 	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
488 	gtk_widget_show (widget);
489 
490 	g_object_bind_property (
491 		smime_ext, "signing-algorithm",
492 		widget, "active-id",
493 		G_BINDING_SYNC_CREATE |
494 		G_BINDING_BIDIRECTIONAL);
495 
496 	/* Make sure the combo box has an active item. */
497 	if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (widget)) == NULL)
498 		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
499 
500 	text = _("Always sign outgoing messages when using this account");
501 	widget = gtk_check_button_new_with_mnemonic (text);
502 	gtk_widget_set_margin_left (widget, 12);
503 	gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 4, 1);
504 	gtk_widget_show (widget);
505 
506 	g_object_bind_property (
507 		smime_ext, "sign-by-default",
508 		widget, "active",
509 		G_BINDING_SYNC_CREATE |
510 		G_BINDING_BIDIRECTIONAL);
511 
512 	g_object_bind_property_full (
513 		smime_ext, "signing-certificate",
514 		widget, "sensitive",
515 		G_BINDING_SYNC_CREATE,
516 		mail_config_security_page_string_has_text,
517 		NULL,
518 		NULL, (GDestroyNotify) NULL);
519 
520 	/* Add extra padding between signing stuff and encryption stuff. */
521 	gtk_widget_set_margin_bottom (widget, 6);
522 
523 	text = _("Encryption certificate:");
524 	widget = gtk_label_new_with_mnemonic (text);
525 	gtk_widget_set_margin_left (widget, 12);
526 	gtk_size_group_add_widget (size_group, widget);
527 	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
528 	gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 1, 1);
529 	gtk_widget_show (widget);
530 
531 	label = GTK_LABEL (widget);
532 
533 	widget = gtk_entry_new ();
534 	gtk_widget_set_hexpand (widget, TRUE);
535 	gtk_label_set_mnemonic_widget (label, widget);
536 	gtk_grid_attach (GTK_GRID (container), widget, 1, 4, 1, 1);
537 	gtk_widget_show (widget);
538 
539 	g_object_bind_property (
540 		smime_ext, "encryption-certificate",
541 		widget, "text",
542 		G_BINDING_BIDIRECTIONAL |
543 		G_BINDING_SYNC_CREATE);
544 
545 	entry = GTK_ENTRY (widget);
546 
547 	widget = gtk_button_new_with_label (_("Select"));
548 	gtk_grid_attach (GTK_GRID (container), widget, 2, 4, 1, 1);
549 	gtk_widget_show (widget);
550 
551 	g_signal_connect (
552 		widget, "clicked",
553 		G_CALLBACK (mail_config_security_page_select_encrypt_cert),
554 		entry);
555 
556 	widget = gtk_button_new_from_stock (GTK_STOCK_CLEAR);
557 	gtk_grid_attach (GTK_GRID (container), widget, 3, 4, 1, 1);
558 	gtk_widget_show (widget);
559 
560 	g_signal_connect (
561 		widget, "clicked",
562 		G_CALLBACK (mail_config_security_page_clear_cert),
563 		entry);
564 
565 	text = _("Always encrypt outgoing messages when using this account");
566 	widget = gtk_check_button_new_with_mnemonic (text);
567 	gtk_widget_set_margin_left (widget, 12);
568 	gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 4, 1);
569 	gtk_widget_show (widget);
570 
571 	g_object_bind_property (
572 		smime_ext, "encrypt-by-default",
573 		widget, "active",
574 		G_BINDING_SYNC_CREATE |
575 		G_BINDING_BIDIRECTIONAL);
576 
577 	g_object_bind_property_full (
578 		smime_ext, "encryption-certificate",
579 		widget, "sensitive",
580 		G_BINDING_SYNC_CREATE,
581 		mail_config_security_page_string_has_text,
582 		NULL,
583 		NULL, (GDestroyNotify) NULL);
584 
585 	text = _("Always encrypt to myself when sending encrypted messages");
586 	widget = gtk_check_button_new_with_mnemonic (text);
587 	gtk_widget_set_margin_left (widget, 12);
588 	gtk_grid_attach (GTK_GRID (container), widget, 0, 6, 4, 1);
589 	gtk_widget_show (widget);
590 
591 	g_object_bind_property (
592 		smime_ext, "encrypt-to-self",
593 		widget, "active",
594 		G_BINDING_SYNC_CREATE |
595 		G_BINDING_BIDIRECTIONAL);
596 
597 	g_object_bind_property_full (
598 		smime_ext, "encryption-certificate",
599 		widget, "sensitive",
600 		G_BINDING_SYNC_CREATE,
601 		mail_config_security_page_string_has_text,
602 		NULL,
603 		NULL, (GDestroyNotify) NULL);
604 
605 #endif /* HAVE_NSS */
606 
607 	g_object_unref (size_group);
608 
609 	e_extensible_load_extensions (E_EXTENSIBLE (page));
610 }
611 
612 static void
613 e_mail_config_security_page_class_init (EMailConfigSecurityPageClass *class)
614 {
615 	GObjectClass *object_class;
616 
617 	g_type_class_add_private (
618 		class, sizeof (EMailConfigSecurityPagePrivate));
619 
620 	object_class = G_OBJECT_CLASS (class);
621 	object_class->set_property = mail_config_security_page_set_property;
622 	object_class->get_property = mail_config_security_page_get_property;
623 	object_class->dispose = mail_config_security_page_dispose;
624 	object_class->constructed = mail_config_security_page_constructed;
625 
626 	g_object_class_install_property (
627 		object_class,
628 		PROP_IDENTITY_SOURCE,
629 		g_param_spec_object (
630 			"identity-source",
631 			"Identity Source",
632 			"Mail identity source being edited",
633 			E_TYPE_SOURCE,
634 			G_PARAM_READWRITE |
635 			G_PARAM_CONSTRUCT_ONLY |
636 			G_PARAM_STATIC_STRINGS));
637 }
638 
639 static void
640 e_mail_config_security_page_interface_init (EMailConfigPageInterface *interface)
641 {
642 	interface->title = _("Security");
643 	interface->sort_order = E_MAIL_CONFIG_SECURITY_PAGE_SORT_ORDER;
644 }
645 
646 static void
647 e_mail_config_security_page_init (EMailConfigSecurityPage *page)
648 {
649 	page->priv = E_MAIL_CONFIG_SECURITY_PAGE_GET_PRIVATE (page);
650 }
651 
652 EMailConfigPage *
653 e_mail_config_security_page_new (ESource *identity_source)
654 {
655 	g_return_val_if_fail (E_IS_SOURCE (identity_source), NULL);
656 
657 	return g_object_new (
658 		E_TYPE_MAIL_CONFIG_SECURITY_PAGE,
659 		"identity-source", identity_source, NULL);
660 }
661 
662 ESource *
663 e_mail_config_security_page_get_identity_source (EMailConfigSecurityPage *page)
664 {
665 	g_return_val_if_fail (E_IS_MAIL_CONFIG_SECURITY_PAGE (page), NULL);
666 
667 	return page->priv->identity_source;
668 }