[evolution-patches] Bug 45210 - LDAP PostalAddress compliance patch for evolution-data-server, contacts



Here is an updated version of my patch to fix the storage postalAddress
fields in LDAP.  This is based off of evolution-data-server CVS HEAD.

-- 
Edward Rudd <eddie omegaware com>
Website http://www.outoforder.cc/
Index: addressbook/backends/ldap/e-book-backend-ldap.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/backends/ldap/e-book-backend-ldap.c,v
retrieving revision 1.17
diff -u -3 -p -r1.17 e-book-backend-ldap.c
--- a/addressbook/backends/ldap/e-book-backend-ldap.c	23 Apr 2004 08:42:22 -0000	1.17
+++ b/addressbook/backends/ldap/e-book-backend-ldap.c	2 May 2004 18:14:01 -0000
@@ -163,6 +163,18 @@ static void category_populate (EContact 
 struct berval** category_ber (EContact *contact);
 static gboolean category_compare (EContact *contact1, EContact *contact2);
 
+static void home_address_populate(EContact * card, char **values);
+struct berval **home_address_ber(EContact * card);
+static gboolean home_address_compare(EContact * ecard1, EContact * ecard2);
+
+static void work_address_populate(EContact * card, char **values);
+struct berval **work_address_ber(EContact * card);
+static gboolean work_address_compare(EContact * ecard1, EContact * ecard2);
+
+static void other_address_populate(EContact * card, char **values);
+struct berval **other_address_ber(EContact * card);
+static gboolean other_address_compare(EContact * ecard1, EContact * ecard2);
+
 static void photo_populate (EContact *contact, struct berval **ber_values);
 
 static void cert_populate (EContact *contact, struct berval **ber_values);
@@ -235,9 +247,9 @@ struct prop_info {
 	E_STRING_PROP (E_CONTACT_ASSISTANT, "assistantName"), 
 
 	/* addresses */
-	STRING_PROP   (E_CONTACT_ADDRESS_LABEL_WORK,  "postalAddress"),
-	STRING_PROP   (E_CONTACT_ADDRESS_LABEL_HOME,  "homePostalAddress"),
-	E_STRING_PROP (E_CONTACT_ADDRESS_LABEL_OTHER, "otherPostalAddress"),
+	COMPLEX_PROP  (E_CONTACT_ADDRESS_LABEL_WORK, "postalAddress", work_address_populate, work_address_ber, work_address_compare),
+	COMPLEX_PROP  (E_CONTACT_ADDRESS_LABEL_HOME,     "homePostalAddress", home_address_populate, home_address_ber, home_address_compare),
+	E_COMPLEX_PROP(E_CONTACT_ADDRESS_LABEL_OTHER,    "otherPostalAddress", other_address_populate, other_address_ber, other_address_compare),
 
 	/* photos */
 	BINARY_PROP  (E_CONTACT_PHOTO,       "jpegPhoto", photo_populate, NULL/*XXX*/, NULL/*XXX*/),
@@ -2228,6 +2240,119 @@ category_compare (EContact *contact1, EC
 }
 
 static void
+address_populate(EContact * card, char **values, EContactField field)
+{
+	if (values[0]) {
+		char *temp = g_strdup(values[0]);
+		char *i;
+		for (i = temp; *i != '\0'; i++) {
+			if (*i == '$') {
+				*i = '\n';
+			}
+		}
+		e_contact_set(card, field, temp);
+		g_free(temp);
+	}
+}
+
+static void
+home_address_populate(EContact * card, char **values)
+{
+	address_populate(card, values, E_CONTACT_ADDRESS_LABEL_HOME);
+}
+
+static void
+work_address_populate(EContact * card, char **values)
+{
+	address_populate(card, values, E_CONTACT_ADDRESS_LABEL_WORK);
+}
+
+static void
+other_address_populate(EContact * card, char **values)
+{
+	address_populate(card, values, E_CONTACT_ADDRESS_LABEL_OTHER);
+}
+
+struct berval **
+address_ber(EContact * card, EContactField field)
+{
+	struct berval **result = NULL;
+	const char *address;
+	char *temp, *i;
+
+	address = e_contact_get(card, field);
+	if (address) {
+		temp = g_strdup(address);
+		for (i = temp; *i != '\0'; i++) {
+			if (*i == '\n') {
+				*i = '$';
+			}
+		}
+
+		result = g_new(struct berval *, 2);
+		result[0] = g_new(struct berval, 1);
+		result[0]->bv_val = temp;
+		result[0]->bv_len = strlen(temp);
+
+		result[1] = NULL;
+	}
+	return result;
+}
+
+struct berval **
+home_address_ber(EContact * card)
+{
+	return address_ber(card, E_CONTACT_ADDRESS_LABEL_HOME);
+}
+
+struct berval **
+work_address_ber(EContact * card)
+{
+	return address_ber(card, E_CONTACT_ADDRESS_LABEL_WORK);
+}
+
+struct berval **
+other_address_ber(EContact * card)
+{
+	return address_ber(card, E_CONTACT_ADDRESS_LABEL_OTHER);
+}
+
+static gboolean
+address_compare(EContact * ecard1, EContact * ecard2, EContactField field)
+{
+	const char *address1, *address2;
+
+	gboolean equal;
+	address1 = e_contact_get(ecard1, field);
+	address2 = e_contact_get(ecard2, field);
+
+	if (address1 && address2)
+		equal = !strcmp(address1, address2);
+	else
+		equal = (!!address1 == !!address2);
+
+	return equal;
+}
+
+static gboolean
+home_address_compare(EContact * ecard1, EContact * ecard2)
+{
+	return address_compare(ecard1, ecard2, E_CONTACT_ADDRESS_LABEL_HOME);
+}
+
+static gboolean
+work_address_compare(EContact * ecard1, EContact * ecard2)
+{
+	return address_compare(ecard1, ecard2, E_CONTACT_ADDRESS_LABEL_WORK);
+}
+
+static gboolean
+other_address_compare(EContact * ecard1, EContact * ecard2)
+{
+	return address_compare(ecard1, ecard2, E_CONTACT_ADDRESS_LABEL_OTHER);
+}
+
+static void
 photo_populate (EContact *contact, struct berval **ber_values)
 {
         if (ber_values && ber_values[0]) {


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