summaryrefslogtreecommitdiff
path: root/addressbook
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2003-12-19 23:00:13 +0000
committerChris Toshok <toshok@src.gnome.org>2003-12-19 23:00:13 +0000
commitd70c46cf35211bb4e6f0b122a1297024932b765c (patch)
tree16b967bb2dbf0ea049fb899703eb1d7a75be03b3 /addressbook
parentfef14acd8bfaaaa1acac6f3cc3034391969f7f17 (diff)
downloadevolution-data-server-d70c46cf35211bb4e6f0b122a1297024932b765c.tar.gz
add lots more #defines, some EVC_X ones for attribute TYPE's, as well as
2003-12-19 Chris Toshok <toshok@ximian.com> * libebook/e-vcard.h: add lots more #defines, some EVC_X ones for attribute TYPE's, as well as the vcard specified "KEY" attribute. * libedata-book/e-book-backend.c (e_book_backend_remove_client): reorder some code so we hold the lock up until we're done with backend->priv->clients. * backends/ldap/e-book-backend-ldap.c (prop_info): add an entry for E_CONTACT_X509_CERT, and map it to the userCertificate ldap attribute. not sure if this is strictly correct... the inetOrgPerson schema mentions using userSMIMECertificate (which contains the full certificate chain in pkcs#7 form) in favor of userCertificate for S/MIME applications. * libebook/e-contact.h: add the CERT field types, the EContactCert struct type, and prototypes for e_contact_cert_get_type and e_contact_cert_free. * libebook/e-contact.c (field_info): add E_CONTACT_X509_CERT (cert_getter, cert_setter): new functions, implement getting/setting of certs. (e_contact_cert_free): new function. (e_contact_cert_copy): same. (e_contact_cert_get_type): same.
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog27
-rw-r--r--addressbook/backends/ldap/e-book-backend-ldap.c23
-rw-r--r--addressbook/libebook/e-contact.c90
-rw-r--r--addressbook/libebook/e-contact.h11
-rw-r--r--addressbook/libebook/e-vcard.h8
-rw-r--r--addressbook/libedata-book/e-book-backend.c7
6 files changed, 151 insertions, 15 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 8c7a01853..901554061 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,30 @@
+2003-12-19 Chris Toshok <toshok@ximian.com>
+
+ * libebook/e-vcard.h: add lots more #defines, some EVC_X ones for
+ attribute TYPE's, as well as the vcard specified "KEY" attribute.
+
+ * libedata-book/e-book-backend.c (e_book_backend_remove_client):
+ reorder some code so we hold the lock up until we're done with
+ backend->priv->clients.
+
+ * backends/ldap/e-book-backend-ldap.c (prop_info): add an entry
+ for E_CONTACT_X509_CERT, and map it to the userCertificate ldap
+ attribute. not sure if this is strictly correct... the
+ inetOrgPerson schema mentions using userSMIMECertificate (which
+ contains the full certificate chain in pkcs#7 form) in favor of
+ userCertificate for S/MIME applications.
+
+ * libebook/e-contact.h: add the CERT field types, the EContactCert
+ struct type, and prototypes for e_contact_cert_get_type and
+ e_contact_cert_free.
+
+ * libebook/e-contact.c (field_info): add E_CONTACT_X509_CERT
+ (cert_getter, cert_setter): new functions, implement
+ getting/setting of certs.
+ (e_contact_cert_free): new function.
+ (e_contact_cert_copy): same.
+ (e_contact_cert_get_type): same.
+
2003-12-17 Chris Toshok <toshok@ximian.com>
* libebook/e-book-async.c (_get_book_view_response_dtor): if
diff --git a/addressbook/backends/ldap/e-book-backend-ldap.c b/addressbook/backends/ldap/e-book-backend-ldap.c
index 01dbbe117..740472044 100644
--- a/addressbook/backends/ldap/e-book-backend-ldap.c
+++ b/addressbook/backends/ldap/e-book-backend-ldap.c
@@ -181,6 +181,8 @@ static gboolean category_compare (EContact *contact1, EContact *contact2);
static void photo_populate (EContact *contact, struct berval **ber_values);
+static void cert_populate (EContact *contact, struct berval **ber_values);
+
struct prop_info {
EContactField field_id;
char *ldap_attr;
@@ -256,6 +258,15 @@ struct prop_info {
/* photos */
BINARY_PROP (E_CONTACT_PHOTO, "jpegPhoto", photo_populate, NULL/*XXX*/, NULL/*XXX*/),
+ /* certificate foo. */
+ BINARY_PROP (E_CONTACT_X509_CERT, "userCertificate", cert_populate, NULL/*XXX*/, NULL/*XXX*/),
+#if 0
+ /* hm, which do we use? the inetOrgPerson schema says that
+ userSMIMECertificate should be used in favor of
+ userCertificate for S/MIME applications. */
+ BINARY_PROP (E_CONTACT_X509_CERT, "userSMIMECertificate", cert_populate, NULL/*XXX*/, NULL/*XXX*/),
+#endif
+
/* misc fields */
STRING_PROP (E_CONTACT_HOMEPAGE_URL, "labeledURI"),
/* map nickname to displayName */
@@ -2169,6 +2180,18 @@ photo_populate (EContact *contact, struct berval **ber_values)
}
}
+static void
+cert_populate (EContact *contact, struct berval **ber_values)
+{
+ if (ber_values && ber_values[0]) {
+ EContactCert cert;
+ cert.data = ber_values[0]->bv_val;
+ cert.length = ber_values[0]->bv_len;
+
+ e_contact_set (contact, E_CONTACT_X509_CERT, &cert);
+ }
+}
+
typedef struct {
GList *list;
EBookBackendLDAP *bl;
diff --git a/addressbook/libebook/e-contact.c b/addressbook/libebook/e-contact.c
index 021483d83..82e814782 100644
--- a/addressbook/libebook/e-contact.c
+++ b/addressbook/libebook/e-contact.c
@@ -76,6 +76,8 @@ static void* adr_getter (EContact *contact, EVCardAttribute *attr);
static void adr_setter (EContact *contact, EVCardAttribute *attr, void *data);
static void* date_getter (EContact *contact, EVCardAttribute *attr);
static void date_setter (EContact *contact, EVCardAttribute *attr, void *data);
+static void* cert_getter (EContact *contact, EVCardAttribute *attr);
+static void cert_setter (EContact *contact, EVCardAttribute *attr, void *data);
#define STRING_FIELD(id,vc,n,pn,ro) { E_CONTACT_FIELD_TYPE_STRING, (id), (vc), (n), (pn), (ro) }
#define BOOLEAN_FIELD(id,vc,n,pn,ro) { E_CONTACT_FIELD_TYPE_BOOLEAN, (id), (vc), (n), (pn), (ro) }
@@ -87,6 +89,7 @@ static void date_setter (EContact *contact, EVCardAttribute *attr, void *data);
#define LIST_ELEM_STR_FIELD(id,vc,n,pn,ro,nm) { E_CONTACT_FIELD_TYPE_LIST_ELEM | E_CONTACT_FIELD_TYPE_SYNTHETIC | E_CONTACT_FIELD_TYPE_STRING, (id), (vc), (n), (pn), (ro), (nm) }
#define MULTI_ELEM_STR_FIELD(id,vc,n,pn,ro,nm) { E_CONTACT_FIELD_TYPE_MULTI_ELEM | E_CONTACT_FIELD_TYPE_SYNTHETIC | E_CONTACT_FIELD_TYPE_STRING, (id), (vc), (n), (pn), (ro), (nm) }
#define ATTR_TYPE_STR_FIELD(id,vc,n,pn,ro,at1,nth) { E_CONTACT_FIELD_TYPE_ATTR_TYPE | E_CONTACT_FIELD_TYPE_SYNTHETIC | E_CONTACT_FIELD_TYPE_STRING, (id), (vc), (n), (pn), (ro), (nth), (at1), NULL }
+#define ATTR_TYPE_GETSET_FIELD(id,vc,n,pn,ro,at1,nth,get,set) { E_CONTACT_FIELD_TYPE_ATTR_TYPE | E_CONTACT_FIELD_TYPE_GETSET, (id), (vc), (n), (pn), (ro), (nth), (at1), NULL, (get), (set) }
#define ATTR2_TYPE_STR_FIELD(id,vc,n,pn,ro,at1,at2,nth) { E_CONTACT_FIELD_TYPE_ATTR_TYPE | E_CONTACT_FIELD_TYPE_SYNTHETIC | E_CONTACT_FIELD_TYPE_STRING, (id), (vc), (n), (pn), (ro), (nth), (at1), (at2) }
#define ATTR_TYPE_STRUCT_FIELD(id,vc,n,pn,ro,at,get,set,ty) { E_CONTACT_FIELD_TYPE_ATTR_TYPE | E_CONTACT_FIELD_TYPE_SYNTHETIC | E_CONTACT_FIELD_TYPE_GETSET | E_CONTACT_FIELD_TYPE_STRUCT, (id), (vc), (n), (pn), (ro), 0, (at), NULL, (get), (set), (ty) }
@@ -115,11 +118,11 @@ static EContactFieldInfo field_info[] = {
ATTR_TYPE_STR_FIELD (E_CONTACT_ADDRESS_LABEL_WORK, EVC_LABEL, "address_label_work", N_("Work Address Label"), FALSE, "WORK", 0),
ATTR_TYPE_STR_FIELD (E_CONTACT_ADDRESS_LABEL_OTHER, EVC_LABEL, "address_label_other", N_("Other Address Label"), FALSE, "OTHER", 0),
- ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_ASSISTANT, EVC_TEL, "assistant_phone", N_("Assistant Phone"), FALSE, "X-EVOLUTION-ASSISTANT", 0),
+ ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_ASSISTANT, EVC_TEL, "assistant_phone", N_("Assistant Phone"), FALSE, EVC_X_ASSISTANT, 0),
ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_BUSINESS, EVC_TEL, "business_phone", N_("Business Phone"), FALSE, "WORK", "VOICE", 0),
ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_BUSINESS_2, EVC_TEL, "business_phone_2", N_("Business Phone 2"), FALSE, "WORK", "VOICE", 1),
ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_BUSINESS_FAX, EVC_TEL, "business_fax", N_("Business Fax"), FALSE, "WORK", "FAX", 0),
- ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_CALLBACK, EVC_TEL, "callback_phone", N_("Callback Phone"), FALSE, "X-EVOLUTION-CALLBACK", 0),
+ ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_CALLBACK, EVC_TEL, "callback_phone", N_("Callback Phone"), FALSE, EVC_X_CALLBACK, 0),
ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_CAR, EVC_TEL, "car_phone", N_("Car Phone"), FALSE, "CAR", 0),
ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_COMPANY, EVC_TEL, "company_phone", N_("Company Phone"), FALSE, "WORK", "VOICE", 2),
ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_HOME, EVC_TEL, "home_phone", N_("Home Phone"), FALSE, "HOME", "VOICE", 0),
@@ -131,9 +134,9 @@ static EContactFieldInfo field_info[] = {
ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_OTHER_FAX, EVC_TEL, "other_fax", N_("Other Fax"), FALSE, "FAX", 0), /* XXX */
ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_PAGER, EVC_TEL, "pager", N_("Pager"), FALSE, "PAGER", 0),
ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_PRIMARY, EVC_TEL, "primary_phone", N_("Primary Phone"), FALSE, "PREF", 0),
- ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_RADIO, EVC_TEL, "radio", N_("Radio"), FALSE, "X-EVOLUTION-RADIO", 0),
- ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_TELEX, EVC_TEL, "telex", N_("Telex"), FALSE, "X-EVOLUTION-TELEX", 0),
- ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_TTYTDD, EVC_TEL, "tty", N_("TTY"), FALSE, "X-EVOLUTION-TTYTDD", 0),
+ ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_RADIO, EVC_TEL, "radio", N_("Radio"), FALSE, EVC_X_RADIO, 0),
+ ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_TELEX, EVC_TEL, "telex", N_("Telex"), FALSE, EVC_X_TELEX, 0),
+ ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_TTYTDD, EVC_TEL, "tty", N_("TTY"), FALSE, EVC_X_TTYTDD, 0),
/* Email fields */
MULTI_LIST_FIELD (E_CONTACT_EMAIL, EVC_EMAIL, "email", N_("Email List"), FALSE),
@@ -168,6 +171,9 @@ static EContactFieldInfo field_info[] = {
STRUCT_FIELD (E_CONTACT_PHOTO, EVC_PHOTO, "photo", N_("Photo"), FALSE, photo_getter, photo_setter, e_contact_photo_get_type),
STRUCT_FIELD (E_CONTACT_LOGO, EVC_LOGO, "logo", N_("Logo"), FALSE, photo_getter, photo_setter, e_contact_photo_get_type),
+ /* 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),
+
/* Contact categories */
#if notyet
LIST_FIELD (E_CONTACT_CATEGORY_LIST, EVC_CATEGORIES, "category_list", N_("Category List"), FALSE),
@@ -370,7 +376,6 @@ photo_setter (EContact *contact, EVCardAttribute *attr, void *data)
e_vcard_attribute_param_new (EVC_TYPE),
image_type);
- printf ("adding photo of type `%s' of length %d\n", image_type, photo->length);
e_vcard_attribute_add_value_decoded (attr, photo->data, photo->length);
}
@@ -523,6 +528,46 @@ date_setter (EContact *contact, EVCardAttribute *attr, void *data)
+static void*
+cert_getter (EContact *contact, EVCardAttribute *attr)
+{
+ if (attr) {
+ /* the certificate is stored in this vcard. just
+ return the data */
+ GList *values = e_vcard_attribute_get_values_decoded (attr);
+
+ if (values && values->data) {
+ GString *s = values->data;
+ EContactCert *cert = g_new (EContactCert, 1);
+
+ cert->length = s->len;
+ cert->data = g_malloc (cert->length);
+ memcpy (cert->data, s->str, cert->length);
+
+ return cert;
+ }
+ }
+
+ /* XXX if we stored a fingerprint in the cert we could look it
+ up via NSS, but that would require the additional NSS dep
+ here, and we'd have more than one process opening the
+ certdb, which is bad. *sigh* */
+}
+
+static void
+cert_setter (EContact *contact, EVCardAttribute *attr, void *data)
+{
+ EContactCert *cert = data;
+
+ e_vcard_attribute_add_param_with_value (attr,
+ e_vcard_attribute_param_new (EVC_ENCODING),
+ "b");
+
+ e_vcard_attribute_add_value_decoded (attr, cert->data, cert->length);
+}
+
+
+
/* Set_arg handler for the contact */
static void
e_contact_set_property (GObject *object,
@@ -1438,3 +1483,36 @@ e_contact_address_get_type (void)
(GBoxedFreeFunc) e_contact_address_free);
return type_id;
}
+
+void
+e_contact_cert_free (EContactCert *cert)
+{
+ if (!cert)
+ return;
+
+ g_free (cert->data);
+ g_free (cert);
+}
+
+static EContactCert *
+e_contact_cert_copy (EContactCert *cert)
+{
+ EContactCert *cert2 = g_new (EContactCert, 1);
+ cert2->length = cert->length;
+ cert2->data = g_malloc (cert2->length);
+ memcpy (cert2->data, cert->data, cert->length);
+
+ return cert2;
+}
+
+GType
+e_contact_cert_get_type (void)
+{
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static ("EContactCert",
+ (GBoxedCopyFunc) e_contact_cert_copy,
+ (GBoxedFreeFunc) e_contact_cert_free);
+ return type_id;
+}
diff --git a/addressbook/libebook/e-contact.h b/addressbook/libebook/e-contact.h
index 957923070..742f86d48 100644
--- a/addressbook/libebook/e-contact.h
+++ b/addressbook/libebook/e-contact.h
@@ -128,8 +128,7 @@ typedef enum {
E_CONTACT_ANNIVERSARY, /* structured field (EContactDate) */
/* Security Fields */
- E_CONTACT_X509_CERT, /* string field */
- E_CONTACT_X509_CERT_SHA1_FINGERPRINT, /* string field */
+ E_CONTACT_X509_CERT, /* structured field (EContactCert) */
/* Convenience field for getting a name from the contact.
Returns the first one of [File-As, Full Name, Org, Email1]
@@ -183,6 +182,11 @@ typedef struct {
int day;
} EContactDate;
+typedef struct {
+ int length;
+ char *data;
+} EContactCert;
+
struct _EContact {
EVCard parent;
@@ -231,6 +235,9 @@ void e_contact_name_free (EContactName *name);
GType e_contact_photo_get_type (void);
void e_contact_photo_free (EContactPhoto *photo);
+GType e_contact_cert_get_type (void);
+void e_contact_cert_free (EContactCert *cert);
+
GType e_contact_address_get_type (void);
void e_contact_address_free (EContactAddress *address);
diff --git a/addressbook/libebook/e-vcard.h b/addressbook/libebook/e-vcard.h
index cedc2b4c7..7b10aa6a9 100644
--- a/addressbook/libebook/e-vcard.h
+++ b/addressbook/libebook/e-vcard.h
@@ -35,6 +35,7 @@
#define EVC_FBURL "FBURL"
#define EVC_FN "FN"
#define EVC_ICSCALENDAR "ICSCALENDAR" /* XXX should this be X-EVOLUTION-ICSCALENDAR? */
+#define EVC_KEY "KEY"
#define EVC_LABEL "LABEL"
#define EVC_LOGO "LOGO"
#define EVC_MAILER "MAILER"
@@ -60,6 +61,7 @@
#define EVC_X_ASSISTANT "X-EVOLUTION-ASSISTANT"
#define EVC_X_BIRTHDAY "X-EVOLUTION-BIRTHDAY"
#define EVC_X_BLOG_URL "X-EVOLUTION-BLOG-URL"
+#define EVC_X_CALLBACK "X-EVOLUTION-CALLBACK"
#define EVC_X_FILE_AS "X-EVOLUTION-FILE-AS"
#define EVC_X_ICQ "X-ICQ"
#define EVC_X_JABBER "X-JABBER"
@@ -67,9 +69,11 @@
#define EVC_X_LIST "X-EVOLUTION-LIST"
#define EVC_X_MANAGER "X-EVOLUTION-MANAGER"
#define EVC_X_MSN "X-MSN"
+#define EVC_X_RADIO "X-EVOLUTION-RADIO"
#define EVC_X_SPOUSE "X-EVOLUTION-SPOUSE"
-#define EVC_X_WANTS_HTML "X-MOZILLA-HTML"
-#define EVC_X_WANTS_HTML "X-MOZILLA-HTML"
+#define EVC_X_TELEX "X-EVOLUTION-TELEX"
+#define EVC_X_TTYTDD "X-EVOLUTION-TTYTDD"
+#define EVC_X_WANTS_HTML "X-MOZILLA-HTML"
#define EVC_X_YAHOO "X-YAHOO"
typedef enum {
diff --git a/addressbook/libedata-book/e-book-backend.c b/addressbook/libedata-book/e-book-backend.c
index 207347263..a86eb277d 100644
--- a/addressbook/libedata-book/e-book-backend.c
+++ b/addressbook/libedata-book/e-book-backend.c
@@ -366,23 +366,20 @@ void
e_book_backend_remove_client (EBookBackend *backend,
EDataBook *book)
{
- /* XXX this needs a bit more thinking wrt the mutex - we
- should be holding it when we check to see if clients is
- NULL */
-
g_return_if_fail (E_IS_BOOK_BACKEND (backend));
g_return_if_fail (E_IS_DATA_BOOK (book));
/* Disconnect */
g_mutex_lock (backend->priv->clients_mutex);
backend->priv->clients = g_list_remove (backend->priv->clients, book);
- g_mutex_unlock (backend->priv->clients_mutex);
/* When all clients go away, notify the parent factory about it so that
* it may decide whether to kill the backend or not.
*/
if (!backend->priv->clients)
last_client_gone (backend);
+
+ g_mutex_unlock (backend->priv->clients_mutex);
}
char *