[evolution-data-server] Add E_CONTACT_PGP_CERT EContact field



commit e30450db6dc20f0c468d0553704a03065a596df6
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jul 1 16:45:50 2015 +0200

    Add E_CONTACT_PGP_CERT EContact field
    
    A counterpart for E_CONTACT_X509_CERT.

 addressbook/libebook-contacts/e-contact.c    |    1 +
 addressbook/libebook-contacts/e-contact.h    |    1 +
 configure.ac                                 |    2 +-
 tests/libebook-contacts/test-contact-types.c |   57 ++++++++++++++++++++++++++
 4 files changed, 60 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libebook-contacts/e-contact.c b/addressbook/libebook-contacts/e-contact.c
index cfc81ba..5ac55e9 100644
--- a/addressbook/libebook-contacts/e-contact.c
+++ b/addressbook/libebook-contacts/e-contact.c
@@ -294,6 +294,7 @@ static const EContactFieldInfo field_info[] = {
 
        /* Security fields */
        ATTR_TYPE_STRUCT_FIELD (E_CONTACT_X509_CERT,  EVC_KEY, "x509Cert",  N_("X.509 Certificate"), FALSE, 
"X509", cert_getter, cert_setter, e_contact_cert_get_type),
+       ATTR_TYPE_STRUCT_FIELD (E_CONTACT_PGP_CERT,   EVC_KEY, "pgpCert",  N_("PGP Certificate"), FALSE, 
"PGP", cert_getter, cert_setter, e_contact_cert_get_type),
 
        ATTR_TYPE_STR_FIELD (E_CONTACT_IM_GADUGADU_HOME_1,  EVC_X_GADUGADU,  "im_gadugadu_home_1",  
N_("Gadu-Gadu Home ID 1"), FALSE, "HOME", 0),
        ATTR_TYPE_STR_FIELD (E_CONTACT_IM_GADUGADU_HOME_2,  EVC_X_GADUGADU,  "im_gadugadu_home_2",  
N_("Gadu-Gadu Home ID 2"), FALSE, "HOME", 1),
diff --git a/addressbook/libebook-contacts/e-contact.h b/addressbook/libebook-contacts/e-contact.h
index 3406a67..3f1e084 100644
--- a/addressbook/libebook-contacts/e-contact.h
+++ b/addressbook/libebook-contacts/e-contact.h
@@ -214,6 +214,7 @@ typedef enum {
 
        /* Security Fields */
        E_CONTACT_X509_CERT,     /* structured field (EContactCert) */
+       E_CONTACT_PGP_CERT,      /* structured field (EContactCert) */
 
        E_CONTACT_IM_GADUGADU_HOME_1,  /* Synthetic string field */
        E_CONTACT_IM_GADUGADU_HOME_2,  /* Synthetic string field */
diff --git a/configure.ac b/configure.ac
index 0cff292..5beb03d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,7 +130,7 @@ LIBEBOOK_CURRENT=19
 LIBEBOOK_REVISION=1
 LIBEBOOK_AGE=3
 
-LIBEBOOK_CONTACTS_CURRENT=1
+LIBEBOOK_CONTACTS_CURRENT=2
 LIBEBOOK_CONTACTS_REVISION=0
 LIBEBOOK_CONTACTS_AGE=0
 
diff --git a/tests/libebook-contacts/test-contact-types.c b/tests/libebook-contacts/test-contact-types.c
index 606f306..fd12429 100644
--- a/tests/libebook-contacts/test-contact-types.c
+++ b/tests/libebook-contacts/test-contact-types.c
@@ -83,6 +83,57 @@ test_date (TypesFixture *fixture,
        e_contact_date_free (dp);
 }
 
+/************ CERTIFICATES ***************/
+static void
+test_certificates (TypesFixture *fixture,
+                  gconstpointer user_data)
+{
+       const gchar pgp_blob[] = "fake\tpgp-certificate-blob\n\x1\x2\x3\x4\x5\x6\x7\x8\x9\x0 abc";
+       const gchar x509_blob[] = "fake\tX.509-certificate-blob\n\x1\x2\x3\x4\x5\x6\x7\x8\x9\x0 def";
+       gsize pgp_blob_length = sizeof (pgp_blob);
+       gsize x509_blob_length = sizeof (x509_blob);
+       gsize ii;
+       EContactCert *cert;
+
+       cert = e_contact_cert_new ();
+       cert->data = g_memdup (pgp_blob, pgp_blob_length);
+       cert->length = pgp_blob_length;
+       e_contact_set (fixture->contact, E_CONTACT_PGP_CERT, cert);
+       e_contact_cert_free (cert);
+
+       cert = e_contact_cert_new ();
+       cert->data = g_memdup (x509_blob, x509_blob_length);
+       cert->length = x509_blob_length;
+       e_contact_set (fixture->contact, E_CONTACT_X509_CERT, cert);
+       e_contact_cert_free (cert);
+
+       cert = e_contact_get (fixture->contact, E_CONTACT_PGP_CERT);
+       g_assert_nonnull (cert);
+       g_assert_cmpuint (cert->length, ==, pgp_blob_length);
+
+       for (ii = 0; ii < pgp_blob_length; ii++) {
+               if (cert->data[ii] != pgp_blob[ii])
+                       break;
+       }
+
+       g_assert (ii == pgp_blob_length);
+
+       e_contact_cert_free (cert);
+
+       cert = e_contact_get (fixture->contact, E_CONTACT_X509_CERT);
+       g_assert_nonnull (cert);
+       g_assert_cmpuint (cert->length, ==, x509_blob_length);
+
+       for (ii = 0; ii < x509_blob_length; ii++) {
+               if (cert->data[ii] != x509_blob[ii])
+                       break;
+       }
+
+       g_assert (ii == x509_blob_length);
+
+       e_contact_cert_free (cert);
+}
+
 /***************** PHOTO *****************/
 static const gchar *photo_data =
        "/9j/4AAQSkZJRgABAQEARwBHAAD//gAXQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q/9sAQwAIBgYHB"
@@ -210,6 +261,12 @@ main (gint argc,
                test_date,
                types_teardown);
        g_test_add (
+               "/Contact/Types/Certificates",
+               TypesFixture, NULL,
+               types_setup,
+               test_certificates,
+               types_teardown);
+       g_test_add (
                "/Contact/Types/Photo",
                TypesFixture, NULL,
                types_setup,


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