[gmime: 3/23] GMimeCertificate: add User ID



commit 4ec8cead19a03d947c0d51257ee55c1bc5ad3677
Author: Daniel Kahn Gillmor <dkg fifthhorseman net>
Date:   Sun Oct 15 23:46:02 2017 -0400

    GMimeCertificate: add User ID
    
    GPGME reports full User IDs as well as name and e-mail address.  We
    should also be capable of exposing the full User ID, as not every User
    ID will be formed from exactly a name and an E-mail address.  This
    changeset makes it possible to export the User ID from GMime.
    
    Note that this is an API change and an ABI extension, but it's one
    that has no effect on anyone who uses GMime in the standard way (with
    constructors, destructors, and accessor methods, rather than static
    allocation of GMime objects on the stack or direct manipulation of the
    underlying struct).
    
    This API extension is comparable to the addition of
    retrieve_session_key to the GMimeGpgContext last year (in the
    transition from 2.6.20 to 2.6.21), so hopefully it's not considered a
    breaking change.
    
    fixup add user_id to GMimeCertificate

 docs/reference/gmime-sections.txt |    2 ++
 gmime/gmime-certificate.c         |   36 ++++++++++++++++++++++++++++++++++++
 gmime/gmime-certificate.h         |    5 +++++
 tests/test-pgpmime.c              |    1 +
 tests/test-smime.c                |    1 +
 5 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gmime-sections.txt b/docs/reference/gmime-sections.txt
index 4ae47af..76bfd0d 100644
--- a/docs/reference/gmime-sections.txt
+++ b/docs/reference/gmime-sections.txt
@@ -1407,6 +1407,8 @@ g_mime_certificate_get_email
 g_mime_certificate_set_email
 g_mime_certificate_get_name
 g_mime_certificate_set_name
+g_mime_certificate_get_user_id
+g_mime_certificate_set_user_id
 <SUBSECTION>
 GMimeCertificateList
 g_mime_certificate_list_new
diff --git a/gmime/gmime-certificate.c b/gmime/gmime-certificate.c
index 5687174..2f51c39 100644
--- a/gmime/gmime-certificate.c
+++ b/gmime/gmime-certificate.c
@@ -94,6 +94,7 @@ g_mime_certificate_init (GMimeCertificate *cert, GMimeCertificateClass *klass)
        cert->keyid = NULL;
        cert->email = NULL;
        cert->name = NULL;
+       cert->user_id = NULL;
 }
 
 static void
@@ -107,6 +108,7 @@ g_mime_certificate_finalize (GObject *object)
        g_free (cert->keyid);
        g_free (cert->email);
        g_free (cert->name);
+       g_free (cert->user_id);
        
        G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -432,6 +434,40 @@ g_mime_certificate_get_name (GMimeCertificate *cert)
 
 
 /**
+ * g_mime_certificate_set_user_id:
+ * @cert: a #GMimeCertificate
+ * @name: the full User ID for a certificate
+ *
+ * Set the certificate's User ID.
+ **/
+void
+g_mime_certificate_set_user_id (GMimeCertificate *cert, const char *user_id)
+{
+       g_return_if_fail (GMIME_IS_CERTIFICATE (cert));
+       
+       g_free (cert->user_id);
+       cert->user_id = g_strdup (user_id);
+}
+
+
+/**
+ * g_mime_certificate_get_user_id:
+ * @cert: a #GMimeCertificate
+ *
+ * Get the certificate's full User ID.
+ *
+ * Returns: the certificate's User ID or %NULL if unspecified.
+ **/
+const char *
+g_mime_certificate_get_user_id (GMimeCertificate *cert)
+{
+       g_return_val_if_fail (GMIME_IS_CERTIFICATE (cert), NULL);
+       
+       return cert->user_id;
+}
+
+
+/**
  * g_mime_certificate_set_created:
  * @cert: a #GMimeCertificate
  * @created: creation date
diff --git a/gmime/gmime-certificate.h b/gmime/gmime-certificate.h
index 0135de5..1df4444 100644
--- a/gmime/gmime-certificate.h
+++ b/gmime/gmime-certificate.h
@@ -153,6 +153,7 @@ typedef enum {
  * @keyid: The certificate's key id.
  * @email: The email address of the person or entity.
  * @name: The name of the person or entity.
+ * @user_id: The full User ID of the certificate.
  *
  * An object containing useful information about a certificate.
  **/
@@ -170,6 +171,7 @@ struct _GMimeCertificate {
        char *keyid;
        char *email;
        char *name;
+       char *user_id;
 };
 
 struct _GMimeCertificateClass {
@@ -209,6 +211,9 @@ const char *g_mime_certificate_get_email (GMimeCertificate *cert);
 void g_mime_certificate_set_name (GMimeCertificate *cert, const char *name);
 const char *g_mime_certificate_get_name (GMimeCertificate *cert);
 
+void g_mime_certificate_set_user_id (GMimeCertificate *cert, const char *user_id);
+const char *g_mime_certificate_get_user_id (GMimeCertificate *cert);
+
 void g_mime_certificate_set_created (GMimeCertificate *cert, time_t created);
 time_t g_mime_certificate_get_created (GMimeCertificate *cert);
 
diff --git a/tests/test-pgpmime.c b/tests/test-pgpmime.c
index 48fc901..236337b 100644
--- a/tests/test-pgpmime.c
+++ b/tests/test-pgpmime.c
@@ -92,6 +92,7 @@ print_verify_results (GMimeSignatureList *signatures)
                
                fprintf (stdout, "\tName: %s\n", sig->cert->name ? sig->cert->name : "(null)");
                fprintf (stdout, "\tKeyId: %s\n", sig->cert->keyid ? sig->cert->keyid : "(null)");
+               fprintf (stdout, "\tUserID: %s\n", sig->cert->user_id ? sig->cert->user_id : "(null)");
                fprintf (stdout, "\tFingerprint: %s\n", sig->cert->fingerprint ? sig->cert->fingerprint : 
"(null)");
                fprintf (stdout, "\tTrust: ");
                
diff --git a/tests/test-smime.c b/tests/test-smime.c
index 3d87e3a..5f75bc2 100644
--- a/tests/test-smime.c
+++ b/tests/test-smime.c
@@ -94,6 +94,7 @@ print_verify_results (GMimeSignatureList *signatures)
                
                fprintf (stdout, "\tName: %s\n", sig->cert->name ? sig->cert->name : "(null)");
                fprintf (stdout, "\tKeyId: %s\n", sig->cert->keyid ? sig->cert->keyid : "(null)");
+               fprintf (stdout, "\tUserID: %s\n", sig->cert->user_id ? sig->cert->user_id : "(null)");
                fprintf (stdout, "\tFingerprint: %s\n", sig->cert->fingerprint ? sig->cert->fingerprint : 
"(null)");
                fprintf (stdout, "\tTrust: ");
                


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