[gmime] Renamed GMimeCertificateTrust to GMimeTrust and sync'd values with gpgme



commit 5bca3ddef7f79fe3308d9c36a09a14cab33b51b3
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Tue Mar 14 19:00:08 2017 -0400

    Renamed GMimeCertificateTrust to GMimeTrust and sync'd values with gpgme

 PORTING                           |    3 +++
 docs/reference/changes-3.0.sgml   |    1 +
 docs/reference/gmime-sections.txt |    2 +-
 gmime/gmime-certificate.c         |   10 +++++-----
 gmime/gmime-certificate.h         |   36 ++++++++++++++++++------------------
 gmime/gmime-gpgme-utils.c         |   24 ++----------------------
 tests/test-pgpmime.c              |   16 ++++++++--------
 tests/test-smime.c                |   16 ++++++++--------
 8 files changed, 46 insertions(+), 62 deletions(-)
---
diff --git a/PORTING b/PORTING
index bc352bb..ec87014 100644
--- a/PORTING
+++ b/PORTING
@@ -70,6 +70,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 GMimeCertificateTrust to GMimeTrust and GMIME_CERTIFICATE_TRUST_NONE
+  to GMIME_TRUST_UNKNOWN.
+
 - Removed g_mime_gpg_context_[get,set]_always_trust(). This can now be accomplished
   by passing GMIME_ENCRYPT_FLAGS_ALWAYS_TRUST to g_mime_crypto_context_encrypt().
 
diff --git a/docs/reference/changes-3.0.sgml b/docs/reference/changes-3.0.sgml
index 4643a6e..6a24117 100644
--- a/docs/reference/changes-3.0.sgml
+++ b/docs/reference/changes-3.0.sgml
@@ -22,6 +22,7 @@
     </itemizedlist>
     <para>Cryptography related API changes:</para>
     <itemizedlist>
+      <listitem><para>Renamed GMimeCertificateTrust to GMimeTrust and GMIME_CERTIFICATE_TRUST_NONE to 
GMIME_TRUST_UNKNOWN.</para></listitem>
       <listitem><para>Removed <function>g_mime_gpg_context_get_always_trust()</function> and 
<function>g_mime_gpg_context_set_always_trust()</function>. This can now be accomplished by passing 
GMIME_ENCRYPT_FLAGS_ALWAYS_TRUST to <function>g_mime_crypto_context_encrypt()</function>.</para></listitem>
       <listitem><para>Removed <function>g_mime_gpg_context_get_use_agent()</function> and 
<function>g_mime_gpg_context_set_use_agent()</function>. This should no longer be needed.</para></listitem>
       <listitem><para>Removed <function>g_mime_gpg_context_get_auto_key_retrieve()</function> and 
<function>g_mime_gpg_context_set_auto_key_retrieve()</function>.</para></listitem>
diff --git a/docs/reference/gmime-sections.txt b/docs/reference/gmime-sections.txt
index 39847f1..416f1c6 100644
--- a/docs/reference/gmime-sections.txt
+++ b/docs/reference/gmime-sections.txt
@@ -1237,7 +1237,7 @@ g_mime_iconv_locale_to_utf8_length
 <FILE>gmime-certificate</FILE>
 GMimePubKeyAlgo
 GMimeDigestAlgo
-GMimeCertificateTrust
+GMimeTrust
 GMimeCertificate
 g_mime_certificate_new
 g_mime_certificate_get_pubkey_algo
diff --git a/gmime/gmime-certificate.c b/gmime/gmime-certificate.c
index 94d460f..121393f 100644
--- a/gmime/gmime-certificate.c
+++ b/gmime/gmime-certificate.c
@@ -85,7 +85,7 @@ g_mime_certificate_init (GMimeCertificate *cert, GMimeCertificateClass *klass)
 {
        cert->pubkey_algo = GMIME_PUBKEY_ALGO_DEFAULT;
        cert->digest_algo = GMIME_DIGEST_ALGO_DEFAULT;
-       cert->trust = GMIME_CERTIFICATE_TRUST_NONE;
+       cert->trust = GMIME_TRUST_UNKNOWN;
        cert->issuer_serial = NULL;
        cert->issuer_name = NULL;
        cert->fingerprint = NULL;
@@ -129,12 +129,12 @@ g_mime_certificate_new (void)
 /**
  * g_mime_certificate_set_trust:
  * @cert: a #GMimeCertificate
- * @trust: a #GMimeCertificateTrust value
+ * @trust: a #GMimeTrust value
  *
  * Set the certificate trust.
  **/
 void
-g_mime_certificate_set_trust (GMimeCertificate *cert, GMimeCertificateTrust trust)
+g_mime_certificate_set_trust (GMimeCertificate *cert, GMimeTrust trust)
 {
        g_return_if_fail (GMIME_IS_CERTIFICATE (cert));
        
@@ -150,10 +150,10 @@ g_mime_certificate_set_trust (GMimeCertificate *cert, GMimeCertificateTrust trus
  *
  * Returns: the certificate trust.
  **/
-GMimeCertificateTrust
+GMimeTrust
 g_mime_certificate_get_trust (GMimeCertificate *cert)
 {
-       g_return_val_if_fail (GMIME_IS_CERTIFICATE (cert), GMIME_CERTIFICATE_TRUST_NONE);
+       g_return_val_if_fail (GMIME_IS_CERTIFICATE (cert), GMIME_TRUST_UNKNOWN);
        
        return cert->trust;
 }
diff --git a/gmime/gmime-certificate.h b/gmime/gmime-certificate.h
index 86afc24..1b7b558 100644
--- a/gmime/gmime-certificate.h
+++ b/gmime/gmime-certificate.h
@@ -120,24 +120,24 @@ typedef enum {
 } GMimePubKeyAlgo;
 
 /**
- * GMimeCertificateTrust:
- * @GMIME_CERTIFICATE_TRUST_NONE: No trust assigned.
- * @GMIME_CERTIFICATE_TRUST_NEVER: Never trust this certificate.
- * @GMIME_CERTIFICATE_TRUST_UNDEFINED: Undefined trust for this certificate.
- * @GMIME_CERTIFICATE_TRUST_MARGINAL: Trust this certificate maginally.
- * @GMIME_CERTIFICATE_TRUST_FULLY: Trust this certificate fully.
- * @GMIME_CERTIFICATE_TRUST_ULTIMATE: Trust this certificate ultimately.
+ * GMimeTrustLevel:
+ * @GMIME_TRUST_UNKNOWN: The certificate or key is of unknown validity.
+ * @GMIME_TRUST_UNDEFINED: The validity of the certificate or key is undefined.
+ * @GMIME_TRUST_NEVER: The certificate or key should never be treated as valid.
+ * @GMIME_TRUST_MARGINAL: The certificate or key is marginally valid.
+ * @GMIME_TRUST_FULL: The certificate or key is fully valid.
+ * @GMIME_TRUST_ULTIMATE: The certificate or key is ultimately valid.
  *
- * The trust value of a certificate.
+ * The trust level of a certificate or key.
  **/
 typedef enum {
-       GMIME_CERTIFICATE_TRUST_NONE,
-       GMIME_CERTIFICATE_TRUST_NEVER,
-       GMIME_CERTIFICATE_TRUST_UNDEFINED,
-       GMIME_CERTIFICATE_TRUST_MARGINAL,
-       GMIME_CERTIFICATE_TRUST_FULLY,
-       GMIME_CERTIFICATE_TRUST_ULTIMATE
-} GMimeCertificateTrust;
+       GMIME_TRUST_UNKNOWN   = 0,
+       GMIME_TRUST_UNDEFINED = 1,
+       GMIME_TRUST_NEVER     = 2,
+       GMIME_TRUST_MARGINAL  = 3,
+       GMIME_TRUST_FULL      = 4,
+       GMIME_TRUST_ULTIMATE  = 5
+} GMimeTrust;
 
 /**
  * GMimeCertificate:
@@ -161,7 +161,7 @@ struct _GMimeCertificate {
        
        GMimePubKeyAlgo pubkey_algo;
        GMimeDigestAlgo digest_algo;
-       GMimeCertificateTrust trust;
+       GMimeTrust trust;
        char *issuer_serial;
        char *issuer_name;
        char *fingerprint;
@@ -182,8 +182,8 @@ GType g_mime_certificate_get_type (void);
 
 GMimeCertificate *g_mime_certificate_new (void);
 
-void g_mime_certificate_set_trust (GMimeCertificate *cert, GMimeCertificateTrust trust);
-GMimeCertificateTrust g_mime_certificate_get_trust (GMimeCertificate *cert);
+void g_mime_certificate_set_trust (GMimeCertificate *cert, GMimeTrust trust);
+GMimeTrust g_mime_certificate_get_trust (GMimeCertificate *cert);
 
 void g_mime_certificate_set_pubkey_algo (GMimeCertificate *cert, GMimePubKeyAlgo algo);
 GMimePubKeyAlgo g_mime_certificate_get_pubkey_algo (GMimeCertificate *cert);
diff --git a/gmime/gmime-gpgme-utils.c b/gmime/gmime-gpgme-utils.c
index bf03bb8..a9cf380 100644
--- a/gmime/gmime-gpgme-utils.c
+++ b/gmime/gmime-gpgme-utils.c
@@ -244,26 +244,6 @@ g_mime_gpgme_sign (gpgme_ctx_t ctx, gpgme_sig_mode_t mode, const char *userid,
        return (GMimeDigestAlgo) result->signatures->hash_algo;
 }
 
-static GMimeCertificateTrust
-get_trust (gpgme_validity_t trust)
-{
-       switch (trust) {
-       case GPGME_VALIDITY_UNKNOWN:
-       default:
-               return GMIME_CERTIFICATE_TRUST_NONE;
-       case GPGME_VALIDITY_UNDEFINED:
-               return GMIME_CERTIFICATE_TRUST_UNDEFINED;
-       case GPGME_VALIDITY_NEVER:
-               return GMIME_CERTIFICATE_TRUST_NEVER;
-       case GPGME_VALIDITY_MARGINAL:
-               return GMIME_CERTIFICATE_TRUST_MARGINAL;
-       case GPGME_VALIDITY_FULL:
-               return GMIME_CERTIFICATE_TRUST_FULLY;
-       case GPGME_VALIDITY_ULTIMATE:
-               return GMIME_CERTIFICATE_TRUST_ULTIMATE;
-       }
-}
-
 static GMimeSignatureList *
 g_mime_gpgme_get_signatures (gpgme_ctx_t ctx, gboolean verify)
 {
@@ -297,7 +277,7 @@ g_mime_gpgme_get_signatures (gpgme_ctx_t ctx, gboolean verify)
                
                if (gpgme_get_key (ctx, sig->fpr, &key, 0) == GPG_ERR_NO_ERROR && key) {
                        /* get more signer info from their signing key */
-                       g_mime_certificate_set_trust (signature->cert, get_trust (key->owner_trust));
+                       g_mime_certificate_set_trust (signature->cert, (GMimeTrust) key->owner_trust);
                        g_mime_certificate_set_issuer_serial (signature->cert, key->issuer_serial);
                        g_mime_certificate_set_issuer_name (signature->cert, key->issuer_name);
                        
@@ -334,7 +314,7 @@ g_mime_gpgme_get_signatures (gpgme_ctx_t ctx, gboolean verify)
                        /* If we don't have the signer's public key, then we can't tell what
                         * the status is, so set it to ERROR if it hasn't already been
                         * designated as BAD. */
-                       g_mime_certificate_set_trust (signature->cert, GMIME_CERTIFICATE_TRUST_UNDEFINED);
+                       g_mime_certificate_set_trust (signature->cert, GMIME_TRUST_UNDEFINED);
                }
                
                sig = sig->next;
diff --git a/tests/test-pgpmime.c b/tests/test-pgpmime.c
index fbba3c3..f71879a 100644
--- a/tests/test-pgpmime.c
+++ b/tests/test-pgpmime.c
@@ -96,22 +96,22 @@ print_verify_results (GMimeSignatureList *signatures)
                fprintf (stdout, "\tTrust: ");
                
                switch (sig->cert->trust) {
-               case GMIME_CERTIFICATE_TRUST_NONE:
-                       fputs ("None\n", stdout);
+               case GMIME_TRUST_UNKNOWN:
+                       fputs ("Unknown\n", stdout);
                        break;
-               case GMIME_CERTIFICATE_TRUST_NEVER:
+               case GMIME_TRUST_NEVER:
                        fputs ("Never\n", stdout);
                        break;
-               case GMIME_CERTIFICATE_TRUST_UNDEFINED:
+               case GMIME_TRUST_UNDEFINED:
                        fputs ("Undefined\n", stdout);
                        break;
-               case GMIME_CERTIFICATE_TRUST_MARGINAL:
+               case GMIME_TRUST_MARGINAL:
                        fputs ("Marginal\n", stdout);
                        break;
-               case GMIME_CERTIFICATE_TRUST_FULLY:
-                       fputs ("Fully\n", stdout);
+               case GMIME_TRUST_FULL:
+                       fputs ("Full\n", stdout);
                        break;
-               case GMIME_CERTIFICATE_TRUST_ULTIMATE:
+               case GMIME_TRUST_ULTIMATE:
                        fputs ("Ultimate\n", stdout);
                        break;
                }
diff --git a/tests/test-smime.c b/tests/test-smime.c
index aee8d18..22cd3ee 100644
--- a/tests/test-smime.c
+++ b/tests/test-smime.c
@@ -98,22 +98,22 @@ print_verify_results (GMimeSignatureList *signatures)
                fprintf (stdout, "\tTrust: ");
                
                switch (sig->cert->trust) {
-               case GMIME_CERTIFICATE_TRUST_NONE:
-                       fputs ("None\n", stdout);
+               case GMIME_TRUST_UNKNOWN:
+                       fputs ("Unknown\n", stdout);
                        break;
-               case GMIME_CERTIFICATE_TRUST_NEVER:
+               case GMIME_TRUST_NEVER:
                        fputs ("Never\n", stdout);
                        break;
-               case GMIME_CERTIFICATE_TRUST_UNDEFINED:
+               case GMIME_TRUST_UNDEFINED:
                        fputs ("Undefined\n", stdout);
                        break;
-               case GMIME_CERTIFICATE_TRUST_MARGINAL:
+               case GMIME_TRUST_MARGINAL:
                        fputs ("Marginal\n", stdout);
                        break;
-               case GMIME_CERTIFICATE_TRUST_FULLY:
-                       fputs ("Fully\n", stdout);
+               case GMIME_TRUST_FULL:
+                       fputs ("Full\n", stdout);
                        break;
-               case GMIME_CERTIFICATE_TRUST_ULTIMATE:
+               case GMIME_TRUST_ULTIMATE:
                        fputs ("Ultimate\n", stdout);
                        break;
                }


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