[couchdb-glib] Added missing couchdb_document_contact_set_addresses implementation
- From: Rodrigo Moya <rodrigo src gnome org>
- To: svn-commits-list gnome org
- Subject: [couchdb-glib] Added missing couchdb_document_contact_set_addresses implementation
- Date: Wed, 24 Jun 2009 16:06:56 +0000 (UTC)
commit 5ba43945ee3f3fccbf5a8d1b74e9e12c64449a67
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Wed Jun 24 17:49:56 2009 +0200
Added missing couchdb_document_contact_set_addresses implementation
couchdb-glib/couchdb-document-contact.c | 41 +++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/couchdb-glib/couchdb-document-contact.c b/couchdb-glib/couchdb-document-contact.c
index e468e4e..6bafc4f 100644
--- a/couchdb-glib/couchdb-document-contact.c
+++ b/couchdb-glib/couchdb-document-contact.c
@@ -235,6 +235,47 @@ couchdb_document_contact_get_addresses (CouchDBDocument *document)
return list;
}
+void
+couchdb_document_contact_set_addresses (CouchDBDocument *document, GSList *list)
+{
+ GSList *l;
+ JsonObject *addresses;
+
+ g_return_if_fail (COUCHDB_IS_DOCUMENT (document));
+
+ addresses = json_object_new ();
+ for (l = list; l != NULL; l = l->next) {
+ const gchar *street_str;
+ CouchDBStructField *sf = (CouchDBStructField *) l->data;
+
+ street_str = couchdb_document_contact_address_get_street (sf);
+ if (street_str) {
+ JsonObject *this_address;
+
+ this_address = json_object_new ();
+ json_object_set_string_member (this_address, "street", street_str);
+ json_object_set_string_member (this_address, "city",
+ couchdb_document_contact_address_get_city (sf));
+ json_object_set_string_member (this_address, "state",
+ couchdb_document_contact_address_get_state (sf));
+ json_object_set_string_member (this_address, "country",
+ couchdb_document_contact_address_get_country (sf));
+ json_object_set_string_member (this_address, "postalcode",
+ couchdb_document_contact_address_get_postalcode (sf));
+ json_object_set_string_member (this_address, "pobox",
+ couchdb_document_contact_address_get_pobox (sf));
+ json_object_set_string_member (this_address, "description",
+ couchdb_document_contact_address_get_description (sf));
+
+ json_object_set_object_member (addresses, street_str, this_address);
+ /* FIXME: crashes if we _unref json_object_unref (this_address); */
+ }
+ }
+
+ json_object_set_object_member (json_node_get_object (document->root_node), "addresses", addresses);
+ /* FIXME: crashes if we _unref json_object_unref (addresses); */
+}
+
CouchDBStructField *
couchdb_document_contact_email_new (const char *address, const char *description)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]