[couchdb-glib] Add missing couchdb_document_contact_set_email_addresses implementation
- From: Rodrigo Moya <rodrigo src gnome org>
- To: svn-commits-list gnome org
- Subject: [couchdb-glib] Add missing couchdb_document_contact_set_email_addresses implementation
- Date: Wed, 24 Jun 2009 12:44:03 +0000 (UTC)
commit 352c908aac8afb71803685e79a5711a41a574ea6
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Wed Jun 24 13:28:44 2009 +0200
Add missing couchdb_document_contact_set_email_addresses implementation
couchdb-glib/couchdb-document-contact.c | 40 +++++++++++++++++++++++++++++++
couchdb-glib/couchdb-document-contact.h | 9 ++++---
2 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/couchdb-glib/couchdb-document-contact.c b/couchdb-glib/couchdb-document-contact.c
index 747f3e1..443016d 100644
--- a/couchdb-glib/couchdb-document-contact.c
+++ b/couchdb-glib/couchdb-document-contact.c
@@ -134,6 +134,32 @@ couchdb_document_contact_get_email_addresses (CouchDBDocument *document)
void
couchdb_document_contact_set_email_addresses (CouchDBDocument *document, GSList *list)
{
+ GSList *l;
+ JsonObject *addresses_json;
+
+ g_return_if_fail (COUCHDB_IS_DOCUMENT (document));
+
+ addresses_json = json_object_new ();
+ for (l = list; l != NULL; l = l->next) {
+ const gchar *address_str, *description_str;
+ CouchDBStructField *sf = (CouchDBStructField *) l->data;
+
+ address_str = couchdb_document_contact_email_get_address (sf);
+ if (address_str) {
+ JsonObject *this_address;
+
+ this_address = json_object_new ();
+ json_object_set_string_member (this_address, "address", address_str);
+ json_object_set_string_member (this_address, "description",
+ couchdb_document_contact_email_get_description (sf));
+
+ json_object_set_object_member (addresses_json, address_str, this_address);
+ json_object_unref (this_address);
+ }
+ }
+
+ json_object_set_object_member (json_node_get_object (document->root_node), "email_addresses", addresses_json);
+ json_object_unref (addresses_json);
}
GSList *
@@ -181,6 +207,20 @@ couchdb_document_contact_get_addresses (CouchDBDocument *document)
return list;
}
+CouchDBStructField *
+couchdb_document_contact_email_new (const char *address, const char *description)
+{
+ CouchDBStructField *sf;
+
+ sf = couchdb_struct_field_new_from_json_object (json_object_new ());
+ if (address)
+ couchdb_document_contact_email_set_address (sf, address);
+ if (description)
+ couchdb_document_contact_email_set_description (sf, description);
+
+ return sf;
+}
+
const char *
couchdb_document_contact_email_get_address (CouchDBStructField *sf)
{
diff --git a/couchdb-glib/couchdb-document-contact.h b/couchdb-glib/couchdb-document-contact.h
index 7571b4e..4f51d7c 100644
--- a/couchdb-glib/couchdb-document-contact.h
+++ b/couchdb-glib/couchdb-document-contact.h
@@ -48,10 +48,11 @@ void couchdb_document_contact_set_addresses (CouchDBDocument *document, G
* Utility functions to manipulate email addresses fields
*/
-const char *couchdb_document_contact_email_get_address (CouchDBStructField *sf);
-void couchdb_document_contact_email_set_address (CouchDBStructField *sf, const char *email);
-const char *couchdb_document_contact_email_get_description (CouchDBStructField *sf);
-void couchdb_document_contact_email_set_description (CouchDBStructField *sf, const char *description);
+CouchDBStructField *couchdb_document_contact_email_new (const char *address, const char *description);
+const char *couchdb_document_contact_email_get_address (CouchDBStructField *sf);
+void couchdb_document_contact_email_set_address (CouchDBStructField *sf, const char *email);
+const char *couchdb_document_contact_email_get_description (CouchDBStructField *sf);
+void couchdb_document_contact_email_set_description (CouchDBStructField *sf, const char *description);
/*
* Utility functions to manipulate phone numbers
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]