diff options
author | Milan Crha <mcrha@redhat.com> | 2022-06-28 13:31:48 +0200 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2022-06-28 13:31:48 +0200 |
commit | ab825489f51dfa5172233c572c3435d26efaf5d0 (patch) | |
tree | e6bcbd2a96bd3e37d7ab637d4a75b8f1306d33c2 /src/libedataserver/e-source-openpgp.c | |
parent | 5d731c9e2188b82b0bc248f42f8e47a5fb75d442 (diff) | |
download | evolution-data-server-ab825489f51dfa5172233c572c3435d26efaf5d0.tar.gz |
I#39 - Add Web Key Directory (WKD) support for OpenPGP
Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/39
Diffstat (limited to 'src/libedataserver/e-source-openpgp.c')
-rw-r--r-- | src/libedataserver/e-source-openpgp.c | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/src/libedataserver/e-source-openpgp.c b/src/libedataserver/e-source-openpgp.c index a9ac320c6..0a70ae482 100644 --- a/src/libedataserver/e-source-openpgp.c +++ b/src/libedataserver/e-source-openpgp.c @@ -47,6 +47,7 @@ struct _ESourceOpenPGPPrivate { gboolean sign_by_default; gboolean encrypt_by_default; gboolean prefer_inline; + gboolean locate_keys; }; enum { @@ -57,7 +58,8 @@ enum { PROP_SIGNING_ALGORITHM, PROP_SIGN_BY_DEFAULT, PROP_ENCRYPT_BY_DEFAULT, - PROP_PREFER_INLINE + PROP_PREFER_INLINE, + PROP_LOCATE_KEYS }; G_DEFINE_TYPE_WITH_PRIVATE ( @@ -113,6 +115,12 @@ source_openpgp_set_property (GObject *object, E_SOURCE_OPENPGP (object), g_value_get_boolean (value)); return; + + case PROP_LOCATE_KEYS: + e_source_openpgp_set_locate_keys ( + E_SOURCE_OPENPGP (object), + g_value_get_boolean (value)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -173,6 +181,13 @@ source_openpgp_get_property (GObject *object, e_source_openpgp_get_prefer_inline ( E_SOURCE_OPENPGP (object))); return; + + case PROP_LOCATE_KEYS: + g_value_set_boolean ( + value, + e_source_openpgp_get_locate_keys ( + E_SOURCE_OPENPGP (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -303,6 +318,20 @@ e_source_openpgp_class_init (ESourceOpenPGPClass *class) G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS | E_SOURCE_PARAM_SETTING)); + + g_object_class_install_property ( + object_class, + PROP_LOCATE_KEYS, + g_param_spec_boolean ( + "locate-keys", + "Locate Keys", + "Locate keys in WKD for encryption", + TRUE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_EXPLICIT_NOTIFY | + G_PARAM_STATIC_STRINGS | + E_SOURCE_PARAM_SETTING)); } static void @@ -690,3 +719,49 @@ e_source_openpgp_set_prefer_inline (ESourceOpenPGP *extension, g_object_notify (G_OBJECT (extension), "prefer-inline"); } + +/** + * e_source_openpgp_get_locate_keys: + * @extension: an #ESourceOpenPGP + * + * Returns, whether gpg can locate keys using Web Key Directory (WKD) lookup + * when encrypting messages. The default is %TRUE. + * + * Returns: whether gpg can locate keys using Web Key Directory (WKD) lookup + * when encrypting messages. + * + * Since: 3.46 + **/ + +gboolean +e_source_openpgp_get_locate_keys (ESourceOpenPGP *extension) +{ + g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), FALSE); + + return extension->priv->locate_keys; +} + +/** + * e_source_openpgp_set_locate_keys: + * @extension: an #ESourceOpenPGP + * @locate_keys: value to set + * + * Sets the @locate_keys on the @extension, which is used to instruct + * gpg to locate keys using Web Key Directory (WKD) lookup when encrypting + * messages. + * + * Since: 3.46 + **/ +void +e_source_openpgp_set_locate_keys (ESourceOpenPGP *extension, + gboolean locate_keys) +{ + g_return_if_fail (E_IS_SOURCE_OPENPGP (extension)); + + if (!extension->priv->locate_keys == !locate_keys) + return; + + extension->priv->locate_keys = locate_keys; + + g_object_notify (G_OBJECT (extension), "locate-keys"); +} |