[gmime] code cleanup



commit 0d55ee243f7fa524e2ee53b1e5cb5a641bc7560c
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Sun Feb 5 17:50:46 2017 -0500

    code cleanup

 gmime/gmime-crypto-context.c |  224 +++++++++++++++++++++---------------------
 gmime/gmime-crypto-context.h |   29 ++----
 2 files changed, 122 insertions(+), 131 deletions(-)
---
diff --git a/gmime/gmime-crypto-context.c b/gmime/gmime-crypto-context.c
index ede7793..a06a9ef 100644
--- a/gmime/gmime-crypto-context.c
+++ b/gmime/gmime-crypto-context.c
@@ -170,118 +170,6 @@ g_mime_crypto_context_set_request_password (GMimeCryptoContext *ctx, GMimePasswo
 }
 
 
-static gboolean
-crypto_get_retrieve_session_key (GMimeCryptoContext *ctx)
-{
-       return FALSE;
-}
-
-/**
- * g_mime_crypto_context_get_retrieve_session_key:
- * @ctx: a #GMimeCryptoContext
- *
- * Gets whether or not the @ctx is configured to retrieve a session
- * key during decryption (see g_mime_decrypt_result_get_session_key()).
- *
- * Returns: %TRUE if the @ctx is configured to retrieve a session key
- * or %FALSE otherwise.
- **/
-gboolean
-g_mime_crypto_context_get_retrieve_session_key (GMimeCryptoContext *ctx)
-{
-       g_return_val_if_fail (GMIME_IS_CRYPTO_CONTEXT (ctx), FALSE);
-       
-       return GMIME_CRYPTO_CONTEXT_GET_CLASS (ctx)->get_retrieve_session_key (ctx);
-}
-
-static int
-crypto_set_retrieve_session_key (GMimeCryptoContext *ctx, gboolean retrieve_session_key,
-                                GError **err)
-{
-       if (!retrieve_session_key)
-               return 0;
-       
-       g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED,
-                    "Session key retrieval is not supported by this crypto context");
-       
-       return -1;
-}
-
-/**
- * g_mime_crypto_context_set_retrieve_session_key:
- * @ctx: a #GMimeCryptoContext
- * @retrieve_session_key: whether to retrieve session keys during decryption
- * @err: a #GError
- *
- * Configures whether @ctx should produce a session key during future
- * decryption operations (see
- * g_mime_decrypt_result_get_session_key()).
- *
- * Returns: %0 on success or %-1 on fail.
- **/
-int
-g_mime_crypto_context_set_retrieve_session_key (GMimeCryptoContext *ctx,
-                                               gboolean retrieve_session_key,
-                                               GError **err)
-{
-       if (!GMIME_IS_CRYPTO_CONTEXT (ctx)) {
-               g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED,
-                            "Not a GMimeCryptoContext, can't set retrieve_session_key");
-               return -1;
-       }
-       
-       return GMIME_CRYPTO_CONTEXT_GET_CLASS (ctx)->set_retrieve_session_key (ctx, retrieve_session_key, 
err);
-}
-
-
-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)
 {
@@ -712,6 +600,118 @@ g_mime_crypto_context_export_keys (GMimeCryptoContext *ctx, GPtrArray *keys,
 }
 
 
+static gboolean
+crypto_get_retrieve_session_key (GMimeCryptoContext *ctx)
+{
+       return FALSE;
+}
+
+/**
+ * g_mime_crypto_context_get_retrieve_session_key:
+ * @ctx: a #GMimeCryptoContext
+ *
+ * Gets whether or not the @ctx is configured to retrieve a session
+ * key during decryption (see g_mime_decrypt_result_get_session_key()).
+ *
+ * Returns: %TRUE if the @ctx is configured to retrieve a session key
+ * or %FALSE otherwise.
+ **/
+gboolean
+g_mime_crypto_context_get_retrieve_session_key (GMimeCryptoContext *ctx)
+{
+       g_return_val_if_fail (GMIME_IS_CRYPTO_CONTEXT (ctx), FALSE);
+       
+       return GMIME_CRYPTO_CONTEXT_GET_CLASS (ctx)->get_retrieve_session_key (ctx);
+}
+
+static int
+crypto_set_retrieve_session_key (GMimeCryptoContext *ctx, gboolean retrieve_session_key,
+                                GError **err)
+{
+       if (!retrieve_session_key)
+               return 0;
+       
+       g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED,
+                    "Session key retrieval is not supported by this crypto context");
+       
+       return -1;
+}
+
+/**
+ * g_mime_crypto_context_set_retrieve_session_key:
+ * @ctx: a #GMimeCryptoContext
+ * @retrieve_session_key: whether to retrieve session keys during decryption
+ * @err: a #GError
+ *
+ * Configures whether @ctx should produce a session key during future
+ * decryption operations (see
+ * g_mime_decrypt_result_get_session_key()).
+ *
+ * Returns: %0 on success or %-1 on fail.
+ **/
+int
+g_mime_crypto_context_set_retrieve_session_key (GMimeCryptoContext *ctx,
+                                               gboolean retrieve_session_key,
+                                               GError **err)
+{
+       if (!GMIME_IS_CRYPTO_CONTEXT (ctx)) {
+               g_set_error (err, GMIME_ERROR, GMIME_ERROR_NOT_SUPPORTED,
+                            "Not a GMimeCryptoContext, can't set retrieve_session_key");
+               return -1;
+       }
+       
+       return GMIME_CRYPTO_CONTEXT_GET_CLASS (ctx)->set_retrieve_session_key (ctx, retrieve_session_key, 
err);
+}
+
+
+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 void g_mime_decrypt_result_class_init (GMimeDecryptResultClass *klass);
 static void g_mime_decrypt_result_init (GMimeDecryptResult *cert, GMimeDecryptResultClass *klass);
 static void g_mime_decrypt_result_finalize (GObject *object);
diff --git a/gmime/gmime-crypto-context.h b/gmime/gmime-crypto-context.h
index 3c3b802..f1477ce 100644
--- a/gmime/gmime-crypto-context.h
+++ b/gmime/gmime-crypto-context.h
@@ -83,13 +83,10 @@ struct _GMimeCryptoContextClass {
        GObjectClass parent_class;
        
        GMimeDigestAlgo          (* digest_id)   (GMimeCryptoContext *ctx, const char *name);
-       
        const char *             (* digest_name) (GMimeCryptoContext *ctx, GMimeDigestAlgo digest);
        
        const char *             (* get_signature_protocol) (GMimeCryptoContext *ctx);
-       
        const char *             (* get_encryption_protocol) (GMimeCryptoContext *ctx);
-       
        const char *             (* get_key_exchange_protocol) (GMimeCryptoContext *ctx);
        
        int                      (* sign)        (GMimeCryptoContext *ctx, const char *userid,
@@ -107,6 +104,9 @@ struct _GMimeCryptoContextClass {
        
        GMimeDecryptResult *     (* decrypt)     (GMimeCryptoContext *ctx, GMimeStream *istream,
                                                  GMimeStream *ostream, GError **err);
+       GMimeDecryptResult *     (* decrypt_session) (GMimeCryptoContext *ctx, const char *session_key,
+                                                     GMimeStream *istream, GMimeStream *ostream,
+                                                     GError **err);
        
        int                      (* import_keys) (GMimeCryptoContext *ctx, GMimeStream *istream,
                                                  GError **err);
@@ -114,10 +114,6 @@ 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);
-       
        gboolean                 (* get_retrieve_session_key) (GMimeCryptoContext *ctx);
        
        int                      (* set_retrieve_session_key) (GMimeCryptoContext *ctx,
@@ -133,25 +129,13 @@ GType g_mime_crypto_context_get_type (void);
 
 void g_mime_crypto_context_set_request_password (GMimeCryptoContext *ctx, GMimePasswordRequestFunc 
request_passwd);
 
-gboolean g_mime_crypto_context_get_retrieve_session_key (GMimeCryptoContext *ctx);
-
-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);
-
 const char *g_mime_crypto_context_digest_name (GMimeCryptoContext *ctx, GMimeDigestAlgo digest);
 
 /* protocol routines */
 const char *g_mime_crypto_context_get_signature_protocol (GMimeCryptoContext *ctx);
-
 const char *g_mime_crypto_context_get_encryption_protocol (GMimeCryptoContext *ctx);
-
 const char *g_mime_crypto_context_get_key_exchange_protocol (GMimeCryptoContext *ctx);
 
 /* crypto routines */
@@ -181,6 +165,13 @@ int g_mime_crypto_context_import_keys (GMimeCryptoContext *ctx, GMimeStream *ist
 int g_mime_crypto_context_export_keys (GMimeCryptoContext *ctx, GPtrArray *keys,
                                       GMimeStream *ostream, GError **err);
 
+gboolean g_mime_crypto_context_get_retrieve_session_key (GMimeCryptoContext *ctx);
+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);
 
 
 /**


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