[couchdb-glib] Move DesktopcouchDocument* classes to couchdb-glib, so that they can be used in other CouchdbSession



commit 47e511231e6911c4ab3dd86b6ef893781e5222c3
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Wed Jul 7 13:44:30 2010 +0200

    Move DesktopcouchDocument* classes to couchdb-glib, so that they can be used in other CouchdbSession's

 couchdb-glib/Makefile.am                           |    6 +
 couchdb-glib/couchdb-database.c                    |   80 ++--
 couchdb-glib/couchdb-database.h                    |    3 -
 .../couchdb-document-contact.c                     |  438 ++++++++++----------
 couchdb-glib/couchdb-document-contact.h            |  225 ++++++++++
 couchdb-glib/couchdb-document-task.c               |   85 ++++
 couchdb-glib/couchdb-document-task.h               |   57 +++
 couchdb-glib/couchdb-document.c                    |  108 +++++
 couchdb-glib/couchdb-document.h                    |   17 +
 couchdb-glib/couchdb-glib.h                        |    2 +
 couchdb-glib/couchdb-session.c                     |    9 +-
 couchdb-glib/couchdb-session.h                     |    3 -
 desktopcouch-glib/Makefile.am                      |    9 -
 desktopcouch-glib/desktopcouch-document-contact.h  |  225 ----------
 desktopcouch-glib/desktopcouch-document-task.c     |   85 ----
 desktopcouch-glib/desktopcouch-document-task.h     |   57 ---
 desktopcouch-glib/desktopcouch-document.c          |  151 -------
 desktopcouch-glib/desktopcouch-document.h          |   63 ---
 desktopcouch-glib/desktopcouch-glib.h              |    3 -
 desktopcouch-glib/desktopcouch-session.c           |   56 ---
 20 files changed, 756 insertions(+), 926 deletions(-)
---
diff --git a/couchdb-glib/Makefile.am b/couchdb-glib/Makefile.am
index 683d1f6..845dff1 100644
--- a/couchdb-glib/Makefile.am
+++ b/couchdb-glib/Makefile.am
@@ -31,7 +31,9 @@ libcouchdb_glib_1_0_la_headers =	\
 	couchdb-database.h		\
 	couchdb-design-document.h	\
 	couchdb-document.h		\
+	couchdb-document-contact.h	\
 	couchdb-document-info.h		\
+	couchdb-document-task.h		\
 	couchdb-glib.h			\
 	couchdb-session.h		\
 	couchdb-struct-field.h		\
@@ -46,7 +48,9 @@ libcouchdb_glib_1_0_la_sources =	\
 	couchdb-database.c		\
 	couchdb-design-document.c	\
 	couchdb-document.c		\
+	couchdb-document-contact.c	\
 	couchdb-document-info.c		\
+	couchdb-document-task.c		\
 	couchdb-session.c		\
 	couchdb-struct-field.c		\
 	dbwatch.c			\
@@ -76,7 +80,9 @@ h_DATA = 				\
 	couchdb-database.h		\
 	couchdb-design-document.h	\
 	couchdb-document.h		\
+	couchdb-document-contact.h	\
 	couchdb-document-info.h		\
+	couchdb-document-task.h		\
 	couchdb-glib.h			\
 	couchdb-session.h		\
 	couchdb-struct-field.h		\
diff --git a/couchdb-glib/couchdb-database.c b/couchdb-glib/couchdb-database.c
index 82e2aae..be4eca5 100644
--- a/couchdb-glib/couchdb-database.c
+++ b/couchdb-glib/couchdb-database.c
@@ -21,12 +21,7 @@
 
 #include <libsoup/soup-message.h>
 #include <libsoup/soup-uri.h>
-#include "couchdb-database.h"
-#include "couchdb-design-document.h"
-#include "couchdb-document-info.h"
-#include "couchdb-document.h"
-#include "couchdb-marshal.h"
-#include "couchdb-types.h"
+#include "couchdb-glib.h"
 #include "dbwatch.h"
 #include "utils.h"
 
@@ -130,7 +125,6 @@ couchdb_database_class_init (CouchdbDatabaseClass *klass)
 	object_class->finalize = couchdb_database_finalize;
 	object_class->set_property = couchdb_database_set_property;
 	object_class->get_property = couchdb_database_get_property;
-	klass->create_document_from_json = NULL;
 
 	g_object_class_install_property (object_class,
         	                         PROP_SESSION,
@@ -183,6 +177,35 @@ couchdb_database_init (CouchdbDatabase *database)
 	database->priv = g_new0 (CouchdbDatabasePrivate, 1);
 }
 
+static CouchdbDocument *
+create_document_from_json_object (JsonObject *json_object)
+{
+	CouchdbDocument *document;
+
+	if (g_str_has_prefix (json_object_get_string_member (json_object, "id"),
+			      "_design/")) {
+		document = COUCHDB_DOCUMENT (couchdb_design_document_new ());
+		couchdb_document_set_from_json_object (document,
+						       json_object_get_object_member (json_object, "doc"));
+	} else {
+		if (json_object_has_member (json_object, "record_type")) {
+			if (g_strcmp0 (json_object_get_string_member (json_object, "record_type"),
+				       COUCHDB_RECORD_TYPE_CONTACT) == 0) {
+				document = COUCHDB_DOCUMENT (couchdb_document_contact_new ());
+			} else if (g_strcmp0 (json_object_get_string_member (json_object, "record_type"),
+					      COUCHDB_RECORD_TYPE_TASK) == 0) {
+				document = COUCHDB_DOCUMENT (couchdb_document_task_new ());
+			} else
+				document = couchdb_document_new ();
+
+			couchdb_document_set_from_json_object (document, json_object);
+		} else
+			document = couchdb_document_new_from_json_object (json_object);
+	}
+
+	return document;
+}
+
 /**
  * couchdb_database_new:
  * @session: A #CouchdbSession object
@@ -378,21 +401,7 @@ couchdb_database_get_all_documents (CouchdbDatabase *database, GError **error)
 			if (!obj)
 				continue;
 
-			if (g_str_has_prefix (json_object_get_string_member (obj, "id"),
-					      "_design/")) {
-				document = COUCHDB_DOCUMENT (couchdb_design_document_new ());
-				couchdb_document_set_from_json_object (document,
-								       json_object_get_object_member (obj, "doc"));
-			} else {
-				if (COUCHDB_DATABASE_GET_CLASS (database)->create_document_from_json != NULL) {
-					document = COUCHDB_DATABASE_GET_CLASS (database)->create_document_from_json (
-						database,
-						json_object_get_object_member (obj, "doc"));
-				} else {
-					document = couchdb_document_new_from_json_object (
-						json_object_get_object_member (obj, "doc"));
-				}
-			}
+			document = create_document_from_json_object (obj);
 			if (document != NULL) {
 				g_object_set (G_OBJECT (document), "database", database, NULL);
 				doclist = g_slist_append (doclist, document);
@@ -463,25 +472,10 @@ couchdb_database_execute_view (CouchdbDatabase *database,
 			if (!obj)
 				continue;
 
-			if (g_str_has_prefix (json_object_get_string_member (obj, "id"),
-					      "_design/")) {
-				document = COUCHDB_DOCUMENT (couchdb_design_document_new ());
-				couchdb_document_set_from_json_object (document,
-								       json_object_get_object_member (obj, "value"));
-			} else {
-				if (COUCHDB_DATABASE_GET_CLASS (database)->create_document_from_json != NULL) {
-					document = COUCHDB_DATABASE_GET_CLASS (database)->create_document_from_json (
-						database,
-						json_object_get_object_member (obj, "value"));
-				} else {
-					document = couchdb_document_new_from_json_object (
-						json_object_get_object_member (obj, "value"));
-				}
-			}
-
-			couchdb_document_set_id (document, json_object_get_string_member (obj, "id"));
+			document = create_document_from_json_object (obj);
 
 			if (document != NULL) {
+				couchdb_document_set_id (document, json_object_get_string_member (obj, "id"));
 				g_object_set (G_OBJECT (document), "database", database, NULL);
 				doclist = g_slist_append (doclist, document);
 			}
@@ -547,13 +541,9 @@ couchdb_database_get_document (CouchdbDatabase *database,
 			       database->priv->dbname, encoded_docid);
 	parser = json_parser_new ();
 	if (couchdb_session_send_message (database->priv->session, SOUP_METHOD_GET, url, NULL, parser, error)) {
-		if (COUCHDB_DATABASE_GET_CLASS (database)->create_document_from_json != NULL) {
-			document = COUCHDB_DATABASE_GET_CLASS (database)->create_document_from_json (
-				database, json_node_get_object (json_parser_get_root (parser)));
-		} else {
-			document = couchdb_document_new_from_json_object (json_node_get_object (json_parser_get_root (parser)));
-		}
+		JsonObject *json_object = json_node_get_object (json_parser_get_root (parser));
 
+		document = create_document_from_json_object (json_object);
 		g_object_set (G_OBJECT (document), "database", database, NULL);
 	}
 
diff --git a/couchdb-glib/couchdb-database.h b/couchdb-glib/couchdb-database.h
index 17bb980..072aa7a 100644
--- a/couchdb-glib/couchdb-database.h
+++ b/couchdb-glib/couchdb-database.h
@@ -50,9 +50,6 @@ typedef struct {
 	void (* document_created) (CouchdbDatabase *database, CouchdbDocument *document);
 	void (* document_updated) (CouchdbDatabase *database, CouchdbDocument *document);
 	void (* document_deleted) (CouchdbDatabase *database, const char *docid);
-
-	/* Virtual methods */
-	CouchdbDocument * (* create_document_from_json) (CouchdbDatabase *database, gpointer json_data);
 } CouchdbDatabaseClass;
 
 GType            couchdb_database_get_type (void);
diff --git a/desktopcouch-glib/desktopcouch-document-contact.c b/couchdb-glib/couchdb-document-contact.c
similarity index 51%
rename from desktopcouch-glib/desktopcouch-document-contact.c
rename to couchdb-glib/couchdb-document-contact.c
index 14301d9..2021a1f 100644
--- a/desktopcouch-glib/desktopcouch-document-contact.c
+++ b/couchdb-glib/couchdb-document-contact.c
@@ -19,317 +19,317 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "desktopcouch-document-contact.h"
+#include "couchdb-document-contact.h"
 #include "utils.h"
 
-G_DEFINE_TYPE(DesktopcouchDocumentContact, desktopcouch_document_contact, DESKTOPCOUCH_TYPE_DOCUMENT)
+G_DEFINE_TYPE(CouchdbDocumentContact, couchdb_document_contact, COUCHDB_TYPE_DOCUMENT)
 
 static void
-desktopcouch_document_contact_class_init (DesktopcouchDocumentContactClass *klass)
+couchdb_document_contact_class_init (CouchdbDocumentContactClass *klass)
 {
 }
 
 static void
-desktopcouch_document_contact_init (DesktopcouchDocumentContact *document)
+couchdb_document_contact_init (CouchdbDocumentContact *document)
 {
-	desktopcouch_document_set_record_type (DESKTOPCOUCH_DOCUMENT (document), DESKTOPCOUCH_RECORD_TYPE_CONTACT);
+	couchdb_document_set_record_type (COUCHDB_DOCUMENT (document), COUCHDB_RECORD_TYPE_CONTACT);
 }
 
 /**
- * desktopcouch_document_contact_new:
+ * couchdb_document_contact_new:
  *
- * Create a new #DesktopcouchDocumentContact object.
+ * Create a new #CouchdbDocumentContact object.
  */
-DesktopcouchDocumentContact *
-desktopcouch_document_contact_new (void)
+CouchdbDocumentContact *
+couchdb_document_contact_new (void)
 {
-	return g_object_new (DESKTOPCOUCH_TYPE_DOCUMENT_CONTACT, NULL);
+	return g_object_new (COUCHDB_TYPE_DOCUMENT_CONTACT, NULL);
 }
 
 const char *
-desktopcouch_document_contact_get_title (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_title (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "title");
 }
 
 void
-desktopcouch_document_contact_set_title (DesktopcouchDocumentContact *document, const char *title)
+couchdb_document_contact_set_title (CouchdbDocumentContact *document, const char *title)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (title != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "title", title);
 }
 
 const char *
-desktopcouch_document_contact_get_first_name (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_first_name (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "first_name");
 }
 
 void
-desktopcouch_document_contact_set_first_name (DesktopcouchDocumentContact *document, const char *first_name)
+couchdb_document_contact_set_first_name (CouchdbDocumentContact *document, const char *first_name)
 {
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (first_name != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "first_name", first_name);
 }
 
 const char *
-desktopcouch_document_contact_get_middle_name (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_middle_name (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "middle_name");
 }
 
 void
-desktopcouch_document_contact_set_middle_name (DesktopcouchDocumentContact *document, const char *middle_name)
+couchdb_document_contact_set_middle_name (CouchdbDocumentContact *document, const char *middle_name)
 {
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (middle_name != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "middle_name", middle_name);
 }
 
 const char *
-desktopcouch_document_contact_get_last_name (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_last_name (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "last_name");
 }
 
 void
-desktopcouch_document_contact_set_last_name (DesktopcouchDocumentContact *document, const char *last_name)
+couchdb_document_contact_set_last_name (CouchdbDocumentContact *document, const char *last_name)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (last_name != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "last_name", last_name);
 }
 
 const char *
-desktopcouch_document_contact_get_suffix (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_suffix (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "suffix");
 }
 
 void
-desktopcouch_document_contact_set_suffix (DesktopcouchDocumentContact *document, const char *suffix)
+couchdb_document_contact_set_suffix (CouchdbDocumentContact *document, const char *suffix)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (suffix != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "suffix", suffix);
 }
 
 const char *
-desktopcouch_document_contact_get_nick_name (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_nick_name (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "nick_name");
 }
 
 void
-desktopcouch_document_contact_set_nick_name (DesktopcouchDocumentContact *document, const char *nick_name)
+couchdb_document_contact_set_nick_name (CouchdbDocumentContact *document, const char *nick_name)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (nick_name != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "nick_name", nick_name);
 }
 
 const char *
-desktopcouch_document_contact_get_spouse_name (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_spouse_name (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "spouse_name");
 }
 
 void
-desktopcouch_document_contact_set_spouse_name (DesktopcouchDocumentContact *document, const char *spouse_name)
+couchdb_document_contact_set_spouse_name (CouchdbDocumentContact *document, const char *spouse_name)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (spouse_name != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "spouse_name", spouse_name);
 }
 
 const char *
-desktopcouch_document_contact_get_birth_date (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_birth_date (CouchdbDocumentContact *document)
 {
 	JsonObject *object;
 
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "birth_date");
 }
 
 void
-desktopcouch_document_contact_set_birth_date (DesktopcouchDocumentContact *document, const char *birth_date)
+couchdb_document_contact_set_birth_date (CouchdbDocumentContact *document, const char *birth_date)
 {
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (birth_date != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "birth_date", birth_date);
 }
 
 const char *
-desktopcouch_document_contact_get_wedding_date (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_wedding_date (CouchdbDocumentContact *document)
 {
 	JsonObject *object;
 
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "wedding_date");
 }
 
 void
-desktopcouch_document_contact_set_wedding_date (DesktopcouchDocumentContact *document, const char *wedding_date)
+couchdb_document_contact_set_wedding_date (CouchdbDocumentContact *document, const char *wedding_date)
 {
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (wedding_date != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "wedding_date", wedding_date);
 }
 
 const char *
-desktopcouch_document_contact_get_company (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_company (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "company");
 }
 
 void
-desktopcouch_document_contact_set_company (DesktopcouchDocumentContact *document, const char *company)
+couchdb_document_contact_set_company (CouchdbDocumentContact *document, const char *company)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (company != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "company", company);
 }
 
 const char *
-desktopcouch_document_contact_get_department (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_department (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "department");
 }
 
 void
-desktopcouch_document_contact_set_department (DesktopcouchDocumentContact *document, const char *department)
+couchdb_document_contact_set_department (CouchdbDocumentContact *document, const char *department)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (department != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "department", department);
 }
 
 const char *
-desktopcouch_document_contact_get_job_title (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_job_title (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "job_title");
 }
 
 void
-desktopcouch_document_contact_set_job_title (DesktopcouchDocumentContact *document, const char *job_title)
+couchdb_document_contact_set_job_title (CouchdbDocumentContact *document, const char *job_title)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (job_title != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "job_title", job_title);
 }
 
 const char *
-desktopcouch_document_contact_get_manager_name (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_manager_name (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "manager_name");
 }
 
 void
-desktopcouch_document_contact_set_manager_name (DesktopcouchDocumentContact *document, const char *manager_name)
+couchdb_document_contact_set_manager_name (CouchdbDocumentContact *document, const char *manager_name)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (manager_name != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "manager_name", manager_name);
 }
 
 const char *
-desktopcouch_document_contact_get_assistant_name (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_assistant_name (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "assistant_name");
 }
 
 void
-desktopcouch_document_contact_set_assistant_name (DesktopcouchDocumentContact *document, const char *assistant_name)
+couchdb_document_contact_set_assistant_name (CouchdbDocumentContact *document, const char *assistant_name)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (assistant_name != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "assistant_name", assistant_name);
 }
 
 const char *
-desktopcouch_document_contact_get_office (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_office (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "office");
 }
 
 void
-desktopcouch_document_contact_set_office (DesktopcouchDocumentContact *document, const char *office)
+couchdb_document_contact_set_office (CouchdbDocumentContact *document, const char *office)
 {
-      	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (office != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "office", office);
@@ -354,12 +354,12 @@ foreach_object_cb (JsonObject *object,
 }
 
 /**
- * desktopcouch_document_contact_get_email_addresses:
- * @document: A #DesktopcouchDocumentContact object representing a contact
+ * couchdb_document_contact_get_email_addresses:
+ * @document: A #CouchdbDocumentContact object representing a contact
  *
  * Retrieve a list of email addresses from the specified contact document.
  * Email addresses are returned in a GSList of #CouchdbStructField objects,
- * which can be manipulated with the desktopcouch_document_contact_email_* functions
+ * which can be manipulated with the couchdb_document_contact_email_* functions
  * and freed with:
  *     g_slist_foreach (list, (GFunc) couchdb_struct_field_unref, NULL);
  *     g_slist_free (list);
@@ -367,13 +367,13 @@ foreach_object_cb (JsonObject *object,
  * Return value: a #GSList of #CouchdbStructField objects.
  */
 GSList *
-desktopcouch_document_contact_get_email_addresses (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_email_addresses (CouchdbDocumentContact *document)
 {
 	GSList *list = NULL;
 	JsonObject *addresses_json;
 
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	addresses_json = json_object_get_object_member (
 		couchdb_document_get_json_object (COUCHDB_DOCUMENT (document)), "email_addresses");;
@@ -387,26 +387,26 @@ desktopcouch_document_contact_get_email_addresses (DesktopcouchDocumentContact *
 }
 
 void
-desktopcouch_document_contact_set_email_addresses (DesktopcouchDocumentContact *document, GSList *list)
+couchdb_document_contact_set_email_addresses (CouchdbDocumentContact *document, GSList *list)
 {
 	GSList *l;
 	JsonObject *addresses_json;
 
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
 
 	addresses_json = json_object_new ();
 	for (l = list; l != NULL; l = l->next) {
 		const gchar *address_str;
 		CouchdbStructField *sf = (CouchdbStructField *) l->data;
 
-		address_str = desktopcouch_document_contact_email_get_address (sf);
+		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",
-						       desktopcouch_document_contact_email_get_description (sf));
+						       couchdb_document_contact_email_get_description (sf));
 
 			json_object_set_object_member (addresses_json,
 						       couchdb_struct_field_get_uuid (sf),
@@ -420,13 +420,13 @@ desktopcouch_document_contact_set_email_addresses (DesktopcouchDocumentContact *
 }
 
 GSList *
-desktopcouch_document_contact_get_phone_numbers (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_phone_numbers (CouchdbDocumentContact *document)
 {
 	GSList *list = NULL;
 	JsonObject *phone_numbers;
 
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	phone_numbers = json_object_get_object_member (
 		couchdb_document_get_json_object (COUCHDB_DOCUMENT (document)), "phone_numbers");
@@ -440,28 +440,28 @@ desktopcouch_document_contact_get_phone_numbers (DesktopcouchDocumentContact *do
 }
 
 void
-desktopcouch_document_contact_set_phone_numbers (DesktopcouchDocumentContact *document, GSList *list)
+couchdb_document_contact_set_phone_numbers (CouchdbDocumentContact *document, GSList *list)
 {
 	GSList *l;
 	JsonObject *phone_numbers;
 
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (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 = desktopcouch_document_contact_phone_get_number (sf);
+		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",
-						       desktopcouch_document_contact_phone_get_description (sf));
+						       couchdb_document_contact_phone_get_description (sf));
 			json_object_set_int_member (this_phone, "priority",
-						    desktopcouch_document_contact_phone_get_priority (sf));
+						    couchdb_document_contact_phone_get_priority (sf));
 
 			json_object_set_object_member (phone_numbers,
 						       couchdb_struct_field_get_uuid (sf),
@@ -474,13 +474,13 @@ desktopcouch_document_contact_set_phone_numbers (DesktopcouchDocumentContact *do
 }
 
 GSList *
-desktopcouch_document_contact_get_addresses (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_addresses (CouchdbDocumentContact *document)
 {
 	GSList *list = NULL;
 	JsonObject *addresses;
 
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	addresses = json_object_get_object_member (
 		couchdb_document_get_json_object (COUCHDB_DOCUMENT (document)), "addresses");
@@ -494,19 +494,19 @@ desktopcouch_document_contact_get_addresses (DesktopcouchDocumentContact *docume
 }
 
 void
-desktopcouch_document_contact_set_addresses (DesktopcouchDocumentContact *document, GSList *list)
+couchdb_document_contact_set_addresses (CouchdbDocumentContact *document, GSList *list)
 {
 	GSList *l;
 	JsonObject *addresses;
 
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
 
 	addresses = json_object_new ();
 	for (l = list; l != NULL; l = l->next) {
 		const gchar *street_str;
 		CouchdbStructField *sf = (CouchdbStructField *) l->data;
 
-		street_str = desktopcouch_document_contact_address_get_street (sf);
+		street_str = couchdb_document_contact_address_get_street (sf);
 		if (street_str) {
 			JsonObject *this_address;
 
@@ -514,19 +514,19 @@ desktopcouch_document_contact_set_addresses (DesktopcouchDocumentContact *docume
 
 			json_object_set_string_member (this_address, "address1", street_str);
 			json_object_set_string_member (this_address, "address2",
-						       desktopcouch_document_contact_address_get_ext_street (sf));
+						       couchdb_document_contact_address_get_ext_street (sf));
 			json_object_set_string_member (this_address, "city",
-						       desktopcouch_document_contact_address_get_city (sf));
+						       couchdb_document_contact_address_get_city (sf));
 			json_object_set_string_member (this_address, "state",
-						       desktopcouch_document_contact_address_get_state (sf));
+						       couchdb_document_contact_address_get_state (sf));
 			json_object_set_string_member (this_address, "country",
-						       desktopcouch_document_contact_address_get_country (sf));
+						       couchdb_document_contact_address_get_country (sf));
 			json_object_set_string_member (this_address, "postalcode",
-						       desktopcouch_document_contact_address_get_postalcode (sf));
+						       couchdb_document_contact_address_get_postalcode (sf));
 			json_object_set_string_member (this_address, "pobox",
-						       desktopcouch_document_contact_address_get_pobox (sf));
+						       couchdb_document_contact_address_get_pobox (sf));
 			json_object_set_string_member (this_address, "description",
-						       desktopcouch_document_contact_address_get_description (sf));
+						       couchdb_document_contact_address_get_description (sf));
 
 			json_object_set_object_member (addresses,
 						       couchdb_struct_field_get_uuid (sf),
@@ -539,13 +539,13 @@ desktopcouch_document_contact_set_addresses (DesktopcouchDocumentContact *docume
 }
 
 GSList *
-desktopcouch_document_contact_get_im_addresses (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_im_addresses (CouchdbDocumentContact *document)
 {
 	GSList *list = NULL;
 	JsonObject *im_addresses;
 
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	im_addresses = json_object_get_object_member (
 		couchdb_document_get_json_object (COUCHDB_DOCUMENT (document)), "im_addresses");
@@ -559,28 +559,28 @@ desktopcouch_document_contact_get_im_addresses (DesktopcouchDocumentContact *doc
 }
 
 void
-desktopcouch_document_contact_set_im_addresses (DesktopcouchDocumentContact *document, GSList *list)
+couchdb_document_contact_set_im_addresses (CouchdbDocumentContact *document, GSList *list)
 {
 	GSList *l;
 	JsonObject *im_addresses_json;
 
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
 
 	im_addresses_json = json_object_new ();
 	for (l = list; l != NULL; l = l->next) {
 		const gchar *address_str;
 		CouchdbStructField *sf = (CouchdbStructField *) l->data;
 
-		address_str = desktopcouch_document_contact_im_get_address (sf);
+		address_str = couchdb_document_contact_im_get_address (sf);
 		if (address_str != NULL) {
 			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",
-						       desktopcouch_document_contact_im_get_description (sf));
+						       couchdb_document_contact_im_get_description (sf));
 			json_object_set_string_member (this_address, "protocol",
-						       desktopcouch_document_contact_im_get_protocol (sf));
+						       couchdb_document_contact_im_get_protocol (sf));
 
 			json_object_set_object_member (im_addresses_json,
 						       couchdb_struct_field_get_uuid (sf),
@@ -593,13 +593,13 @@ desktopcouch_document_contact_set_im_addresses (DesktopcouchDocumentContact *doc
 }
 
 GSList *
-desktopcouch_document_contact_get_urls (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_urls (CouchdbDocumentContact *document)
 {
 	GSList *list = NULL;
 	JsonObject *urls;
 
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	urls = json_object_get_object_member (
 		couchdb_document_get_json_object (COUCHDB_DOCUMENT (document)), "urls");
@@ -613,26 +613,26 @@ desktopcouch_document_contact_get_urls (DesktopcouchDocumentContact *document)
 }
 
 void
-desktopcouch_document_contact_set_urls (DesktopcouchDocumentContact *document, GSList *list)
+couchdb_document_contact_set_urls (CouchdbDocumentContact *document, GSList *list)
 {
 	GSList *l;
 	JsonObject *urls_json;
 
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
 
 	urls_json = json_object_new ();
 	for (l = list; l != NULL; l = l->next) {
 		const gchar *address_str;
 		CouchdbStructField *sf = (CouchdbStructField *) l->data;
 
-		address_str = desktopcouch_document_contact_url_get_address (sf);
+		address_str = couchdb_document_contact_url_get_address (sf);
 		if (address_str) {
 			JsonObject *this_url;
 
 			this_url = json_object_new ();
 			json_object_set_string_member (this_url, "address", address_str);
 			json_object_set_string_member (this_url, "description",
-						       desktopcouch_document_contact_url_get_description (sf));
+						       couchdb_document_contact_url_get_description (sf));
 
 			json_object_set_object_member (urls_json,
 						       couchdb_struct_field_get_uuid (sf),
@@ -645,53 +645,53 @@ desktopcouch_document_contact_set_urls (DesktopcouchDocumentContact *document, G
 }
 
 /**
- * desktopcouch_document_contact_get_categories:
- * @document: A #DesktopcouchDocumentContact object
+ * couchdb_document_contact_get_categories:
+ * @document: A #CouchdbDocumentContact object
  *
  * Get the list of categories (as a string) for this contact document.
  *
  * Return value: A comma separated list of categories as a string.
  */
 const char *
-desktopcouch_document_contact_get_categories (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_categories (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "categories");
 }
 
 void
-desktopcouch_document_contact_set_categories (DesktopcouchDocumentContact *document, const char *categories)
+couchdb_document_contact_set_categories (CouchdbDocumentContact *document, const char *categories)
 {
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (categories != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "categories", categories);
 }
 
 const char *
-desktopcouch_document_contact_get_notes (DesktopcouchDocumentContact *document)
+couchdb_document_contact_get_notes (CouchdbDocumentContact *document)
 {
-	g_return_val_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document), NULL);
-	g_return_val_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)), NULL);
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)), NULL);
 
 	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "notes");
 }
 
 void
-desktopcouch_document_contact_set_notes (DesktopcouchDocumentContact *document, const char *notes)
+couchdb_document_contact_set_notes (CouchdbDocumentContact *document, const char *notes)
 {
-	g_return_if_fail (DESKTOPCOUCH_IS_DOCUMENT_CONTACT (document));
-	g_return_if_fail (desktopcouch_document_is_contact (DESKTOPCOUCH_DOCUMENT (document)));
+	g_return_if_fail (COUCHDB_IS_DOCUMENT_CONTACT (document));
+	g_return_if_fail (couchdb_document_is_contact (COUCHDB_DOCUMENT (document)));
 	g_return_if_fail (notes != NULL);
 
 	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "notes", notes);
 }
 
 CouchdbStructField *
-desktopcouch_document_contact_email_new (const char *uuid, const char *address, const char *description)
+couchdb_document_contact_email_new (const char *uuid, const char *address, const char *description)
 {
 	CouchdbStructField *sf;
 
@@ -705,15 +705,15 @@ desktopcouch_document_contact_email_new (const char *uuid, const char *address,
 	}
 
 	if (address)
-		desktopcouch_document_contact_email_set_address (sf, address);
+		couchdb_document_contact_email_set_address (sf, address);
 	if (description)
-		desktopcouch_document_contact_email_set_description (sf, description);
+		couchdb_document_contact_email_set_description (sf, description);
 
 	return sf;
 }
 
 const char *
-desktopcouch_document_contact_email_get_address (CouchdbStructField *sf)
+couchdb_document_contact_email_get_address (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -721,7 +721,7 @@ desktopcouch_document_contact_email_get_address (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_email_set_address (CouchdbStructField *sf, const char *email)
+couchdb_document_contact_email_set_address (CouchdbStructField *sf, const char *email)
 {
 	g_return_if_fail (sf != NULL);
 	g_return_if_fail (email != NULL);
@@ -730,7 +730,7 @@ desktopcouch_document_contact_email_set_address (CouchdbStructField *sf, const c
 }
 
 const char *
-desktopcouch_document_contact_email_get_description (CouchdbStructField *sf)
+couchdb_document_contact_email_get_description (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -738,7 +738,7 @@ desktopcouch_document_contact_email_get_description (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_email_set_description (CouchdbStructField *sf, const char *description)
+couchdb_document_contact_email_set_description (CouchdbStructField *sf, const char *description)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -746,7 +746,7 @@ desktopcouch_document_contact_email_set_description (CouchdbStructField *sf, con
 }
 
 CouchdbStructField *
-desktopcouch_document_contact_phone_new (const char *uuid, const char *number, const char *description, gint priority)
+couchdb_document_contact_phone_new (const char *uuid, const char *number, const char *description, gint priority)
 {
 	CouchdbStructField *sf;
 
@@ -760,16 +760,16 @@ desktopcouch_document_contact_phone_new (const char *uuid, const char *number, c
 	}
 
 	if (number)
-		desktopcouch_document_contact_phone_set_number (sf, number);
+		couchdb_document_contact_phone_set_number (sf, number);
 	if (description)
-		desktopcouch_document_contact_phone_set_description (sf, description);
-	desktopcouch_document_contact_phone_set_priority (sf, priority);
+		couchdb_document_contact_phone_set_description (sf, description);
+	couchdb_document_contact_phone_set_priority (sf, priority);
 
 	return sf;
 }
 
 gint
-desktopcouch_document_contact_phone_get_priority (CouchdbStructField *sf)
+couchdb_document_contact_phone_get_priority (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, 0);
 
@@ -777,7 +777,7 @@ desktopcouch_document_contact_phone_get_priority (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_phone_set_priority (CouchdbStructField *sf, gint priority)
+couchdb_document_contact_phone_set_priority (CouchdbStructField *sf, gint priority)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -785,7 +785,7 @@ desktopcouch_document_contact_phone_set_priority (CouchdbStructField *sf, gint p
 }
 
 const char *
-desktopcouch_document_contact_phone_get_number (CouchdbStructField *sf)
+couchdb_document_contact_phone_get_number (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -793,7 +793,7 @@ desktopcouch_document_contact_phone_get_number (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_phone_set_number (CouchdbStructField *sf, const char *number)
+couchdb_document_contact_phone_set_number (CouchdbStructField *sf, const char *number)
 {
 	g_return_if_fail (sf != NULL);
 	g_return_if_fail (number != NULL);
@@ -802,7 +802,7 @@ desktopcouch_document_contact_phone_set_number (CouchdbStructField *sf, const ch
 }
 
 const char *
-desktopcouch_document_contact_phone_get_description (CouchdbStructField *sf)
+couchdb_document_contact_phone_get_description (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -810,7 +810,7 @@ desktopcouch_document_contact_phone_get_description (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_phone_set_description (CouchdbStructField *sf, const char *description)
+couchdb_document_contact_phone_set_description (CouchdbStructField *sf, const char *description)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -818,7 +818,7 @@ desktopcouch_document_contact_phone_set_description (CouchdbStructField *sf, con
 }
 
 CouchdbStructField *
-desktopcouch_document_contact_address_new (const char *uuid,
+couchdb_document_contact_address_new (const char *uuid,
 					   const char *street,
 					   const char *ext_street,
 					   const char *city,
@@ -840,27 +840,27 @@ desktopcouch_document_contact_address_new (const char *uuid,
 	}
 
 	if (street)
-		desktopcouch_document_contact_address_set_street (sf, street);
+		couchdb_document_contact_address_set_street (sf, street);
 	if (ext_street)
-		desktopcouch_document_contact_address_set_ext_street (sf, ext_street);
+		couchdb_document_contact_address_set_ext_street (sf, ext_street);
 	if (city)
-		desktopcouch_document_contact_address_set_city (sf, city);
+		couchdb_document_contact_address_set_city (sf, city);
 	if (state)
-		desktopcouch_document_contact_address_set_state (sf, state);
+		couchdb_document_contact_address_set_state (sf, state);
 	if (country)
-		desktopcouch_document_contact_address_set_country (sf, country);
+		couchdb_document_contact_address_set_country (sf, country);
 	if (postalcode)
-		desktopcouch_document_contact_address_set_postalcode (sf, postalcode);
+		couchdb_document_contact_address_set_postalcode (sf, postalcode);
 	if (pobox)
-		desktopcouch_document_contact_address_set_pobox (sf, pobox);
+		couchdb_document_contact_address_set_pobox (sf, pobox);
 	if (description)
-		desktopcouch_document_contact_address_set_description (sf, description);
+		couchdb_document_contact_address_set_description (sf, description);
 
 	return sf;
 }
 
 const char *
-desktopcouch_document_contact_address_get_street (CouchdbStructField *sf)
+couchdb_document_contact_address_get_street (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -873,7 +873,7 @@ desktopcouch_document_contact_address_get_street (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_address_set_street (CouchdbStructField *sf, const char *street)
+couchdb_document_contact_address_set_street (CouchdbStructField *sf, const char *street)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -881,7 +881,7 @@ desktopcouch_document_contact_address_set_street (CouchdbStructField *sf, const
 }
 
 const char *
-desktopcouch_document_contact_address_get_ext_street (CouchdbStructField *sf)
+couchdb_document_contact_address_get_ext_street (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -889,7 +889,7 @@ desktopcouch_document_contact_address_get_ext_street (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_address_set_ext_street (CouchdbStructField *sf, const char *ext_street)
+couchdb_document_contact_address_set_ext_street (CouchdbStructField *sf, const char *ext_street)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -897,7 +897,7 @@ desktopcouch_document_contact_address_set_ext_street (CouchdbStructField *sf, co
 }
 
 const char *
-desktopcouch_document_contact_address_get_city (CouchdbStructField *sf)
+couchdb_document_contact_address_get_city (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -905,7 +905,7 @@ desktopcouch_document_contact_address_get_city (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_address_set_city (CouchdbStructField *sf, const char *city)
+couchdb_document_contact_address_set_city (CouchdbStructField *sf, const char *city)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -913,7 +913,7 @@ desktopcouch_document_contact_address_set_city (CouchdbStructField *sf, const ch
 }
 
 const char *
-desktopcouch_document_contact_address_get_state (CouchdbStructField *sf)
+couchdb_document_contact_address_get_state (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -921,7 +921,7 @@ desktopcouch_document_contact_address_get_state (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_address_set_state (CouchdbStructField *sf, const char *state)
+couchdb_document_contact_address_set_state (CouchdbStructField *sf, const char *state)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -929,7 +929,7 @@ desktopcouch_document_contact_address_set_state (CouchdbStructField *sf, const c
 }
 
 const char *
-desktopcouch_document_contact_address_get_country (CouchdbStructField *sf)
+couchdb_document_contact_address_get_country (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -937,7 +937,7 @@ desktopcouch_document_contact_address_get_country (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_address_set_country (CouchdbStructField *sf, const char *country)
+couchdb_document_contact_address_set_country (CouchdbStructField *sf, const char *country)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -945,7 +945,7 @@ desktopcouch_document_contact_address_set_country (CouchdbStructField *sf, const
 }
 
 const char *
-desktopcouch_document_contact_address_get_postalcode (CouchdbStructField *sf)
+couchdb_document_contact_address_get_postalcode (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -953,7 +953,7 @@ desktopcouch_document_contact_address_get_postalcode (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_address_set_postalcode (CouchdbStructField *sf, const char *postalcode)
+couchdb_document_contact_address_set_postalcode (CouchdbStructField *sf, const char *postalcode)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -961,7 +961,7 @@ desktopcouch_document_contact_address_set_postalcode (CouchdbStructField *sf, co
 }
 
 const char *
-desktopcouch_document_contact_address_get_pobox (CouchdbStructField *sf)
+couchdb_document_contact_address_get_pobox (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -969,7 +969,7 @@ desktopcouch_document_contact_address_get_pobox (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_address_set_pobox (CouchdbStructField *sf, const char *pobox)
+couchdb_document_contact_address_set_pobox (CouchdbStructField *sf, const char *pobox)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -977,7 +977,7 @@ desktopcouch_document_contact_address_set_pobox (CouchdbStructField *sf, const c
 }
 
 const char *
-desktopcouch_document_contact_address_get_description (CouchdbStructField *sf)
+couchdb_document_contact_address_get_description (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -985,7 +985,7 @@ desktopcouch_document_contact_address_get_description (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_address_set_description (CouchdbStructField *sf, const char *description)
+couchdb_document_contact_address_set_description (CouchdbStructField *sf, const char *description)
 {
 	g_return_if_fail (sf != NULL);
 
@@ -993,7 +993,7 @@ desktopcouch_document_contact_address_set_description (CouchdbStructField *sf, c
 }
 
 CouchdbStructField *
-desktopcouch_document_contact_im_new (const char *uuid,
+couchdb_document_contact_im_new (const char *uuid,
 				 const char *address,
 				 const char *description,
 				 const char *protocol)
@@ -1010,17 +1010,17 @@ desktopcouch_document_contact_im_new (const char *uuid,
 	}
 
 	if (address != NULL)
-		desktopcouch_document_contact_im_set_address (sf, address);
+		couchdb_document_contact_im_set_address (sf, address);
 	if (description != NULL)
-		desktopcouch_document_contact_im_set_description (sf, description);
+		couchdb_document_contact_im_set_description (sf, description);
 	if (protocol != NULL)
-		desktopcouch_document_contact_im_set_protocol (sf, protocol);
+		couchdb_document_contact_im_set_protocol (sf, protocol);
 
 	return sf;
 }
 
 const char *
-desktopcouch_document_contact_im_get_address (CouchdbStructField *sf)
+couchdb_document_contact_im_get_address (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -1028,7 +1028,7 @@ desktopcouch_document_contact_im_get_address (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_im_set_address (CouchdbStructField *sf, const char *address)
+couchdb_document_contact_im_set_address (CouchdbStructField *sf, const char *address)
 {
 	g_return_if_fail (sf != NULL);
 	g_return_if_fail (address != NULL);
@@ -1037,7 +1037,7 @@ desktopcouch_document_contact_im_set_address (CouchdbStructField *sf, const char
 }
 
 const char *
-desktopcouch_document_contact_im_get_description (CouchdbStructField *sf)
+couchdb_document_contact_im_get_description (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -1045,7 +1045,7 @@ desktopcouch_document_contact_im_get_description (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_im_set_description (CouchdbStructField *sf, const char *description)
+couchdb_document_contact_im_set_description (CouchdbStructField *sf, const char *description)
 {
 	g_return_if_fail (sf != NULL);
 	g_return_if_fail (description != NULL);
@@ -1054,7 +1054,7 @@ desktopcouch_document_contact_im_set_description (CouchdbStructField *sf, const
 }
 
 const char *
-desktopcouch_document_contact_im_get_protocol (CouchdbStructField *sf)
+couchdb_document_contact_im_get_protocol (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -1062,7 +1062,7 @@ desktopcouch_document_contact_im_get_protocol (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_im_set_protocol (CouchdbStructField *sf, const char *protocol)
+couchdb_document_contact_im_set_protocol (CouchdbStructField *sf, const char *protocol)
 {
 	g_return_if_fail (sf != NULL);
 	g_return_if_fail (protocol != NULL);
@@ -1071,7 +1071,7 @@ desktopcouch_document_contact_im_set_protocol (CouchdbStructField *sf, const cha
 }
 
 CouchdbStructField *
-desktopcouch_document_contact_url_new (const char *uuid, const char *address, const char *description)
+couchdb_document_contact_url_new (const char *uuid, const char *address, const char *description)
 {
 	CouchdbStructField *sf;
 
@@ -1085,15 +1085,15 @@ desktopcouch_document_contact_url_new (const char *uuid, const char *address, co
 	}
 
 	if (address)
-		desktopcouch_document_contact_url_set_address (sf, address);
+		couchdb_document_contact_url_set_address (sf, address);
 	if (description)
-		desktopcouch_document_contact_url_set_description (sf, description);
+		couchdb_document_contact_url_set_description (sf, description);
 
 	return sf;
 }
 
 const char *
-desktopcouch_document_contact_url_get_address (CouchdbStructField *sf)
+couchdb_document_contact_url_get_address (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -1101,7 +1101,7 @@ desktopcouch_document_contact_url_get_address (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_url_set_address (CouchdbStructField *sf, const char *url)
+couchdb_document_contact_url_set_address (CouchdbStructField *sf, const char *url)
 {
 	g_return_if_fail (sf != NULL);
 	g_return_if_fail (url != NULL);
@@ -1110,7 +1110,7 @@ desktopcouch_document_contact_url_set_address (CouchdbStructField *sf, const cha
 }
 
 const char *
-desktopcouch_document_contact_url_get_description (CouchdbStructField *sf)
+couchdb_document_contact_url_get_description (CouchdbStructField *sf)
 {
 	g_return_val_if_fail (sf != NULL, NULL);
 
@@ -1118,7 +1118,7 @@ desktopcouch_document_contact_url_get_description (CouchdbStructField *sf)
 }
 
 void
-desktopcouch_document_contact_url_set_description (CouchdbStructField *sf, const char *description)
+couchdb_document_contact_url_set_description (CouchdbStructField *sf, const char *description)
 {
 	g_return_if_fail (sf != NULL);
 
diff --git a/couchdb-glib/couchdb-document-contact.h b/couchdb-glib/couchdb-document-contact.h
new file mode 100644
index 0000000..09359d0
--- /dev/null
+++ b/couchdb-glib/couchdb-document-contact.h
@@ -0,0 +1,225 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2010 Canonical Services Ltd (www.canonical.com)
+ *
+ * Authors: Rodrigo Moya <rodrigo moya canonical com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __COUCHDB_DOCUMENT_CONTACT_H__
+#define __COUCHDB_DOCUMENT_CONTACT_H__
+
+#include <couchdb-struct-field.h>
+#include <couchdb-document.h>
+
+G_BEGIN_DECLS
+
+#define COUCHDB_TYPE_DOCUMENT_CONTACT                (couchdb_document_contact_get_type ())
+#define COUCHDB_DOCUMENT_CONTACT(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), COUCHDB_TYPE_DOCUMENT_CONTACT, CouchdbDocumentContact))
+#define COUCHDB_IS_DOCUMENT_CONTACT(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COUCHDB_TYPE_DOCUMENT_CONTACT))
+#define COUCHDB_DOCUMENT_CONTACT_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), COUCHDB_TYPE_DOCUMENT_CONTACT, CouchdbDocumentContactClass))
+#define COUCHDB_IS_DOCUMENT_CONTACT_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), COUCHDB_TYPE_DOCUMENT_CONTACT))
+#define COUCHDB_DOCUMENT_CONTACTGET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), COUCHDB_TYPE_DOCUMENT_CONTACT, CouchdbDocumentContactClass))
+
+typedef struct {
+	CouchdbDocument parent;
+} CouchdbDocumentContact;
+
+typedef struct {
+	CouchdbDocumentClass parent_class;
+} CouchdbDocumentContactClass;
+
+GType       couchdb_document_contact_get_type (void);
+
+CouchdbDocumentContact *couchdb_document_contact_new (void);
+
+/*
+ * Top level functions to manipulate documents representing a contact
+ */
+
+const char *couchdb_document_contact_get_title (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_title (CouchdbDocumentContact *document, const char *title);
+const char *couchdb_document_contact_get_first_name (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_first_name (CouchdbDocumentContact *document, const char *first_name);
+const char *couchdb_document_contact_get_middle_name (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_middle_name (CouchdbDocumentContact *document, const char *middle_name);
+const char *couchdb_document_contact_get_last_name (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_last_name (CouchdbDocumentContact *document, const char *last_name);
+const char *couchdb_document_contact_get_suffix (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_suffix (CouchdbDocumentContact *document, const char *suffix);
+
+const char *couchdb_document_contact_get_nick_name (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_nick_name (CouchdbDocumentContact *document, const char *nick_name);
+const char *couchdb_document_contact_get_spouse_name (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_spouse_name (CouchdbDocumentContact *document, const char *spouse_name);
+const char *couchdb_document_contact_get_birth_date (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_birth_date (CouchdbDocumentContact *document, const char *birth_date);
+const char *couchdb_document_contact_get_wedding_date (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_wedding_date (CouchdbDocumentContact *document, const char *wedding_date);
+
+const char *couchdb_document_contact_get_company (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_company (CouchdbDocumentContact *document, const char *company);
+const char *couchdb_document_contact_get_department (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_department (CouchdbDocumentContact *document, const char *department);
+const char *couchdb_document_contact_get_job_title (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_job_title (CouchdbDocumentContact *document, const char *job_title);
+const char *couchdb_document_contact_get_manager_name (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_manager_name (CouchdbDocumentContact *document, const char *manager_name);
+const char *couchdb_document_contact_get_assistant_name (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_assistant_name (CouchdbDocumentContact *document, const char *assistant_name);
+const char *couchdb_document_contact_get_office (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_office (CouchdbDocumentContact *document, const char *office);
+
+GSList     *couchdb_document_contact_get_email_addresses (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_email_addresses (CouchdbDocumentContact *document, GSList *list);
+
+GSList     *couchdb_document_contact_get_phone_numbers (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_phone_numbers (CouchdbDocumentContact *document, GSList *list);
+
+GSList     *couchdb_document_contact_get_addresses (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_addresses (CouchdbDocumentContact *document, GSList *list);
+
+GSList     *couchdb_document_contact_get_im_addresses (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_im_addresses (CouchdbDocumentContact *document, GSList *list);
+
+GSList     *couchdb_document_contact_get_urls (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_urls (CouchdbDocumentContact *document, GSList *list);
+
+const char *couchdb_document_contact_get_categories (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_categories (CouchdbDocumentContact *document, const char *categories);
+
+const char *couchdb_document_contact_get_notes (CouchdbDocumentContact *document);
+void        couchdb_document_contact_set_notes (CouchdbDocumentContact *document, const char *notes);
+
+/*
+ * Utility functions to manipulate email addresses fields
+ */
+
+CouchdbStructField *couchdb_document_contact_email_new (const char *uuid, 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);
+
+#define COUCHDB_DOCUMENT_CONTACT_EMAIL_DESCRIPTION_HOME  "home"
+#define COUCHDB_DOCUMENT_CONTACT_EMAIL_DESCRIPTION_OTHER "other"
+#define COUCHDB_DOCUMENT_CONTACT_EMAIL_DESCRIPTION_WORK  "work"
+
+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
+ */
+
+CouchdbStructField *couchdb_document_contact_phone_new (const char *uuid, const char *number, const char *description, gint priority);
+gint                couchdb_document_contact_phone_get_priority (CouchdbStructField *sf);
+void                couchdb_document_contact_phone_set_priority (CouchdbStructField *sf, gint priority);
+const char         *couchdb_document_contact_phone_get_number (CouchdbStructField *sf);
+void                couchdb_document_contact_phone_set_number (CouchdbStructField *sf, const char *number);
+
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_ASSISTANT "assistant"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_CALLBACK  "callback"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_CAR       "car"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_COMPANY   "company"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_HOME      "home"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_HOME_FAX  "home fax"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_MOBILE    "mobile"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_OTHER     "other"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_OTHER_FAX "other fax"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_PAGER     "pager"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_PRIMARY   "primary"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_RADIO     "radio"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_TELEX     "telex"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_WORK      "work"
+#define COUCHDB_DOCUMENT_CONTACT_PHONE_DESCRIPTION_WORK_FAX  "work fax"
+
+const char         *couchdb_document_contact_phone_get_description (CouchdbStructField *sf);
+void                couchdb_document_contact_phone_set_description (CouchdbStructField *sf, const char *description);
+
+/*
+ * Utility functions to manipulate addresses
+ */
+CouchdbStructField *couchdb_document_contact_address_new (const char *uuid,
+							       const char *street,
+							       const char *ext_street,
+							       const char *city,
+							       const char *state,
+							       const char *country,
+							       const char *postalcode,
+							       const char *pobox,
+							       const char *description);
+const char         *couchdb_document_contact_address_get_street (CouchdbStructField *sf);
+void                couchdb_document_contact_address_set_street (CouchdbStructField *sf, const char *street);
+const char         *couchdb_document_contact_address_get_ext_street (CouchdbStructField *sf);
+void                couchdb_document_contact_address_set_ext_street (CouchdbStructField *sf, const char *ext_street);
+const char         *couchdb_document_contact_address_get_city (CouchdbStructField *sf);
+void                couchdb_document_contact_address_set_city (CouchdbStructField *sf, const char *city);
+const char         *couchdb_document_contact_address_get_state (CouchdbStructField *sf);
+void                couchdb_document_contact_address_set_state (CouchdbStructField *sf, const char *state);
+const char         *couchdb_document_contact_address_get_country (CouchdbStructField *sf);
+void                couchdb_document_contact_address_set_country (CouchdbStructField *sf, const char *country);
+const char         *couchdb_document_contact_address_get_postalcode (CouchdbStructField *sf);
+void                couchdb_document_contact_address_set_postalcode (CouchdbStructField *sf, const char *postalcode);
+const char         *couchdb_document_contact_address_get_pobox (CouchdbStructField *sf);
+void                couchdb_document_contact_address_set_pobox (CouchdbStructField *sf, const char *pobox);
+
+#define COUCHDB_DOCUMENT_CONTACT_ADDRESS_DESCRIPTION_HOME  "home"
+#define COUCHDB_DOCUMENT_CONTACT_ADDRESS_DESCRIPTION_OTHER "other"
+#define COUCHDB_DOCUMENT_CONTACT_ADDRESS_DESCRIPTION_WORK  "work"
+
+const char         *couchdb_document_contact_address_get_description (CouchdbStructField *sf);
+void                couchdb_document_contact_address_set_description (CouchdbStructField *sf, const char *description);
+
+/*
+ * Utility functions to manipulate IM addresses
+ */
+CouchdbStructField *couchdb_document_contact_im_new (const char *uuid,
+						     const char *address,
+						     const char *description,
+						     const char *protocol);
+const char         *couchdb_document_contact_im_get_address (CouchdbStructField *sf);
+void                couchdb_document_contact_im_set_address (CouchdbStructField *sf, const char *address);
+const char         *couchdb_document_contact_im_get_description (CouchdbStructField *sf);
+void                couchdb_document_contact_im_set_description (CouchdbStructField *sf, const char *description);
+
+#define COUCHDB_DOCUMENT_CONTACT_IM_PROTOCOL_AIM       "aim"
+#define COUCHDB_DOCUMENT_CONTACT_IM_PROTOCOL_GADU_GADU "gadu-gadu"
+#define COUCHDB_DOCUMENT_CONTACT_IM_PROTOCOL_GROUPWISE "groupwise"
+#define COUCHDB_DOCUMENT_CONTACT_IM_PROTOCOL_ICQ       "icq"
+#define COUCHDB_DOCUMENT_CONTACT_IM_PROTOCOL_IRC       "irc"
+#define COUCHDB_DOCUMENT_CONTACT_IM_PROTOCOL_JABBER    "jabber"
+#define COUCHDB_DOCUMENT_CONTACT_IM_PROTOCOL_MSN       "msn"
+#define COUCHDB_DOCUMENT_CONTACT_IM_PROTOCOL_SKYPE     "skype"
+#define COUCHDB_DOCUMENT_CONTACT_IM_PROTOCOL_YAHOO     "yahoo"
+
+const char         *couchdb_document_contact_im_get_protocol (CouchdbStructField *sf);
+void                couchdb_document_contact_im_set_protocol (CouchdbStructField *sf, const char *protocol);
+
+/*
+ * Utility functions to manipulate URLs
+ */
+CouchdbStructField *couchdb_document_contact_url_new (const char *uuid, const char *address, const char *description);
+const char         *couchdb_document_contact_url_get_address  (CouchdbStructField *sf);
+void                couchdb_document_contact_url_set_address (CouchdbStructField *sf, const char *address);
+
+#define COUCHDB_DOCUMENT_CONTACT_URL_DESCRIPTION_BLOG     "blog"
+#define COUCHDB_DOCUMENT_CONTACT_URL_DESCRIPTION_HOMEPAGE "home page"
+
+const char         *couchdb_document_contact_url_get_description (CouchdbStructField *sf);
+void                couchdb_document_contact_url_set_description (CouchdbStructField *sf, const char *description);
+
+G_END_DECLS
+
+#endif /* __COUCHDB_DOCUMENT_CONTACT_H__ */
diff --git a/couchdb-glib/couchdb-document-task.c b/couchdb-glib/couchdb-document-task.c
new file mode 100644
index 0000000..f33012e
--- /dev/null
+++ b/couchdb-glib/couchdb-document-task.c
@@ -0,0 +1,85 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Canonical Services Ltd (www.canonical.com)
+ *
+ * Authors: Miguel Angel Rodelas Delgado <miguel rodelas gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "couchdb-document-task.h"
+#include "utils.h"
+
+G_DEFINE_TYPE(CouchdbDocumentTask, couchdb_document_task, COUCHDB_TYPE_DOCUMENT)
+
+static void
+couchdb_document_task_class_init (CouchdbDocumentTaskClass *klass)
+{
+}
+
+static void
+couchdb_document_task_init (CouchdbDocumentTask *document)
+{
+	couchdb_document_set_record_type (COUCHDB_DOCUMENT (document), COUCHDB_RECORD_TYPE_TASK);
+}
+
+/**
+ * couchdb_document_task_new:
+ *
+ * Create a new #CouchdbDocumentTask object.
+ */
+CouchdbDocumentTask *
+couchdb_document_task_new (void)
+{
+	return g_object_new (COUCHDB_TYPE_DOCUMENT_TASK, NULL);
+}
+
+const char *
+couchdb_document_task_get_summary (CouchdbDocumentTask *document)
+{
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_TASK (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_task (COUCHDB_DOCUMENT (document)), NULL);
+
+	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "summary");
+}
+
+void
+couchdb_document_task_set_summary (CouchdbDocumentTask *document, const char *summary)
+{
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_TASK (document));
+	g_return_if_fail (couchdb_document_is_task (COUCHDB_DOCUMENT (document)));
+	g_return_if_fail (summary != NULL);
+
+	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "summary", summary);
+}
+
+const char *
+couchdb_document_task_get_description (CouchdbDocumentTask *document)
+{
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT_TASK (document), NULL);
+	g_return_val_if_fail (couchdb_document_is_task (COUCHDB_DOCUMENT (document)), NULL);
+
+	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "description");
+}
+
+void
+couchdb_document_task_set_description (CouchdbDocumentTask *document, const char *description)
+{
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT_TASK (document));
+	g_return_if_fail (couchdb_document_is_task (COUCHDB_DOCUMENT (document)));
+	g_return_if_fail (description != NULL);
+
+	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "description", description);
+}
diff --git a/couchdb-glib/couchdb-document-task.h b/couchdb-glib/couchdb-document-task.h
new file mode 100644
index 0000000..aef8a38
--- /dev/null
+++ b/couchdb-glib/couchdb-document-task.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2010 Canonical Services Ltd (www.canonical.com)
+ *
+ * Authors: Miguel Angel Rodelas Delgado <miguel rodelas gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __COUCHDB_DOCUMENT_TASK_H__
+#define __COUCHDB_DOCUMENT_TASK_H__
+
+#include <couchdb-struct-field.h>
+#include <couchdb-document.h>
+
+G_BEGIN_DECLS
+
+#define COUCHDB_TYPE_DOCUMENT_TASK                (couchdb_document_task_get_type ())
+#define COUCHDB_DOCUMENT_TASK(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), COUCHDB_TYPE_DOCUMENT_TASK, CouchdbDocumentTask))
+#define COUCHDB_IS_DOCUMENT_TASK(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COUCHDB_TYPE_DOCUMENT_TASK))
+#define COUCHDB_DOCUMENT_TASK_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), COUCHDB_TYPE_DOCUMENT_TASK, CouchdbDocumentTaskClass))
+#define COUCHDB_IS_DOCUMENT_TASK_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), COUCHDB_TYPE_DOCUMENT_TASK))
+#define COUCHDB_DOCUMENT_TASKGET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), COUCHDB_TYPE_DOCUMENT_TASK, CouchdbDocumentTaskClass))
+
+typedef struct {
+	CouchdbDocument parent;
+} CouchdbDocumentTask;
+
+typedef struct {
+	CouchdbDocumentClass parent_class;
+} CouchdbDocumentTaskClass;
+
+GType       couchdb_document_task_get_type (void);
+
+CouchdbDocumentTask *couchdb_document_task_new (void);
+
+const char *couchdb_document_task_get_summary (CouchdbDocumentTask *document);
+void        couchdb_document_task_set_summary (CouchdbDocumentTask *document, const char *summary);
+
+const char *couchdb_document_task_get_description (CouchdbDocumentTask *document);
+void        couchdb_document_task_set_description (CouchdbDocumentTask *document, const char *description);
+
+G_END_DECLS
+
+#endif /* __COUCHDB_DOCUMENT_TASK_H__ */
diff --git a/couchdb-glib/couchdb-document.c b/couchdb-glib/couchdb-document.c
index 84667a0..68a6e68 100644
--- a/couchdb-glib/couchdb-document.c
+++ b/couchdb-glib/couchdb-document.c
@@ -612,3 +612,111 @@ couchdb_document_get_json_object (CouchdbDocument *document)
 	
 	return document->priv->root_object;
 }
+
+/**
+ * couchdb_document_get_record_type:
+ * @document: A #CouchdbDocument object
+ *
+ * Retrieve the record type of the given document. Record types are special
+ * fields in the CouchDB documents, used in Couchdb, to identify
+ * standard records. All supported record types are listed at
+ * http://www.freedesktop.org/wiki/Specifications/desktopcouch#Formats.
+ *
+ * Return value: The record type of the given document.
+ */
+const char *
+couchdb_document_get_record_type (CouchdbDocument *document)
+{
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT (document), NULL);
+
+	return couchdb_document_get_string_field (COUCHDB_DOCUMENT (document), "record_type");
+}
+
+/**
+ * couchdb_document_set_record_type:
+ * @document: A #CouchdbDocument object
+ * @record_type: Record type to set the document to
+ *
+ * Set the record type of the given document.
+ */
+void
+couchdb_document_set_record_type (CouchdbDocument *document, const char *record_type)
+{
+	g_return_if_fail (COUCHDB_IS_DOCUMENT (document));
+	g_return_if_fail (record_type != NULL);
+
+	couchdb_document_set_string_field (COUCHDB_DOCUMENT (document), "record_type", record_type);
+}
+
+/**
+ * couchdb_document_get_application_annotations:
+ * @document: A #CouchdbDocument object
+ *
+ * Retrieve the application annotations for the given document.
+ *
+ * Application annotations is a special field (named "application_annotations"), used
+ * in couchdb to allow applications to set values on standard documents (as defined
+ * at http://www.freedesktop.org/wiki/Specifications/desktopcouch#Formats) that are
+ * not part of the standard, but still needed by the application.
+ *
+ * Return value: A #CouchdbStructField containing the value of the application
+ * annotations for the given document.
+ */
+CouchdbStructField *
+couchdb_document_get_application_annotations (CouchdbDocument *document)
+{
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT (document), NULL);
+
+	return couchdb_document_get_struct_field (COUCHDB_DOCUMENT (document), "application_annotations");
+}
+
+/**
+ * couchdb_document_set_application_annotations:
+ * @document: A #CouchdbDocument object
+ * @annotations: A #CouchdbStructField with the contents of the application_annotations field.
+ *
+ * Set the application annotations for the given document.
+ */
+void
+couchdb_document_set_application_annotations (CouchdbDocument *document, CouchdbStructField *annotations)
+{
+	g_return_if_fail (COUCHDB_IS_DOCUMENT (document));
+
+	couchdb_document_set_struct_field (COUCHDB_DOCUMENT (document), "application_annotations", annotations);
+}
+
+/**
+ * couchdb_document_is_contact:
+ * @document: A #CouchdbDocument object
+ *
+ * Check whether the given document represents a contact record, as specified
+ * at http://www.freedesktop.org/wiki/Specifications/desktopcouch/contact
+ *
+ * Return value: TRUE if the document represents a contact, FALSE otherwise.
+ */
+gboolean
+couchdb_document_is_contact (CouchdbDocument *document)
+{
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT (document), FALSE);
+
+	return !g_ascii_strcasecmp (couchdb_document_get_record_type (document),
+				    COUCHDB_RECORD_TYPE_CONTACT);
+}
+
+/**
+ * couchdb_document_is_task:
+ * @document: A #CouchdbDocument object
+ *
+ * Check whether the given document represents a contact record, as specified
+ * at http://www.freedesktop.org/wiki/Specifications/desktopcouch/task
+ *
+ * Return value: TRUE if the document represents a task, FALSE otherwise.
+ */
+gboolean
+couchdb_document_is_task (CouchdbDocument *document)
+{
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT (document), FALSE);
+
+	return !g_ascii_strcasecmp (couchdb_document_get_record_type (document),
+				    COUCHDB_RECORD_TYPE_TASK);
+}
diff --git a/couchdb-glib/couchdb-document.h b/couchdb-glib/couchdb-document.h
index 6b429fb..a952b6c 100644
--- a/couchdb-glib/couchdb-document.h
+++ b/couchdb-glib/couchdb-document.h
@@ -86,6 +86,23 @@ void                couchdb_document_foreach_attachment (CouchdbDocument *docume
 
 char               *couchdb_document_to_string (CouchdbDocument *document);
 
+/*
+ * Methods to deal with standard documents from Freedesktop specification
+ */
+const char         *couchdb_document_get_record_type (CouchdbDocument *document);
+void                couchdb_document_set_record_type (CouchdbDocument *document,
+						      const char *record_type);
+
+CouchdbStructField *couchdb_document_get_application_annotations (CouchdbDocument *document);
+void                couchdb_document_set_application_annotations (CouchdbDocument *document,
+								  CouchdbStructField *annotations);
+
+#define COUCHDB_RECORD_TYPE_CONTACT "http://www.freedesktop.org/wiki/Specifications/desktopcouch/contact";
+#define COUCHDB_RECORD_TYPE_TASK "http://www.freedesktop.org/wiki/Specifications/desktopcouch/task";
+
+gboolean            couchdb_document_is_contact (CouchdbDocument *document);
+gboolean            couchdb_document_is_task (CouchdbDocument *document);
+
 G_END_DECLS
 
 #endif /* __COUCHDB_DOCUMENT_H__ */
diff --git a/couchdb-glib/couchdb-glib.h b/couchdb-glib/couchdb-glib.h
index ea8ae7c..2282ce9 100644
--- a/couchdb-glib/couchdb-glib.h
+++ b/couchdb-glib/couchdb-glib.h
@@ -31,7 +31,9 @@
 #include <couchdb-database.h>
 #include <couchdb-design-document.h>
 #include <couchdb-document.h>
+#include <couchdb-document-contact.h>
 #include <couchdb-document-info.h>
+#include <couchdb-document-task.h>
 #include <couchdb-session.h>
 #include <couchdb-struct-field.h>
 
diff --git a/couchdb-glib/couchdb-session.c b/couchdb-glib/couchdb-session.c
index baa03bd..362ab91 100644
--- a/couchdb-glib/couchdb-session.c
+++ b/couchdb-glib/couchdb-session.c
@@ -139,7 +139,6 @@ couchdb_session_class_init (CouchdbSessionClass *klass)
 	object_class->finalize = couchdb_session_finalize;
 	object_class->set_property = couchdb_session_set_property;
 	object_class->get_property = couchdb_session_get_property;
-	klass->get_database = NULL;
 
 	g_object_class_install_property (object_class,
         	                         PROP_URI,
@@ -344,12 +343,8 @@ couchdb_session_get_database (CouchdbSession *session, const char *dbname, GErro
 	g_return_val_if_fail (dbname != NULL, NULL);
 
 	dbinfo = couchdb_session_get_database_info (session, dbname, error);
-	if (dbinfo != NULL) {
-		if (COUCHDB_SESSION_GET_CLASS (session)->get_database != NULL)
-			return COUCHDB_SESSION_GET_CLASS (session)->get_database (session, dbname);
-		else
-			return couchdb_database_new (session, dbname);
-	}
+	if (dbinfo != NULL)
+		return couchdb_database_new (session, dbname);
 
 	return NULL;
 }
diff --git a/couchdb-glib/couchdb-session.h b/couchdb-glib/couchdb-session.h
index c94bcef..e65c852 100644
--- a/couchdb-glib/couchdb-session.h
+++ b/couchdb-glib/couchdb-session.h
@@ -56,9 +56,6 @@ typedef struct {
 
 	void (* database_created) (CouchdbSession *session, const char *dbname);
 	void (* database_deleted) (CouchdbSession *session, const char *dbname);
-
-	/* Virtual methods */
-	CouchdbDatabase * (* get_database) (CouchdbSession *session, const char *dbname);
 } CouchdbSessionClass;
 
 GType                couchdb_session_get_type (void);
diff --git a/desktopcouch-glib/Makefile.am b/desktopcouch-glib/Makefile.am
index ec5532a..050e2b9 100644
--- a/desktopcouch-glib/Makefile.am
+++ b/desktopcouch-glib/Makefile.am
@@ -8,17 +8,11 @@ INCLUDES =				\
 lib_LTLIBRARIES = libdesktopcouch-glib-1.0.la
 
 libdesktopcouch_glib_1_0_la_headers =	\
-	desktopcouch-document.h		\
-	desktopcouch-document-contact.h	\
-	desktopcouch-document-task.h	\
 	desktopcouch-glib.h		\
 	desktopcouch-session.h
 
 libdesktopcouch_glib_1_0_la_SOURCES =		\
 	$(libdesktopcouch_glib_1_0_la_headers) 	\
-	desktopcouch-document.c			\
-	desktopcouch-document-contact.c		\
-	desktopcouch-document-task.c		\
 	desktopcouch-session.c
 
 libdesktopcouch_glib_1_0_la_LIBADD =				\
@@ -31,9 +25,6 @@ libdesktopcouch_glib_1_0_la_LDFLAGS =	\
 
 hdir = $(includedir)/desktopcouch-glib-1.0
 h_DATA = 				\
-	desktopcouch-document.h		\
-	desktopcouch-document-contact.h	\
-	desktopcouch-document-task.h	\
 	desktopcouch-glib.h		\
 	desktopcouch-session.h
 
diff --git a/desktopcouch-glib/desktopcouch-glib.h b/desktopcouch-glib/desktopcouch-glib.h
index a35be2b..e5ee60a 100644
--- a/desktopcouch-glib/desktopcouch-glib.h
+++ b/desktopcouch-glib/desktopcouch-glib.h
@@ -22,9 +22,6 @@
 #ifndef __DESKTOPCOUCH_GLIB_H__
 #define __DESKTOPCOUCH_GLIB_H__
 
-#include <desktopcouch-document.h>
-#include <desktopcouch-document-contact.h>
-#include <desktopcouch-document-task.h>
 #include <desktopcouch-session.h>
 
 #endif /* __DESKTOPCOUCH_GLIB_H__ */
diff --git a/desktopcouch-glib/desktopcouch-session.c b/desktopcouch-glib/desktopcouch-session.c
index f4adc41..12bcaf5 100644
--- a/desktopcouch-glib/desktopcouch-session.c
+++ b/desktopcouch-glib/desktopcouch-session.c
@@ -22,53 +22,8 @@
 #include <dbus/dbus-glib.h>
 #include <gnome-keyring.h>
 #include "utils.h"
-#include "desktopcouch-document-contact.h"
 #include "desktopcouch-session.h"
 
-typedef struct {
-	CouchdbDatabase parent;
-} DesktopcouchDatabase;
-
-typedef struct {
-	CouchdbDatabaseClass parent_class;
-} DesktopcouchDatabaseClass;
-
-G_DEFINE_TYPE(DesktopcouchDatabase, desktopcouch_database, COUCHDB_TYPE_DATABASE)
-
-static CouchdbDocument *
-desktopcouch_database_create_document_from_json (CouchdbDatabase *database, gpointer json_data)
-{
-	DesktopcouchDocument *document;
-
-	JsonObject *json_object = (JsonObject *) json_data;
-
-	if (json_object_has_member (json_object, "record_type")) {
-		if (g_strcmp0 (json_object_get_string_member (json_object, "record_type"),
-			       DESKTOPCOUCH_RECORD_TYPE_CONTACT) == 0)
-			document = desktopcouch_document_contact_new ();
-		else
-			document = desktopcouch_document_new ();
-	} else
-		document = desktopcouch_document_new ();
-
-	couchdb_document_set_from_json_object (COUCHDB_DOCUMENT (document), json_object);
-
-	return COUCHDB_DOCUMENT (document);
-}
-
-static void
-desktopcouch_database_class_init (DesktopcouchDatabaseClass *klass)
-{
-	CouchdbDatabaseClass *db_class = COUCHDB_DATABASE_CLASS (klass);
-
-	db_class->create_document_from_json = desktopcouch_database_create_document_from_json;
-}
-
-static void
-desktopcouch_database_init (DesktopcouchDatabase *database)
-{
-}
-
 G_DEFINE_TYPE(DesktopcouchSession, desktopcouch_session, COUCHDB_TYPE_SESSION)
 
 static void
@@ -77,23 +32,12 @@ desktopcouch_session_finalize (GObject *object)
 	G_OBJECT_CLASS (desktopcouch_session_parent_class)->finalize (object);
 }
 
-static CouchdbDatabase *
-desktopcouch_session_get_database (CouchdbSession *session, const char *dbname)
-{
-	return g_object_new (desktopcouch_database_get_type (),
-			     "session", session,
-			     "database_name", dbname,
-			     NULL);
-}
-
 static void
 desktopcouch_session_class_init (DesktopcouchSessionClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	CouchdbSessionClass *session_class = COUCHDB_SESSION_CLASS (klass);
 
 	object_class->finalize = desktopcouch_session_finalize;
-	session_class->get_database = desktopcouch_session_get_database;
 }
 
 static void



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