[evolution-data-server] Bug 748770 - Add "encrypt-by-default" property to ESourceOpenPGP



commit 8b21c884ee50c13d398a77945962b6710f243995
Author: Milan Crha <mcrha redhat com>
Date:   Tue May 5 16:39:03 2015 +0200

    Bug 748770 - Add "encrypt-by-default" property to ESourceOpenPGP

 libedataserver/e-source-openpgp.c |   73 ++++++++++++++++++++++++++++++++++++-
 libedataserver/e-source-openpgp.h |    5 +++
 2 files changed, 77 insertions(+), 1 deletions(-)
---
diff --git a/libedataserver/e-source-openpgp.c b/libedataserver/e-source-openpgp.c
index cc8569f..91fbddc 100644
--- a/libedataserver/e-source-openpgp.c
+++ b/libedataserver/e-source-openpgp.c
@@ -49,6 +49,7 @@ struct _ESourceOpenPGPPrivate {
        gboolean always_trust;
        gboolean encrypt_to_self;
        gboolean sign_by_default;
+       gboolean encrypt_by_default;
 };
 
 enum {
@@ -57,7 +58,8 @@ enum {
        PROP_ENCRYPT_TO_SELF,
        PROP_KEY_ID,
        PROP_SIGNING_ALGORITHM,
-       PROP_SIGN_BY_DEFAULT
+       PROP_SIGN_BY_DEFAULT,
+       PROP_ENCRYPT_BY_DEFAULT
 };
 
 G_DEFINE_TYPE (
@@ -101,6 +103,12 @@ source_openpgp_set_property (GObject *object,
                                E_SOURCE_OPENPGP (object),
                                g_value_get_boolean (value));
                        return;
+
+               case PROP_ENCRYPT_BY_DEFAULT:
+                       e_source_openpgp_set_encrypt_by_default (
+                               E_SOURCE_OPENPGP (object),
+                               g_value_get_boolean (value));
+                       return;
        }
 
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -147,6 +155,13 @@ source_openpgp_get_property (GObject *object,
                                e_source_openpgp_get_sign_by_default (
                                E_SOURCE_OPENPGP (object)));
                        return;
+
+               case PROP_ENCRYPT_BY_DEFAULT:
+                       g_value_set_boolean (
+                               value,
+                               e_source_openpgp_get_encrypt_by_default (
+                               E_SOURCE_OPENPGP (object)));
+                       return;
        }
 
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -246,6 +261,19 @@ e_source_openpgp_class_init (ESourceOpenPGPClass *class)
                        G_PARAM_CONSTRUCT |
                        G_PARAM_STATIC_STRINGS |
                        E_SOURCE_PARAM_SETTING));
+
+       g_object_class_install_property (
+               object_class,
+               PROP_ENCRYPT_BY_DEFAULT,
+               g_param_spec_boolean (
+                       "encrypt-by-default",
+                       "Encrypt By Default",
+                       "Encrypt outgoing messages by default",
+                       FALSE,
+                       G_PARAM_READWRITE |
+                       G_PARAM_CONSTRUCT |
+                       G_PARAM_STATIC_STRINGS |
+                       E_SOURCE_PARAM_SETTING));
 }
 
 static void
@@ -550,3 +578,46 @@ e_source_openpgp_set_sign_by_default (ESourceOpenPGP *extension,
        g_object_notify (G_OBJECT (extension), "sign-by-default");
 }
 
+/**
+ * e_source_openpgp_get_encrypt_by_default:
+ * @extension: an #ESourceOpenPGP
+ *
+ * Returns whether to digitally encrypt outgoing messages by default using
+ * OpenPGP-compliant software such as GNU Privacy Guard (GnuPG).
+ *
+ * Returns: whether to encrypt outgoing messages by default
+ *
+ * Since: 3.18
+ **/
+gboolean
+e_source_openpgp_get_encrypt_by_default (ESourceOpenPGP *extension)
+{
+       g_return_val_if_fail (E_IS_SOURCE_OPENPGP (extension), FALSE);
+
+       return extension->priv->encrypt_by_default;
+}
+
+/**
+ * e_source_openpgp_set_encrypt_by_default:
+ * @extension: an #ESourceOpenPGP
+ * @encrypt_by_default: whether to encrypt outgoing messages by default
+ *
+ * Sets whether to digitally encrypt outgoing messages by default using
+ * OpenPGP-compliant software such as GNU Privacy Guard (GnuPG).
+ *
+ * Since: 3.18
+ **/
+void
+e_source_openpgp_set_encrypt_by_default (ESourceOpenPGP *extension,
+                                         gboolean encrypt_by_default)
+{
+       g_return_if_fail (E_IS_SOURCE_OPENPGP (extension));
+
+       if (extension->priv->encrypt_by_default == encrypt_by_default)
+               return;
+
+       extension->priv->encrypt_by_default = encrypt_by_default;
+
+       g_object_notify (G_OBJECT (extension), "encrypt-by-default");
+}
+
diff --git a/libedataserver/e-source-openpgp.h b/libedataserver/e-source-openpgp.h
index 3298c87..0660862 100644
--- a/libedataserver/e-source-openpgp.h
+++ b/libedataserver/e-source-openpgp.h
@@ -103,6 +103,11 @@ gboolean   e_source_openpgp_get_sign_by_default
 void           e_source_openpgp_set_sign_by_default
                                                (ESourceOpenPGP *extension,
                                                 gboolean sign_by_default);
+gboolean       e_source_openpgp_get_encrypt_by_default
+                                               (ESourceOpenPGP *extension);
+void           e_source_openpgp_set_encrypt_by_default
+                                               (ESourceOpenPGP *extension,
+                                                gboolean encrypt_by_default);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]