[couchdb-glib] Deprecate CouchdbDocumentInfo class



commit fa2707b2210bbfafb7c5ac91956d95570b1526ed
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Thu Mar 24 16:43:12 2011 +0100

    Deprecate CouchdbDocumentInfo class

 couchdb-glib/couchdb-database.c      |    8 ++++----
 couchdb-glib/couchdb-database.h      |    2 ++
 couchdb-glib/couchdb-document-info.c |    2 +-
 couchdb-glib/couchdb-glib.h          |    2 ++
 tests/test-couchdb-glib.c            |   22 +++++-----------------
 tests/test-list-databases.c          |   13 ++-----------
 6 files changed, 16 insertions(+), 33 deletions(-)
---
diff --git a/couchdb-glib/couchdb-database.c b/couchdb-glib/couchdb-database.c
index 4dd7b2b..3a945ff 100644
--- a/couchdb-glib/couchdb-database.c
+++ b/couchdb-glib/couchdb-database.c
@@ -242,6 +242,8 @@ call_all_docs_uri (CouchdbSession *session, const char *url, JsonParser *parser,
 	return rows;
 }
 
+#ifdef COUCHDB_ENABLE_DEPRECATED
+
 /**
  * couchdb_database_list_documents:
  * @database: A #CouchdbDatabase object
@@ -299,6 +301,7 @@ couchdb_database_list_documents (CouchdbDatabase *database, GError **error)
 
 	return doclist;
 }
+#endif 
 
 /**
  * couchdb_database_get_design_documents:
@@ -510,10 +513,7 @@ couchdb_database_free_document_list (GSList *doclist)
 
 		doclist = g_slist_remove (doclist, data);
 
-		if (COUCHDB_IS_DOCUMENT (data))
-			g_object_unref (G_OBJECT (data));
-		else
-			couchdb_document_info_unref (data);
+		g_object_unref (G_OBJECT (data));
 	}
 }
 
diff --git a/couchdb-glib/couchdb-database.h b/couchdb-glib/couchdb-database.h
index 072aa7a..71f0986 100644
--- a/couchdb-glib/couchdb-database.h
+++ b/couchdb-glib/couchdb-database.h
@@ -55,7 +55,9 @@ typedef struct {
 GType            couchdb_database_get_type (void);
 CouchdbDatabase *couchdb_database_new (CouchdbSession *session, const char *dbname);
 
+#ifdef COUCHDB_ENABLE_DEPRECATED
 GSList          *couchdb_database_list_documents (CouchdbDatabase *database, GError **error);
+#endif
 GSList          *couchdb_database_get_design_documents (CouchdbDatabase *database, GError **error);
 GSList          *couchdb_database_get_all_documents (CouchdbDatabase *database, GError **error);
 GSList          *couchdb_database_execute_view (CouchdbDatabase *database,
diff --git a/couchdb-glib/couchdb-document-info.c b/couchdb-glib/couchdb-document-info.c
index cf8b4e7..cc82ee5 100644
--- a/couchdb-glib/couchdb-document-info.c
+++ b/couchdb-glib/couchdb-document-info.c
@@ -26,7 +26,7 @@
 G_DEFINE_BOXED_TYPE(CouchdbDocumentInfo, couchdb_document_info, couchdb_document_info_ref, couchdb_document_info_unref);
 
 struct _CouchdbDocumentInfo {
-	gint ref_count;
+	volatile gint ref_count;
 
 	char *docid;
 	char *revision;
diff --git a/couchdb-glib/couchdb-glib.h b/couchdb-glib/couchdb-glib.h
index 7a99154..9b30e42 100644
--- a/couchdb-glib/couchdb-glib.h
+++ b/couchdb-glib/couchdb-glib.h
@@ -32,7 +32,9 @@
 #include <couchdb-design-document.h>
 #include <couchdb-document.h>
 #include <couchdb-document-contact.h>
+#ifdef COUCHDB_ENABLE_DEPRECATED
 #include <couchdb-document-info.h>
+#endif
 #include <couchdb-document-task.h>
 #include <couchdb-query.h>
 #include <couchdb-response.h>
diff --git a/tests/test-couchdb-glib.c b/tests/test-couchdb-glib.c
index cdd8634..e2c716d 100644
--- a/tests/test-couchdb-glib.c
+++ b/tests/test-couchdb-glib.c
@@ -129,7 +129,7 @@ test_list_databases (void)
 
 		/* Get list of documents to compare against couchdb_database_info_get_documents_count */
 		error = NULL;
-		doclist = couchdb_database_list_documents (database, &error);
+		doclist = couchdb_database_get_all_documents (database, &error);
 		g_assert (error == NULL);
 		g_assert (g_slist_length (doclist) == couchdb_database_info_get_documents_count (dbinfo));
 		if (doclist)
@@ -160,31 +160,19 @@ test_list_documents (void)
 		g_assert (database != NULL);
 
 		error = NULL;
-		doclist = couchdb_database_list_documents (database, &error);
+		doclist = couchdb_database_get_all_documents (database, &error);
 		g_assert (error == NULL);
 
 		while (doclist) {
-			CouchdbDocumentInfo *doc_info = doclist->data;
-			CouchdbDocument *document;
+			CouchdbDocument *document = COUCHDB_DOCUMENT (doclist->data);
 			char *str;
 
-			error = NULL;
-			document = couchdb_database_get_document (database,
-								  couchdb_document_info_get_docid (doc_info),
-								  &error);
-			g_assert (error == NULL);
-			g_assert (document != NULL);
-			g_assert (g_strcmp0 (couchdb_document_info_get_docid (doc_info), couchdb_document_get_id (document)) == 0);
-			g_assert (g_strcmp0 (couchdb_document_info_get_revision (doc_info), couchdb_document_get_revision (document)) == 0);
-
 			str = couchdb_document_to_string (document);
 			g_assert (str != NULL);
 			g_free (str);
 
-			g_object_unref (G_OBJECT (document));
-
-			doclist = g_slist_remove (doclist, doc_info);
-			couchdb_document_info_unref (doc_info);
+			doclist = g_slist_remove (doclist, document);
+			g_object_unref (document);
 		}
 
 		dblist = g_slist_remove (dblist, dblist->data);
diff --git a/tests/test-list-databases.c b/tests/test-list-databases.c
index e4d0c6a..4c7908e 100644
--- a/tests/test-list-databases.c
+++ b/tests/test-list-databases.c
@@ -80,19 +80,14 @@ main (int argc, char *argv[])
 		g_assert (database != NULL);
 
 		error = NULL;
-		doclist = couchdb_database_list_documents (database, &error);
+		doclist = couchdb_database_get_all_documents (database, &error);
 		if (doclist) {
 			GSList *sl_doc;
 
 			g_print ("\tDocuments:\n");
 			for (sl_doc = doclist; sl_doc != NULL; sl_doc = sl_doc->next) {
-				CouchdbDocumentInfo *doc_info = sl_doc->data;
-				CouchdbDocument *document;
+				CouchdbDocument *document = COUCHDB_DOCUMENT (sl_doc->data);
 
-				error = NULL;
-				document = couchdb_database_get_document (database,
-									  couchdb_document_info_get_docid (doc_info),
-									  &error);
 				if (document) {
 					char *json;
 
@@ -105,10 +100,6 @@ main (int argc, char *argv[])
 					g_free (json);
 
 					g_object_unref (G_OBJECT (document));
-				} else {
-					g_print ("\t\t%s\t(rev: %s)\n",
-						 couchdb_document_info_get_docid (doc_info),
-						 couchdb_document_info_get_revision (doc_info));
 				}
 			}
 



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