[evolution-couchdb] Get postal addresses



commit 714d41b7925556bc08e8af7bb1f5668057bf8b28
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Mon Jun 22 13:01:54 2009 +0200

    Get postal addresses

 addressbook/e-book-backend-couchdb.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/e-book-backend-couchdb.c b/addressbook/e-book-backend-couchdb.c
index 8f0d40e..59211ae 100644
--- a/addressbook/e-book-backend-couchdb.c
+++ b/addressbook/e-book-backend-couchdb.c
@@ -98,11 +98,42 @@ vcard_from_couch_document (CouchDBDocument *document)
 		else
 			e_contact_set (contact, E_CONTACT_PHONE_OTHER, (const gpointer) phone_str);
 
-		/* remove address from list */
+		/* remove phones from list */
 		list = g_slist_remove (list, phone_number);
 		couchdb_struct_field_unref (phone_number);
 	}
 
+	/* parse postal addresses */
+	list = couchdb_document_contact_get_addresses (document);
+	while (list != NULL) {
+		const char *description_str;
+		EContactAddress *contact_address;
+		CouchDBStructField *address = (CouchDBStructField *) list->data;
+
+		contact_address = g_new0 (EContactAddress, 1);
+		contact_address->address_format = g_strdup ("");
+		contact_address->street = g_strdup (couchdb_document_contact_address_get_street (address));
+		contact_address->locality = g_strdup (couchdb_document_contact_address_get_city (address));
+		contact_address->region = g_strdup (couchdb_document_contact_address_get_state (address));
+		contact_address->country = g_strdup (couchdb_document_contact_address_get_country (address));
+		contact_address->code = g_strdup (couchdb_document_contact_address_get_postalcode (address));
+		contact_address->po = g_strdup (couchdb_document_contact_address_get_pobox (address));
+		
+		description_str = couchdb_document_contact_address_get_description (address);
+		if (!g_ascii_strcasecmp (description_str, "home"))
+			e_contact_set (contact, E_CONTACT_ADDRESS_HOME, (const gpointer) contact_address);
+		else if (!g_ascii_strcasecmp (description_str, "work"))
+			e_contact_set (contact, E_CONTACT_ADDRESS_WORK, (const gpointer) contact_address);
+		else
+			e_contact_set (contact, E_CONTACT_ADDRESS_OTHER, (const gpointer) contact_address);
+
+		/* remove addresses from list */
+		list = g_slist_remove (list, address);
+		couchdb_struct_field_unref (address);
+
+		e_contact_address_free (contact_address);
+	}
+
 	/* birth date */
 	str = (char *) couchdb_document_contact_get_birth_date (document);
 	if (str) {



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