[gmime] Moved get/set_always_trust to GMimeCryptoContext



commit 34771f58fd2340c46b63c193b367fa86d376b3c4
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Sun Feb 5 17:29:38 2017 -0500

    Moved get/set_always_trust to GMimeCryptoContext

 PORTING                      |    3 +
 gmime/GMime-2.6.metadata     |   27 ---------
 gmime/gmime-crypto-context.c |   57 +++++++++++++++++-
 gmime/gmime-crypto-context.h |   12 +++-
 gmime/gmime-gpg-context.c    |  133 +++++++++++++++++++++---------------------
 gmime/gmime-gpg-context.h    |   31 ----------
 6 files changed, 132 insertions(+), 131 deletions(-)
---
diff --git a/PORTING b/PORTING
index a413bc5..dcdee3f 100644
--- a/PORTING
+++ b/PORTING
@@ -47,6 +47,9 @@ Porting from GMime 2.6 to GMime 3.0
 - g_mime_stream_write_to_stream(), g_mime_stream_writev(), and g_mime_stream_printf()
   now return a gint64.
 
+- Renamed g_mime_gpg_context_[get,set]_always_trust() to
+  g_mime_crypto_context_[get,set]_always_trust().
+
 
 Porting from GMime 2.4 to GMime 2.6
 -----------------------------------
diff --git a/gmime/gmime-crypto-context.c b/gmime/gmime-crypto-context.c
index 5ed2edb..ede7793 100644
--- a/gmime/gmime-crypto-context.c
+++ b/gmime/gmime-crypto-context.c
@@ -49,15 +49,15 @@ static GMimeDigestAlgo crypto_digest_id (GMimeCryptoContext *ctx, const char *na
 static const char *crypto_digest_name (GMimeCryptoContext *ctx, GMimeDigestAlgo );
 
 static const char *crypto_get_signature_protocol (GMimeCryptoContext *ctx);
-
 static const char *crypto_get_encryption_protocol (GMimeCryptoContext *ctx);
-
 static const char *crypto_get_key_exchange_protocol (GMimeCryptoContext *ctx);
 
-static int crypto_set_retrieve_session_key (GMimeCryptoContext *ctx, gboolean retrieve_session_key,
-                                           GError **err);
+static int crypto_set_retrieve_session_key (GMimeCryptoContext *ctx, gboolean retrieve_session_key, GError 
**err);
 static gboolean crypto_get_retrieve_session_key (GMimeCryptoContext *ctx);
 
+static void crypto_set_always_trust (GMimeCryptoContext *ctx, gboolean always_trust);
+static gboolean crypto_get_always_trust (GMimeCryptoContext *ctx);
+
 static int crypto_sign (GMimeCryptoContext *ctx, const char *userid,
                        GMimeDigestAlgo digest, GMimeStream *istream,
                        GMimeStream *ostream, GError **err);
@@ -136,6 +136,8 @@ g_mime_crypto_context_class_init (GMimeCryptoContextClass *klass)
        klass->get_key_exchange_protocol = crypto_get_key_exchange_protocol;
        klass->get_retrieve_session_key = crypto_get_retrieve_session_key;
        klass->set_retrieve_session_key = crypto_set_retrieve_session_key;
+       klass->get_always_trust = crypto_get_always_trust;
+       klass->set_always_trust = crypto_set_always_trust;
 }
 
 static void
@@ -232,6 +234,53 @@ g_mime_crypto_context_set_retrieve_session_key (GMimeCryptoContext *ctx,
 }
 
 
+static gboolean
+crypto_get_always_trust (GMimeCryptoContext *ctx)
+{
+       return FALSE;
+}
+
+
+/**
+ * g_mime_crypto_context_get_always_trust:
+ * @ctx: a #GMimeCryptoContext
+ *
+ * Gets whther or not keys should always be trusted when encrypting.
+ *
+ * Returns: %TRUE if keys should always be trusted when encrypting or
+ * %FALSE otherwise.
+ **/
+gboolean
+g_mime_crypto_context_get_always_trust (GMimeCryptoContext *ctx)
+{
+       g_return_val_if_fail (GMIME_IS_CRYPTO_CONTEXT (ctx), FALSE);
+       
+       return GMIME_CRYPTO_CONTEXT_GET_CLASS (ctx)->get_always_trust (ctx);
+}
+
+
+static void
+crypto_set_always_trust (GMimeCryptoContext *ctx, gboolean always_trust)
+{
+}
+
+
+/**
+ * g_mime_crypto_context_set_always_trust:
+ * @ctx: a #GMimeCryptoContext
+ * @always_trust: %TRUE if keys should always be trusted when encrypting
+ *
+ * Sets whether or not key should always be trusted when encrypting.
+ **/
+void
+g_mime_crypto_context_set_always_trust (GMimeCryptoContext *ctx, gboolean always_trust)
+{
+       g_return_if_fail (GMIME_IS_CRYPTO_CONTEXT (ctx));
+       
+       GMIME_CRYPTO_CONTEXT_GET_CLASS (ctx)->set_always_trust (ctx, always_trust);
+}
+
+
 
 static GMimeDigestAlgo
 crypto_digest_id (GMimeCryptoContext *ctx, const char *name)
diff --git a/gmime/gmime-crypto-context.h b/gmime/gmime-crypto-context.h
index 632d62e..3c3b802 100644
--- a/gmime/gmime-crypto-context.h
+++ b/gmime/gmime-crypto-context.h
@@ -114,15 +114,18 @@ struct _GMimeCryptoContextClass {
        int                      (* export_keys) (GMimeCryptoContext *ctx, GPtrArray *keys,
                                                  GMimeStream *ostream, GError **err);
        
-       GMimeDecryptResult *     (* decrypt_session)     (GMimeCryptoContext *ctx, const char *session_key,
-                                                         GMimeStream *istream, GMimeStream *ostream,
-                                                         GError **err);
+       GMimeDecryptResult *     (* decrypt_session) (GMimeCryptoContext *ctx, const char *session_key,
+                                                     GMimeStream *istream, GMimeStream *ostream,
+                                                     GError **err);
        
        gboolean                 (* get_retrieve_session_key) (GMimeCryptoContext *ctx);
        
        int                      (* set_retrieve_session_key) (GMimeCryptoContext *ctx,
                                                               gboolean retrieve_session_key,
                                                               GError **err);
+
+       gboolean                 (* get_always_trust) (GMimeCryptoContext *ctx);
+       void                     (* set_always_trust) (GMimeCryptoContext *ctx, gboolean always_trust);
 };
 
 
@@ -136,6 +139,9 @@ int g_mime_crypto_context_set_retrieve_session_key (GMimeCryptoContext *ctx,
                                                    gboolean retrieve_session_key,
                                                    GError **err);
 
+gboolean g_mime_crypto_context_get_always_trust (GMimeCryptoContext *ctx);
+void g_mime_crypto_context_set_always_trust (GMimeCryptoContext *ctx, gboolean always_trust);
+
 /* digest algo mapping */
 GMimeDigestAlgo g_mime_crypto_context_digest_id (GMimeCryptoContext *ctx, const char *name);
 
diff --git a/gmime/gmime-gpg-context.c b/gmime/gmime-gpg-context.c
index b77bb2c..9f5b026 100644
--- a/gmime/gmime-gpg-context.c
+++ b/gmime/gmime-gpg-context.c
@@ -78,27 +78,52 @@ typedef unsigned int nfds_t;
  **/
 
 
+/**
+ * GMimeGpgContext:
+ * @parent_object: parent #GMimeCryptoContext
+ * @auto_key_retrieve: %TRUE if gpg should automatically retrieve unknown keys from the web
+ * @use_agent: %TRUE if gpg should use the gpg-agent for requesting passphrases
+ * @path: path to gpg
+ * @version: The GnuPG version.
+ *
+ * A GnuPG crypto context.
+ **/
+struct _GMimeGpgContext {
+       GMimeCryptoContext parent_object;
+       gboolean retrieve_session_key;
+       gboolean auto_key_retrieve;
+       gboolean always_trust;
+       gboolean use_agent;
+       int version;
+       char *path;
+};
+
+struct _GMimeGpgContextClass {
+       GMimeCryptoContextClass parent_class;
+       
+};
+
+
 static void g_mime_gpg_context_class_init (GMimeGpgContextClass *klass);
 static void g_mime_gpg_context_init (GMimeGpgContext *ctx, GMimeGpgContextClass *klass);
 static void g_mime_gpg_context_finalize (GObject *object);
 
 static GMimeDigestAlgo gpg_digest_id (GMimeCryptoContext *ctx, const char *name);
-
 static const char *gpg_digest_name (GMimeCryptoContext *ctx, GMimeDigestAlgo digest);
 
 static gboolean gpg_get_retrieve_session_key (GMimeCryptoContext *context);
-
 static int gpg_set_retrieve_session_key (GMimeCryptoContext *ctx, gboolean retrieve_session_key,
                                         GError **err);
 
+static gboolean gpg_get_always_trust (GMimeCryptoContext *context);
+static void gpg_set_always_trust (GMimeCryptoContext *ctx, gboolean always_trust);
+
 static int gpg_sign (GMimeCryptoContext *ctx, const char *userid,
                     GMimeDigestAlgo digest, GMimeStream *istream,
                     GMimeStream *ostream, GError **err);
 
 static const char *gpg_get_signature_protocol (GMimeCryptoContext *ctx);
-
 static const char *gpg_get_encryption_protocol (GMimeCryptoContext *ctx);
-
 static const char *gpg_get_key_exchange_protocol (GMimeCryptoContext *ctx);
 
 static GMimeSignatureList *gpg_verify (GMimeCryptoContext *ctx, GMimeDigestAlgo digest,
@@ -175,6 +200,8 @@ g_mime_gpg_context_class_init (GMimeGpgContextClass *klass)
        crypto_class->get_key_exchange_protocol = gpg_get_key_exchange_protocol;
        crypto_class->get_retrieve_session_key = gpg_get_retrieve_session_key;
        crypto_class->set_retrieve_session_key = gpg_set_retrieve_session_key;
+       crypto_class->get_always_trust = gpg_get_always_trust;
+       crypto_class->set_always_trust = gpg_set_always_trust;
 }
 
 static void
@@ -2295,6 +2322,42 @@ gpg_export_keys (GMimeCryptoContext *context, GPtrArray *keys, GMimeStream *ostr
 #endif /* ENABLE_CRYPTO */
 }
 
+static gboolean
+gpg_get_retrieve_session_key (GMimeCryptoContext *context)
+{
+       GMimeGpgContext *ctx = (GMimeGpgContext *) context;
+       
+       return ctx->retrieve_session_key;
+}
+
+
+static int
+gpg_set_retrieve_session_key (GMimeCryptoContext *context, gboolean retrieve_session_key, GError **err)
+{
+       GMimeGpgContext *ctx = (GMimeGpgContext *) context;
+       
+       ctx->retrieve_session_key = retrieve_session_key;
+       
+       return 0;
+}
+
+static gboolean
+gpg_get_always_trust (GMimeCryptoContext *context)
+{
+       GMimeGpgContext *ctx = (GMimeGpgContext *) context;
+       
+       return ctx->always_trust;
+}
+
+static void
+gpg_set_always_trust (GMimeCryptoContext *context, gboolean always_trust)
+{
+       GMimeGpgContext *ctx = (GMimeGpgContext *) context;
+       
+       ctx->always_trust = always_trust;
+}
+
+
 int
 _g_mime_get_gpg_version (const char *path)
 {
@@ -2415,40 +2478,6 @@ g_mime_gpg_context_set_auto_key_retrieve (GMimeGpgContext *ctx, gboolean auto_ke
 
 
 /**
- * g_mime_gpg_context_get_always_trust:
- * @ctx: a #GMimeGpgContext
- *
- * Gets whther or not gpg should always trust keys when encrypting.
- *
- * Returns: %TRUE if gpg should always trust keys when encrypting or
- * %FALSE otherwise.
- **/
-gboolean
-g_mime_gpg_context_get_always_trust (GMimeGpgContext *ctx)
-{
-       g_return_val_if_fail (GMIME_IS_GPG_CONTEXT (ctx), FALSE);
-       
-       return ctx->always_trust;
-}
-
-
-/**
- * g_mime_gpg_context_set_always_trust:
- * @ctx: a #GMimeGpgContext
- * @always_trust: %TRUE if gpg should always trust keys when encrypting
- *
- * Sets whether or not gpg should always trust keys when encrypting.
- **/
-void
-g_mime_gpg_context_set_always_trust (GMimeGpgContext *ctx, gboolean always_trust)
-{
-       g_return_if_fail (GMIME_IS_GPG_CONTEXT (ctx));
-       
-       ctx->always_trust = always_trust;
-}
-
-
-/**
  * g_mime_gpg_context_get_use_agent:
  * @ctx: a #GMimeGpgContext
  *
@@ -2482,31 +2511,3 @@ g_mime_gpg_context_set_use_agent (GMimeGpgContext *ctx, gboolean use_agent)
        
        ctx->use_agent = use_agent;
 }
-
-static gboolean
-gpg_get_retrieve_session_key (GMimeCryptoContext *context)
-{
-       GMimeGpgContext *ctx = (GMimeGpgContext *) context;
-       
-       g_return_val_if_fail (GMIME_IS_GPG_CONTEXT (ctx), FALSE);
-       
-       return ctx->retrieve_session_key;
-}
-
-
-static int
-gpg_set_retrieve_session_key (GMimeCryptoContext *context, gboolean retrieve_session_key,
-                             GError **err)
-{
-       GMimeGpgContext *ctx = (GMimeGpgContext *) context;
-       
-       if (!GMIME_IS_GPG_CONTEXT (ctx)) {
-               g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED,
-                            "Not a GMimeGpgContext, can't set retrieve_session_key");
-               return -1;
-       }
-       
-       ctx->retrieve_session_key = retrieve_session_key;
-       
-       return 0;
-}
diff --git a/gmime/gmime-gpg-context.h b/gmime/gmime-gpg-context.h
index 658943d..9ccc076 100644
--- a/gmime/gmime-gpg-context.h
+++ b/gmime/gmime-gpg-context.h
@@ -37,34 +37,6 @@ typedef struct _GMimeGpgContext GMimeGpgContext;
 typedef struct _GMimeGpgContextClass GMimeGpgContextClass;
 
 
-/**
- * GMimeGpgContext:
- * @parent_object: parent #GMimeCryptoContext
- * @auto_key_retrieve: %TRUE if gpg should automatically retrieve unknown keys from the web
- * @always_trust: %TRUE if keys should always be trusted
- * @use_agent: %TRUE if gpg should use the gpg-agent for requesting passphrases
- * @path: path to gpg
- * @retrieve_session_key: %TRUE if session keys should be retrieved when decrypting
- * @version: The GnuPG version.
- *
- * A GnuPG crypto context.
- **/
-struct _GMimeGpgContext {
-       GMimeCryptoContext parent_object;
-       gboolean retrieve_session_key;
-       gboolean auto_key_retrieve;
-       gboolean always_trust;
-       gboolean use_agent;
-       int version;
-       char *path;
-};
-
-struct _GMimeGpgContextClass {
-       GMimeCryptoContextClass parent_class;
-       
-};
-
-
 GType g_mime_gpg_context_get_type (void);
 
 
@@ -73,9 +45,6 @@ GMimeCryptoContext *g_mime_gpg_context_new (GMimePasswordRequestFunc request_pas
 gboolean g_mime_gpg_context_get_auto_key_retrieve (GMimeGpgContext *ctx);
 void g_mime_gpg_context_set_auto_key_retrieve (GMimeGpgContext *ctx, gboolean auto_key_retrieve);
 
-gboolean g_mime_gpg_context_get_always_trust (GMimeGpgContext *ctx);
-void g_mime_gpg_context_set_always_trust (GMimeGpgContext *ctx, gboolean always_trust);
-
 gboolean g_mime_gpg_context_get_use_agent (GMimeGpgContext *ctx);
 void g_mime_gpg_context_set_use_agent (GMimeGpgContext *ctx, gboolean use_agent);
 


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