[couchdb-glib] Added missing couchdb_document_contact_set_phone_numbers implementation



commit 123521cc12893180e2436e7037123c679ea522d3
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Wed Jun 24 14:43:49 2009 +0200

    Added missing couchdb_document_contact_set_phone_numbers implementation

 couchdb-glib/couchdb-document-contact.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/couchdb-glib/couchdb-document-contact.c b/couchdb-glib/couchdb-document-contact.c
index 9c21834..64bb29a 100644
--- a/couchdb-glib/couchdb-document-contact.c
+++ b/couchdb-glib/couchdb-document-contact.c
@@ -185,6 +185,34 @@ couchdb_document_contact_get_phone_numbers (CouchDBDocument *document)
 void
 couchdb_document_contact_set_phone_numbers (CouchDBDocument *document, GSList *list)
 {
+	GSList *l;
+	JsonObject *phone_numbers;
+
+	g_return_if_fail (COUCHDB_IS_DOCUMENT (document));
+
+	phone_numbers = json_object_new ();
+	for (l = list; l != NULL; l = l->next) {
+		const gchar *number_str;
+		CouchDBStructField *sf = (CouchDBStructField *) l->data;
+
+		number_str = couchdb_document_contact_phone_get_number (sf);
+		if (number_str) {
+			JsonObject *this_phone;
+
+			this_phone = json_object_new ();
+			json_object_set_string_member (this_phone, "number", number_str);
+			json_object_set_string_member (this_phone, "description",
+						       couchdb_document_contact_phone_get_description (sf));
+			json_object_set_int_member (this_phone, "priority",
+						    couchdb_document_contact_phone_get_priority (sf));
+
+			json_object_set_object_member (phone_numbers, number_str, this_phone);
+			/* FIXME: crashes if we _unref json_object_unref (this_phone); */
+		}
+	}
+
+	json_object_set_object_member (json_node_get_object (document->root_node), "phone_numbers", phone_numbers);
+	/* FIXME: crashes if we _unref json_object_unref (phone_numbers); */
 }
 
 GSList *



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