[evolution-couchdb] Build with evolution* >= 3.0.0



commit 6cd22b62265819819855b5d212677210414176f9
Author: Milan Crha <mcrha redhat com>
Date:   Wed May 25 11:04:24 2011 +0200

    Build with evolution* >= 3.0.0

 addressbook/e-book-backend-couchdb.c |  322 ++++++++++++++++++++++++---------
 configure.ac                         |   31 +++-
 2 files changed, 256 insertions(+), 97 deletions(-)
---
diff --git a/addressbook/e-book-backend-couchdb.c b/addressbook/e-book-backend-couchdb.c
index 735cade..e17d75d 100644
--- a/addressbook/e-book-backend-couchdb.c
+++ b/addressbook/e-book-backend-couchdb.c
@@ -50,6 +50,72 @@ e_book_backend_couchdb_error_quark (void)
 }
 #endif
 
+static EContactField supported_fields[] = {
+	/* Basic fields */
+	E_CONTACT_UID,
+	E_CONTACT_GIVEN_NAME,
+	E_CONTACT_FAMILY_NAME,
+	E_CONTACT_FULL_NAME,
+	E_CONTACT_NAME,
+	E_CONTACT_NICKNAME,
+	E_CONTACT_SPOUSE,
+	E_CONTACT_BIRTH_DATE,
+	E_CONTACT_ANNIVERSARY,
+	E_CONTACT_NOTE,
+	E_CONTACT_CATEGORIES,
+	E_CONTACT_REV,
+
+	/* URLS */
+	E_CONTACT_HOMEPAGE_URL,
+	E_CONTACT_BLOG_URL,
+
+	/* Company fields */
+	E_CONTACT_ORG,
+	E_CONTACT_ORG_UNIT,
+	E_CONTACT_TITLE,
+	E_CONTACT_MANAGER,
+	E_CONTACT_ASSISTANT,
+	E_CONTACT_OFFICE,
+
+	/* Email addresses */
+	E_CONTACT_EMAIL_1,
+	E_CONTACT_EMAIL_2,
+	E_CONTACT_EMAIL_3,
+	E_CONTACT_EMAIL_4,
+
+	/* Phone numbers */
+	E_CONTACT_PHONE_HOME,
+	E_CONTACT_PHONE_HOME_FAX,
+	E_CONTACT_PHONE_BUSINESS,
+	E_CONTACT_PHONE_BUSINESS_FAX,
+	E_CONTACT_PHONE_OTHER,
+	E_CONTACT_PHONE_OTHER_FAX,
+	E_CONTACT_PHONE_PAGER,
+	E_CONTACT_PHONE_MOBILE,
+	E_CONTACT_PHONE_ASSISTANT,
+	E_CONTACT_PHONE_CALLBACK,
+	E_CONTACT_PHONE_CAR,
+	E_CONTACT_PHONE_PRIMARY,
+	E_CONTACT_PHONE_RADIO,
+	E_CONTACT_PHONE_TELEX,
+	E_CONTACT_PHONE_COMPANY,
+
+	/* Postal addresses */
+	E_CONTACT_ADDRESS_HOME,
+	E_CONTACT_ADDRESS_WORK,
+	E_CONTACT_ADDRESS_OTHER,
+
+	/* IM addresses */
+	E_CONTACT_IM_AIM,
+	E_CONTACT_IM_GADUGADU,
+	E_CONTACT_IM_GROUPWISE,
+	E_CONTACT_IM_ICQ,
+	E_CONTACT_IM_JABBER,
+	E_CONTACT_IM_MSN,
+	E_CONTACT_IM_SKYPE,
+	E_CONTACT_IM_YAHOO
+};
+
 static void
 get_current_time (gchar time_string[100])
 {
@@ -974,7 +1040,14 @@ document_deleted_cb (CouchdbDatabase *database, const char *docid, gpointer user
 	e_book_backend_notify_remove (E_BOOK_BACKEND (couchdb_backend), docid);
 }
 
-#if EDS_CHECK_VERSION(2, 31, 0)
+#if EDS_CHECK_VERSION(3, 1, 2)
+static void
+e_book_backend_couchdb_open (EBookBackend *backend,
+			     EDataBook *book,
+			     guint32 opid,
+			     GCancellable *cancellable,
+			     gboolean only_if_exists)
+#elif EDS_CHECK_VERSION(2, 31, 0)
 static void
 e_book_backend_couchdb_load_source (EBookBackend *backend,
 				    ESource *source,
@@ -994,6 +1067,9 @@ e_book_backend_couchdb_load_source (EBookBackend *backend,
 	GSList *doc_list, *sl;
 	const gchar *db_name;
 	EBookBackendCouchDB *couchdb_backend = E_BOOK_BACKEND_COUCHDB (backend);
+#if EDS_CHECK_VERSION(3, 1, 2)
+	ESource *source = e_book_backend_get_source (backend);
+#endif
 
 #if EDS_CHECK_VERSION(2, 31, 0)
 	g_return_if_fail (E_IS_BOOK_BACKEND_COUCHDB (couchdb_backend));
@@ -1018,7 +1094,10 @@ e_book_backend_couchdb_load_source (EBookBackend *backend,
 	property = e_source_get_property (source, "couchdb_instance");
 	if (g_strcmp0 (property, "user") == 0) {
 		if (! (couchdb_backend->couchdb = COUCHDB_SESSION (desktopcouch_session_new ()))) {
-#if EDS_CHECK_VERSION(2, 31, 0)
+#if EDS_CHECK_VERSION(3, 1, 2)
+			e_book_backend_notify_opened (backend, e_data_book_create_error (E_DATA_BOOK_STATUS_OTHER_ERROR, _("Could not create DesktopcouchSession object")));
+			return;
+#elif EDS_CHECK_VERSION(2, 31, 0)
 			g_set_error (ret_error, ERROR_QUARK, 100, _("Could not create DesktopcouchSession object"));
 			return;
 #else
@@ -1036,7 +1115,10 @@ e_book_backend_couchdb_load_source (EBookBackend *backend,
 
 		if (! (couchdb_backend->couchdb = couchdb_session_new (uri))) {
 			g_free (uri);
-#if EDS_CHECK_VERSION(2, 31, 0)
+#if EDS_CHECK_VERSION(3, 1, 2)
+			e_book_backend_notify_opened (backend, e_data_book_create_error (E_DATA_BOOK_STATUS_OTHER_ERROR, _("Could not create CouchdbSession object")));
+			return;
+#elif EDS_CHECK_VERSION(2, 31, 0)
 			g_set_error (ret_error, ERROR_QUARK, 100, _("Could not create CouchdbSession object"));
 			return;
 #else
@@ -1061,7 +1143,15 @@ e_book_backend_couchdb_load_source (EBookBackend *backend,
 			g_warning ("Could not get CouchDB database info: %s", error->message);
 
 		if (only_if_exists) {
-#if EDS_CHECK_VERSION(2, 31, 0)
+#if EDS_CHECK_VERSION(3, 1, 2)
+			if (error) {
+				e_book_backend_notify_opened (backend, e_data_book_create_error (E_DATA_BOOK_STATUS_NO_SUCH_BOOK, error->message));
+				g_error_free (error);
+			} else {
+				e_book_backend_notify_opened (backend, e_data_book_create_error_fmt (E_DATA_BOOK_STATUS_NO_SUCH_BOOK, _("Could not open database %s"), db_name));
+			}
+			return;
+#elif EDS_CHECK_VERSION(2, 31, 0)
 			if (error) {
 				g_propagate_error (ret_error, error);
 				g_error_free (error);
@@ -1082,7 +1172,9 @@ e_book_backend_couchdb_load_source (EBookBackend *backend,
 		if (!couchdb_session_create_database (couchdb_backend->couchdb,
 						      db_name,
 						      &error)) {
-#if EDS_CHECK_VERSION(2, 31, 0)
+#if EDS_CHECK_VERSION(3, 1, 2)
+			e_book_backend_notify_opened (backend, e_data_book_create_error (E_DATA_BOOK_STATUS_PERMISSION_DENIED, error->message));
+#elif EDS_CHECK_VERSION(2, 31, 0)
 			g_propagate_error (ret_error, error);
 #endif
 			g_warning ("Could not create 'contacts' database: %s", error->message);
@@ -1141,10 +1233,16 @@ e_book_backend_couchdb_load_source (EBookBackend *backend,
 	g_signal_connect (G_OBJECT (couchdb_backend->database), "document_deleted",
 			  G_CALLBACK (document_deleted_cb), couchdb_backend);
 	couchdb_database_listen_for_changes (couchdb_backend->database);
-
+#if EDS_CHECK_VERSION(3, 1, 2)
+	e_book_backend_notify_readonly (backend, FALSE);
+#else
 	e_book_backend_set_is_loaded (backend, TRUE);
 	e_book_backend_set_is_writable (backend, TRUE);
-#if EDS_CHECK_VERSION(2, 31, 0)
+#endif
+#if EDS_CHECK_VERSION(3, 1, 2)
+	e_book_backend_notify_online (backend, TRUE);
+	e_book_backend_notify_opened (backend, NULL);
+#elif EDS_CHECK_VERSION(2, 31, 0)
 	e_book_backend_notify_connection_status (backend, TRUE);
 #else
 	return GNOME_Evolution_Addressbook_Success;
@@ -1152,7 +1250,13 @@ e_book_backend_couchdb_load_source (EBookBackend *backend,
 }
 
 static void
-e_book_backend_couchdb_remove (EBookBackend *backend, EDataBook *book, guint32 opid)
+e_book_backend_couchdb_remove (EBookBackend *backend,
+			       EDataBook *book,
+			       guint32 opid
+#if EDS_CHECK_VERSION(3, 1, 2)
+			     , GCancellable *cancellable
+#endif
+			      )
 {
 	EBookBackendCouchDB *couchdb_backend = E_BOOK_BACKEND_COUCHDB (backend);
 
@@ -1173,12 +1277,6 @@ e_book_backend_couchdb_remove (EBookBackend *backend, EDataBook *book, guint32 o
 #endif
 }
 
-static char *
-e_book_backend_couchdb_get_static_capabilities (EBookBackend *backend)
-{
-	return g_strdup ("local,do-initial-query,bulk-removes");
-}
-
 static EContact *
 put_document (EBookBackendCouchDB *couchdb_backend, CouchdbDocument *document, GError **error)
 {
@@ -1207,6 +1305,9 @@ static void
 e_book_backend_couchdb_create_contact (EBookBackend *backend,
 				       EDataBook *book,
 				       guint32 opid,
+#if EDS_CHECK_VERSION(3, 1, 2)
+				       GCancellable *cancellable,
+#endif
 				       const char *vcard)
 {
 	EContact *contact, *new_contact;
@@ -1242,9 +1343,19 @@ static void
 e_book_backend_couchdb_remove_contacts (EBookBackend *backend,
 					EDataBook *book,
 					guint32 opid,
+#if EDS_CHECK_VERSION(3, 1, 2)
+					GCancellable *cancellable,
+					const GSList *id_list)
+#else
 					GList *id_list)
+#endif
 {
+#if EDS_CHECK_VERSION(3, 1, 2)
+	const GSList *l;
+	GSList *deleted_ids = NULL;
+#else
 	GList *l, *deleted_ids = NULL;
+#endif
 	GError *error = NULL;
 	EBookBackendCouchDB *couchdb_backend = E_BOOK_BACKEND_COUCHDB (backend);
 
@@ -1278,7 +1389,11 @@ e_book_backend_couchdb_remove_contacts (EBookBackend *backend,
 
 				/* Now put the new revision of the document */
 				if (couchdb_database_put_document (couchdb_backend->database, document, &error)) {
+					#if EDS_CHECK_VERSION(3, 1, 2)
+					deleted_ids = g_slist_append (deleted_ids, (gpointer) uid);
+					#else
 					deleted_ids = g_list_append (deleted_ids, (gpointer) uid);
+					#endif
 					e_book_backend_cache_remove_contact (couchdb_backend->cache, uid);
 				} else {
 					if (error != NULL)
@@ -1295,7 +1410,11 @@ e_book_backend_couchdb_remove_contacts (EBookBackend *backend,
 				g_object_unref (private_annotations);
 			} else {
 				if (couchdb_database_delete_document (couchdb_backend->database, document, &error)) {
+					#if EDS_CHECK_VERSION(3, 1, 2)
+					deleted_ids = g_slist_append (deleted_ids, (gpointer) uid);
+					#else
 					deleted_ids = g_list_append (deleted_ids, (gpointer) uid);
+					#endif
 					e_book_backend_cache_remove_contact (couchdb_backend->cache, uid);
 					g_hash_table_remove (couchdb_backend->revisions, uid);
 				} else {
@@ -1324,7 +1443,11 @@ e_book_backend_couchdb_remove_contacts (EBookBackend *backend,
 		e_data_book_respond_remove_contacts (book, opid,
 						     GNOME_Evolution_Addressbook_Success, deleted_ids);
 #endif
+		#if EDS_CHECK_VERSION(3, 1, 2)
+		g_slist_free (deleted_ids);
+		#else
 		g_list_free (deleted_ids);
+		#endif
 	} else {
 #if EDS_CHECK_VERSION(2, 31, 0)
 		if (error == NULL)
@@ -1341,6 +1464,9 @@ static void
 e_book_backend_couchdb_modify_contact (EBookBackend *backend,
 				       EDataBook *book,
 				       guint32 opid,
+#if EDS_CHECK_VERSION(3, 1, 2)
+				       GCancellable *cancellable,
+#endif
 				       const char *vcard)
 {
 	EContact *contact, *new_contact;
@@ -1376,6 +1502,9 @@ static void
 e_book_backend_couchdb_get_contact (EBookBackend *backend,
 				    EDataBook *book,
 				    guint32 opid,
+#if EDS_CHECK_VERSION(3, 1, 2)
+				    GCancellable *cancellable,
+#endif
 				    const char *id)
 {
 	EContact *contact;
@@ -1413,9 +1542,18 @@ e_book_backend_couchdb_get_contact (EBookBackend *backend,
 static void
 e_book_backend_couchdb_get_contact_list (EBookBackend *backend,
 					 EDataBook *book,
-					 guint32 opid, const char *query)
+					 guint32 opid,
+#if EDS_CHECK_VERSION(3, 1, 2)
+					 GCancellable *cancellable,
+#endif
+					 const char *query)
 {
-	GList *doc_list, *contacts = NULL;
+	GList *doc_list;
+#if EDS_CHECK_VERSION(3, 1, 2)
+	GSList *contacts = NULL;
+#else
+	GList *contacts = NULL;
+#endif
 	EBookBackendCouchDB *couchdb_backend = E_BOOK_BACKEND_COUCHDB (backend);
 
 	/* Get the list of documents from cache */
@@ -1425,8 +1563,13 @@ e_book_backend_couchdb_get_contact_list (EBookBackend *backend,
 		EContact *contact = E_CONTACT (doc_list->data);
 
 		vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
-		if (vcard != NULL)
+		if (vcard != NULL) {
+			#if EDS_CHECK_VERSION(3, 1, 2)
+			contacts = g_slist_prepend (contacts, vcard);
+			#else
 			contacts = g_list_prepend (contacts, vcard);
+			#endif
+		}
 
 		doc_list = g_list_remove (doc_list, contact);
 		g_object_unref (G_OBJECT (contact));
@@ -1437,6 +1580,12 @@ e_book_backend_couchdb_get_contact_list (EBookBackend *backend,
 #else
 	e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_Success, contacts);
 #endif
+	#if EDS_CHECK_VERSION(3, 1, 2)
+	g_slist_foreach (contacts, (GFunc) g_free, NULL);
+	g_slist_free (contacts);
+	#else
+	g_list_free (contacts);
+	#endif
 }
 
 static void
@@ -1479,6 +1628,57 @@ e_book_backend_couchdb_stop_book_view (EBookBackend *backend,
 	e_book_backend_remove_book_view (backend, book_view);
 }
 
+#if EDS_CHECK_VERSION(3, 1, 2)
+static void
+e_book_backend_couchdb_authenticate_user (EBookBackend *backend,
+					  GCancellable *cancellable,
+					  ECredentials *credentials)
+{
+}
+
+static void
+e_book_backend_couchdb_get_backend_property (EBookBackend *backend,
+					     EDataBook *book,
+					     guint32 opid,
+					     GCancellable *cancellable,
+					     const gchar *prop_name)
+{
+	g_return_if_fail (backend != NULL);
+	g_return_if_fail (prop_name != NULL);
+
+	if (g_str_equal (prop_name, CLIENT_BACKEND_PROPERTY_CAPABILITIES)) {
+		e_data_book_respond_get_backend_property (book, opid, NULL, "local,do-initial-query,bulk-removes");
+	} else if (g_str_equal (prop_name, BOOK_BACKEND_PROPERTY_REQUIRED_FIELDS)) {
+		e_data_book_respond_get_backend_property (book, opid, NULL, e_contact_field_name (E_CONTACT_GIVEN_NAME));
+	} else if (g_str_equal (prop_name, BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS)) {
+		gint ii;
+		gchar *value;
+		GSList *fields = NULL;
+
+		for (ii = 0; ii < G_N_ELEMENTS (supported_fields); ii++) {
+			fields = g_slist_prepend (fields, (gpointer) e_contact_field_name (supported_fields[ii]));
+		}
+		fields = g_slist_reverse (fields);
+		value = e_data_book_string_slist_to_comma_string (fields);
+
+		e_data_book_respond_get_backend_property (book, opid, NULL, value);
+
+		g_slist_free (fields);
+		g_free (value);
+	} else if (g_str_equal (prop_name, BOOK_BACKEND_PROPERTY_SUPPORTED_AUTH_METHODS)) {
+		e_data_book_respond_get_backend_property (book, opid, NULL, "plain/password");
+	} else {
+		(* E_BOOK_BACKEND_CLASS (e_book_backend_couchdb_parent_class)->get_backend_property) (backend, book, opid, cancellable, prop_name);
+	}
+}
+
+#else /* EDS_CHECK_VERSION(3, 1, 2) */
+static char *
+e_book_backend_couchdb_get_static_capabilities (EBookBackend *backend)
+{
+	return g_strdup ("local,do-initial-query,bulk-removes");
+}
+
 static void
 e_book_backend_couchdb_get_changes (EBookBackend *backend,
 				    EDataBook *book,
@@ -1525,70 +1725,12 @@ e_book_backend_couchdb_get_supported_fields (EBookBackend *backend,
 					     guint32 opid)
 {
 	GList *fields = NULL;
+	gint ii;
 
-	/* Basic fields */
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_UID)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_GIVEN_NAME)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FAMILY_NAME)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_FULL_NAME)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NAME)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NICKNAME)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_SPOUSE)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_BIRTH_DATE)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ANNIVERSARY)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_NOTE)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_CATEGORIES)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_REV)));
-
-	/* URLS */
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_HOMEPAGE_URL)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_BLOG_URL)));
-
-	/* Company fields */
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ORG)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ORG_UNIT)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_TITLE)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_MANAGER)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ASSISTANT)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_OFFICE)));
-
-	/* Email addresses */
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_1)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_2)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_3)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_EMAIL_4)));
-
-	/* Phone numbers */
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_HOME)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_HOME_FAX)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_BUSINESS)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_BUSINESS_FAX)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_OTHER)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_OTHER_FAX)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_PAGER)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_MOBILE)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_ASSISTANT)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_CALLBACK)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_CAR)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_PRIMARY)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_RADIO)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_TELEX)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_PHONE_COMPANY)));
-
-	/* Postal addresses */
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_HOME)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_WORK)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_ADDRESS_OTHER)));
-
-	/* IM addresses */
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_AIM)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_GADUGADU)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_GROUPWISE)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_ICQ)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_JABBER)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_MSN)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_SKYPE)));
-	fields = g_list_append (fields, g_strdup (e_contact_field_name (E_CONTACT_IM_YAHOO)));
+	for (ii = 0; ii < G_N_ELEMENTS (supported_fields); ii++) {
+		fields = g_list_prepend (fields, (gpointer) e_contact_field_name (supported_fields[ii]));
+	}
+	fields = g_list_reverse (fields);
 
 #if EDS_CHECK_VERSION(2, 31, 0)
 	e_data_book_respond_get_supported_fields (book, opid, NULL, fields);
@@ -1597,7 +1739,6 @@ e_book_backend_couchdb_get_supported_fields (EBookBackend *backend,
 						  GNOME_Evolution_Addressbook_Success, fields);
 #endif
 
-	g_list_foreach (fields, (GFunc) g_free, NULL);
 	g_list_free (fields);
 }
 
@@ -1640,6 +1781,7 @@ e_book_backend_couchdb_set_mode (EBookBackend *backend, GNOME_Evolution_Addressb
 #endif
 {
 }
+#endif /* else of EDS_CHECK_VERSION(3, 1, 2) */
 
 /**
  * e_book_backend_couchdb_new:
@@ -1687,9 +1829,19 @@ e_book_backend_couchdb_class_init (EBookBackendCouchDBClass *klass)
 
 	parent_class = E_BOOK_BACKEND_CLASS (klass);
 
+#if EDS_CHECK_VERSION(3, 1, 2)
+	parent_class->open                    = e_book_backend_couchdb_open;
+	parent_class->get_backend_property    = e_book_backend_couchdb_get_backend_property;
+#else
 	parent_class->load_source             = e_book_backend_couchdb_load_source;
 	parent_class->get_static_capabilities = e_book_backend_couchdb_get_static_capabilities;
-
+	parent_class->get_changes             = e_book_backend_couchdb_get_changes;
+	parent_class->get_required_fields     = e_book_backend_couchdb_get_required_fields;
+	parent_class->get_supported_fields    = e_book_backend_couchdb_get_supported_fields;
+	parent_class->get_supported_auth_methods = e_book_backend_couchdb_get_supported_auth_methods;
+	parent_class->cancel_operation        = e_book_backend_couchdb_cancel_operation;
+	parent_class->set_mode                = e_book_backend_couchdb_set_mode;
+#endif
 	parent_class->create_contact          = e_book_backend_couchdb_create_contact;
 	parent_class->remove_contacts         = e_book_backend_couchdb_remove_contacts;
 	parent_class->modify_contact          = e_book_backend_couchdb_modify_contact;
@@ -1697,14 +1849,8 @@ e_book_backend_couchdb_class_init (EBookBackendCouchDBClass *klass)
 	parent_class->get_contact_list        = e_book_backend_couchdb_get_contact_list;
 	parent_class->start_book_view         = e_book_backend_couchdb_start_book_view;
 	parent_class->stop_book_view          = e_book_backend_couchdb_stop_book_view;
-	parent_class->get_changes             = e_book_backend_couchdb_get_changes;
 	parent_class->authenticate_user       = e_book_backend_couchdb_authenticate_user;
-	parent_class->get_required_fields     = e_book_backend_couchdb_get_required_fields;
-	parent_class->get_supported_fields    = e_book_backend_couchdb_get_supported_fields;
-	parent_class->get_supported_auth_methods = e_book_backend_couchdb_get_supported_auth_methods;
-	parent_class->cancel_operation        = e_book_backend_couchdb_cancel_operation;
 	parent_class->remove                  = e_book_backend_couchdb_remove;
-	parent_class->set_mode                = e_book_backend_couchdb_set_mode;
 
 	object_class->dispose                 = e_book_backend_couchdb_dispose;
 }
diff --git a/configure.ac b/configure.ac
index 7852e48..74caf48 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,22 +40,35 @@ PKG_CHECK_MODULES(EVOLUTION, glib-2.0 couchdb-glib-1.0 >= 0.6.93 desktopcouch-gl
 AC_SUBST(EVOLUTION_CFLAGS)
 AC_SUBST(EVOLUTION_LIBS)
 
-PKG_CHECK_MODULES(EPLUGIN, gtk+-2.0 evolution-plugin)
+PKG_CHECK_EXISTS(evolution-plugin-3.0,
+	EVOLUTION_PLUGIN=evolution-plugin-3.0
+	EVOLUTION_PLUGIN_GTK=gtk+-3.0,
+	PKG_CHECK_EXISTS(evolution-plugin,
+		EVOLUTION_PLUGIN=evolution-plugin
+		EVOLUTION_PLUGIN_GTK=gtk+-2.0,
+		AC_MSG_ERROR(You need evolution-plugin to compile evolution-couchdb))
+	)
+
+PKG_CHECK_MODULES(EPLUGIN, $EVOLUTION_PLUGIN $EVOLUTION_PLUGIN_GTK)
 AC_SUBST(EPLUGIN_CFLAGS)
 AC_SUBST(EPLUGIN_LIBS)
 
+EVOLUTION_PLUGINS_DIR=`$PKG_CONFIG --variable=plugindir $EVOLUTION_PLUGIN`
+AC_SUBST(EVOLUTION_PLUGINS_DIR)
+
 EDS_API_VERSION=1.2
-PKG_CHECK_EXISTS(evolution-data-server-1.2,
-	EDS_EXTENSION_DIR=`$PKG_CONFIG --variable=extensiondir evolution-data-server-1.2`,
-	AC_MSG_ERROR(You need evolution-data-server to compile evolution-couchdb))				    
+if test "$EVOLUTION_PLUGIN" = "evolution-plugin-3.0"; then
+	PKG_CHECK_EXISTS(libedata-book-1.2,
+		EDS_EXTENSION_DIR=`$PKG_CONFIG --variable=backenddir libedata-book-1.2`,
+		AC_MSG_ERROR(You need evolution-data-server to compile evolution-couchdb))
+else
+	PKG_CHECK_EXISTS(evolution-data-server-1.2,
+		EDS_EXTENSION_DIR=`$PKG_CONFIG --variable=extensiondir evolution-data-server-1.2`,
+		AC_MSG_ERROR(You need evolution-data-server to compile evolution-couchdb))
+fi
 AC_SUBST(EDS_API_VERSION)
 AC_SUBST(EDS_EXTENSION_DIR)
 
-PKG_CHECK_EXISTS(evolution-plugin,
-	EVOLUTION_PLUGINS_DIR=`$PKG_CONFIG --variable=plugindir evolution-plugin`,
-	AC_MSG_ERROR(You need evolution-plugin to compile evolution-couchdb))
-AC_SUBST(EVOLUTION_PLUGINS_DIR)
-
 dnl Makefiles
 AC_OUTPUT([
 Makefile



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