1 /*
2  * e-source-openpgp.c
3  *
4  * This library is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11  * for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library. If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17 
18 /**
19  * SECTION: e-source-openpgp
20  * @include: libedataserver/libedataserver.h
21  * @short_description: #ESource extension for OpenPGP settings
22  *
23  * The #ESourceOpenPGP extension tracks OpenPGP (RFC 4880) settings to be
24  * applied to outgoing mail messages.
25  *
26  * Access the extension as follows:
27  *
28  * |[
29  *   #include <libedataserver/libedataserver.h>
30  *
31  *   ESourceOpenPGP *extension;
32  *
33  *   extension = e_source_get_extension (source, E_SOURCE_EXTENSION_OPENPGP);
34  * ]|
35  **/
36 
37 #include "e-source-openpgp.h"
38 
39 #include <libedataserver/e-data-server-util.h>
40 
41 struct _ESourceOpenPGPPrivate {
42 	gchar *key_id;
43 	gchar *signing_algorithm;
44 
45 	gboolean always_trust;
46 	gboolean encrypt_to_self;
47 	gboolean sign_by_default;
48 	gboolean encrypt_by_default;
49 	gboolean prefer_inline;
50 };
51 
52 enum {
53 	PROP_0,
54 	PROP_ALWAYS_TRUST,
55 	PROP_ENCRYPT_TO_SELF,
56 	PROP_KEY_ID,
57 	PROP_SIGNING_ALGORITHM,
58 	PROP_SIGN_BY_DEFAULT,
59 	PROP_ENCRYPT_BY_DEFAULT,
60 	PROP_PREFER_INLINE
61 };
62 
G_DEFINE_TYPE_WITH_PRIVATE(ESourceOpenPGP,e_source_openpgp,E_TYPE_SOURCE_EXTENSION)63 G_DEFINE_TYPE_WITH_PRIVATE (
64 	ESourceOpenPGP,
65 	e_source_openpgp,
66 	E_TYPE_SOURCE_EXTENSION)
67 
68 static void
69 source_openpgp_set_property (GObject *object,
70                              guint property_id,
71                              const GValue *value,
72                              GParamSpec *pspec)
73 {
74 	switch (property_id) {
75 		case PROP_ALWAYS_TRUST:
76 			e_source_openpgp_set_always_trust (
77 				E_SOURCE_OPENPGP (object),
78 				g_value_get_boolean (value));
79 			return;
80 
81 		case PROP_ENCRYPT_TO_SELF:
82 			e_source_openpgp_set_encrypt_to_self (
83 				E_SOURCE_OPENPGP (object),
84 				g_value_get_boolean (value));
85 			return;
86 
87 		case PROP_KEY_ID:
88 			e_source_openpgp_set_key_id (
89 				E_SOURCE_OPENPGP (object),
90 				g_value_get_string (value));
91 			return;
92 
93 		case PROP_SIGNING_ALGORITHM:
94 			e_source_openpgp_set_signing_algorithm (
95 				E_SOURCE_OPENPGP (object),
96 				g_value_get_string (value));
97 			return;
98 
99 		case PROP_SIGN_BY_DEFAULT:
100 			e_source_openpgp_set_sign_by_default (
101 				E_SOURCE_OPENPGP (object),
102 				g_value_get_boolean (value));
103 			return;
104 
105 		case PROP_ENCRYPT_BY_DEFAULT:
106 			e_source_openpgp_set_encrypt_by_default (
107 				E_SOURCE_OPENPGP (object),
108 				g_value_get_boolean (value));
109 			return;
110 
111 		case PROP_PREFER_INLINE:
112 			e_source_openpgp_set_prefer_inline (
113 				E_SOURCE_OPENPGP (object),
114 				g_value_get_boolean (value));
115 			return;
116 	}
117 
118 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
119 }
120 
121 static void
source_openpgp_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)122 source_openpgp_get_property (GObject *object,
123                              guint property_id,
124                              GValue *value,
125                              GParamSpec *pspec)
126 {
127 	switch (property_id) {
128 		case PROP_ALWAYS_TRUST:
129 			g_value_set_boolean (
130 				value,
131 				e_source_openpgp_get_always_trust (
132 				E_SOURCE_OPENPGP (object)));
133 			return;
134 
135 		case PROP_ENCRYPT_TO_SELF:
136 			g_value_set_boolean (
137 				value,
138 				e_source_openpgp_get_encrypt_to_self (
139 				E_SOURCE_OPENPGP (object)));
140 			return;
141 
142 		case PROP_KEY_ID:
143 			g_value_take_string (
144 				value,
145 				e_source_openpgp_dup_key_id (
146 				E_SOURCE_OPENPGP (object)));
147 			return;
148 
149 		case PROP_SIGNING_ALGORITHM:
150 			g_value_take_string (
151 				value,
152 				e_source_openpgp_dup_signing_algorithm (
153 				E_SOURCE_OPENPGP (object)));
154 			return;
155 
156 		case PROP_SIGN_BY_DEFAULT:
157 			g_value_set_boolean (
158 				value,
159 				e_source_openpgp_get_sign_by_default (
160 				E_SOURCE_OPENPGP (object)));
161 			return;
162 
163 		case PROP_ENCRYPT_BY_DEFAULT:
164 			g_value_set_boolean (
165 				value,
166 				e_source_openpgp_get_encrypt_by_default (
167 				E_SOURCE_OPENPGP (object)));
168 			return;
169 
170 		case PROP_PREFER_INLINE:
171 			g_value_set_boolean (
172 				value,
173 				e_source_openpgp_get_prefer_inline (
174 				E_SOURCE_OPENPGP (object)));
175 			return;
176 	}
177 
178 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
179 }
180 
181 static void
source_openpgp_finalize(GObject * object)182 source_openpgp_finalize (GObject *object)
183 {
184 	ESourceOpenPGPPrivate *priv;
185 
186 	priv = E_SOURCE_OPENPGP (object)->priv;
187 
188 	g_free (priv->key_id);
189 	g_free (priv->signing_algorithm);
190 
191 	/* Chain up to parent's finalize() method. */
192 	G_OBJECT_CLASS (e_source_openpgp_parent_class)->finalize (object);
193 }
194 
195 static void
e_source_openpgp_class_init(ESourceOpenPGPClass * class)196 e_source_openpgp_class_init (ESourceOpenPGPClass *class)
197 {
198 	GObjectClass *object_class;
199 	ESourceExtensionClass *extension_class;
200 
201 	object_class = G_OBJECT_CLASS (class);
202 	object_class->set_property = source_openpgp_set_property;
203 	object_class->get_property = source_openpgp_get_property;
204 	object_class->finalize = source_openpgp_finalize;
205 
206 	extension_class = E_SOURCE_EXTENSION_CLASS (class);
207 	extension_class->name = E_SOURCE_EXTENSION_OPENPGP;
208 
209 	g_object_class_install_property (
210 		object_class,
211 		PROP_ALWAYS_TRUST,
212 		g_param_spec_boolean (
213 			"always-trust",
214 			"Always Trust",
215 			"Always trust keys in my keyring",
216 			FALSE,
217 			G_PARAM_READWRITE |
218 			G_PARAM_CONSTRUCT |
219 			G_PARAM_EXPLICIT_NOTIFY |
220 			G_PARAM_STATIC_STRINGS |
221 			E_SOURCE_PARAM_SETTING));
222 
223 	g_object_class_install_property (
224 		object_class,
225 		PROP_ENCRYPT_TO_SELF,
226 		g_param_spec_boolean (
227 			"encrypt-to-self",
228 			"Encrypt To Self",
229 			"Always encrypt to myself",
230 			TRUE,
231 			G_PARAM_READWRITE |
232 			G_PARAM_CONSTRUCT |
233 			G_PARAM_EXPLICIT_NOTIFY |
234 			G_PARAM_STATIC_STRINGS |
235 			E_SOURCE_PARAM_SETTING));
236 
237 	g_object_class_install_property (
238 		object_class,
239 		PROP_KEY_ID,
240 		g_param_spec_string (
241 			"key-id",
242 			"Key ID",
243 			"PGP/GPG Key ID",
244 			NULL,
245 			G_PARAM_READWRITE |
246 			G_PARAM_CONSTRUCT |
247 			G_PARAM_EXPLICIT_NOTIFY |
248 			G_PARAM_STATIC_STRINGS |
249 			E_SOURCE_PARAM_SETTING));
250 
251 	g_object_class_install_property (
252 		object_class,
253 		PROP_SIGNING_ALGORITHM,
254 		g_param_spec_string (
255 			"signing-algorithm",
256 			"Signing Algorithm",
257 			"Hash algorithm used to sign messages",
258 			NULL,
259 			G_PARAM_READWRITE |
260 			G_PARAM_CONSTRUCT |
261 			G_PARAM_EXPLICIT_NOTIFY |
262 			G_PARAM_STATIC_STRINGS |
263 			E_SOURCE_PARAM_SETTING));
264 
265 	g_object_class_install_property (
266 		object_class,
267 		PROP_SIGN_BY_DEFAULT,
268 		g_param_spec_boolean (
269 			"sign-by-default",
270 			"Sign By Default",
271 			"Sign outgoing messages by default",
272 			FALSE,
273 			G_PARAM_READWRITE |
274 			G_PARAM_CONSTRUCT |
275 			G_PARAM_EXPLICIT_NOTIFY |
276 			G_PARAM_STATIC_STRINGS |
277 			E_SOURCE_PARAM_SETTING));
278 
279 	g_object_class_install_property (
280 		object_class,
281 		PROP_ENCRYPT_BY_DEFAULT,
282 		g_param_spec_boolean (
283 			"encrypt-by-default",
284 			"Encrypt By Default",
285 			"Encrypt outgoing messages by default",
286 			FALSE,
287 			G_PARAM_READWRITE |
288 			G_PARAM_CONSTRUCT |
289 			G_PARAM_EXPLICIT_NOTIFY |
290 			G_PARAM_STATIC_STRINGS |
291 			E_SOURCE_PARAM_SETTING));
292 
293 	g_object_class_install_property (
294 		object_class,
295 		PROP_PREFER_INLINE,
296 		g_param_spec_boolean (
297 			"prefer-inline",
298 			"Prefer inline",
299 			"Prefer inline sign/encrypt",
300 			FALSE,
301 			G_PARAM_READWRITE |
302 			G_PARAM_CONSTRUCT |
303 			G_PARAM_EXPLICIT_NOTIFY |
304 			G_PARAM_STATIC_STRINGS |
305 			E_SOURCE_PARAM_SETTING));
306 }
307 
308 static void
e_source_openpgp_init(ESourceOpenPGP * extension)309 e_source_openpgp_init (ESourceOpenPGP *extension)
310 {
311 	extension->priv = e_source_openpgp_get_instance_private (extension);
312 }
313 
314 /**
315  * e_source_openpgp_get_always_trust:
316  * @extension: an #ESourceOpenPGP
317  *
318  * Returns whether to skip key validation and assume that used keys are
319  * always fully trusted.
320  *
321  * Returns: whether used keys are always fully trusted
322  *
323  * Since: 3.6
324  **/
325 gboolean
e_source_openpgp_get_always_trust(ESourceOpenPGP * extension)326 e_source_openpgp_get_always_trust (ESourceOpenPGP *extension)
327 {
328 	g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), FALSE);
329 
330 	return extension->priv->always_trust;
331 }
332 
333 /**
334  * e_source_openpgp_set_always_trust:
335  * @extension: an #ESourceOpenPGP
336  * @always_trust: whether used keys are always fully trusted
337  *
338  * Sets whether to skip key validation and assume that used keys are
339  * always fully trusted.
340  *
341  * Since: 3.6
342  **/
343 void
e_source_openpgp_set_always_trust(ESourceOpenPGP * extension,gboolean always_trust)344 e_source_openpgp_set_always_trust (ESourceOpenPGP *extension,
345                                    gboolean always_trust)
346 {
347 	g_return_if_fail (E_IS_SOURCE_OPENPGP (extension));
348 
349 	if (extension->priv->always_trust == always_trust)
350 		return;
351 
352 	extension->priv->always_trust = always_trust;
353 
354 	g_object_notify (G_OBJECT (extension), "always-trust");
355 }
356 
357 /**
358  * e_source_openpgp_get_encrypt_to_self:
359  * @extension: an #ESourceOpenPGP
360  *
361  * Returns whether to "encrypt-to-self" when sending encrypted messages.
362  *
363  * Returns: whether to "encrypt-to-self"
364  *
365  * Since: 3.6
366  **/
367 gboolean
e_source_openpgp_get_encrypt_to_self(ESourceOpenPGP * extension)368 e_source_openpgp_get_encrypt_to_self (ESourceOpenPGP *extension)
369 {
370 	g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), FALSE);
371 
372 	return extension->priv->encrypt_to_self;
373 }
374 
375 /**
376  * e_source_openpgp_set_encrypt_to_self:
377  * @extension: an #ESourceOpenPGP
378  * @encrypt_to_self: whether to "encrypt-to-self"
379  *
380  * Sets whether to "encrypt-to-self" when sending encrypted messages.
381  *
382  * Since: 3.6
383  **/
384 void
e_source_openpgp_set_encrypt_to_self(ESourceOpenPGP * extension,gboolean encrypt_to_self)385 e_source_openpgp_set_encrypt_to_self (ESourceOpenPGP *extension,
386                                       gboolean encrypt_to_self)
387 {
388 	g_return_if_fail (E_IS_SOURCE_OPENPGP (extension));
389 
390 	if (extension->priv->encrypt_to_self == encrypt_to_self)
391 		return;
392 
393 	extension->priv->encrypt_to_self = encrypt_to_self;
394 
395 	g_object_notify (G_OBJECT (extension), "encrypt-to-self");
396 }
397 
398 /**
399  * e_source_openpgp_get_key_id:
400  * @extension: an #ESourceOpenPGP
401  *
402  * Returns the OpenPGP key ID used to sign and encrypt messages.
403  *
404  * Returns: the key ID used to sign and encrypt messages
405  *
406  * Since: 3.6
407  **/
408 const gchar *
e_source_openpgp_get_key_id(ESourceOpenPGP * extension)409 e_source_openpgp_get_key_id (ESourceOpenPGP *extension)
410 {
411 	g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), NULL);
412 
413 	return extension->priv->key_id;
414 }
415 
416 /**
417  * e_source_openpgp_dup_key_id:
418  * @extension: an #ESourceOpenPGP
419  *
420  * Thread-safe variation of e_source_openpgp_get_key_id().
421  * Use this function when accessing @extension from multiple threads.
422  *
423  * The returned string should be freed with g_free() when no longer needed.
424  *
425  * Returns: a newly-allocated copy of #ESourceOpenPGP:key-id
426  *
427  * Since: 3.6
428  **/
429 gchar *
e_source_openpgp_dup_key_id(ESourceOpenPGP * extension)430 e_source_openpgp_dup_key_id (ESourceOpenPGP *extension)
431 {
432 	const gchar *protected;
433 	gchar *duplicate;
434 
435 	g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), NULL);
436 
437 	e_source_extension_property_lock (E_SOURCE_EXTENSION (extension));
438 
439 	protected = e_source_openpgp_get_key_id (extension);
440 	duplicate = g_strdup (protected);
441 
442 	e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
443 
444 	return duplicate;
445 }
446 
447 /**
448  * e_source_openpgp_set_key_id:
449  * @extension: an #ESourceOpenPGP
450  * @key_id: the key ID used to sign and encrypt messages
451  *
452  * Sets the OpenPGP key ID used to sign and encrypt messages.
453  *
454  * The internal copy of @key_id is automatically stripped of leading and
455  * trailing whitespace.  If the resulting string is empty, %NULL is set
456  * instead.
457  *
458  * Since: 3.6
459  **/
460 void
e_source_openpgp_set_key_id(ESourceOpenPGP * extension,const gchar * key_id)461 e_source_openpgp_set_key_id (ESourceOpenPGP *extension,
462                              const gchar *key_id)
463 {
464 	g_return_if_fail (E_IS_SOURCE_OPENPGP (extension));
465 
466 	e_source_extension_property_lock (E_SOURCE_EXTENSION (extension));
467 
468 	if (e_util_strcmp0 (extension->priv->key_id, key_id) == 0) {
469 		e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
470 		return;
471 	}
472 
473 	g_free (extension->priv->key_id);
474 	extension->priv->key_id = e_util_strdup_strip (key_id);
475 
476 	e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
477 
478 	g_object_notify (G_OBJECT (extension), "key-id");
479 }
480 
481 /**
482  * e_source_openpgp_get_signing_algorithm:
483  * @extension: an #ESourceOpenPGP
484  *
485  * Returns the name of the hash algorithm used to digitally sign outgoing
486  * messages.
487  *
488  * Returns: the signing algorithm for outgoing messages
489  *
490  * Since: 3.6
491  **/
492 const gchar *
e_source_openpgp_get_signing_algorithm(ESourceOpenPGP * extension)493 e_source_openpgp_get_signing_algorithm (ESourceOpenPGP *extension)
494 {
495 	g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), NULL);
496 
497 	return extension->priv->signing_algorithm;
498 }
499 
500 /**
501  * e_source_openpgp_dup_signing_algorithm:
502  * @extension: an #ESourceOpenPGP
503  *
504  * Thread-safe variation of e_source_openpgp_get_signing_algorithm().
505  * Use this function when accessing @extension from multiple threads.
506  *
507  * The returned string should be freed with g_free() when no longer needed.
508  *
509  * Returns: a newly-allocated copy of #ESourceOpenPGP:signing-algorithm
510  *
511  * Since: 3.6
512  **/
513 gchar *
e_source_openpgp_dup_signing_algorithm(ESourceOpenPGP * extension)514 e_source_openpgp_dup_signing_algorithm (ESourceOpenPGP *extension)
515 {
516 	const gchar *protected;
517 	gchar *duplicate;
518 
519 	g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), NULL);
520 
521 	e_source_extension_property_lock (E_SOURCE_EXTENSION (extension));
522 
523 	protected = e_source_openpgp_get_signing_algorithm (extension);
524 	duplicate = g_strdup (protected);
525 
526 	e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
527 
528 	return duplicate;
529 }
530 
531 /**
532  * e_source_openpgp_set_signing_algorithm:
533  * @extension: an #ESourceOpenPGP
534  * @signing_algorithm: the signing algorithm for outgoing messages
535  *
536  * Sets the name of the hash algorithm used to digitally sign outgoing
537  * messages.
538  *
539  * The internal copy of @signing_algorithm is automatically stripped of
540  * leading and trailing whitespace.  If the resulting string is empty,
541  * %NULL is set instead.
542  *
543  * Since: 3.6
544  **/
545 void
e_source_openpgp_set_signing_algorithm(ESourceOpenPGP * extension,const gchar * signing_algorithm)546 e_source_openpgp_set_signing_algorithm (ESourceOpenPGP *extension,
547                                         const gchar *signing_algorithm)
548 {
549 	g_return_if_fail (E_IS_SOURCE_OPENPGP (extension));
550 
551 	e_source_extension_property_lock (E_SOURCE_EXTENSION (extension));
552 
553 	if (e_util_strcmp0 (extension->priv->signing_algorithm, signing_algorithm) == 0) {
554 		e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
555 		return;
556 	}
557 
558 	g_free (extension->priv->signing_algorithm);
559 	extension->priv->signing_algorithm =
560 		e_util_strdup_strip (signing_algorithm);
561 
562 	e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
563 
564 	g_object_notify (G_OBJECT (extension), "signing-algorithm");
565 }
566 
567 /**
568  * e_source_openpgp_get_sign_by_default:
569  * @extension: an #ESourceOpenPGP
570  *
571  * Returns whether to digitally sign outgoing messages by default using
572  * OpenPGP-compliant software such as GNU Privacy Guard (GnuPG).
573  *
574  * Returns: whether to sign outgoing messages by default
575  *
576  * Since: 3.6
577  **/
578 gboolean
e_source_openpgp_get_sign_by_default(ESourceOpenPGP * extension)579 e_source_openpgp_get_sign_by_default (ESourceOpenPGP *extension)
580 {
581 	g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), FALSE);
582 
583 	return extension->priv->sign_by_default;
584 }
585 
586 /**
587  * e_source_openpgp_set_sign_by_default:
588  * @extension: an #ESourceOpenPGP
589  * @sign_by_default: whether to sign outgoing messages by default
590  *
591  * Sets whether to digitally sign outgoing messages by default using
592  * OpenPGP-compliant software such as GNU Privacy Guard (GnuPG).
593  *
594  * Since: 3.6
595  **/
596 void
e_source_openpgp_set_sign_by_default(ESourceOpenPGP * extension,gboolean sign_by_default)597 e_source_openpgp_set_sign_by_default (ESourceOpenPGP *extension,
598                                       gboolean sign_by_default)
599 {
600 	g_return_if_fail (E_IS_SOURCE_OPENPGP (extension));
601 
602 	if (extension->priv->sign_by_default == sign_by_default)
603 		return;
604 
605 	extension->priv->sign_by_default = sign_by_default;
606 
607 	g_object_notify (G_OBJECT (extension), "sign-by-default");
608 }
609 
610 /**
611  * e_source_openpgp_get_encrypt_by_default:
612  * @extension: an #ESourceOpenPGP
613  *
614  * Returns whether to digitally encrypt outgoing messages by default using
615  * OpenPGP-compliant software such as GNU Privacy Guard (GnuPG).
616  *
617  * Returns: whether to encrypt outgoing messages by default
618  *
619  * Since: 3.18
620  **/
621 gboolean
e_source_openpgp_get_encrypt_by_default(ESourceOpenPGP * extension)622 e_source_openpgp_get_encrypt_by_default (ESourceOpenPGP *extension)
623 {
624 	g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), FALSE);
625 
626 	return extension->priv->encrypt_by_default;
627 }
628 
629 /**
630  * e_source_openpgp_set_encrypt_by_default:
631  * @extension: an #ESourceOpenPGP
632  * @encrypt_by_default: whether to encrypt outgoing messages by default
633  *
634  * Sets whether to digitally encrypt outgoing messages by default using
635  * OpenPGP-compliant software such as GNU Privacy Guard (GnuPG).
636  *
637  * Since: 3.18
638  **/
639 void
e_source_openpgp_set_encrypt_by_default(ESourceOpenPGP * extension,gboolean encrypt_by_default)640 e_source_openpgp_set_encrypt_by_default (ESourceOpenPGP *extension,
641                                          gboolean encrypt_by_default)
642 {
643 	g_return_if_fail (E_IS_SOURCE_OPENPGP (extension));
644 
645 	if (extension->priv->encrypt_by_default == encrypt_by_default)
646 		return;
647 
648 	extension->priv->encrypt_by_default = encrypt_by_default;
649 
650 	g_object_notify (G_OBJECT (extension), "encrypt-by-default");
651 }
652 
653 /**
654  * e_source_openpgp_get_prefer_inline:
655  * @extension: an #ESourceOpenPGP
656  *
657  * Returns whether to prefer inline sign/encrypt of the text/plain messages.
658  *
659  * Returns: whether to prefer inline sign/encrypt of the text/plain messages
660  *
661  * Since: 3.20
662  **/
663 gboolean
e_source_openpgp_get_prefer_inline(ESourceOpenPGP * extension)664 e_source_openpgp_get_prefer_inline (ESourceOpenPGP *extension)
665 {
666 	g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), FALSE);
667 
668 	return extension->priv->prefer_inline;
669 }
670 
671 /**
672  * e_source_openpgp_set_prefer_inline:
673  * @extension: an #ESourceOpenPGP
674  * @prefer_inline: whether to prefer inline sign/encrypt of the text/plain messages
675  *
676  * Sets whether to prefer inline sign/encrypt of the text/plain messages.
677  *
678  * Since: 3.20
679  **/
680 void
e_source_openpgp_set_prefer_inline(ESourceOpenPGP * extension,gboolean prefer_inline)681 e_source_openpgp_set_prefer_inline (ESourceOpenPGP *extension,
682 				    gboolean prefer_inline)
683 {
684 	g_return_if_fail (E_IS_SOURCE_OPENPGP (extension));
685 
686 	if (extension->priv->prefer_inline == prefer_inline)
687 		return;
688 
689 	extension->priv->prefer_inline = prefer_inline;
690 
691 	g_object_notify (G_OBJECT (extension), "prefer-inline");
692 }
693