[evolution-data-server] Do not use deprecated EBook/ECal API



commit df52a3fa652503a2b7c8eb25f0ce7a5ea77e45ba
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jun 14 08:51:15 2011 +0200

    Do not use deprecated EBook/ECal API

 addressbook/libebook/e-book-client-view.c          |   17 +-
 addressbook/libebook/e-book-client-view.h          |    2 +-
 addressbook/libebook/e-book-client.c               |   38 ++-
 addressbook/libebook/e-book-client.h               |    6 +-
 addressbook/libebook/e-book-query.h                |    4 +-
 addressbook/libebook/e-book-view-private.h         |    5 +
 addressbook/libebook/e-book-view.c                 |    4 +
 addressbook/libebook/e-book.c                      |    2 +-
 addressbook/libebook/e-destination.c               |   41 +++-
 addressbook/libebook/e-destination.h               |   10 +-
 addressbook/libedata-book/e-data-book-factory.c    |   10 +-
 addressbook/libedata-book/e-data-book.c            |    8 +-
 .../backends/contacts/e-cal-backend-contacts.c     |  122 ++++----
 calendar/backends/file/e-cal-backend-file.c        |    5 +-
 calendar/libecal/e-cal-check-timezones.c           |  333 +++++++++++++++++++-
 calendar/libecal/e-cal-check-timezones.h           |   35 ++-
 calendar/libecal/e-cal-client-view.c               |   17 +-
 calendar/libecal/e-cal-client-view.h               |    2 +-
 calendar/libecal/e-cal-client.c                    |   52 +++-
 calendar/libecal/e-cal-client.h                    |   10 +-
 calendar/libecal/e-cal-view-private.h              |    4 +
 calendar/libecal/e-cal-view.c                      |    4 +
 calendar/libecal/e-cal.c                           |    4 +
 calendar/libedata-cal/e-data-cal-factory.c         |   42 ++--
 configure.ac                                       |   21 ++-
 libedataserver/e-client-private.h                  |    1 -
 libedataserver/e-client.c                          |   43 +++-
 libedataserver/e-client.h                          |   13 +-
 libedataserverui/e-book-auth-util.c                |   11 +
 libedataserverui/e-book-auth-util.h                |    7 +-
 libedataserverui/e-client-utils.c                  |  186 +++++++++---
 libedataserverui/e-client-utils.h                  |   11 +-
 libedataserverui/e-contact-store.c                 |  323 +++++++++++--------
 libedataserverui/e-contact-store.h                 |   23 +-
 libedataserverui/e-name-selector-dialog.c          |  131 +++++---
 libedataserverui/e-name-selector-dialog.h          |    1 -
 libedataserverui/e-name-selector-entry.c           |  156 ++++++----
 libedataserverui/e-name-selector.c                 |   53 ++--
 libedataserverui/e-passwords.c                     |    2 +-
 tests/libebook/Makefile.am                         |  103 ++++---
 tests/libecal/Makefile.am                          |   20 +-
 tests/libedataserverui/test-client-examine-auth.c  |   10 +-
 tests/libedataserverui/test-contact-store.c        |   10 +-
 43 files changed, 1355 insertions(+), 547 deletions(-)
---
diff --git a/addressbook/libebook/e-book-client-view.c b/addressbook/libebook/e-book-client-view.c
index d7415a5..394a2e8 100644
--- a/addressbook/libebook/e-book-client-view.c
+++ b/addressbook/libebook/e-book-client-view.c
@@ -209,12 +209,13 @@ e_book_client_view_start (EBookClientView *view, GError **error)
 	if (priv->gdbus_bookview) {
 		GError *local_error = NULL;
 
-		if (e_gdbus_book_view_call_start_sync (priv->gdbus_bookview, NULL, &local_error))
-			priv->running = TRUE;
+		priv->running = TRUE;
+		if (!e_gdbus_book_view_call_start_sync (priv->gdbus_bookview, NULL, &local_error))
+			priv->running = FALSE;
 
-		e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+		e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
 	} else {
-		g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot start view, D-Bus proxy gone"));
+		g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot start view, D-Bus proxy gone"));
 	}
 }
 
@@ -241,9 +242,9 @@ e_book_client_view_stop (EBookClientView *view, GError **error)
 
 		e_gdbus_book_view_call_stop_sync (priv->gdbus_bookview, NULL, &local_error);
 
-		e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+		e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
 	} else {
-		g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot stop view, D-Bus proxy gone"));
+		g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot stop view, D-Bus proxy gone"));
 	}
 }
 
@@ -282,9 +283,9 @@ e_book_client_view_set_fields_of_interest (EBookClientView *view, const GSList *
 		e_gdbus_book_view_call_set_fields_of_interest_sync (priv->gdbus_bookview, (const gchar * const *) strv, NULL, &local_error);
 		g_strfreev (strv);
 
-		e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+		e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
 	} else {
-		g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot set fields of interest, D-Bus proxy gone"));
+		g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot set fields of interest, D-Bus proxy gone"));
 	}
 }
 
diff --git a/addressbook/libebook/e-book-client-view.h b/addressbook/libebook/e-book-client-view.h
index 247a2ae..60d58a6 100644
--- a/addressbook/libebook/e-book-client-view.h
+++ b/addressbook/libebook/e-book-client-view.h
@@ -54,7 +54,7 @@ struct _EBookClientViewClass {
 	void (* objects_modified)	(EBookClientView *view, const GSList *objects);
 	void (* objects_removed)	(EBookClientView *view, const GSList *uids);
 
-	void (* progress)		(EBookClientView *view, const gchar *message);
+	void (* progress)		(EBookClientView *view, guint percent, const gchar *message);
 	void (* complete)		(EBookClientView *view, const GError *error);
 };
 
diff --git a/addressbook/libebook/e-book-client.c b/addressbook/libebook/e-book-client.c
index 3078803..d3944f3 100644
--- a/addressbook/libebook/e-book-client.c
+++ b/addressbook/libebook/e-book-client.c
@@ -87,14 +87,8 @@ e_book_client_error_to_string (EBookClientError code)
 		return C_("BookClientError", "Contact not found");
 	case E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EXISTS:
 		return C_("BookClientError", "Contact ID already exists");
-	case E_BOOK_CLIENT_ERROR_TLS_NOT_AVAILABLE:
-		return C_("BookClientError", "TLS not available");
 	case E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE:
 		return C_("BookClientError", "No such source");
-	case E_BOOK_CLIENT_ERROR_OFFLINE_UNAVAILABLE:
-		return C_("BookClientError", "Offline unavailable");
-	case E_BOOK_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD:
-		return C_("BookClientError", "Unsupported authentication method");
 	case E_BOOK_CLIENT_ERROR_NO_SPACE:
 		return C_("BookClientError", "No space");
 	}
@@ -103,6 +97,24 @@ e_book_client_error_to_string (EBookClientError code)
 }
 
 /**
+ * e_book_client_error_create:
+ * @code: an #EBookClientError code to create
+ * @custom_msg: custom message to use for the error; can be %NULL
+ *
+ * Returns: a new #GError containing an E_BOOK_CLIENT_ERROR of the given
+ * @code. If the @custom_msg is NULL, then the error message is
+ * the one returned from e_book_client_error_to_string() for the @code,
+ * otherwise the given message is used.
+ *
+ * Returned pointer should be freed with g_error_free().
+ **/
+GError *
+e_book_client_error_create (EBookClientError code, const gchar *custom_msg)
+{
+	return g_error_new_literal (E_BOOK_CLIENT_ERROR, code, custom_msg ? custom_msg : e_book_client_error_to_string (code));
+}
+
+/**
  * If the specified GError is a remote error, then create a new error
  * representing the remote error.  If the error is anything else, then
  * leave it alone.
@@ -116,26 +128,26 @@ unwrap_dbus_error (GError *error, GError **client_error)
 		{ err ("Success",				-1) },
 		{ err ("ContactNotFound",			E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND) },
 		{ err ("ContactIDAlreadyExists",		E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EXISTS) },
-		{ err ("UnsupportedAuthenticationMethod",	E_BOOK_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD) },
-		{ err ("TLSNotAvailable",			E_BOOK_CLIENT_ERROR_TLS_NOT_AVAILABLE) },
 		{ err ("NoSuchBook",				E_BOOK_CLIENT_ERROR_NO_SUCH_BOOK) },
 		{ err ("BookRemoved",				E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE) },
-		{ err ("OfflineUnavailable",			E_BOOK_CLIENT_ERROR_OFFLINE_UNAVAILABLE) },
 		{ err ("NoSpace",				E_BOOK_CLIENT_ERROR_NO_SPACE) }
 	}, cl_errors[] = {
 		{ err ("Busy",					E_CLIENT_ERROR_BUSY) },
 		{ err ("RepositoryOffline",			E_CLIENT_ERROR_REPOSITORY_OFFLINE) },
+		{ err ("OfflineUnavailable",			E_CLIENT_ERROR_OFFLINE_UNAVAILABLE) },
 		{ err ("PermissionDenied",			E_CLIENT_ERROR_PERMISSION_DENIED) },
 		{ err ("AuthenticationFailed",			E_CLIENT_ERROR_AUTHENTICATION_FAILED) },
 		{ err ("AuthenticationRequired",		E_CLIENT_ERROR_AUTHENTICATION_REQUIRED) },
 		{ err ("CouldNotCancel",			E_CLIENT_ERROR_COULD_NOT_CANCEL) },
 		{ err ("InvalidArg",				E_CLIENT_ERROR_INVALID_ARG) },
 		{ err ("NotSupported",				E_CLIENT_ERROR_NOT_SUPPORTED) },
+		{ err ("UnsupportedAuthenticationMethod",	E_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD) },
+		{ err ("TLSNotAvailable",			E_CLIENT_ERROR_TLS_NOT_AVAILABLE) },
+		{ err ("SearchSizeLimitExceeded",		E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED) },
+		{ err ("SearchTimeLimitExceeded",		E_CLIENT_ERROR_SEARCH_TIME_LIMIT_EXCEEDED) },
+		{ err ("InvalidQuery",				E_CLIENT_ERROR_INVALID_QUERY) },
+		{ err ("QueryRefused",				E_CLIENT_ERROR_QUERY_REFUSED) },
 		{ err ("UnsupportedField",			E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("SearchSizeLimitExceeded",		E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("SearchTimeLimitExceeded",		E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("InvalidQuery",				E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("QueryRefused",				E_CLIENT_ERROR_OTHER_ERROR) },
 		{ err ("InvalidServerVersion",			E_CLIENT_ERROR_OTHER_ERROR) },
 		{ err ("OtherError",				E_CLIENT_ERROR_OTHER_ERROR) }
 	};
diff --git a/addressbook/libebook/e-book-client.h b/addressbook/libebook/e-book-client.h
index ef6d601..8c51203 100644
--- a/addressbook/libebook/e-book-client.h
+++ b/addressbook/libebook/e-book-client.h
@@ -50,14 +50,12 @@ typedef enum {
 	E_BOOK_CLIENT_ERROR_NO_SUCH_BOOK,
 	E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND,
 	E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EXISTS,
-	E_BOOK_CLIENT_ERROR_TLS_NOT_AVAILABLE,
 	E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE,
-	E_BOOK_CLIENT_ERROR_OFFLINE_UNAVAILABLE,
-	E_BOOK_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD,
 	E_BOOK_CLIENT_ERROR_NO_SPACE
 } EBookClientError;
 
-const gchar *e_book_client_error_to_string (EBookClientError code);
+const gchar *	e_book_client_error_to_string (EBookClientError code);
+GError *	e_book_client_error_create (EBookClientError code, const gchar *custom_msg);
 
 typedef struct _EBookClient        EBookClient;
 typedef struct _EBookClientClass   EBookClientClass;
diff --git a/addressbook/libebook/e-book-query.h b/addressbook/libebook/e-book-query.h
index 4bf9667..47ca60c 100644
--- a/addressbook/libebook/e-book-query.h
+++ b/addressbook/libebook/e-book-query.h
@@ -34,9 +34,9 @@ EBookQuery* e_book_query_ref          (EBookQuery *q);
 void        e_book_query_unref        (EBookQuery *q);
 
 EBookQuery* e_book_query_and          (gint nqs, EBookQuery **qs, gboolean unref);
-EBookQuery* e_book_query_andv         (EBookQuery *q, ...);
+EBookQuery* e_book_query_andv         (EBookQuery *q, ...) G_GNUC_NULL_TERMINATED;
 EBookQuery* e_book_query_or           (gint nqs, EBookQuery **qs, gboolean unref);
-EBookQuery* e_book_query_orv          (EBookQuery *q, ...);
+EBookQuery* e_book_query_orv          (EBookQuery *q, ...) G_GNUC_NULL_TERMINATED;
 
 EBookQuery* e_book_query_not          (EBookQuery *q, gboolean unref);
 
diff --git a/addressbook/libebook/e-book-view-private.h b/addressbook/libebook/e-book-view-private.h
index 1b49f60..9197809 100644
--- a/addressbook/libebook/e-book-view-private.h
+++ b/addressbook/libebook/e-book-view-private.h
@@ -26,10 +26,15 @@
 #include "e-book-client.h"
 #include "e-book-view.h"
 
+G_BEGIN_DECLS
+
+#ifndef E_BOOK_DISABLE_DEPRECATED
 struct _EGdbusBookView;
 
 EBookView *_e_book_view_new (EBook *book, struct _EGdbusBookView *gdbus_bookview);
 
+#endif /* E_BOOK_DISABLE_DEPRECATED */
+
 G_END_DECLS
 
 #endif /* __E_BOOK_VIEW_PRIVATE_H__ */
diff --git a/addressbook/libebook/e-book-view.c b/addressbook/libebook/e-book-view.c
index 50c90c8..3204671 100644
--- a/addressbook/libebook/e-book-view.c
+++ b/addressbook/libebook/e-book-view.c
@@ -27,6 +27,8 @@
 #include "libedata-book/e-data-book-types.h"
 #include "e-gdbus-book-view.h"
 
+#ifndef E_BOOK_DISABLE_DEPRECATED
+
 G_DEFINE_TYPE (EBookView, e_book_view, G_TYPE_OBJECT);
 
 struct _EBookViewPrivate {
@@ -350,3 +352,5 @@ e_book_view_class_init (EBookViewClass *klass)
 
 	object_class->dispose = e_book_view_dispose;
 }
+
+#endif /* E_BOOK_DISABLE_DEPRECATED */
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index 3484861..338c608 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -2027,7 +2027,7 @@ e_book_get_book_view (EBook       *book,
 		*book_view = _e_book_view_new (book, gdbus_bookview);
 	} else {
 		*book_view = NULL;
-		g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_DBUS_EXCEPTION,
+		g_set_error_literal (error, E_BOOK_ERROR, E_BOOK_ERROR_DBUS_EXCEPTION,
 			     "Cannot get connection to view");
 		ret = FALSE;
 	}
diff --git a/addressbook/libebook/e-destination.c b/addressbook/libebook/e-destination.c
index 6556082..5ed6b34 100644
--- a/addressbook/libebook/e-destination.c
+++ b/addressbook/libebook/e-destination.c
@@ -122,6 +122,9 @@ e_destination_dispose (GObject *object)
 	if (dest->priv) {
 		e_destination_clear (dest);
 
+		g_free (dest->priv->source_uid);
+		dest->priv->source_uid = NULL;
+
 		g_free (dest->priv);
 		dest->priv = NULL;
 	}
@@ -218,9 +221,6 @@ e_destination_copy (const EDestination *dest)
 static void
 e_destination_clear (EDestination *dest)
 {
-	g_free (dest->priv->source_uid);
-	dest->priv->source_uid = NULL;
-
 	g_free (dest->priv->contact_uid);
 	dest->priv->contact_uid = NULL;
 
@@ -443,6 +443,7 @@ e_destination_set_contact (EDestination *dest, EContact *contact, gint email_num
 
 }
 
+#ifndef E_BOOK_DISABLE_DEPRECATED
 /**
  * e_destination_set_book:
  * @dest: an #EDestination
@@ -450,6 +451,8 @@ e_destination_set_contact (EDestination *dest, EContact *contact, gint email_num
  *
  * Specify the source @dest's contact comes from. This is useful
  * if you need to update the contact later.
+ *
+ * Deprecated: 3.2: Use e_destination_set_client() instead.
  **/
 void
 e_destination_set_book (EDestination *dest, EBook *book)
@@ -465,7 +468,37 @@ e_destination_set_book (EDestination *dest, EBook *book)
 	g_return_if_fail (uid != NULL);
 
 	if (!dest->priv->source_uid || strcmp (uid, dest->priv->source_uid)) {
-		e_destination_clear (dest);
+		g_free (dest->priv->source_uid);
+		dest->priv->source_uid = g_strdup (uid);
+
+		g_signal_emit (dest, signals[CHANGED], 0);
+	}
+}
+#endif /* E_BOOK_DISABLE_DEPRECATED */
+
+/**
+ * e_destination_set_client:
+ * @dest: an #EDestination
+ * @client: an #EBookClient
+ *
+ * Specify the source @dest's contact comes from. This is useful
+ * if you need to update the contact later.
+ **/
+void
+e_destination_set_client (EDestination *dest, EBookClient *client)
+{
+	ESource *source;
+	const gchar *uid;
+
+	g_return_if_fail (dest && E_IS_DESTINATION (dest));
+	g_return_if_fail (client && E_IS_BOOK_CLIENT (client));
+
+	source = e_client_get_source (E_CLIENT (client));
+	uid = e_source_peek_uid (source);
+	g_return_if_fail (uid != NULL);
+
+	if (!dest->priv->source_uid || strcmp (uid, dest->priv->source_uid)) {
+		g_free (dest->priv->source_uid);
 		dest->priv->source_uid = g_strdup (uid);
 
 		g_signal_emit (dest, signals[CHANGED], 0);
diff --git a/addressbook/libebook/e-destination.h b/addressbook/libebook/e-destination.h
index 938caa2..6ac4e13 100644
--- a/addressbook/libebook/e-destination.h
+++ b/addressbook/libebook/e-destination.h
@@ -29,9 +29,13 @@
 #define __E_DESTINATION_H__
 
 #include <libebook/e-contact.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
 #include <libxml/tree.h>
 
+#ifndef E_BOOK_DISABLE_DEPRECATED
+#include <libebook/e-book.h>
+#endif /* E_BOOK_DISABLE_DEPRECATED */
+
 #define E_TYPE_DESTINATION           (e_destination_get_type ())
 #define E_DESTINATION(o)             (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_DESTINATION, EDestination))
 #define E_DESTINATION_CLASS(k)       (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_DESTINATION, EDestinationClass))
@@ -74,7 +78,10 @@ gboolean       e_destination_equal              (const EDestination *a, const ED
 /* for use with EDestinations that wrap a particular contact */
 void           e_destination_set_contact        (EDestination *dest, EContact *contact, gint email_num);
 void           e_destination_set_contact_uid    (EDestination *dest, const gchar *uid, gint email_num);
+#ifndef E_BOOK_DISABLE_DEPRECATED
 void           e_destination_set_book           (EDestination *dest, EBook *book);
+#endif
+void		e_destination_set_client	(EDestination *dest, EBookClient *client);
 EContact      *e_destination_get_contact        (const EDestination *dest);
 const gchar    *e_destination_get_source_uid     (const EDestination *dest);
 const gchar    *e_destination_get_contact_uid    (const EDestination *dest);
@@ -123,4 +130,3 @@ void          e_destination_export_to_vcard_attribute   (EDestination *dest, EVC
 void           e_destination_freev              (EDestination **destv);
 
 #endif /* __E_DESTINATION_H__ */
-
diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index e041e81..f26012f 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -61,11 +61,11 @@ static gboolean opt_keep_running = FALSE;
 
 /* Convenience macro to test and set a GError/return on failure */
 #define g_set_error_val_if_fail(test, returnval, error, domain, code) G_STMT_START{ \
-		if G_LIKELY (test) {} else {				\
-			g_set_error (error, domain, code, #test);	\
-			g_warning(#test " failed");			\
-			return (returnval);				\
-		}							\
+		if G_LIKELY (test) {} else {					\
+			g_set_error_literal (error, domain, code, #test);	\
+			g_warning (#test " failed");				\
+			return (returnval);					\
+		}								\
 	}G_STMT_END
 
 G_DEFINE_TYPE (EDataBookFactory, e_data_book_factory, G_TYPE_OBJECT);
diff --git a/addressbook/libedata-book/e-data-book.c b/addressbook/libedata-book/e-data-book.c
index 2f96114..6e75ae7 100644
--- a/addressbook/libedata-book/e-data-book.c
+++ b/addressbook/libedata-book/e-data-book.c
@@ -65,7 +65,7 @@ typedef enum {
 	OP_MODIFY_CONTACT,
 	OP_GET_BACKEND_PROPERTY,
 	OP_SET_BACKEND_PROPERTY,
-	OP_GET_BOOK_VIEW,
+	OP_GET_VIEW,
 	OP_CANCEL_OPERATION,
 	OP_CANCEL_ALL,
 	OP_CLOSE
@@ -89,7 +89,7 @@ typedef struct {
 		/* OP_ADD_CONTACT */
 		/* OP_MODIFY_CONTACT */
 		gchar *vcard;
-		/* OP_GET_BOOK_VIEW */
+		/* OP_GET_VIEW */
 		/* OP_GET_CONTACTS */
 		/* OP_GET_CONTACTS_UIDS */
 		gchar *query;
@@ -182,7 +182,7 @@ operation_thread (gpointer data, gpointer user_data)
 		g_free (op->d.sbp.prop_name);
 		g_free (op->d.sbp.prop_value);
 		break;
-	case OP_GET_BOOK_VIEW:
+	case OP_GET_VIEW:
 		if (op->d.query) {
 			EBookBackendSExp *card_sexp;
 			EDataBookView *book_view;
@@ -695,7 +695,7 @@ impl_Book_get_view (EGdbusBook *object, GDBusMethodInvocation *invocation, const
 		return TRUE;
 	}
 
-	op = op_new (OP_GET_BOOK_VIEW, book);
+	op = op_new (OP_GET_VIEW, book);
 	op->d.query = g_strdup (in_query);
 
 	e_gdbus_book_complete_get_view (book->priv->gdbus_object, invocation, op->id);
diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c b/calendar/backends/contacts/e-cal-backend-contacts.c
index cd60bca..afa5b7d 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -39,7 +39,9 @@
 #include <libecal/e-cal-util.h>
 #include <libedata-cal/e-cal-backend-util.h>
 #include <libedata-cal/e-cal-backend-sexp.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-query.h>
+#include <libebook/e-contact.h>
 
 #define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
 
@@ -61,7 +63,7 @@ struct _ECalBackendContactsPrivate {
 	GHashTable   *addressbooks;       /* UID -> BookRecord */
 	gboolean      addressbook_loaded;
 
-	EBookView    *book_view;
+	EBookClientView *book_view;
 	GHashTable   *tracked_contacts;   /* UID -> ContactRecord */
 
 	GHashTable *zones;
@@ -81,13 +83,13 @@ struct _ECalBackendContactsPrivate {
 
 typedef struct _BookRecord {
 	ECalBackendContacts *cbc;
-	EBook     *book;
-	EBookView *book_view;
+	EBookClient *book_client;
+	EBookClientView *book_view;
 } BookRecord;
 
 typedef struct _ContactRecord {
 	ECalBackendContacts *cbc;
-	EBook	       *book; /* where it comes from */
+	EBookClient *book_client; /* where it comes from */
 	EContact	    *contact;
 	ECalComponent       *comp_birthday, *comp_anniversary;
 } ContactRecord;
@@ -100,9 +102,9 @@ typedef struct _ContactRecord {
 static ECalComponent * create_birthday (ECalBackendContacts *cbc, EContact *contact);
 static ECalComponent * create_anniversary (ECalBackendContacts *cbc, EContact *contact);
 
-static void contacts_changed_cb (EBookView *book_view, const GList *contacts, gpointer user_data);
-static void contacts_added_cb   (EBookView *book_view, const GList *contacts, gpointer user_data);
-static void contacts_removed_cb (EBookView *book_view, const GList *contact_ids, gpointer user_data);
+static void contacts_modified_cb (EBookClientView *book_view, const GSList *contacts, gpointer user_data);
+static void contacts_added_cb   (EBookClientView *book_view, const GSList *contacts, gpointer user_data);
+static void contacts_removed_cb (EBookClientView *book_view, const GSList *contact_ids, gpointer user_data);
 static void e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *tzobj, GError **perror);
 static void setup_alarm (ECalBackendContacts *cbc, ECalComponent *comp);
 
@@ -110,17 +112,17 @@ static void setup_alarm (ECalBackendContacts *cbc, ECalComponent *comp);
 static BookRecord *
 book_record_new (ECalBackendContacts *cbc, ESource *source)
 {
-	EBook      *book;
-	GList      *fields = NULL;
+	EBookClient *book_client;
 	EBookQuery *query;
-	EBookView  *book_view;
+	EBookClientView *book_view;
 	BookRecord *br;
-	GError     *error = NULL;
+	GError *error = NULL;
+	gchar *query_sexp;
 
-	book = e_book_new (source, &error);
-	if (!book || !e_book_open (book, TRUE, &error) || error) {
-		if (book)
-			g_object_unref (book);
+	book_client = e_book_client_new (source, &error);
+	if (!book_client || !e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, &error) || error) {
+		if (book_client)
+			g_object_unref (book_client);
 		if (error) {
 			g_warning ("%s: Failed to open book: %s", G_STRFUNC, error->message);
 			g_error_free (error);
@@ -128,36 +130,38 @@ book_record_new (ECalBackendContacts *cbc, ESource *source)
 		return NULL;
 	}
 
-	/* Create book view */
-	fields = g_list_append (fields, (gchar *) e_contact_field_name (E_CONTACT_FILE_AS));
-	fields = g_list_append (fields, (gchar *) e_contact_field_name (E_CONTACT_BIRTH_DATE));
-	fields = g_list_append (fields, (gchar *) e_contact_field_name (E_CONTACT_ANNIVERSARY));
-	query = e_book_query_any_field_contains ("");
+	query = e_book_query_andv (
+		e_book_query_field_exists (E_CONTACT_FILE_AS),
+		e_book_query_orv (
+			e_book_query_field_exists (E_CONTACT_BIRTH_DATE),
+			e_book_query_field_exists (E_CONTACT_ANNIVERSARY),
+			NULL),
+		NULL);
+	query_sexp = e_book_query_to_string (query);
+	e_book_query_unref (query);
 
-	if (!e_book_get_book_view (book, query, fields, -1, &book_view, &error)) {
+	if (!e_book_client_get_view_sync (book_client, query_sexp, &book_view, NULL, &error)) {
 		g_warning ("%s: Failed to get book view on '%s': %s", G_STRFUNC, e_source_peek_name (source), error ? error->message : "Unknown error");
 
-		e_book_query_unref (query);
-		g_object_unref (book);
-		g_list_free (fields);
+		g_free (query_sexp);
+		g_object_unref (book_client);
 
 		if (error)
 			g_error_free (error);
 
 		return NULL;
 	}
-	e_book_query_unref (query);
-	g_list_free (fields);
+	g_free (query_sexp);
 
-	g_signal_connect (book_view, "contacts_added", G_CALLBACK (contacts_added_cb), cbc);
-	g_signal_connect (book_view, "contacts_removed", G_CALLBACK (contacts_removed_cb), cbc);
-	g_signal_connect (book_view, "contacts_changed", G_CALLBACK (contacts_changed_cb), cbc);
+	g_signal_connect (book_view, "objects-added", G_CALLBACK (contacts_added_cb), cbc);
+	g_signal_connect (book_view, "objects-removed", G_CALLBACK (contacts_removed_cb), cbc);
+	g_signal_connect (book_view, "objects-modified", G_CALLBACK (contacts_modified_cb), cbc);
 
-	e_book_view_start (book_view);
+	e_book_client_view_start (book_view, NULL);
 
 	br = g_new (BookRecord, 1);
 	br->cbc = cbc;
-	br->book = book;
+	br->book_client = book_client;
 	br->book_view = book_view;
 
 	return br;
@@ -167,9 +171,9 @@ static gboolean
 remove_by_book (gpointer key, gpointer value, gpointer user_data)
 {
 	ContactRecord *cr = value;
-	EBook *book = user_data;
+	EBookClient *book_client = user_data;
 
-	return (cr && cr->book == book);
+	return (cr && cr->book_client == book_client);
 }
 
 static void
@@ -178,38 +182,35 @@ book_record_free (BookRecord *br)
 	if (!br)
 		return;
 
-	g_hash_table_foreach_remove (br->cbc->priv->tracked_contacts, remove_by_book, br->book);
+	g_hash_table_foreach_remove (br->cbc->priv->tracked_contacts, remove_by_book, br->book_client);
 	g_object_unref (br->book_view);
-	g_object_unref (br->book);
+	g_object_unref (br->book_client);
 
 	g_free (br);
 }
 
 /* ContactRecord methods */
 static ContactRecord *
-contact_record_new (ECalBackendContacts *cbc, EBook *book, EContact *contact)
+contact_record_new (ECalBackendContacts *cbc, EBookClient *book_client, EContact *contact)
 {
 	ContactRecord *cr = g_new0 (ContactRecord, 1);
 	gchar *comp_str;
 
 	cr->cbc = cbc;
-	cr->book = book;
+	cr->book_client = book_client;
 	cr->contact = contact;
 	cr->comp_birthday = create_birthday (cbc, contact);
 	cr->comp_anniversary = create_anniversary (cbc, contact);
 
 	if (cr->comp_birthday) {
 		comp_str = e_cal_component_get_as_string (cr->comp_birthday);
-		e_cal_backend_notify_object_created (E_CAL_BACKEND (cbc),
-						     comp_str);
+		e_cal_backend_notify_object_created (E_CAL_BACKEND (cbc), comp_str);
 		g_free (comp_str);
 	}
 
 	if (cr->comp_anniversary) {
-
 		comp_str = e_cal_component_get_as_string (cr->comp_anniversary);
-		e_cal_backend_notify_object_created (E_CAL_BACKEND (cbc),
-						     comp_str);
+		e_cal_backend_notify_object_created (E_CAL_BACKEND (cbc), comp_str);
 		g_free (comp_str);
 	}
 
@@ -421,14 +422,14 @@ source_group_removed_cb (ESourceList *source_list, ESourceGroup *group, gpointer
 /************************************************************************************/
 
 static void
-contacts_changed_cb (EBookView *book_view, const GList *contacts, gpointer user_data)
+contacts_modified_cb (EBookClientView *book_view, const GSList *contacts, gpointer user_data)
 {
 	ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (user_data);
-	EBook *book = e_book_view_get_book (book_view);
-	const GList *i;
+	EBookClient *book_client = e_book_client_view_get_client (book_view);
+	const GSList *ii;
 
-	for (i = contacts; i; i = i->next) {
-		EContact *contact = E_CONTACT (i->data);
+	for (ii = contacts; ii; ii = ii->next) {
+		EContact *contact = E_CONTACT (ii->data);
 		const gchar *uid = e_contact_get_const (contact, E_CONTACT_UID);
 		EContactDate *birthday, *anniversary;
 
@@ -441,7 +442,7 @@ contacts_changed_cb (EBookView *book_view, const GList *contacts, gpointer user_
 		anniversary = e_contact_get (contact, E_CONTACT_ANNIVERSARY);
 
 		if (birthday || anniversary) {
-			ContactRecord *cr = contact_record_new (cbc, book, contact);
+			ContactRecord *cr = contact_record_new (cbc, book_client, contact);
 			g_hash_table_insert (cbc->priv->tracked_contacts, g_strdup (uid), cr);
 		}
 
@@ -451,23 +452,22 @@ contacts_changed_cb (EBookView *book_view, const GList *contacts, gpointer user_
 }
 
 static void
-contacts_added_cb (EBookView *book_view, const GList *contacts, gpointer user_data)
+contacts_added_cb (EBookClientView *book_view, const GSList *contacts, gpointer user_data)
 {
 	ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (user_data);
-	EBook *book = e_book_view_get_book (book_view);
-	const GList *i;
+	EBookClient *book_client = e_book_client_view_get_client (book_view);
+	const GSList *ii;
 
 	/* See if any new contacts have BIRTHDAY or ANNIVERSARY fields */
-	for (i = contacts; i; i = i->next)
-	{
-		EContact *contact = E_CONTACT (i->data);
+	for (ii = contacts; ii; ii = ii->next) {
+		EContact *contact = E_CONTACT (ii->data);
 		EContactDate *birthday, *anniversary;
 
 		birthday = e_contact_get (contact, E_CONTACT_BIRTH_DATE);
 		anniversary = e_contact_get (contact, E_CONTACT_ANNIVERSARY);
 
 		if (birthday || anniversary) {
-			ContactRecord *cr = contact_record_new (cbc, book, contact);
+			ContactRecord *cr = contact_record_new (cbc, book_client, contact);
 			const gchar    *uid = e_contact_get_const (contact, E_CONTACT_UID);
 
 			g_hash_table_insert (cbc->priv->tracked_contacts, g_strdup (uid), cr);
@@ -479,14 +479,14 @@ contacts_added_cb (EBookView *book_view, const GList *contacts, gpointer user_da
 }
 
 static void
-contacts_removed_cb (EBookView *book_view, const GList *contact_ids, gpointer user_data)
+contacts_removed_cb (EBookClientView *book_view, const GSList *contact_ids, gpointer user_data)
 {
 	ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (user_data);
-	const GList *i;
+	const GSList *ii;
 
 	/* Stop tracking these */
-	for (i = contact_ids; i; i = i->next)
-		g_hash_table_remove (cbc->priv->tracked_contacts, i->data);
+	for (ii = contact_ids; ii; ii = ii->next)
+		g_hash_table_remove (cbc->priv->tracked_contacts, ii->data);
 }
 
 /************************************************************************************/
@@ -1144,7 +1144,7 @@ e_cal_backend_contacts_init (ECalBackendContacts *cbc)
 
 	priv = g_new0 (ECalBackendContactsPrivate, 1);
 
-	e_book_get_addressbooks (&priv->addressbook_sources, NULL);
+	e_book_client_get_sources (&priv->addressbook_sources, NULL);
 
 	priv->addressbooks = g_hash_table_new_full (g_str_hash, g_str_equal,
 						    g_free, (GDestroyNotify) book_record_free);
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index bbf391c..fb24a10 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -3055,10 +3055,11 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, GCa
 
         /* check and patch timezones */
 	if (!err) {
-	    if (!e_cal_check_timezones (toplevel_comp,
+		if (!e_cal_client_check_timezones (toplevel_comp,
 				       NULL,
-				       e_cal_tzlookup_icomp,
+				       e_cal_client_tzlookup_icomp,
 				       priv->icalcomp,
+				       NULL,
 				       &err)) {
                 /*
                  * This makes assumptions about what kind of
diff --git a/calendar/libecal/e-cal-check-timezones.c b/calendar/libecal/e-cal-check-timezones.c
index 5da2cdf..d230b49 100644
--- a/calendar/libecal/e-cal-check-timezones.c
+++ b/calendar/libecal/e-cal-check-timezones.c
@@ -17,10 +17,17 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <libical/ical.h>
 
 #include "e-cal-check-timezones.h"
+#ifndef E_CAL_DISABLE_DEPRECATED
 #include <libecal/e-cal.h>
+#endif
+#include <libecal/e-cal-client.h>
 #include <string.h>
 #include <ctype.h>
 
@@ -196,6 +203,8 @@ static void addsystemtz (gpointer key,
     }
 }
 
+#ifndef E_CAL_DISABLE_DEPRECATED
+
 /**
  * e_cal_check_timezones:
  * @comp:     a VCALENDAR containing a list of
@@ -249,6 +258,8 @@ static void addsystemtz (gpointer key,
  * Returns: TRUE if successful, FALSE otherwise.
  *
  * Since: 2.24
+ *
+ * Deprecated: 3.2: Use e_cal_client_check_timezones() instead.
  */
 gboolean
 e_cal_check_timezones (icalcomponent *comp,
@@ -459,6 +470,8 @@ e_cal_check_timezones (icalcomponent *comp,
  * can use. Calls e_cal_get_timezone().
  *
  * Since: 2.24
+ *
+ * Deprecated: 3.2: Use e_cal_client_tzlookup() instead.
  */
 icaltimezone *
 e_cal_tzlookup_ecal (const gchar *tzid,
@@ -469,6 +482,9 @@ e_cal_tzlookup_ecal (const gchar *tzid,
 	icaltimezone *zone = NULL;
 	GError *local_error = NULL;
 
+	g_return_val_if_fail (ecal != NULL, NULL);
+	g_return_val_if_fail (E_IS_CAL (ecal), NULL);
+
 	if (e_cal_get_timezone (ecal, tzid, &zone, &local_error)) {
 		g_warn_if_fail (local_error == NULL);
 		return zone;
@@ -497,7 +513,9 @@ e_cal_tzlookup_ecal (const gchar *tzid,
  * in the component list.
  *
  * Since: 2.24
- */
+ *
+ * Deprecated: 3.2: Use e_cal_client_tzlookup_icomp() instead.
+ **/
 icaltimezone *
 e_cal_tzlookup_icomp (const gchar *tzid,
                       gconstpointer custom,
@@ -507,3 +525,316 @@ e_cal_tzlookup_icomp (const gchar *tzid,
 
     return icalcomponent_get_timezone (icomp, (gchar *) tzid);
 }
+
+#endif /* E_CAL_DISABLE_DEPRECATED */
+
+/**
+ * e_cal_client_check_timezones:
+ * @comp:     a VCALENDAR containing a list of
+ *            VTIMEZONE and arbitrary other components, in
+ *            arbitrary order: these other components are
+ *            modified by this call
+ * @comps:    a list of icalcomponent instances which
+ *            also have to be patched; may be NULL
+ * @tzlookup: a callback function which is called to retrieve
+ *            a calendar's VTIMEZONE definition; the returned
+ *            definition is *not* freed by e_cal_client_check_timezones()
+ *            (to be compatible with e_cal_get_timezone());
+ *            NULL indicates that no such timezone exists
+ *            or an error occurred
+ * @ecalclient: an arbitrary pointer which is passed through to
+ *            the @tzlookup function
+ * @cancellable: a #GCancellable to use in @tzlookup function
+ * @error:    an error description in case of a failure
+ *
+ * This function cleans up VEVENT, VJOURNAL, VTODO and VTIMEZONE
+ * items which are to be imported into Evolution.
+ *
+ * Using VTIMEZONE definitions is problematic because they cannot be
+ * updated properly when timezone definitions change. They are also
+ * incomplete (for compatibility reason only one set of rules for
+ * summer saving changes can be included, even if different rules
+ * apply in different years). This function looks for matches of the
+ * used TZIDs against system timezones and replaces such TZIDs with
+ * the corresponding system timezone. This works for TZIDs containing
+ * a location (found via a fuzzy string search) and for Outlook TZIDs
+ * (via a hard-coded lookup table).
+ *
+ * Some programs generate broken meeting invitations with TZID, but
+ * without including the corresponding VTIMEZONE. Importing such
+ * invitations unchanged causes problems later on (meeting displayed
+ * incorrectly, e_cal_get_component_as_string() fails). The situation
+ * where this occurred in the past (found by a SyncEvolution user) is
+ * now handled via the location based mapping.
+ *
+ * If this mapping fails, this function also deals with VTIMEZONE
+ * conflicts: such conflicts occur when the calendar already contains
+ * an old VTIMEZONE definition with the same TZID, but different
+ * summer saving rules. Replacing the VTIMEZONE potentially breaks
+ * displaying of old events, whereas not replacing it breaks the new
+ * events (the behavior in Evolution <= 2.22.1).
+ *
+ * The way this problem is resolved is by renaming the new VTIMEZONE
+ * definition until the TZID is unique. A running count is appended to
+ * the TZID. All items referencing the renamed TZID are adapted
+ * accordingly.
+ *
+ * Returns: TRUE if successful, FALSE otherwise.
+ *
+ * Since: 3.2
+ **/
+gboolean
+e_cal_client_check_timezones (
+			icalcomponent *comp,
+			GList *comps,
+			icaltimezone *(*tzlookup) (const gchar *tzid,
+						   gconstpointer ecalclient,
+						   GCancellable *cancellable,
+                                                   GError **error),
+                       gconstpointer ecalclient,
+		       GCancellable *cancellable,
+                       GError **error)
+{
+	gboolean success = TRUE;
+	icalcomponent *subcomp = NULL;
+	icaltimezone *zone = icaltimezone_new ();
+	gchar *key = NULL, *value = NULL;
+	gchar *buffer = NULL;
+	gchar *zonestr = NULL;
+	gchar *tzid = NULL;
+	GList *l;
+
+	/* a hash from old to new tzid; strings dynamically allocated */
+	GHashTable *mapping = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+	/* a hash of all system time zone IDs which have to be added; strings are shared with mapping hash */
+	GHashTable *systemtzids = g_hash_table_new (g_str_hash, g_str_equal);
+
+	*error = NULL;
+
+	if (!mapping || !zone) {
+		goto nomem;
+	}
+
+	/* iterate over all VTIMEZONE definitions */
+	subcomp = icalcomponent_get_first_component (comp, ICAL_VTIMEZONE_COMPONENT);
+	while (subcomp) {
+		if (icaltimezone_set_component (zone, subcomp)) {
+			g_free (tzid);
+			tzid = g_strdup (icaltimezone_get_tzid (zone));
+			if (tzid) {
+				const gchar *newtzid = e_cal_match_tzid (tzid);
+				if (newtzid) {
+					/* matched against system time zone */
+					g_free (key);
+					key = g_strdup (tzid);
+					if (!key) {
+						goto nomem;
+					}
+
+					g_free (value);
+					value = g_strdup (newtzid);
+					if (!value) {
+						goto nomem;
+					}
+
+					g_hash_table_insert (mapping, key, value);
+					g_hash_table_insert (systemtzids, value, NULL);
+					key = value = NULL;
+				} else {
+					gint counter;
+
+					zonestr = icalcomponent_as_ical_string_r (subcomp);
+
+					/* check for collisions with existing timezones */
+					for (counter = 0;
+					     counter < 100 /* sanity limit */;
+					     counter++) {
+						icaltimezone *existing_zone;
+
+						if (counter) {
+							g_free (value);
+							value = g_strdup_printf("%s %d", tzid, counter);
+						}
+						existing_zone = tzlookup (counter ? value : tzid, ecalclient, cancellable, error);
+						if (!existing_zone) {
+							if (*error) {
+								goto failed;
+							} else {
+								break;
+							}
+						}
+						g_free (buffer);
+						buffer = icalcomponent_as_ical_string_r (icaltimezone_get_component (existing_zone));
+
+						if (counter) {
+							gchar *fulltzid = g_strdup_printf("TZID:%s", value);
+							gsize baselen = strlen("TZID:") + strlen(tzid);
+							gsize fulllen = strlen (fulltzid);
+							gchar *tzidprop;
+							/*
+							 * Map TZID with counter suffix back to basename.
+							 */
+							tzidprop = strstr (buffer, fulltzid);
+							if (tzidprop) {
+								memmove (tzidprop + baselen,
+									 tzidprop + fulllen,
+									 strlen (tzidprop + fulllen) + 1);
+							}
+							g_free (fulltzid);
+						}
+
+						/*
+						 * If the strings are identical, then the
+						 * VTIMEZONE definitions are identical.  If
+						 * they are not identical, then VTIMEZONE
+						 * definitions might still be semantically
+						 * correct and we waste some space by
+						 * needlesly duplicating the VTIMEZONE. This
+						 * is expected to occur rarely (if at all) in
+						 * practice.
+						 */
+						if (!strcmp (zonestr, buffer)) {
+							break;
+						}
+					}
+
+					if (!counter) {
+						/* does not exist, nothing to do */
+					} else {
+						/* timezone renamed */
+						icalproperty *prop = icalcomponent_get_first_property (subcomp, ICAL_TZID_PROPERTY);
+						while (prop) {
+							icalproperty_set_value_from_string(prop, value, "NO");
+							prop = icalcomponent_get_next_property (subcomp, ICAL_ANY_PROPERTY);
+						}
+						g_free (key);
+						key = g_strdup (tzid);
+						g_hash_table_insert (mapping, key, value);
+						key = value = NULL;
+					}
+				}
+			}
+		}
+
+		subcomp = icalcomponent_get_next_component (comp, ICAL_VTIMEZONE_COMPONENT);
+	}
+
+	/*
+	 * now replace all TZID parameters in place
+	 */
+	subcomp = icalcomponent_get_first_component (comp, ICAL_ANY_COMPONENT);
+	while (subcomp) {
+		/*
+		 * Leave VTIMEZONE unchanged, iterate over properties of
+		 * everything else.
+		 *
+		 * Note that no attempt is made to remove unused VTIMEZONE
+		 * definitions. That would just make the code more complex for
+		 * little additional gain. However, newly used time zones are
+		 * added below.
+		 */
+		patch_tzids (subcomp, mapping);
+		subcomp = icalcomponent_get_next_component (comp, ICAL_ANY_COMPONENT);
+	}
+
+	for (l = comps; l; l = l->next) {
+		patch_tzids (l->data, mapping);
+	}
+
+	/*
+	 * add system time zones that we mapped to: adding them ensures
+	 * that the VCALENDAR remains consistent
+	 */
+	g_hash_table_foreach (systemtzids, addsystemtz, comp);
+
+	goto done;
+ nomem:
+	/* set gerror for "out of memory" if possible, otherwise abort via g_error() */
+	*error = g_error_new (E_CLIENT_ERROR, E_CLIENT_ERROR_OTHER_ERROR, "out of memory");
+	if (!*error) {
+		g_error("e_cal_check_timezones(): out of memory, cannot proceed - sorry!");
+	}
+ failed:
+	/* gerror should have been set already */
+	success = FALSE;
+ done:
+	if (mapping) {
+		g_hash_table_destroy (mapping);
+	}
+	if (systemtzids) {
+		g_hash_table_destroy (systemtzids);
+	}
+	if (zone) {
+		icaltimezone_free (zone, 1);
+	}
+	g_free (tzid);
+	g_free (zonestr);
+	g_free (buffer);
+	g_free (key);
+	g_free (value);
+
+	return success;
+}
+
+/**
+ * e_cal_client_tzlookup:
+ * @ecalclient: must be a valid ECalCleint pointer
+ *
+ * An implementation of the tzlookup callback which clients
+ * can use. Calls e_cal_client_get_timezone_sync().
+ *
+ * Since: 3.2
+ */
+icaltimezone *
+e_cal_client_tzlookup (const gchar *tzid,
+		       gconstpointer ecalclient,
+		       GCancellable *cancellable,
+                       GError **error)
+{
+	ECalClient *cal_client = (ECalClient *) ecalclient;
+	icaltimezone *zone = NULL;
+	GError *local_error = NULL;
+
+	g_return_val_if_fail (cal_client != NULL, NULL);
+	g_return_val_if_fail (E_IS_CAL_CLIENT (cal_client), NULL);
+
+	if (e_cal_client_get_timezone_sync (cal_client, tzid, &zone, cancellable, &local_error)) {
+		g_warn_if_fail (local_error == NULL);
+		return zone;
+	}
+
+	if (g_error_matches (local_error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) {
+		/* We had to trigger this error to check for the
+		 * timezone existance, clear it and return NULL. */
+		g_clear_error (&local_error);
+	}
+
+	if (local_error)
+		g_propagate_error (error, local_error);
+
+	return NULL;
+}
+
+/**
+ * e_cal_client_tzlookup_icomp:
+ * @custom: must be a icalcomponent pointer which contains
+ *          either a VCALENDAR with VTIMEZONEs or VTIMEZONES
+ *          directly
+ *
+ * An implementation of the tzlookup callback which backends
+ * like the file backend can use. Searches for the timezone
+ * in the component list.
+ *
+ * Since: 3.2
+ */
+icaltimezone *
+e_cal_client_tzlookup_icomp (const gchar *tzid,
+			     gconstpointer custom,
+			     GCancellable *cancellable,
+			     GError **error)
+{
+	icalcomponent *icomp = (icalcomponent *) custom;
+
+	return icalcomponent_get_timezone (icomp, (gchar *) tzid);
+}
diff --git a/calendar/libecal/e-cal-check-timezones.h b/calendar/libecal/e-cal-check-timezones.h
index d67af8e..1a27c0b 100644
--- a/calendar/libecal/e-cal-check-timezones.h
+++ b/calendar/libecal/e-cal-check-timezones.h
@@ -22,9 +22,12 @@
 
 #include <libical/ical.h>
 #include <glib.h>
+#include <gio/gio.h>
 
 G_BEGIN_DECLS
 
+#ifndef E_CAL_DISABLE_DEPRECATED
+
 gboolean e_cal_check_timezones (icalcomponent *comp,
                                GList *comps,
                                icaltimezone *(*tzlookup)(const gchar *tzid,
@@ -37,9 +40,35 @@ icaltimezone *e_cal_tzlookup_ecal (const gchar *tzid,
                                   gconstpointer custom,
                                   GError **error);
 
-icaltimezone *e_cal_tzlookup_icomp (const gchar *tzid,
-                                   gconstpointer custom,
-                                   GError **error);
+icaltimezone *e_cal_tzlookup_icomp
+				(const gchar *tzid,
+				 gconstpointer custom,
+				 GError **error);
+
+#endif /* E_CAL_DISABLE_DEPRECATED */
+
+gboolean e_cal_client_check_timezones
+				(icalcomponent *comp,
+				 GList *comps,
+				 icaltimezone *(*tzlookup) (const gchar *tzid,
+							    gconstpointer ecalclient,
+							    GCancellable *cancellable,
+                                                            GError **error),
+				 gconstpointer ecalclient,
+				 GCancellable *cancellable,
+				 GError **error);
+
+icaltimezone *e_cal_client_tzlookup
+				(const gchar *tzid,
+				 gconstpointer ecalclient,
+				 GCancellable *cancellable,
+				 GError **error);
+
+icaltimezone *e_cal_client_tzlookup_icomp
+				(const gchar *tzid,
+				 gconstpointer custom,
+				 GCancellable *cancellable,
+				 GError **error);
 
 const gchar *e_cal_match_tzid (const gchar *tzid);
 
diff --git a/calendar/libecal/e-cal-client-view.c b/calendar/libecal/e-cal-client-view.c
index 33cc8b1..2c01065 100644
--- a/calendar/libecal/e-cal-client-view.c
+++ b/calendar/libecal/e-cal-client-view.c
@@ -447,12 +447,13 @@ e_cal_client_view_start (ECalClientView *view, GError **error)
 	if (priv->gdbus_calview) {
 		GError *local_error = NULL;
 
-		if (e_gdbus_cal_view_call_start_sync (priv->gdbus_calview, NULL, &local_error))
-			priv->running = TRUE;
+		priv->running = TRUE;
+		if (!e_gdbus_cal_view_call_start_sync (priv->gdbus_calview, NULL, &local_error))
+			priv->running = FALSE;
 
-		e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+		e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
 	} else {
-		g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot start view, D-Bus proxy gone"));
+		g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot start view, D-Bus proxy gone"));
 	}
 }
 
@@ -479,9 +480,9 @@ e_cal_client_view_stop (ECalClientView *view, GError **error)
 
 		e_gdbus_cal_view_call_stop_sync (priv->gdbus_calview, NULL, &local_error);
 
-		e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+		e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
 	} else {
-		g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot stop view, D-Bus proxy gone"));
+		g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot stop view, D-Bus proxy gone"));
 	}
 }
 
@@ -520,8 +521,8 @@ e_cal_client_view_set_fields_of_interest (ECalClientView *view, const GSList *fi
 		e_gdbus_cal_view_call_set_fields_of_interest_sync (priv->gdbus_calview, (const gchar * const *) strv, NULL, &local_error);
 		g_strfreev (strv);
 
-		e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+		e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
 	} else {
-		g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot set fields of interest, D-Bus proxy gone"));
+		g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot set fields of interest, D-Bus proxy gone"));
 	}
 }
diff --git a/calendar/libecal/e-cal-client-view.h b/calendar/libecal/e-cal-client-view.h
index 5a4cecf..d6dd05c 100644
--- a/calendar/libecal/e-cal-client-view.h
+++ b/calendar/libecal/e-cal-client-view.h
@@ -52,7 +52,7 @@ struct _ECalClientViewClass {
 	void (* objects_modified)	(ECalClientView *view, const GSList *objects);
 	void (* objects_removed)	(ECalClientView *view, const GSList *uids);
 
-	void (* progress)		(ECalClientView *view, gint percent, const gchar *message);
+	void (* progress)		(ECalClientView *view, guint percent, const gchar *message);
 	void (* complete)		(ECalClientView *view, const GError *error);
 };
 
diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c
index 7fcca6c..4f8e39d 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -133,12 +133,32 @@ e_cal_client_error_to_string (ECalClientError code)
 		return C_("CalClientError", "Unknown user");
 	case E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS:
 		return C_("CalClientError", "Object ID already exists");
+	case E_CAL_CLIENT_ERROR_INVALID_RANGE:
+		return C_("CalClientError", "Invalid range");
 	}
 
 	return C_("CalClientError", "Unknown error");
 }
 
 /**
+ * e_cal_client_error_create:
+ * @code: an #ECalClientError code to create
+ * @custom_msg: custom message to use for the error; can be %NULL
+ *
+ * Returns: a new #GError containing an E_CAL_CLIENT_ERROR of the given
+ * @code. If the @custom_msg is NULL, then the error message is
+ * the one returned from e_cal_client_error_to_string() for the @code,
+ * otherwise the given message is used.
+ *
+ * Returned pointer should be freed with g_error_free().
+ **/
+GError *
+e_cal_client_error_create (ECalClientError code, const gchar *custom_msg)
+{
+	return g_error_new_literal (E_CAL_CLIENT_ERROR, code, custom_msg ? custom_msg : e_cal_client_error_to_string (code));
+}
+
+/**
  * If the specified GError is a remote error, then create a new error
  * representing the remote error.  If the error is anything else, then
  * leave it alone.
@@ -155,25 +175,25 @@ unwrap_dbus_error (GError *error, GError **client_error)
 		{ err ("ObjectIdAlreadyExists",			E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS) },
 		{ err ("NoSuchCal",				E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR) },
 		{ err ("UnknownUser",				E_CAL_CLIENT_ERROR_UNKNOWN_USER) },
+		{ err ("InvalidRange",				E_CAL_CLIENT_ERROR_INVALID_RANGE) },
 	}, cl_errors[] = {
 		{ err ("Busy",					E_CLIENT_ERROR_BUSY) },
 		{ err ("InvalidArg",				E_CLIENT_ERROR_INVALID_ARG) },
 		{ err ("RepositoryOffline",			E_CLIENT_ERROR_REPOSITORY_OFFLINE) },
+		{ err ("OfflineUnavailable",			E_CLIENT_ERROR_OFFLINE_UNAVAILABLE) },
 		{ err ("PermissionDenied",			E_CLIENT_ERROR_PERMISSION_DENIED) },
 		{ err ("AuthenticationFailed",			E_CLIENT_ERROR_AUTHENTICATION_FAILED) },
 		{ err ("AuthenticationRequired",		E_CLIENT_ERROR_AUTHENTICATION_REQUIRED) },
 		{ err ("CouldNotCancel",			E_CLIENT_ERROR_COULD_NOT_CANCEL) },
 		{ err ("NotSupported",				E_CLIENT_ERROR_NOT_SUPPORTED) },
-		{ err ("InvalidRange",				E_CLIENT_ERROR_OTHER_ERROR) },
+		{ err ("UnsupportedAuthenticationMethod",	E_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD) },
+		{ err ("TLSNotAvailable",			E_CLIENT_ERROR_TLS_NOT_AVAILABLE) },
+		{ err ("SearchSizeLimitExceeded",		E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED) },
+		{ err ("SearchTimeLimitExceeded",		E_CLIENT_ERROR_SEARCH_TIME_LIMIT_EXCEEDED) },
+		{ err ("InvalidQuery",				E_CLIENT_ERROR_INVALID_QUERY) },
+		{ err ("QueryRefused",				E_CLIENT_ERROR_QUERY_REFUSED) },
 		{ err ("UnsupportedField",			E_CLIENT_ERROR_OTHER_ERROR) },
 		{ err ("UnsupportedMethod",			E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("UnsupportedAuthenticationMethod",	E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("TLSNotAvailable",			E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("OfflineUnavailable",			E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("SearchSizeLimitExceeded",		E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("SearchTimeLimitExceeded",		E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("InvalidQuery",				E_CLIENT_ERROR_OTHER_ERROR) },
-		{ err ("QueryRefused",				E_CLIENT_ERROR_OTHER_ERROR) },
 		{ err ("InvalidServerVersion",			E_CLIENT_ERROR_OTHER_ERROR) },
 		{ err ("OtherError",				E_CLIENT_ERROR_OTHER_ERROR) }
 	};
@@ -1469,7 +1489,7 @@ generate_instances (ECalClient *client, time_t start, time_t end, const gchar *u
 }
 
 /**
- * e_cal_generate_instances:
+ * e_cal_client_generate_instances:
  * @client: A calendar client.
  * @start: Start time for query.
  * @end: End time for query.
@@ -1926,7 +1946,7 @@ complete_string_exchange (gboolean res, gchar *out_string, gchar **result, GErro
 		res = FALSE;
 
 		if (error && !*error)
-			g_set_error_literal (error, E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG, e_client_error_to_string (E_CLIENT_ERROR_INVALID_ARG));
+			g_propagate_error (error, e_client_error_create (E_CLIENT_ERROR_INVALID_ARG, NULL));
 	}
 
 	return res;
@@ -1961,7 +1981,7 @@ complete_get_object (gboolean res, gchar *out_string, icalcomponent **icalcomp,
 	if (res && out_string) {
 		*icalcomp = icalparser_parse_string (out_string);
 		if (!*icalcomp) {
-			g_set_error_literal (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, e_cal_client_error_to_string (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
+			g_propagate_error (error, e_cal_client_error_create (E_CAL_CLIENT_ERROR_INVALID_OBJECT, NULL));
 			res = FALSE;
 		}
 	} else {
@@ -3096,13 +3116,13 @@ complete_send_objects (gboolean res, gchar **out_strv, GSList **users, icalcompo
 		if (e_gdbus_cal_decode_send_objects ((const gchar * const *) out_strv, &calobj, users)) {
 			*modified_icalcomp = icalparser_parse_string (calobj);
 			if (!*modified_icalcomp) {
-				g_set_error_literal (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, e_cal_client_error_to_string (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
+				g_propagate_error (error, e_cal_client_error_create (E_CAL_CLIENT_ERROR_INVALID_OBJECT, NULL));
 				e_client_util_free_string_slist (*users);
 				*users = NULL;
 				res = FALSE;
 			}
 		} else {
-			g_set_error_literal (error, E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG, e_client_error_to_string (E_CLIENT_ERROR_INVALID_ARG));
+			g_propagate_error (error, e_client_error_create (E_CLIENT_ERROR_INVALID_ARG, NULL));
 			e_client_util_free_string_slist (*users);
 			*users = NULL;
 			res = FALSE;
@@ -3709,7 +3729,7 @@ complete_get_timezone (ECalClient *client, gboolean res, gchar *out_string, ical
 				icaltimezone_free (*zone, 1);
 				icalcomponent_free (icalcomp);
 				res = FALSE;
-				g_set_error_literal (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, e_cal_client_error_to_string (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
+				g_propagate_error (error, e_cal_client_error_create (E_CAL_CLIENT_ERROR_INVALID_OBJECT, NULL));
 			} else {
 				g_mutex_lock (client->priv->zone_cache_lock);
 				g_hash_table_insert (client->priv->zone_cache, g_strdup (icaltimezone_get_tzid (*zone)), *zone);
@@ -3717,7 +3737,7 @@ complete_get_timezone (ECalClient *client, gboolean res, gchar *out_string, ical
 			}
 		} else {
 			res = FALSE;
-			g_set_error_literal (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, e_cal_client_error_to_string (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
+			g_propagate_error (error, e_cal_client_error_create (E_CAL_CLIENT_ERROR_INVALID_OBJECT, NULL));
 		}
 	} else {
 		res = FALSE;
@@ -3890,7 +3910,7 @@ e_cal_client_add_timezone_sync (ECalClient *client, /* const */ icaltimezone *zo
 
 	icalcomp = icaltimezone_get_component (zone);
 	if (!icalcomp) {
-		g_set_error_literal (error, E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG, e_client_error_to_string (E_CLIENT_ERROR_INVALID_ARG));
+		g_propagate_error (error, e_client_error_create (E_CLIENT_ERROR_INVALID_ARG, NULL));
 		return FALSE;
 	}
 
diff --git a/calendar/libecal/e-cal-client.h b/calendar/libecal/e-cal-client.h
index 7a1c19a..debdbc6 100644
--- a/calendar/libecal/e-cal-client.h
+++ b/calendar/libecal/e-cal-client.h
@@ -60,10 +60,12 @@ typedef enum {
 	E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND,
 	E_CAL_CLIENT_ERROR_INVALID_OBJECT,
 	E_CAL_CLIENT_ERROR_UNKNOWN_USER,
-	E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS
+	E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS,
+	E_CAL_CLIENT_ERROR_INVALID_RANGE
 } ECalClientError;
 
-const gchar *e_cal_client_error_to_string (ECalClientError code);
+const gchar *	e_cal_client_error_to_string (ECalClientError code);
+GError *	e_cal_client_error_create (ECalClientError code, const gchar *custom_msg);
 
 typedef struct _ECalClient        ECalClient;
 typedef struct _ECalClientClass   ECalClientClass;
@@ -123,10 +125,6 @@ void		e_cal_client_get_default_object			(ECalClient *client, GCancellable *cance
 gboolean	e_cal_client_get_default_object_finish		(ECalClient *client, GAsyncResult *result, icalcomponent **icalcomp, GError **error);
 gboolean	e_cal_client_get_default_object_sync		(ECalClient *client, icalcomponent **icalcomp, GCancellable *cancellable, GError **error);
 
-void		e_cal_client_refresh				(ECalClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
-gboolean	e_cal_client_refresh_finish			(ECalClient *client, GAsyncResult *result, GError **error);
-gboolean	e_cal_client_refresh_sync			(ECalClient *client, GCancellable *cancellable, GError **error);
-
 void		e_cal_client_get_object				(ECalClient *client, const gchar *uid, const gchar *rid, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
 gboolean	e_cal_client_get_object_finish			(ECalClient *client, GAsyncResult *result, icalcomponent **icalcomp, GError **error);
 gboolean	e_cal_client_get_object_sync			(ECalClient *client, const gchar *uid, const gchar *rid, icalcomponent **icalcomp, GCancellable *cancellable, GError **error);
diff --git a/calendar/libecal/e-cal-view-private.h b/calendar/libecal/e-cal-view-private.h
index 9aa39df..1c8fbbf 100644
--- a/calendar/libecal/e-cal-view-private.h
+++ b/calendar/libecal/e-cal-view-private.h
@@ -26,10 +26,14 @@
 
 G_BEGIN_DECLS
 
+#ifndef E_CAL_DISABLE_DEPRECATED
+
 struct _EGdbusCalView;
 
 ECalView *_e_cal_view_new (struct _ECal *client,  struct _EGdbusCalView *gdbus_calview);
 
+#endif /* E_CAL_DISABLE_DEPRECATED */
+
 G_END_DECLS
 
 #endif
diff --git a/calendar/libecal/e-cal-view.c b/calendar/libecal/e-cal-view.c
index 988aa65..29097e5 100644
--- a/calendar/libecal/e-cal-view.c
+++ b/calendar/libecal/e-cal-view.c
@@ -25,6 +25,8 @@
 #include <config.h>
 #endif
 
+#ifndef E_CAL_DISABLE_DEPRECATED
+
 #include <string.h>
 #include "e-cal-marshal.h"
 #include "e-cal.h"
@@ -489,3 +491,5 @@ e_cal_view_stop (ECalView *view)
 		g_error_free (error);
 	}
 }
+
+#endif /* E_CAL_DISABLE_DEPRECATED */
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 97dca9d..43624cc 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -36,6 +36,8 @@
 #include <config.h>
 #endif
 
+#ifndef E_CAL_DISABLE_DEPRECATED
+
 #include <unistd.h>
 #include <string.h>
 #include <glib/gi18n-lib.h>
@@ -4679,3 +4681,5 @@ e_cal_get_sources (ESourceList **sources, ECalSourceType type, GError **error)
 		     e_cal_get_error_message (E_CALENDAR_STATUS_NO_SUCH_CALENDAR));
 	return FALSE;
 }
+
+#endif /* E_CAL_DISABLE_DEPRECATED */
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index b2ad2fc..d58f410 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -40,7 +40,7 @@
 #include <libedataserver/e-source-list.h>
 #include <libebackend/e-data-server-module.h>
 #include <libebackend/e-offline-listener.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
 #include "e-cal-backend.h"
 #include "e-cal-backend-factory.h"
 #include "e-data-cal.h"
@@ -73,11 +73,11 @@ static gboolean opt_keep_running = FALSE;
 
 /* Convenience macro to test and set a GError/return on failure */
 #define g_set_error_val_if_fail(test, returnval, error, domain, code) G_STMT_START{ \
-		if G_LIKELY (test) {} else {				\
-			g_set_error (error, domain, code, #test);	\
-			g_warning(#test " failed");			\
-			return (returnval);				\
-		}							\
+		if G_LIKELY (test) {} else {					\
+			g_set_error_literal (error, domain, code, #test);	\
+			g_warning(#test " failed");				\
+			return (returnval);					\
+		}								\
 	} G_STMT_END
 
 G_DEFINE_TYPE (EDataCalFactory, e_data_cal_factory, G_TYPE_OBJECT);
@@ -99,10 +99,10 @@ struct _EDataCalFactoryPrivate {
 	gboolean is_online;
 
 	/* this is for notifications of source changes */
-	ESourceList *lists[E_CAL_SOURCE_TYPE_LAST];
+	ESourceList *lists[E_CAL_CLIENT_SOURCE_TYPE_LAST];
 
 	/* backends divided by their type */
-	GSList *backends_by_type[E_CAL_SOURCE_TYPE_LAST];
+	GSList *backends_by_type[E_CAL_CLIENT_SOURCE_TYPE_LAST];
 
 	guint exit_timeout;
 };
@@ -154,21 +154,21 @@ calobjtype_to_string (const EDataCalObjType type)
 	return "UNKNOWN COMPONENT";
 }
 
-static ECalSourceType
-icalkind_to_ecalsourcetype (const icalcomponent_kind kind)
+static ECalClientSourceType
+icalkind_to_ecalclientsourcetype (const icalcomponent_kind kind)
 {
 	switch (kind) {
 	case ICAL_VEVENT_COMPONENT:
-		return E_CAL_SOURCE_TYPE_EVENT;
+		return E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
 	case ICAL_VTODO_COMPONENT:
-		return E_CAL_SOURCE_TYPE_TODO;
+		return E_CAL_CLIENT_SOURCE_TYPE_TASKS;
 	case ICAL_VJOURNAL_COMPONENT:
-		return E_CAL_SOURCE_TYPE_JOURNAL;
+		return E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
 	default:
 		break;
 	}
 
-	return E_CAL_SOURCE_TYPE_LAST;
+	return E_CAL_CLIENT_SOURCE_TYPE_LAST;
 }
 
 static void
@@ -203,7 +203,7 @@ source_list_changed_cb (ESourceList *list,
 
 	g_mutex_lock (priv->backends_mutex);
 
-	for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
+	for (i = 0; i < E_CAL_CLIENT_SOURCE_TYPE_LAST; i++) {
 		GSList *iter;
 
 		if (list != priv->lists[i])
@@ -452,7 +452,7 @@ impl_CalFactory_get_cal (EGdbusCalFactory *object,
 	}
 
 	if (!backend) {
-		ECalSourceType st;
+		ECalClientSourceType st;
 
 		/* There was no existing backend, create a new one */
 		if (E_IS_CAL_BACKEND_LOADER_FACTORY (backend_factory)) {
@@ -473,11 +473,9 @@ impl_CalFactory_get_cal (EGdbusCalFactory *object,
 			goto cleanup;
 		}
 
-		st = icalkind_to_ecalsourcetype (
-			e_cal_backend_get_kind (backend));
-		if (st != E_CAL_SOURCE_TYPE_LAST) {
-			if (!priv->lists[st] && e_cal_get_sources (
-					&(priv->lists[st]), st, NULL)) {
+		st = icalkind_to_ecalclientsourcetype (e_cal_backend_get_kind (backend));
+		if (st != E_CAL_CLIENT_SOURCE_TYPE_LAST) {
+			if (!priv->lists[st] && e_cal_client_get_sources (&(priv->lists[st]), st, NULL)) {
 				g_signal_connect (
 					priv->lists[st], "changed",
 					G_CALLBACK (source_list_changed_cb),
@@ -630,7 +628,7 @@ e_data_cal_factory_finalize (GObject *object)
 
 	g_mutex_free (factory->priv->backends_mutex);
 
-	for (ii = 0; ii < E_CAL_SOURCE_TYPE_LAST; ii++) {
+	for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++) {
 		if (factory->priv->lists[ii]) {
 			g_object_unref (factory->priv->lists[ii]);
 			factory->priv->lists[ii] = NULL;
diff --git a/configure.ac b/configure.ac
index 00fb322..cd3d8d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,7 +78,7 @@ LIBEDATASERVER_CURRENT=14
 LIBEDATASERVER_REVISION=0
 LIBEDATASERVER_AGE=0
 
-LIBEDATASERVERUI_CURRENT=0
+LIBEDATASERVERUI_CURRENT=1
 LIBEDATASERVERUI_REVISION=0
 LIBEDATASERVERUI_AGE=0
 
@@ -194,6 +194,25 @@ case "$host" in
 	;;
 esac
 
+dnl define disable deprecated for EBook and ECal .am files
+case "$WARNING_FLAGS" in
+*E_BOOK_DISABLE_DEPRECATED*)
+	AM_CONDITIONAL(HAVE_E_BOOK_DISABLE_DEPRECATED, [ test 1 == 1 ])
+	;;
+*)
+	AM_CONDITIONAL(HAVE_E_BOOK_DISABLE_DEPRECATED, [ test 0 == 1 ])
+	;;
+esac
+
+case "$WARNING_FLAGS" in
+*E_CAL_DISABLE_DEPRECATED*)
+	AM_CONDITIONAL(HAVE_E_CAL_DISABLE_DEPRECATED, [ test 1 == 1 ])
+	;;
+*)
+	AM_CONDITIONAL(HAVE_E_CAL_DISABLE_DEPRECATED, [ test 0 == 1 ])
+	;;
+esac
+
 dnl ******************************
 dnl Initialize maintainer mode
 dnl ******************************
diff --git a/libedataserver/e-client-private.h b/libedataserver/e-client-private.h
index b2cf4b3..59b451d 100644
--- a/libedataserver/e-client-private.h
+++ b/libedataserver/e-client-private.h
@@ -49,7 +49,6 @@ ESource *	e_client_util_get_source_for_uri (ESourceList *source_list, const gcha
 
 /* protected functions simplifying sync/async calls */
 GDBusProxy *	e_client_get_dbus_proxy		(EClient *client);
-void		e_client_unwrap_dbus_error	(EClient *client, GError *dbus_error, GError **out_error);
 
 void		e_client_proxy_return_async_error	(EClient *client, const GError *error, GAsyncReadyCallback callback, gpointer user_data, gpointer source_tag);
 
diff --git a/libedataserver/e-client.c b/libedataserver/e-client.c
index 59e56fc..5812045 100644
--- a/libedataserver/e-client.c
+++ b/libedataserver/e-client.c
@@ -118,6 +118,8 @@ e_client_error_to_string (EClientError code)
 		return C_("ClientError", "Authentication required");
 	case E_CLIENT_ERROR_REPOSITORY_OFFLINE:
 		return C_("ClientError", "Repository offline");
+	case E_CLIENT_ERROR_OFFLINE_UNAVAILABLE:
+		return C_("ClientError", "Offline unavailable");
 	case E_CLIENT_ERROR_PERMISSION_DENIED:
 		return C_("ClientError", "Permission denied");
 	case E_CLIENT_ERROR_CANCELLED:
@@ -126,6 +128,18 @@ e_client_error_to_string (EClientError code)
 		return C_("ClientError", "Could not cancel");
 	case E_CLIENT_ERROR_NOT_SUPPORTED:
 		return C_("ClientError", "Not supported");
+	case E_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD:
+		return C_("ClientError", "Unsupported authentication method");
+	case E_CLIENT_ERROR_TLS_NOT_AVAILABLE:
+		return C_("ClientError", "TLS not available");
+	case E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED:
+		return C_("ClientError", "Search size limit exceeded");
+	case E_CLIENT_ERROR_SEARCH_TIME_LIMIT_EXCEEDED:
+		return C_("ClientError", "Search time limit exceeded");
+	case E_CLIENT_ERROR_INVALID_QUERY:
+		return C_("ClientError", "Invalid query");
+	case E_CLIENT_ERROR_QUERY_REFUSED:
+		return C_("ClientError", "Query refused");
 	case E_CLIENT_ERROR_DBUS_ERROR:
 		return C_("ClientError", "D-Bus error");
 	case E_CLIENT_ERROR_OTHER_ERROR:
@@ -135,6 +149,24 @@ e_client_error_to_string (EClientError code)
 	return C_("ClientError", "Unknown error");
 }
 
+/**
+ * e_client_error_create:
+ * @code: an #EClientError code to create
+ * @custom_msg: custom message to use for the error; can be %NULL
+ *
+ * Returns: a new #GError containing an E_CLIENT_ERROR of the given
+ * @code. If the @custom_msg is NULL, then the error message is
+ * the one returned from e_client_error_to_string() for the @code,
+ * otherwise the given message is used.
+ *
+ * Returned pointer should be freed with g_error_free().
+ **/
+GError *
+e_client_error_create (EClientError code, const gchar *custom_msg)
+{
+	return g_error_new_literal (E_CLIENT_ERROR, code, custom_msg ? custom_msg : e_client_error_to_string (code));
+}
+
 static void client_set_source (EClient *client, ESource *source);
 static void client_operation_thread (gpointer data, gpointer user_data);
 static void client_handle_authentication (EClient *client, const ECredentials *credentials);
@@ -387,7 +419,7 @@ client_operation_thread (gpointer data, gpointer user_data)
 		} else {
 			GError *error;
 
-			error = g_error_new_literal (E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_REQUIRED, e_client_error_to_string (E_CLIENT_ERROR_AUTHENTICATION_REQUIRED));
+			error = e_client_error_create (E_CLIENT_ERROR_AUTHENTICATION_REQUIRED, NULL);
 			e_client_emit_opened (op_data->client, error);
 			g_error_free (error);
 		}
@@ -1737,8 +1769,13 @@ e_client_get_dbus_proxy (EClient *client)
 }
 
 /**
- * Unwraps D-Bus error to local error. dbus_error is automatically freed.
- * dbus_erorr and out_error can point to the same variable.
+ * e_client_unwrap_dbus_error:
+ * @client: an #EClient
+ * @dbus_error: a #GError returned bu D-Bus
+ * @out_error: a #GError variable where to store the result
+ *
+ * Unwraps D-Bus error to local error. @dbus_error is automatically freed.
+ * @dbus_erorr and @out_error can point to the same variable.
  **/
 void
 e_client_unwrap_dbus_error (EClient *client, GError *dbus_error, GError **out_error)
diff --git a/libedataserver/e-client.h b/libedataserver/e-client.h
index 9fa310e..4cd2167 100644
--- a/libedataserver/e-client.h
+++ b/libedataserver/e-client.h
@@ -54,15 +54,23 @@ typedef enum {
 	E_CLIENT_ERROR_AUTHENTICATION_FAILED,
 	E_CLIENT_ERROR_AUTHENTICATION_REQUIRED,
 	E_CLIENT_ERROR_REPOSITORY_OFFLINE,
+	E_CLIENT_ERROR_OFFLINE_UNAVAILABLE,
 	E_CLIENT_ERROR_PERMISSION_DENIED,
 	E_CLIENT_ERROR_CANCELLED,
 	E_CLIENT_ERROR_COULD_NOT_CANCEL,
 	E_CLIENT_ERROR_NOT_SUPPORTED,
+	E_CLIENT_ERROR_TLS_NOT_AVAILABLE,
+	E_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD,
+	E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED,
+	E_CLIENT_ERROR_SEARCH_TIME_LIMIT_EXCEEDED,
+	E_CLIENT_ERROR_INVALID_QUERY,
+	E_CLIENT_ERROR_QUERY_REFUSED,
 	E_CLIENT_ERROR_DBUS_ERROR,
 	E_CLIENT_ERROR_OTHER_ERROR
 } EClientError;
 
-const gchar *e_client_error_to_string (EClientError code);
+const gchar *	e_client_error_to_string (EClientError code);
+GError *	e_client_error_create (EClientError code, const gchar *custom_msg);
 
 typedef struct _EClient        EClient;
 typedef struct _EClientClass   EClientClass;
@@ -122,6 +130,7 @@ gboolean	e_client_check_refresh_supported	(EClient *client);
 gboolean	e_client_is_readonly			(EClient *client);
 gboolean	e_client_is_online			(EClient *client);
 gboolean	e_client_is_opened			(EClient *client);
+void		e_client_unwrap_dbus_error		(EClient *client, GError *dbus_error, GError **out_error);
 
 void		e_client_cancel_all			(EClient *client);
 
@@ -152,7 +161,7 @@ GSList *	e_client_util_copy_string_slist		(GSList *copy_to, const GSList *string
 GSList *	e_client_util_copy_object_slist		(GSList *copy_to, const GSList *objects);
 void		e_client_util_free_string_slist		(GSList *strings);
 void		e_client_util_free_object_slist		(GSList *objects);
-GSList *	e_client_util_parse_comma_strings	(const gchar *capabilities);
+GSList *	e_client_util_parse_comma_strings	(const gchar *strings);
 
 struct EClientErrorsList {
 	const gchar *name;
diff --git a/libedataserverui/e-book-auth-util.c b/libedataserverui/e-book-auth-util.c
index c2db5fc..88d682c 100644
--- a/libedataserverui/e-book-auth-util.c
+++ b/libedataserverui/e-book-auth-util.c
@@ -23,7 +23,12 @@
  * Mostly taken from Evolution's addressbook/gui/component/addressbook.c
  */
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
+
+#ifndef E_BOOK_DISABLE_DEPRECATED
+
 #include <string.h>
 #include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
@@ -571,6 +576,8 @@ exit:
  * then call e_load_book_source_finish() to obtain the resulting #EBook.
  *
  * Since: 2.32
+ *
+ * Deprecated: 3.2: Use e_client_utils_open_new(), e_client_utils_open_new_finish() instead.
  **/
 void
 e_load_book_source_async (ESource *source,
@@ -637,6 +644,8 @@ e_load_book_source_async (ESource *source,
  * Returns: a ready-to-use #EBook, or %NULL or error
  *
  * Since: 2.32
+ *
+ * Deprecated: 3.2: Use e_client_utils_open_new(), e_client_utils_open_new_finish() instead.
  **/
 EBook *
 e_load_book_source_finish (ESource *source,
@@ -681,3 +690,5 @@ e_load_book_source_finish (ESource *source,
 
 	return g_object_ref (context->book);
 }
+
+#endif /* E_BOOK_DISABLE_DEPRECATED */
diff --git a/libedataserverui/e-book-auth-util.h b/libedataserverui/e-book-auth-util.h
index b7075b5..67e8056 100644
--- a/libedataserverui/e-book-auth-util.h
+++ b/libedataserverui/e-book-auth-util.h
@@ -26,16 +26,16 @@
 #ifndef E_BOOK_AUTH_UTIL_H
 #define E_BOOK_AUTH_UTIL_H
 
+#ifndef E_BOOK_DISABLE_DEPRECATED
+
 #include <gtk/gtk.h>
 #include <libebook/e-book.h>
 
 G_BEGIN_DECLS
 
-#ifndef E_BOOK_DISABLE_DEPRECATED
 EBook *		e_load_book_source		(ESource *source,
 						 EBookCallback open_func,
 						 gpointer user_data);
-#endif
 
 void		e_load_book_source_async	(ESource *source,
 						 GtkWindow *parent,
@@ -45,7 +45,8 @@ void		e_load_book_source_async	(ESource *source,
 EBook *		e_load_book_source_finish	(ESource *source,
 						 GAsyncResult *result,
 						 GError **error);
-
 G_END_DECLS
 
+#endif /* E_BOOK_DISABLE_DEPRECATED */
+
 #endif /* E_BOOK_AUTH_UTIL_H */
diff --git a/libedataserverui/e-client-utils.c b/libedataserverui/e-client-utils.c
index b8dbd5a..d046c35 100644
--- a/libedataserverui/e-client-utils.c
+++ b/libedataserverui/e-client-utils.c
@@ -270,6 +270,7 @@ typedef struct _EClientUtilsAsyncOpData
 	GAsyncReadyCallback async_cb;
 	gpointer async_cb_user_data;
 	GCancellable *cancellable;
+	ESource *source;
 	EClient *client;
 	ECredentials *used_credentials;
 	gboolean open_finished;
@@ -292,6 +293,7 @@ free_client_utils_async_op_data (EClientUtilsAsyncOpData *async_data)
 		g_error_free (async_data->opened_cb_error);
 	g_object_unref (async_data->cancellable);
 	g_object_unref (async_data->client);
+	g_object_unref (async_data->source);
 	g_free (async_data);
 }
 
@@ -318,28 +320,28 @@ complete_async_op_in_idle_cb (gpointer user_data)
 	return FALSE;
 }
 
-#define return_async_error_if_fail(expr, async_cb, async_cb_user_data, source_tag) G_STMT_START {	\
+#define return_async_error_if_fail(expr, async_cb, async_cb_user_data, src, source_tag) G_STMT_START {	\
 	if (G_LIKELY ((expr))) { } else {								\
 		GError *error;										\
 													\
 		error = g_error_new (E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG,			\
 				"%s: assertion '%s' failed", G_STRFUNC, #expr);				\
 													\
-		return_async_error (error, async_cb, async_cb_user_data, source_tag);			\
+		return_async_error (error, async_cb, async_cb_user_data, src, source_tag);		\
 		g_error_free (error);									\
 		return;											\
 	}												\
 	} G_STMT_END
 
 static void
-return_async_error (const GError *error, GAsyncReadyCallback async_cb, gpointer async_cb_user_data, gpointer source_tag)
+return_async_error (const GError *error, GAsyncReadyCallback async_cb, gpointer async_cb_user_data, ESource *source, gpointer source_tag)
 {
 	GSimpleAsyncResult *simple;
 
 	g_return_if_fail (error != NULL);
 	g_return_if_fail (source_tag != NULL);
 
-	simple = g_simple_async_result_new (NULL, async_cb, async_cb_user_data, source_tag);
+	simple = g_simple_async_result_new (G_OBJECT (source), async_cb, async_cb_user_data, source_tag);
 	g_simple_async_result_set_from_error (simple, error);
 
 	g_object_set_data (G_OBJECT (simple), "run-main-depth", GINT_TO_POINTER (g_main_depth ()));
@@ -360,7 +362,7 @@ client_utils_open_new_done (EClientUtilsAsyncOpData *async_data)
 	if (async_data->auth_handler)
 		g_signal_connect (async_data->client, "authenticate", G_CALLBACK (async_data->auth_handler), async_data->auth_handler_user_data);
 
-	simple = g_simple_async_result_new (NULL, async_data->async_cb, async_data->async_cb_user_data, e_client_utils_open_new);
+	simple = g_simple_async_result_new (G_OBJECT (async_data->source), async_data->async_cb, async_data->async_cb_user_data, e_client_utils_open_new);
 	g_simple_async_result_set_op_res_gpointer (simple, g_object_ref (async_data->client), g_object_unref);
 
 	g_object_set_data (G_OBJECT (simple), "run-main-depth", GINT_TO_POINTER (g_main_depth ()));
@@ -379,7 +381,7 @@ client_utils_open_new_cancelled_cb (GCancellable *cancellable, EClientUtilsAsync
 	g_return_if_fail (async_data->cancellable == cancellable);
 	g_return_if_fail (g_cancellable_set_error_if_cancelled (cancellable, &error));
 
-	return_async_error (error, async_data->async_cb, async_data->async_cb_user_data, e_client_utils_open_new);
+	return_async_error (error, async_data->async_cb, async_data->async_cb_user_data, async_data->source, e_client_utils_open_new);
 	free_client_utils_async_op_data (async_data);
 	g_error_free (error);
 }
@@ -405,7 +407,7 @@ finish_or_retry_open (EClientUtilsAsyncOpData *async_data, const GError *error)
 
 		e_client_process_authentication (async_data->client, async_data->used_credentials);
 	} else if (error) {
-		return_async_error (error, async_data->async_cb, async_data->async_cb_user_data, e_client_utils_open_new);
+		return_async_error (error, async_data->async_cb, async_data->async_cb_user_data, async_data->source, e_client_utils_open_new);
 		free_client_utils_async_op_data (async_data);
 	} else {
 		client_utils_open_new_done (async_data);
@@ -521,9 +523,9 @@ client_utils_open_new_auth_cb (EClient *client, ECredentials *credentials, gpoin
  * @source: an #ESource to be opened
  * @source_type: an #EClientSourceType of the @source
  * @only_if_exists: if %TRUE, fail if this client doesn't already exist, otherwise create it first
+ * @cancellable: a #GCancellable; can be %NULL
  * @auth_handler: authentication handler, to be used; the e_client_utils_authenticate_handler() is usually sufficient
  * @auth_handler_user_data: user data for @auth_handler function
- * @cancellable: a #GCancellable; can be %NULL
  * @async_cb: callback to call when a result is ready
  * @async_cb_user_data: user data for the @async_cb
  *
@@ -539,21 +541,21 @@ client_utils_open_new_auth_cb (EClient *client, ECredentials *credentials, gpoin
  * Since: 3.2
  **/
 void
-e_client_utils_open_new (ESource *source, EClientSourceType source_type, gboolean only_if_exists,
+e_client_utils_open_new (ESource *source, EClientSourceType source_type, gboolean only_if_exists, GCancellable *cancellable,
 			 EClientUtilsAuthenticateHandler auth_handler, gpointer auth_handler_user_data,
-			 GCancellable *cancellable, GAsyncReadyCallback async_cb, gpointer async_cb_user_data)
+			 GAsyncReadyCallback async_cb, gpointer async_cb_user_data)
 {
 	EClient *client;
 	GError *error = NULL;
 	EClientUtilsAsyncOpData *async_data;
 
 	g_return_if_fail (async_cb != NULL);
-	return_async_error_if_fail (source != NULL, async_cb, async_cb_user_data, e_client_utils_open_new);
-	return_async_error_if_fail (E_IS_SOURCE (source), async_cb, async_cb_user_data, e_client_utils_open_new);
+	return_async_error_if_fail (source != NULL, async_cb, async_cb_user_data, source, e_client_utils_open_new);
+	return_async_error_if_fail (E_IS_SOURCE (source), async_cb, async_cb_user_data, source, e_client_utils_open_new);
 
 	client = e_client_utils_new (source, source_type, &error);
 	if (!client) {
-		return_async_error (error, async_cb, async_cb_user_data, e_client_utils_open_new);
+		return_async_error (error, async_cb, async_cb_user_data, source, e_client_utils_open_new);
 		g_error_free (error);
 		return;
 	}
@@ -563,6 +565,7 @@ e_client_utils_open_new (ESource *source, EClientSourceType source_type, gboolea
 	async_data->auth_handler_user_data = auth_handler_user_data;
 	async_data->async_cb = async_cb;
 	async_data->async_cb_user_data = async_cb_user_data;
+	async_data->source = g_object_ref (source);
 	async_data->client = client;
 	async_data->open_finished = FALSE;
 	if (cancellable)
@@ -581,8 +584,9 @@ e_client_utils_open_new (ESource *source, EClientSourceType source_type, gboolea
 
 /**
  * e_client_utils_open_new_finish:
+ * @source: an #ESource on which the e_client_utils_open_new() was invoked
  * @result: a #GAsyncResult
- * @client: (out): Return value for an #EClient.
+ * @client: (out): Return value for an #EClient
  * @error: (out): a #GError to set an error, if any
  *
  * Finishes previous call of e_client_utils_open_new() and
@@ -594,13 +598,14 @@ e_client_utils_open_new (ESource *source, EClientSourceType source_type, gboolea
  * Since: 3.2
  **/
 gboolean
-e_client_utils_open_new_finish (GAsyncResult *result, EClient **client, GError **error)
+e_client_utils_open_new_finish (ESource *source, GAsyncResult *result, EClient **client, GError **error)
 {
 	GSimpleAsyncResult *simple;
 
+	g_return_val_if_fail (source != NULL, FALSE);
 	g_return_val_if_fail (result != NULL, FALSE);
 	g_return_val_if_fail (client != NULL, FALSE);
-	g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL, e_client_utils_open_new), FALSE);
+	g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (source), e_client_utils_open_new), FALSE);
 
 	*client = NULL;
 	simple = G_SIMPLE_ASYNC_RESULT (result);
@@ -613,13 +618,62 @@ e_client_utils_open_new_finish (GAsyncResult *result, EClient **client, GError *
 	return *client != NULL;
 }
 
+/* free returned pointer with g_free() */
+static gchar *
+get_auth_domain (EClient *client)
+{
+	ESource *source;
+	const gchar *auth_domain;
+
+	g_return_val_if_fail (client != NULL, NULL);
+
+	source = e_client_get_source (client);
+	g_return_val_if_fail (source != NULL, NULL);
+
+	auth_domain = e_source_get_property (source, "auth-domain");
+	if (auth_domain && *auth_domain)
+		return g_strdup (auth_domain);
+
+	if (E_IS_BOOK_CLIENT (client))
+		return g_strdup (E_CREDENTIALS_AUTH_DOMAIN_ADDRESSBOOK);
+	if (E_IS_CAL_CLIENT (client))
+		return g_strdup (E_CREDENTIALS_AUTH_DOMAIN_CALENDAR);
+
+	g_return_val_if_reached (NULL);
+}
+
+/* free returned pointer with g_free() */
+static gchar *
+get_prompt_key (EClient *client, const gchar *user_name)
+{
+	SoupURI *suri;
+	gchar *uri_str;
+
+	g_return_val_if_fail (client != NULL, NULL);
+
+	suri = soup_uri_new (e_client_get_uri (client));
+	g_return_val_if_fail (suri != NULL, NULL);
+
+	soup_uri_set_user (suri, user_name);
+	soup_uri_set_password (suri, NULL);
+	soup_uri_set_fragment (suri, NULL);
+
+	uri_str = soup_uri_to_string (suri, FALSE);
+	soup_uri_free (suri);
+
+	return uri_str;
+}
+
 /* This function is suitable as a handler for EClient::authenticate signal.
    It takes care of all the password prompt and such and returns TRUE if
    credentials (password) were provided. Thus just connect it to that signal
    and it'll take care of everything else.
+
+   gtk_window_parent is user_data passed into the callback. It can be a pointer
+   to GtkWindow, used as a parent for a pasword prompt dialog.
 */
 gboolean
-e_client_utils_authenticate_handler (EClient *client, ECredentials *credentials, gpointer unused_user_data)
+e_client_utils_authenticate_handler (EClient *client, ECredentials *credentials, gpointer gtk_window_parent)
 {
 	ESource *source;
 	gboolean is_book, is_cal, res, remember_password = FALSE;
@@ -643,8 +697,21 @@ e_client_utils_authenticate_handler (EClient *client, ECredentials *credentials,
 			return FALSE;
 	}
 
-	if (!e_credentials_has_key (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN))
-		e_credentials_set (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN, is_book ? E_CREDENTIALS_AUTH_DOMAIN_ADDRESSBOOK : E_CREDENTIALS_AUTH_DOMAIN_CALENDAR);
+	if (!e_credentials_has_key (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN)) {
+		gchar *auth_domain = get_auth_domain (client);
+
+		e_credentials_set (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN, auth_domain);
+
+		g_free (auth_domain);
+	}
+
+	if (!e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_KEY)) {
+		gchar *prompt_key = get_prompt_key (client, e_credentials_peek (credentials, E_CREDENTIALS_KEY_USERNAME));
+
+		e_credentials_set (credentials, E_CREDENTIALS_KEY_PROMPT_KEY, prompt_key);
+
+		g_free (prompt_key);
+	}
 
 	if (!e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_TEXT)) {
 		gchar *prompt, *reason;
@@ -667,28 +734,9 @@ e_client_utils_authenticate_handler (EClient *client, ECredentials *credentials,
 		g_free (prompt);
 	}
 
-	if (!e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_KEY)) {
-		SoupURI *suri;
-		gchar *uri_str;
-
-		suri = soup_uri_new (e_client_get_uri (client));
-		g_return_val_if_fail (suri != NULL, FALSE);
-
-		soup_uri_set_user (suri, e_credentials_peek (credentials, E_CREDENTIALS_KEY_USERNAME));
-		soup_uri_set_password (suri, NULL);
-		soup_uri_set_fragment (suri, NULL);
-
-		uri_str = soup_uri_to_string (suri, FALSE);
-
-		e_credentials_set (credentials, E_CREDENTIALS_KEY_PROMPT_KEY, uri_str);
-
-		g_free (uri_str);
-		soup_uri_free (suri);
-	}
-
 	remember_password = g_strcmp0 (e_source_get_property (source, "remember_password"), "true") == 0;
 
-	res = e_credentials_authenticate_helper (credentials, NULL, &remember_password);
+	res = e_credentials_authenticate_helper (credentials, gtk_window_parent, &remember_password);
 
 	if (res)
 		e_source_set_property (source, "remember_password", remember_password ? "true" : NULL);
@@ -698,12 +746,41 @@ e_client_utils_authenticate_handler (EClient *client, ECredentials *credentials,
 	return res;
 }
 
+/**
+ * e_client_utils_forget_password:
+ * @client: An #EClient
+ *
+ * Forgets stored password for the given @client.
+ *
+ * Since: 3.2
+ **/
+void
+e_client_utils_forget_password (EClient *client)
+{
+	gchar *auth_domain, *prompt_key;
+	ESource *source;
+
+	g_return_if_fail (client != NULL);
+	g_return_if_fail (E_IS_CLIENT (client));
+
+	source = e_client_get_source (client);
+	g_return_if_fail (source != NULL);
+	
+	auth_domain = get_auth_domain (client);
+	prompt_key = get_prompt_key (client, e_source_get_property (source, "username"));
+
+	e_passwords_forget_password (auth_domain, prompt_key);
+
+	g_free (auth_domain);
+	g_free (prompt_key);
+}
+
 /* Asks for a password based on the provided credentials information.
    Credentials should have set following keys:
       E_CREDENTIALS_KEY_USERNAME
       E_CREDENTIALS_KEY_AUTH_DOMAIN
-      E_CREDENTIALS_KEY_PROMPT_TEXT
       E_CREDENTIALS_KEY_PROMPT_KEY
+      E_CREDENTIALS_KEY_PROMPT_TEXT
    all other keys are optional. If also E_CREDENTIALS_KEY_PASSWORD key is provided,
    then it implies a reprompt.
 
@@ -721,8 +798,8 @@ e_credentials_authenticate_helper (ECredentials *credentials, GtkWindow *parent,
 	g_return_val_if_fail (credentials != NULL, FALSE);
 	g_return_val_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_USERNAME), FALSE);
 	g_return_val_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN), FALSE);
-	g_return_val_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_TEXT), FALSE);
 	g_return_val_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_KEY), FALSE);
+	g_return_val_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_TEXT), FALSE);
 
 	if (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_FLAGS)) {
 		prompt_flags = e_credentials_util_string_to_prompt_flags (e_credentials_peek (credentials, E_CREDENTIALS_KEY_PROMPT_FLAGS));
@@ -768,3 +845,30 @@ e_credentials_authenticate_helper (ECredentials *credentials, GtkWindow *parent,
 
 	return res;
 }
+
+/**
+ * e_credentials_forget_password:
+ * @credentials: an #ECredentials
+ *
+ * Forgets stored password for given @credentials, which should contain
+ * E_CREDENTIALS_KEY_AUTH_DOMAIN and E_CREDENTIALS_KEY_PROMPT_KEY.
+ *
+ * Since: 3.2
+ **/
+void
+e_credentials_forget_password (const ECredentials *credentials)
+{
+	gchar *auth_domain, *prompt_key;
+
+	g_return_if_fail (credentials != NULL);
+	g_return_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN));
+	g_return_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_KEY));
+
+	auth_domain = e_credentials_get (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN);
+	prompt_key = e_credentials_get (credentials, E_CREDENTIALS_KEY_PROMPT_KEY);
+
+	e_passwords_forget_password (auth_domain, prompt_key);
+
+	g_free (auth_domain);
+	g_free (prompt_key);
+}
diff --git a/libedataserverui/e-client-utils.h b/libedataserverui/e-client-utils.h
index 5f63b63..130a796 100644
--- a/libedataserverui/e-client-utils.h
+++ b/libedataserverui/e-client-utils.h
@@ -47,13 +47,16 @@ gboolean	e_client_utils_set_default		(EClient *client, EClientSourceType source_
 gboolean	e_client_utils_set_default_source	(ESource *source, EClientSourceType source_type, GError **error);
 gboolean	e_client_utils_get_sources		(ESourceList **sources, EClientSourceType source_type, GError **error);
 
-void		e_client_utils_open_new			(ESource *source, EClientSourceType source_type, gboolean only_if_exists,
+void		e_client_utils_open_new			(ESource *source, EClientSourceType source_type, gboolean only_if_exists, GCancellable *cancellable,
 							 EClientUtilsAuthenticateHandler auth_handler, gpointer auth_handler_user_data,
-							 GCancellable *cancellable, GAsyncReadyCallback async_cb, gpointer async_cb_user_data);
-gboolean	e_client_utils_open_new_finish		(GAsyncResult *result, EClient **client, GError **error);
+							 GAsyncReadyCallback async_cb, gpointer async_cb_user_data);
+gboolean	e_client_utils_open_new_finish		(ESource *source, GAsyncResult *result, EClient **client, GError **error);
+
+gboolean	e_client_utils_authenticate_handler	(EClient *client, ECredentials *credentials, gpointer gtk_window_parent);
+void		e_client_utils_forget_password		(EClient *client);
 
-gboolean	e_client_utils_authenticate_handler	(EClient *client, ECredentials *credentials, gpointer unused_user_data);
 gboolean	e_credentials_authenticate_helper	(ECredentials *credentials, GtkWindow *parent, gboolean *remember_password);
+void		e_credentials_forget_password		(const ECredentials *credentials);
 
 G_END_DECLS
 
diff --git a/libedataserverui/e-contact-store.c b/libedataserverui/e-contact-store.c
index 3fba409..e98d690 100644
--- a/libedataserverui/e-contact-store.c
+++ b/libedataserverui/e-contact-store.c
@@ -44,6 +44,16 @@ struct _EContactStorePrivate {
 	GArray *contact_sources;
 };
 
+/* Signals */
+
+enum {
+	START_CLIENT_VIEW,
+	STOP_CLIENT_VIEW,
+	LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
 static void e_contact_store_tree_model_init (GtkTreeModelIface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (
@@ -82,19 +92,19 @@ static gboolean     e_contact_store_iter_parent     (GtkTreeModel       *tree_mo
 
 typedef struct
 {
-	EBook     *book;
+	EBookClient *book_client;
 
-	EBookView *book_view;
+	EBookClientView *client_view;
 	GPtrArray *contacts;
 
-	EBookView *book_view_pending;
+	EBookClientView *client_view_pending;
 	GPtrArray *contacts_pending;
 }
 ContactSource;
 
 static void free_contact_ptrarray (GPtrArray *contacts);
 static void clear_contact_source  (EContactStore *contact_store, ContactSource *source);
-static void stop_view             (EContactStore *contact_store, EBookView *view);
+static void stop_view             (EContactStore *contact_store, EBookClientView *view);
 
 static void
 contact_store_dispose (GObject *object)
@@ -114,7 +124,7 @@ contact_store_dispose (GObject *object)
 
 		clear_contact_source (E_CONTACT_STORE (object), source);
 		free_contact_ptrarray (source->contacts);
-		g_object_unref (source->book);
+		g_object_unref (source->book_client);
 	}
 	g_array_set_size (priv->contact_sources, 0);
 
@@ -150,6 +160,24 @@ e_contact_store_class_init (EContactStoreClass *class)
 	object_class = G_OBJECT_CLASS (class);
 	object_class->dispose = contact_store_dispose;
 	object_class->finalize = contact_store_finalize;
+
+	signals[START_CLIENT_VIEW] =
+		g_signal_new ("start-client-view",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (EContactStoreClass, start_client_view),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__OBJECT,
+			      G_TYPE_NONE, 1, E_TYPE_BOOK_CLIENT_VIEW);
+
+	signals[STOP_CLIENT_VIEW] =
+		g_signal_new ("stop-client-view",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (EContactStoreClass, stop_client_view),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__OBJECT,
+			      G_TYPE_NONE, 1, E_TYPE_BOOK_CLIENT_VIEW);
 }
 
 static void
@@ -245,7 +273,7 @@ row_changed (EContactStore *contact_store, gint n)
  * ---------------------- */
 
 static gint
-find_contact_source_by_book (EContactStore *contact_store, EBook *book)
+find_contact_source_by_client (EContactStore *contact_store, EBookClient *book_client)
 {
 	GArray *array;
 	gint i;
@@ -256,32 +284,15 @@ find_contact_source_by_book (EContactStore *contact_store, EBook *book)
 		ContactSource *source;
 
 		source = &g_array_index (array, ContactSource, i);
-		if (source->book == book)
+		if (source->book_client == book_client)
 			return i;
 	}
 
 	return -1;
 }
 
-EBookView *
-find_contact_source_by_book_return_view (EContactStore *contact_store, EBook *book)
-{
-	ContactSource *source = NULL;
-	GArray *array;
-	gint i;
-
-	array = contact_store->priv->contact_sources;
-
-	for (i = 0; i < array->len; i++) {
-		source = &g_array_index (array, ContactSource, i);
-		if (source->book == book)
-			break;
-	}
-	return source->book_view;;
-}
-
 static gint
-find_contact_source_by_view (EContactStore *contact_store, EBookView *book_view)
+find_contact_source_by_view (EContactStore *contact_store, EBookClientView *client_view)
 {
 	GArray *array;
 	gint i;
@@ -292,8 +303,8 @@ find_contact_source_by_view (EContactStore *contact_store, EBookView *book_view)
 		ContactSource *source;
 
 		source = &g_array_index (array, ContactSource, i);
-		if (source->book_view         == book_view ||
-		    source->book_view_pending == book_view)
+		if (source->client_view == client_view ||
+		    source->client_view_pending == client_view)
 			return i;
 	}
 
@@ -378,7 +389,7 @@ count_contacts (EContactStore *contact_store)
 }
 
 static gint
-find_contact_by_view_and_uid (EContactStore *contact_store, EBookView *find_view, const gchar *find_uid)
+find_contact_by_view_and_uid (EContactStore *contact_store, EBookClientView *find_view, const gchar *find_uid)
 {
 	GArray *array;
 	ContactSource *source;
@@ -395,7 +406,7 @@ find_contact_by_view_and_uid (EContactStore *contact_store, EBookView *find_view
 	array = contact_store->priv->contact_sources;
 	source = &g_array_index (array, ContactSource, source_index);
 
-	if (find_view == source->book_view)
+	if (find_view == source->client_view)
 		contacts = source->contacts;          /* Current view */
 	else
 		contacts = source->contacts_pending;  /* Pending view */
@@ -435,7 +446,7 @@ find_contact_by_uid (EContactStore *contact_store, const gchar *find_uid)
 	return -1;
 }
 
-static EBook *
+static EBookClient *
 get_book_at_row (EContactStore *contact_store, gint row)
 {
 	GArray *array;
@@ -449,7 +460,7 @@ get_book_at_row (EContactStore *contact_store, gint row)
 	array = contact_store->priv->contact_sources;
 	source = &g_array_index (array, ContactSource, source_index);
 
-	return source->book;
+	return source->book_client;
 }
 
 static EContact *
@@ -475,13 +486,13 @@ get_contact_at_row (EContactStore *contact_store, gint row)
 }
 
 static gboolean
-find_contact_source_details_by_view (EContactStore *contact_store, EBookView *book_view,
+find_contact_source_details_by_view (EContactStore *contact_store, EBookClientView *client_view,
 				     ContactSource **contact_source, gint *offset)
 {
 	GArray *array;
 	gint source_index;
 
-	source_index = find_contact_source_by_view (contact_store, book_view);
+	source_index = find_contact_source_by_view (contact_store, client_view);
 	if (source_index < 0)
 		return FALSE;
 
@@ -497,23 +508,23 @@ find_contact_source_details_by_view (EContactStore *contact_store, EBookView *bo
  * ------------------------- */
 
 static void
-view_contacts_added (EContactStore *contact_store, const GList *contacts, EBookView *book_view)
+view_contacts_added (EContactStore *contact_store, const GSList *contacts, EBookClientView *client_view)
 {
 	ContactSource *source;
 	gint           offset;
-	const GList   *l;
+	const GSList  *l;
 
-	if (!find_contact_source_details_by_view (contact_store, book_view, &source, &offset)) {
+	if (!find_contact_source_details_by_view (contact_store, client_view, &source, &offset)) {
 		g_warning ("EContactStore got 'contacts_added' signal from unknown EBookView!");
 		return;
 	}
 
-	for (l = contacts; l; l = g_list_next (l)) {
+	for (l = contacts; l; l = g_slist_next (l)) {
 		EContact *contact = l->data;
 
 		g_object_ref (contact);
 
-		if (book_view == source->book_view) {
+		if (client_view == source->client_view) {
 			/* Current view */
 			g_ptr_array_add (source->contacts, contact);
 			row_inserted (contact_store, offset + source->contacts->len - 1);
@@ -525,20 +536,20 @@ view_contacts_added (EContactStore *contact_store, const GList *contacts, EBookV
 }
 
 static void
-view_contacts_removed (EContactStore *contact_store, const GList *uids, EBookView *book_view)
+view_contacts_removed (EContactStore *contact_store, const GSList *uids, EBookClientView *client_view)
 {
 	ContactSource *source;
 	gint           offset;
-	const GList   *l;
+	const GSList  *l;
 
-	if (!find_contact_source_details_by_view (contact_store, book_view, &source, &offset)) {
+	if (!find_contact_source_details_by_view (contact_store, client_view, &source, &offset)) {
 		g_warning ("EContactStore got 'contacts_removed' signal from unknown EBookView!");
 		return;
 	}
 
-	for (l = uids; l; l = g_list_next (l)) {
+	for (l = uids; l; l = g_slist_next (l)) {
 		const gchar *uid = l->data;
-		gint         n   = find_contact_by_view_and_uid (contact_store, book_view, uid);
+		gint         n   = find_contact_by_view_and_uid (contact_store, client_view, uid);
 		EContact    *contact;
 
 		if (n < 0) {
@@ -546,7 +557,7 @@ view_contacts_removed (EContactStore *contact_store, const GList *uids, EBookVie
 			continue;
 		}
 
-		if (book_view == source->book_view) {
+		if (client_view == source->client_view) {
 			/* Current view */
 			contact = g_ptr_array_index (source->contacts, n);
 			g_object_unref (contact);
@@ -562,28 +573,28 @@ view_contacts_removed (EContactStore *contact_store, const GList *uids, EBookVie
 }
 
 static void
-view_contacts_changed (EContactStore *contact_store, const GList *contacts, EBookView *book_view)
+view_contacts_modified (EContactStore *contact_store, const GSList *contacts, EBookClientView *client_view)
 {
 	GPtrArray     *cached_contacts;
 	ContactSource *source;
 	gint           offset;
-	const GList   *l;
+	const GSList  *l;
 
-	if (!find_contact_source_details_by_view (contact_store, book_view, &source, &offset)) {
+	if (!find_contact_source_details_by_view (contact_store, client_view, &source, &offset)) {
 		g_warning ("EContactStore got 'contacts_changed' signal from unknown EBookView!");
 		return;
 	}
 
-	if (book_view == source->book_view)
+	if (client_view == source->client_view)
 		cached_contacts = source->contacts;
 	else
 		cached_contacts = source->contacts_pending;
 
-	for (l = contacts; l; l = g_list_next (l)) {
+	for (l = contacts; l; l = g_slist_next (l)) {
 		EContact    *cached_contact;
 		EContact    *contact = l->data;
 		const gchar *uid     = e_contact_get_const (contact, E_CONTACT_UID);
-		gint         n       = find_contact_by_view_and_uid (contact_store, book_view, uid);
+		gint         n       = find_contact_by_view_and_uid (contact_store, client_view, uid);
 
 		if (n < 0) {
 			g_warning ("EContactStore got change notification on unknown contact!");
@@ -599,30 +610,30 @@ view_contacts_changed (EContactStore *contact_store, const GList *contacts, EBoo
 		}
 
 		/* Emit changes for current view only */
-		if (book_view == source->book_view)
+		if (client_view == source->client_view)
 			row_changed (contact_store, offset + n);
 	}
 }
 
 static void
-view_complete (EContactStore *contact_store, EBookViewStatus status, const gchar *error_msg, EBookView *book_view)
+view_complete (EContactStore *contact_store, const GError *error, EBookClientView *client_view)
 {
 	ContactSource *source;
 	gint           offset;
 	gint           i;
 
-	if (!find_contact_source_details_by_view (contact_store, book_view, &source, &offset)) {
-		g_warning ("EContactStore got 'sequence_complete' signal from unknown EBookView!");
+	if (!find_contact_source_details_by_view (contact_store, client_view, &source, &offset)) {
+		g_warning ("EContactStore got 'complete' signal from unknown EBookClientView!");
 		return;
 	}
 
 	/* If current view finished, do nothing */
-	if (book_view == source->book_view) {
-		stop_view (contact_store, source->book_view);
+	if (client_view == source->client_view) {
+		stop_view (contact_store, source->client_view);
 		return;
 	}
 
-	g_assert (book_view == source->book_view_pending);
+	g_assert (client_view == source->client_view_pending);
 
 	/* However, if it was a pending view, calculate and emit the differences between that
 	 * and the current view, and move the pending view up to current.
@@ -635,7 +646,7 @@ view_complete (EContactStore *contact_store, EBookViewStatus status, const gchar
 		const gchar *old_uid     = e_contact_get_const (old_contact, E_CONTACT_UID);
 		gint         result;
 
-		result = find_contact_by_view_and_uid (contact_store, source->book_view_pending, old_uid);
+		result = find_contact_by_view_and_uid (contact_store, source->client_view_pending, old_uid);
 		if (result < 0) {
 			/* Contact is not in new view; removed */
 			g_object_unref (old_contact);
@@ -651,7 +662,7 @@ view_complete (EContactStore *contact_store, EBookViewStatus status, const gchar
 		const gchar *new_uid     = e_contact_get_const (new_contact, E_CONTACT_UID);
 		gint         result;
 
-		result = find_contact_by_view_and_uid (contact_store, source->book_view, new_uid);
+		result = find_contact_by_view_and_uid (contact_store, source->client_view, new_uid);
 		if (result < 0) {
 			/* Contact is not in old view; inserted */
 			g_ptr_array_add (source->contacts, new_contact);
@@ -663,10 +674,10 @@ view_complete (EContactStore *contact_store, EBookViewStatus status, const gchar
 	}
 
 	/* Move pending view up to current */
-	stop_view (contact_store, source->book_view);
-	g_object_unref (source->book_view);
-	source->book_view = source->book_view_pending;
-	source->book_view_pending = NULL;
+	stop_view (contact_store, source->client_view);
+	g_object_unref (source->client_view);
+	source->client_view = source->client_view_pending;
+	source->client_view_pending = NULL;
 
 	/* Free array of pending contacts (members have been either moved or unreffed) */
 	g_ptr_array_free (source->contacts_pending, TRUE);
@@ -678,27 +689,31 @@ view_complete (EContactStore *contact_store, EBookViewStatus status, const gchar
  * --------------------- */
 
 static void
-start_view (EContactStore *contact_store, EBookView *view)
+start_view (EContactStore *contact_store, EBookClientView *view)
 {
-	g_signal_connect_swapped (view, "contacts_added",
+	g_signal_emit (contact_store, signals[START_CLIENT_VIEW], 0, view);
+
+	g_signal_connect_swapped (view, "objects-added",
 				  G_CALLBACK (view_contacts_added), contact_store);
-	g_signal_connect_swapped (view, "contacts_removed",
+	g_signal_connect_swapped (view, "objects-removed",
 				  G_CALLBACK (view_contacts_removed), contact_store);
-	g_signal_connect_swapped (view, "contacts_changed",
-				  G_CALLBACK (view_contacts_changed), contact_store);
-	g_signal_connect_swapped (view, "view_complete",
+	g_signal_connect_swapped (view, "objects-modified",
+				  G_CALLBACK (view_contacts_modified), contact_store);
+	g_signal_connect_swapped (view, "complete",
 				  G_CALLBACK (view_complete), contact_store);
 
-	e_book_view_start (view);
+	e_book_client_view_start (view, NULL);
 }
 
 static void
-stop_view (EContactStore *contact_store, EBookView *view)
+stop_view (EContactStore *contact_store, EBookClientView *view)
 {
-	e_book_view_stop (view);
+	e_book_client_view_stop (view, NULL);
 
 	g_signal_handlers_disconnect_matched (view, G_SIGNAL_MATCH_DATA,
 					      0, 0, NULL, NULL, contact_store);
+
+	g_signal_emit (contact_store, signals[STOP_CLIENT_VIEW], 0, view);
 }
 
 static void
@@ -756,60 +771,103 @@ clear_contact_source (EContactStore *contact_store, ContactSource *source)
 
 	/* Free main and pending views, clear cached contacts */
 
-	if (source->book_view) {
-		stop_view (contact_store, source->book_view);
-		g_object_unref (source->book_view);
+	if (source->client_view) {
+		stop_view (contact_store, source->client_view);
+		g_object_unref (source->client_view);
 
-		source->book_view = NULL;
+		source->client_view = NULL;
 	}
 
-	if (source->book_view_pending) {
-		stop_view (contact_store, source->book_view_pending);
-		g_object_unref (source->book_view_pending);
+	if (source->client_view_pending) {
+		stop_view (contact_store, source->client_view_pending);
+		g_object_unref (source->client_view_pending);
 		free_contact_ptrarray (source->contacts_pending);
 
-		source->book_view_pending = NULL;
+		source->client_view_pending = NULL;
 		source->contacts_pending  = NULL;
 	}
 }
 
 static void
+client_view_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+	EContactStore *contact_store = user_data;
+	gint source_idx;
+	EBookClient *book_client;
+	EBookClientView *client_view = NULL;
+
+	g_return_if_fail (contact_store != NULL);
+	g_return_if_fail (source_object != NULL);
+
+	book_client = E_BOOK_CLIENT (source_object);
+	g_return_if_fail (book_client != NULL);
+
+	if (!e_book_client_get_view_finish (book_client, result, &client_view, NULL))
+		client_view = NULL;
+
+	source_idx = find_contact_source_by_client (contact_store, book_client);
+	if (source_idx >= 0) {
+		ContactSource *source;
+
+		source = &g_array_index (contact_store->priv->contact_sources, ContactSource, source_idx);
+		
+		if (source->client_view) {
+			if (source->client_view_pending) {
+				stop_view (contact_store, source->client_view_pending);
+				g_object_unref (source->client_view_pending);
+				free_contact_ptrarray (source->contacts_pending);
+			}
+
+			source->client_view_pending = client_view;
+
+			if (source->client_view_pending) {
+				source->contacts_pending = g_ptr_array_new ();
+				start_view (contact_store, client_view);
+			} else {
+				source->contacts_pending = NULL;
+			}
+		} else {
+			source->client_view = client_view;
+
+			if (source->client_view) {
+				start_view (contact_store, client_view);
+			}
+		}
+	}
+
+	g_object_unref (contact_store);
+}
+
+static void
 query_contact_source (EContactStore *contact_store, ContactSource *source)
 {
-	EBookView *view;
+	gboolean is_opened;
 
-	g_assert (source->book != NULL);
+	g_assert (source->book_client != NULL);
 
 	if (!contact_store->priv->query) {
 		clear_contact_source (contact_store, source);
 		return;
 	}
 
-	if (!e_book_is_opened (source->book) ||
-	    !e_book_get_book_view (source->book, contact_store->priv->query, NULL, -1, &view, NULL))
-		view = NULL;
+	is_opened = e_client_is_opened (E_CLIENT (source->book_client));
 
-	if (source->book_view) {
-		if (source->book_view_pending) {
-			stop_view (contact_store, source->book_view_pending);
-			g_object_unref (source->book_view_pending);
+	if (source->client_view) {
+		if (source->client_view_pending) {
+			stop_view (contact_store, source->client_view_pending);
+			g_object_unref (source->client_view_pending);
 			free_contact_ptrarray (source->contacts_pending);
-		}
-
-		source->book_view_pending = view;
-
-		if (source->book_view_pending) {
-			source->contacts_pending = g_ptr_array_new ();
-			start_view (contact_store, view);
-		} else {
+			source->client_view_pending = NULL;
 			source->contacts_pending = NULL;
 		}
-	} else {
-		source->book_view = view;
+	}
 
-		if (source->book_view) {
-			start_view (contact_store, view);
-		}
+	if (is_opened) {
+		gchar *query_str;
+
+		query_str = e_book_query_to_string (contact_store->priv->query);
+		e_book_client_get_view (source->book_client, query_str, NULL, client_view_ready_cb, g_object_ref (contact_store));
+		g_free (query_str);
 	}
 }
 
@@ -818,16 +876,16 @@ query_contact_source (EContactStore *contact_store, ContactSource *source)
  * ----------------- */
 
 /**
- * e_contact_store_get_book:
+ * e_contact_store_get_client:
  * @contact_store: an #EContactStore
  * @iter: a #GtkTreeIter from @contact_store
  *
- * Gets the #EBook that provided the contact at @iter.
+ * Gets the #EBookClient that provided the contact at @iter.
  *
- * Returns: An #EBook.
+ * Returns: An #EBookClient.
  **/
-EBook *
-e_contact_store_get_book (EContactStore *contact_store, GtkTreeIter *iter)
+EBookClient *
+e_contact_store_get_client (EContactStore *contact_store, GtkTreeIter *iter)
 {
 	gint index;
 
@@ -889,19 +947,19 @@ e_contact_store_find_contact (EContactStore *contact_store, const gchar *uid,
 }
 
 /**
- * e_contact_store_get_books:
+ * e_contact_store_get_clients:
  * @contact_store: an #EContactStore
  *
- * Gets the list of books that provide contacts for @contact_store.
+ * Gets the list of book clients that provide contacts for @contact_store.
  *
- * Returns: A #GList of pointers to #EBook. The caller owns the list,
- * but not the books.
+ * Returns: A #GSList of pointers to #EBookClient. The caller owns the list,
+ * but not the book clients.
  **/
-GList *
-e_contact_store_get_books (EContactStore *contact_store)
+GSList *
+e_contact_store_get_clients (EContactStore *contact_store)
 {
 	GArray *array;
-	GList *book_list = NULL;
+	GSList *client_list = NULL;
 	gint i;
 
 	g_return_val_if_fail (E_IS_CONTACT_STORE (contact_store), NULL);
@@ -912,38 +970,39 @@ e_contact_store_get_books (EContactStore *contact_store)
 		ContactSource *source;
 
 		source = &g_array_index (array, ContactSource, i);
-		book_list = g_list_prepend (book_list, source->book);
+		client_list = g_slist_prepend (client_list, source->book_client);
 	}
 
-	return book_list;
+	return client_list;
 }
 
 /**
- * e_contact_store_add_book:
+ * e_contact_store_add_client:
  * @contact_store: an #EContactStore
- * @book: an #EBook
+ * @book_client: an #EBookClient
  *
- * Adds @book to the list of books that provide contacts for @contact_store.
+ * Adds @book_client to the list of book clients that provide contacts for @contact_store.
+ * The @contact_store adds a reference to @book_client, if added.
  **/
 void
-e_contact_store_add_book (EContactStore *contact_store, EBook *book)
+e_contact_store_add_client (EContactStore *contact_store, EBookClient *book_client)
 {
 	GArray *array;
 	ContactSource source;
 	ContactSource *indexed_source;
 
 	g_return_if_fail (E_IS_CONTACT_STORE (contact_store));
-	g_return_if_fail (E_IS_BOOK (book));
+	g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
 
-	if (find_contact_source_by_book (contact_store, book) >= 0) {
-		g_warning ("Same book added more than once to EContactStore!");
+	if (find_contact_source_by_client (contact_store, book_client) >= 0) {
+		g_warning ("Same book client added more than once to EContactStore!");
 		return;
 	}
 
 	array = contact_store->priv->contact_sources;
 
 	memset (&source, 0, sizeof (ContactSource));
-	source.book     = g_object_ref (book);
+	source.book_client = g_object_ref (book_client);
 	source.contacts = g_ptr_array_new ();
 	g_array_append_val (array, source);
 
@@ -953,25 +1012,25 @@ e_contact_store_add_book (EContactStore *contact_store, EBook *book)
 }
 
 /**
- * e_contact_store_remove_book:
+ * e_contact_store_remove_client:
  * @contact_store: an #EContactStore
- * @book: an #EBook
+ * @book_client: an #EBookClient
  *
- * Removes @book from the list of books that provide contacts for @contact_store.
+ * Removes @book from the list of book clients that provide contacts for @contact_store.
  **/
 void
-e_contact_store_remove_book (EContactStore *contact_store, EBook *book)
+e_contact_store_remove_client (EContactStore *contact_store, EBookClient *book_client)
 {
 	GArray *array;
 	ContactSource *source;
 	gint source_index;
 
 	g_return_if_fail (E_IS_CONTACT_STORE (contact_store));
-	g_return_if_fail (E_IS_BOOK (book));
+	g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
 
-	source_index = find_contact_source_by_book (contact_store, book);
+	source_index = find_contact_source_by_client (contact_store, book_client);
 	if (source_index < 0) {
-		g_warning ("Tried to remove unknown book from EContactStore!");
+		g_warning ("Tried to remove unknown book client from EContactStore!");
 		return;
 	}
 
@@ -980,7 +1039,7 @@ e_contact_store_remove_book (EContactStore *contact_store, EBook *book)
 	source = &g_array_index (array, ContactSource, source_index);
 	clear_contact_source (contact_store, source);
 	free_contact_ptrarray (source->contacts);
-	g_object_unref (book);
+	g_object_unref (book_client);
 
 	g_array_remove_index (array, source_index);  /* Preserve order */
 }
diff --git a/libedataserverui/e-contact-store.h b/libedataserverui/e-contact-store.h
index 513615e..645df62 100644
--- a/libedataserverui/e-contact-store.h
+++ b/libedataserverui/e-contact-store.h
@@ -25,9 +25,9 @@
 
 #include <gtk/gtk.h>
 #include <libebook/e-contact.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-client-view.h>
 #include <libebook/e-book-query.h>
-#include <libebook/e-book-types.h>
 
 /* Standard GObject macros */
 #define E_TYPE_CONTACT_STORE \
@@ -61,12 +61,16 @@ struct _EContactStore {
 
 struct _EContactStoreClass {
 	GObjectClass parent_class;
+
+	/* signals */
+	void (*start_client_view) (EContactStore *contact_store, EBookClientView *client_view);
+	void (*stop_client_view)  (EContactStore *contact_store, EBookClientView *client_view);
 };
 
 GType		e_contact_store_get_type	(void);
 EContactStore *	e_contact_store_new		(void);
 
-EBook *		e_contact_store_get_book	(EContactStore *contact_store,
+EBookClient *	e_contact_store_get_client	(EContactStore *contact_store,
 						 GtkTreeIter *iter);
 EContact *	e_contact_store_get_contact	(EContactStore *contact_store,
 						 GtkTreeIter *iter);
@@ -75,17 +79,14 @@ gboolean	e_contact_store_find_contact	(EContactStore *contact_store,
 						 GtkTreeIter *iter);
 
 /* Returns a shallow copy; free the list when done, but don't unref elements */
-GList *		e_contact_store_get_books	(EContactStore *contact_store);
-void		e_contact_store_add_book	(EContactStore *contact_store,
-						 EBook *book);
-void		e_contact_store_remove_book	(EContactStore *contact_store,
-						 EBook *book);
+GSList *	e_contact_store_get_clients	(EContactStore *contact_store);
+void		e_contact_store_add_client	(EContactStore *contact_store,
+						 EBookClient *book_client);
+void		e_contact_store_remove_client	(EContactStore *contact_store,
+						 EBookClient *book_client);
 void		e_contact_store_set_query	(EContactStore *contact_store,
 						 EBookQuery *book_query);
 EBookQuery *	e_contact_store_peek_query	(EContactStore *contact_store);
-EBookView *	find_contact_source_by_book_return_view
-						(EContactStore *contact_store,
-						 EBook *book);
 
 G_END_DECLS
 
diff --git a/libedataserverui/e-name-selector-dialog.c b/libedataserverui/e-name-selector-dialog.c
index 16558b9..a1b395c 100644
--- a/libedataserverui/e-name-selector-dialog.c
+++ b/libedataserverui/e-name-selector-dialog.c
@@ -30,13 +30,18 @@
 #include <gdk/gdkkeysyms.h>
 #include <glib/gi18n-lib.h>
 #include <gconf/gconf-client.h>
-#include <libedataserverui/e-source-combo-box.h>
-#include <libedataserverui/e-destination-store.h>
-#include <libedataserverui/e-contact-store.h>
-#include <libedataserverui/e-book-auth-util.h>
-#include "libedataserver/e-sexp.h"
-#include "libedataserver/e-categories.h"
-#include "libedataserver/libedataserver-private.h"
+
+#include <libedataserver/e-sexp.h>
+#include <libedataserver/e-categories.h>
+
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-client-view.h>
+#include <libebook/e-book-query.h>
+
+#include "e-source-combo-box.h"
+#include "e-destination-store.h"
+#include "e-contact-store.h"
+#include "e-client-utils.h"
 #include "e-name-selector-dialog.h"
 #include "e-name-selector-entry.h"
 
@@ -304,7 +309,7 @@ e_name_selector_dialog_init (ENameSelectorDialog *name_selector_dialog)
 
 	/* Get addressbook sources */
 
-	if (!e_book_get_addressbooks (&source_list, NULL)) {
+	if (!e_book_client_get_sources (&source_list, NULL)) {
 		g_warning ("ENameSelectorDialog can't find any addressbooks!");
 		return;
 	}
@@ -507,7 +512,7 @@ sort_iter_to_contact_store_iter (ENameSelectorDialog *name_selector_dialog, GtkT
 }
 
 static void
-add_destination (ENameSelectorModel *name_selector_model, EDestinationStore *destination_store, EContact *contact, gint email_n)
+add_destination (ENameSelectorModel *name_selector_model, EDestinationStore *destination_store, EContact *contact, gint email_n, EBookClient *client)
 {
 	EDestination *destination;
 	GList *email_list, *nth;
@@ -524,6 +529,8 @@ add_destination (ENameSelectorModel *name_selector_model, EDestinationStore *des
 
 	destination = e_destination_new ();
 	e_destination_set_contact (destination, contact, email_n);
+	if (client)
+		e_destination_set_client (destination, client);
 	e_destination_store_append_destination (destination_store, destination);
 	g_object_unref (destination);
 }
@@ -532,8 +539,7 @@ static void
 remove_books (ENameSelectorDialog *name_selector_dialog)
 {
 	EContactStore *contact_store;
-	GList         *books;
-	GList         *l;
+	GSList        *clients, *l;
 
 	if (!name_selector_dialog->priv->name_selector_model)
 		return;
@@ -542,12 +548,12 @@ remove_books (ENameSelectorDialog *name_selector_dialog)
 		name_selector_dialog->priv->name_selector_model);
 
 	/* Remove books (should be just one) being viewed */
-	books = e_contact_store_get_books (contact_store);
-	for (l = books; l; l = g_list_next (l)) {
-		EBook *book = l->data;
-		e_contact_store_remove_book (contact_store, book);
+	clients = e_contact_store_get_clients (contact_store);
+	for (l = clients; l; l = g_slist_next (l)) {
+		EBookClient *client = l->data;
+		e_contact_store_remove_client (contact_store, client);
 	}
-	g_list_free (books);
+	g_slist_free (clients);
 
 	/* See if we have a book pending; stop loading it if so */
 	if (name_selector_dialog->priv->cancellable != NULL) {
@@ -852,7 +858,7 @@ model_section_removed (ENameSelectorDialog *name_selector_dialog, const gchar *n
  * -------------------- */
 
 static void
-status_message (EBookView *view, const gchar *message, ENameSelectorDialog *dialog)
+view_progress (EBookClientView *view, guint percent, const gchar *message, ENameSelectorDialog *dialog)
 {
 	if (message == NULL)
 		gtk_label_set_text (dialog->priv->status_label, "");
@@ -861,26 +867,46 @@ status_message (EBookView *view, const gchar *message, ENameSelectorDialog *dial
 }
 
 static void
-view_complete (EBookView *view, EBookViewStatus status, const gchar *error_msg, ENameSelectorDialog *dialog)
+view_complete (EBookClientView *view, const GError *error, ENameSelectorDialog *dialog)
+{
+	view_progress (view, -1, NULL, dialog);
+}
+
+static void
+start_client_view_cb (EContactStore *store, EBookClientView *client_view, ENameSelectorDialog *name_selector_dialog)
+{
+	g_signal_connect (
+		client_view, "progress",
+		G_CALLBACK (view_progress), name_selector_dialog);
+
+	g_signal_connect (
+		client_view, "complete",
+		G_CALLBACK (view_complete), name_selector_dialog);
+}
+
+static void
+stop_client_view_cb (EContactStore *store, EBookClientView *client_view, ENameSelectorDialog *name_selector_dialog)
 {
-	status_message (view, NULL, dialog);
+	g_signal_handlers_disconnect_by_func (client_view, view_progress, name_selector_dialog);
+	g_signal_handlers_disconnect_by_func (client_view, view_complete, name_selector_dialog);
 }
 
 static void
-book_loaded_cb (ESource *source,
+book_loaded_cb (GObject *source_object,
                 GAsyncResult *result,
-                ENameSelectorDialog *name_selector_dialog)
+                gpointer user_data)
 {
-	EBook *book;
-	EBookView *view;
+	ENameSelectorDialog *name_selector_dialog = user_data;
+	EClient *client = NULL;
+	EBookClient *book_client;
 	EContactStore *store;
 	ENameSelectorModel *model;
 	GError *error = NULL;
 
-	book = e_load_book_source_finish (source, result, &error);
+	e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error);
 
 	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
-		g_warn_if_fail (book == NULL);
+		g_warn_if_fail (client == NULL);
 		g_error_free (error);
 		goto exit;
 	}
@@ -894,28 +920,23 @@ book_loaded_cb (ESource *source,
 			name_selector_dialog->priv->status_label, message);
 		g_free (message);
 
-		g_warn_if_fail (book == NULL);
+		g_warn_if_fail (client == NULL);
 		g_error_free (error);
 		goto exit;
 	}
 
+	book_client = E_BOOK_CLIENT (client);
+	if (!book_client) {
+		g_warn_if_fail (book_client != NULL);
+		goto exit;
+	}
+
 	model = name_selector_dialog->priv->name_selector_model;
 	store = e_name_selector_model_peek_contact_store (model);
-	e_contact_store_add_book (store, book);
-
-	view = find_contact_source_by_book_return_view (store, book);
-
-	g_signal_connect (
-		view, "status-message",
-		G_CALLBACK (status_message), name_selector_dialog);
-
-	g_signal_connect (
-		view, "view-complete",
-		G_CALLBACK (view_complete), name_selector_dialog);
+	e_contact_store_add_client (store, book_client);
+	g_object_unref (book_client);
 
-	g_object_unref (book);
-
-exit:
+ exit:
 	g_object_unref (name_selector_dialog);
 }
 
@@ -939,10 +960,10 @@ source_changed (ENameSelectorDialog *name_selector_dialog,
 	name_selector_dialog->priv->cancellable = cancellable;
 
 	/* Start loading selected book */
-	e_load_book_source_async (
-		source, parent, cancellable,
-		(GAsyncReadyCallback) book_loaded_cb,
-		g_object_ref (name_selector_dialog));
+	e_client_utils_open_new (
+		source, E_CLIENT_SOURCE_TYPE_CONTACTS, TRUE, cancellable,
+		e_client_utils_authenticate_handler, parent,
+		book_loaded_cb, g_object_ref (name_selector_dialog));
 }
 
 /* --------------- *
@@ -1000,7 +1021,6 @@ search_changed (ENameSelectorDialog *name_selector_dialog)
 	contact_store = e_name_selector_model_peek_contact_store (
 		name_selector_dialog->priv->name_selector_model);
 	e_contact_store_set_query (contact_store, book_query);
-
 	e_book_query_unref (book_query);
 
 	g_free (query_string);
@@ -1075,7 +1095,8 @@ contact_activated (ENameSelectorDialog *name_selector_dialog, GtkTreePath *path)
 
 	add_destination (
 		name_selector_dialog->priv->name_selector_model,
-		destination_store, contact, email_n);
+		destination_store, contact, email_n,
+		e_contact_store_get_client (contact_store, &iter));
 }
 
 static void
@@ -1265,7 +1286,8 @@ transfer_button_clicked (ENameSelectorDialog *name_selector_dialog, GtkButton *t
 
 		add_destination (
 			name_selector_dialog->priv->name_selector_model,
-			destination_store, contact, email_n);
+			destination_store, contact, email_n,
+			e_contact_store_get_client (contact_store, &iter));
 	}
 	g_list_free (rows);
 }
@@ -1278,6 +1300,7 @@ static void
 setup_name_selector_model (ENameSelectorDialog *name_selector_dialog)
 {
 	ETreeModelGenerator *contact_filter;
+	EContactStore       *contact_store;
 	GList               *new_sections;
 	GList               *l;
 
@@ -1331,6 +1354,12 @@ setup_name_selector_model (ENameSelectorDialog *name_selector_dialog)
 		name_selector_dialog->priv->contact_view,
 		GTK_TREE_MODEL (name_selector_dialog->priv->contact_sort));
 
+	contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->priv->name_selector_model);
+	if (contact_store) {
+		g_signal_connect (contact_store, "start-client-view", G_CALLBACK (start_client_view_cb), name_selector_dialog);
+		g_signal_connect (contact_store, "stop-client-view", G_CALLBACK (stop_client_view_cb), name_selector_dialog);
+	}
+
 	/* Make sure UI is consistent */
 
 	search_changed (name_selector_dialog);
@@ -1359,6 +1388,14 @@ shutdown_name_selector_model (ENameSelectorDialog *name_selector_dialog)
 	/* Free backend model */
 
 	if (name_selector_dialog->priv->name_selector_model) {
+		EContactStore *contact_store;
+
+		contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->priv->name_selector_model);
+		if (contact_store) {
+			g_signal_handlers_disconnect_by_func (contact_store, start_client_view_cb, name_selector_dialog);
+			g_signal_handlers_disconnect_by_func (contact_store, stop_client_view_cb, name_selector_dialog);
+		}
+
 		g_signal_handlers_disconnect_matched (
 			name_selector_dialog->priv->name_selector_model,
 			G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_dialog);
diff --git a/libedataserverui/e-name-selector-dialog.h b/libedataserverui/e-name-selector-dialog.h
index 5b012a7..d95aacf 100644
--- a/libedataserverui/e-name-selector-dialog.h
+++ b/libedataserverui/e-name-selector-dialog.h
@@ -25,7 +25,6 @@
 #define E_NAME_SELECTOR_DIALOG_H
 
 #include <gtk/gtk.h>
-#include <libebook/e-book.h>
 #include <libedataserverui/e-contact-store.h>
 #include <libedataserverui/e-name-selector-model.h>
 
diff --git a/libedataserverui/e-name-selector-entry.c b/libedataserverui/e-name-selector-entry.c
index 18be4cd..8160a20 100644
--- a/libedataserverui/e-name-selector-entry.c
+++ b/libedataserverui/e-name-selector-entry.c
@@ -27,10 +27,10 @@
 #include <gconf/gconf-client.h>
 
 #include <camel/camel.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
 #include <libebook/e-contact.h>
 #include <libebook/e-destination.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libedataserverui/e-client-utils.h>
 #include <libedataserver/e-sexp.h>
 
 #include "e-name-selector-entry.h"
@@ -49,12 +49,12 @@ struct _ENameSelectorEntryPrivate {
 
 	EDestination *popup_destination;
 
-	gpointer	(*contact_editor_func)	(EBook *,
+	gpointer	(*contact_editor_func)	(EBookClient *,
 						 EContact *,
 						 gboolean,
 						 gboolean);
 	gpointer	(*contact_list_editor_func)
-						(EBook *,
+						(EBookClient *,
 						 EContact *,
 						 gboolean,
 						 gboolean);
@@ -778,12 +778,13 @@ contact_match_cue (EContact *contact, const gchar *cue_str,
 
 static gboolean
 find_existing_completion (ENameSelectorEntry *name_selector_entry, const gchar *cue_str,
-			  EContact **contact, gchar **text, EContactField *matched_field)
+			  EContact **contact, gchar **text, EContactField *matched_field, EBookClient **book_client)
 {
 	GtkTreeIter    iter;
 	EContact      *best_contact    = NULL;
 	gint           best_field_rank = G_MAXINT;
 	EContactField  best_field = 0;
+	EBookClient   *best_book_client = NULL;
 
 	g_assert (cue_str);
 
@@ -810,6 +811,7 @@ find_existing_completion (ENameSelectorEntry *name_selector_entry, const gchar *
 			best_contact    = current_contact;
 			best_field_rank = current_field_rank;
 			best_field      = current_field;
+			best_book_client = e_contact_store_get_client (name_selector_entry->priv->contact_store, &iter);
 		}
 	} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (name_selector_entry->priv->contact_store), &iter));
 
@@ -822,6 +824,8 @@ find_existing_completion (ENameSelectorEntry *name_selector_entry, const gchar *
 		*text = build_textrep_for_contact (best_contact, best_field);
 	if (matched_field)
 		*matched_field = best_field;
+	if (book_client)
+		*book_client = best_book_client;
 
 	return TRUE;
 }
@@ -887,6 +891,7 @@ static void
 type_ahead_complete (ENameSelectorEntry *name_selector_entry)
 {
 	EContact      *contact;
+	EBookClient   *book_client = NULL;
 	EContactField  matched_field;
 	EDestination  *destination;
 	gint           cursor_pos;
@@ -917,7 +922,7 @@ type_ahead_complete (ENameSelectorEntry *name_selector_entry)
 
 	cue_str = get_entry_substring (name_selector_entry, range_start, range_end);
 	if (!find_existing_completion (name_selector_entry, cue_str, &contact,
-				       &textrep, &matched_field)) {
+				       &textrep, &matched_field, &book_client)) {
 		g_free (cue_str);
 		return;
 	}
@@ -956,6 +961,8 @@ type_ahead_complete (ENameSelectorEntry *name_selector_entry)
 			email_n = matched_field - E_CONTACT_FIRST_EMAIL_ID;
 
 		e_destination_set_contact (destination, contact, email_n);
+		if (book_client)
+			e_destination_set_client (destination, book_client);
 		generate_attribute_list (name_selector_entry);
 	}
 
@@ -1523,6 +1530,7 @@ completion_match_selected (ENameSelectorEntry *name_selector_entry, ETreeModelGe
 			   GtkTreeIter *generator_iter)
 {
 	EContact      *contact;
+	EBookClient   *book_client;
 	EDestination  *destination;
 	gint           cursor_pos;
 	GtkTreeIter    contact_iter;
@@ -1538,12 +1546,15 @@ completion_match_selected (ENameSelectorEntry *name_selector_entry, ETreeModelGe
 							   generator_iter);
 
 	contact = e_contact_store_get_contact (name_selector_entry->priv->contact_store, &contact_iter);
+	book_client = e_contact_store_get_client (name_selector_entry->priv->contact_store, &contact_iter);
 	cursor_pos = gtk_editable_get_position (GTK_EDITABLE (name_selector_entry));
 
 	/* Set the contact in the model's destination */
 
 	destination = find_destination_at_position (name_selector_entry, cursor_pos);
 	e_destination_set_contact (destination, contact, email_n);
+	if (book_client)
+		e_destination_set_client (destination, book_client);
 	sync_destination_at_position (name_selector_entry, cursor_pos, &cursor_pos);
 
 	g_signal_handlers_block_by_func (name_selector_entry, user_insert_text, name_selector_entry);
@@ -1972,33 +1983,38 @@ setup_contact_store (ENameSelectorEntry *name_selector_entry)
 }
 
 static void
-book_loaded_cb (ESource *source,
+book_loaded_cb (GObject *source_object,
                 GAsyncResult *result,
-                EContactStore *contact_store)
+                gpointer user_data)
 {
-	EBook *book;
+	EContactStore *contact_store = user_data;
+	ESource *source = E_SOURCE (source_object);
+	EBookClient *book_client;
+	EClient *client = NULL;
 	GError *error = NULL;
 
-	book = e_load_book_source_finish (source, result, &error);
+	e_client_utils_open_new_finish (source, result, &client, &error);
 
 	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
-		g_warn_if_fail (book == NULL);
+		g_warn_if_fail (client == NULL);
 		g_error_free (error);
 		goto exit;
 	}
 
 	if (error != NULL) {
 		g_warning ("%s", error->message);
-		g_warn_if_fail (book == NULL);
+		g_warn_if_fail (client == NULL);
 		g_error_free (error);
 		goto exit;
 	}
 
-	g_return_if_fail (E_IS_BOOK (book));
-	e_contact_store_add_book (contact_store, book);
-	g_object_unref (book);
+	book_client = E_BOOK_CLIENT (client);
+
+	g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
+	e_contact_store_add_client (contact_store, book_client);
+	g_object_unref (book_client);
 
-exit:
+ exit:
 	g_object_unref (contact_store);
 }
 
@@ -2038,10 +2054,10 @@ setup_default_contact_store (ENameSelectorEntry *name_selector_entry)
 				&name_selector_entry->priv->cancellables,
 				cancellable);
 
-			e_load_book_source_async (
-				source, NULL, cancellable,
-				(GAsyncReadyCallback) book_loaded_cb,
-				g_object_ref (contact_store));
+			e_client_utils_open_new (
+				source, E_CLIENT_SOURCE_TYPE_CONTACTS, TRUE, cancellable,
+				e_client_utils_authenticate_handler, NULL,
+				book_loaded_cb, g_object_ref (contact_store));
 		}
 	}
 
@@ -2280,22 +2296,36 @@ prepare_popup_destination (ENameSelectorEntry *name_selector_entry, GdkEventButt
 	return FALSE;
 }
 
-static EBook *
-find_book_by_contact (GList *books, const gchar *contact_uid)
+static EBookClient *
+find_client_by_contact (GSList *clients, const gchar *contact_uid, const gchar *source_uid)
 {
-	GList *l;
+	GSList *l;
+
+	if (source_uid && source_uid) {
+		/* this is much quicket than asking each client for an existence */
+		for (l = clients; l; l = g_slist_next (l)) {
+			EBookClient *client = l->data;
+			ESource *source = e_client_get_source (E_CLIENT (client));
+
+			if (!source)
+				continue;
 
-	for (l = books; l; l = g_list_next (l)) {
-		EBook    *book = l->data;
+			if (g_strcmp0 (source_uid, e_source_peek_uid (source)) == 0)
+				return client;
+		}
+	}
+
+	for (l = clients; l; l = g_slist_next (l)) {
+		EBookClient *client = l->data;
 		EContact *contact = NULL;
 		gboolean  result;
 
-		result = e_book_get_contact (book, contact_uid, &contact, NULL);
+		result = e_book_client_get_contact_sync (client, contact_uid, &contact, NULL, NULL);
 		if (contact)
 			g_object_unref (contact);
 
 		if (result)
-			return book;
+			return client;
 	}
 
 	return NULL;
@@ -2307,35 +2337,47 @@ editor_closed_cb (GtkWidget *editor, gpointer data)
 	EContact *contact;
 	gchar *contact_uid;
 	EDestination *destination;
-	GList *books;
-	EBook *book;
+	GSList *clients;
+	EBookClient *book_client;
 	gint email_num;
 	ENameSelectorEntry *name_selector_entry = E_NAME_SELECTOR_ENTRY (data);
 
 	destination = name_selector_entry->priv->popup_destination;
 	contact = e_destination_get_contact (destination);
-	if (!contact)
+	if (!contact) {
+		g_object_unref (name_selector_entry);
 		return;
+	}
+
 	contact_uid = e_contact_get (contact, E_CONTACT_UID);
-	if (!contact_uid)
+	if (!contact_uid) {
+		g_object_unref (contact);
+		g_object_unref (name_selector_entry);
 		return;
+	}
 
 	if (name_selector_entry->priv->contact_store) {
-		books = e_contact_store_get_books (name_selector_entry->priv->contact_store);
-		book = find_book_by_contact (books, contact_uid);
-		g_list_free (books);
+		clients = e_contact_store_get_clients (name_selector_entry->priv->contact_store);
+		book_client = find_client_by_contact (clients, contact_uid, e_destination_get_source_uid (destination));
+		g_slist_free (clients);
 	} else {
-		book = NULL;
+		book_client = NULL;
 	}
-	if (!book)
-		return;
 
-	e_book_get_contact (book, contact_uid, &contact, NULL);
-	email_num = e_destination_get_email_num (destination);
-	e_destination_set_contact (destination, contact, email_num);
+	if (book_client) {
+		contact = NULL;
+
+		e_book_client_get_contact_sync (book_client, contact_uid, &contact, NULL, NULL);
+		email_num = e_destination_get_email_num (destination);
+		e_destination_set_contact (destination, contact, email_num);
+		e_destination_set_client (destination, book_client);
+	} else {
+		contact = NULL;
+	}
 
 	g_free (contact_uid);
-	g_object_unref (contact);
+	if (contact)
+		g_object_unref (contact);
 	g_object_unref (name_selector_entry);
 }
 
@@ -2388,8 +2430,8 @@ popup_activate_inline_expand (ENameSelectorEntry *name_selector_entry, GtkWidget
 static void
 popup_activate_contact (ENameSelectorEntry *name_selector_entry, GtkWidget *menu_item)
 {
-	EBook        *book;
-	GList        *books;
+	EBookClient  *book_client;
+	GSList       *clients;
 	EDestination *destination;
 	EContact     *contact;
 	gchar        *contact_uid;
@@ -2405,17 +2447,17 @@ popup_activate_contact (ENameSelectorEntry *name_selector_entry, GtkWidget *menu
 	contact_uid = e_contact_get (contact, E_CONTACT_UID);
 	if (!contact_uid)
 		return;
+
 	if (name_selector_entry->priv->contact_store) {
-		books = e_contact_store_get_books (name_selector_entry->priv->contact_store);
-		/*FIXME: read URI from contact and get the book ?*/
-		book = find_book_by_contact (books, contact_uid);
-		g_list_free (books);
+		clients = e_contact_store_get_clients (name_selector_entry->priv->contact_store);
+		book_client = find_client_by_contact (clients, contact_uid, e_destination_get_source_uid (destination));
+		g_slist_free (clients);
 		g_free (contact_uid);
 	} else {
-		book = NULL;
+		book_client = NULL;
 	}
 
-	if (!book)
+	if (!book_client)
 		return;
 
 	if (e_destination_is_evolution_list (destination)) {
@@ -2424,7 +2466,7 @@ popup_activate_contact (ENameSelectorEntry *name_selector_entry, GtkWidget *menu
 		if (!name_selector_entry->priv->contact_list_editor_func)
 			return;
 
-		contact_list_editor = (*name_selector_entry->priv->contact_list_editor_func) (book, contact, FALSE, TRUE);
+		contact_list_editor = (*name_selector_entry->priv->contact_list_editor_func) (book_client, contact, FALSE, TRUE);
 		g_object_ref (name_selector_entry);
 		g_signal_connect (contact_list_editor, "editor_closed",
 				  G_CALLBACK (editor_closed_cb), name_selector_entry);
@@ -2434,7 +2476,7 @@ popup_activate_contact (ENameSelectorEntry *name_selector_entry, GtkWidget *menu
 		if (!name_selector_entry->priv->contact_editor_func)
 			return;
 
-		contact_editor = (*name_selector_entry->priv->contact_editor_func) (book, contact, FALSE, TRUE);
+		contact_editor = (*name_selector_entry->priv->contact_editor_func) (book_client, contact, FALSE, TRUE);
 		g_object_ref (name_selector_entry);
 		g_signal_connect (contact_editor, "editor_closed",
 				  G_CALLBACK (editor_closed_cb), name_selector_entry);
@@ -2831,17 +2873,17 @@ e_name_selector_entry_init (ENameSelectorEntry *name_selector_entry)
 
 	/* Source list */
 
-	if (!e_book_get_addressbooks (&name_selector_entry->priv->source_list, NULL)) {
-	  g_warning ("ENameSelectorEntry can't find any addressbooks!");
-	  return;
+	if (!e_book_client_get_sources (&name_selector_entry->priv->source_list, NULL)) {
+		g_warning ("ENameSelectorEntry can't find any addressbooks!");
+		return;
 	}
 
 	/* read minimum_query_length from gconf*/
 	gconf = gconf_client_get_default ();
 	if (COMPLETION_CUE_MIN_LEN == 0) {
-	  if ((COMPLETION_CUE_MIN_LEN = gconf_client_get_int (gconf, MINIMUM_QUERY_LENGTH, NULL)))
-		;
-	  else COMPLETION_CUE_MIN_LEN = 3;
+		if ((COMPLETION_CUE_MIN_LEN = gconf_client_get_int (gconf, MINIMUM_QUERY_LENGTH, NULL)))
+			;
+		else COMPLETION_CUE_MIN_LEN = 3;
 	}
 	COMPLETION_FORCE_SHOW_ADDRESS = gconf_client_get_bool (gconf, FORCE_SHOW_ADDRESS, NULL);
 	name_selector_entry->priv->user_query_fields = gconf_client_get_list (
diff --git a/libedataserverui/e-name-selector.c b/libedataserverui/e-name-selector.c
index 4edb228..821aeb0 100644
--- a/libedataserverui/e-name-selector.c
+++ b/libedataserverui/e-name-selector.c
@@ -27,11 +27,12 @@
 #include <string.h>
 #include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
 #include <libebook/e-contact.h>
-#include <libedataserverui/e-contact-store.h>
-#include <libedataserverui/e-destination-store.h>
-#include <libedataserverui/e-book-auth-util.h>
+
+#include "e-contact-store.h"
+#include "e-destination-store.h"
+#include "e-client-utils.h"
 #include "e-name-selector.h"
 
 typedef struct {
@@ -40,7 +41,7 @@ typedef struct {
 } Section;
 
 typedef struct {
-	EBook *book;
+	EBookClient *client;
 	guint is_completion_book : 1;
 } SourceBook;
 
@@ -78,17 +79,20 @@ reset_pointer_cb (gpointer data, GObject *where_was)
 }
 
 static void
-name_selector_book_loaded_cb (ESource *source,
+name_selector_book_loaded_cb (GObject *source_object,
                               GAsyncResult *result,
-                              ENameSelector *name_selector)
+                              gpointer user_data)
 {
-	EBook *book;
+	ENameSelector *name_selector = user_data;
+	ESource *source = E_SOURCE (source_object);
+	EBookClient *book_client;
+	EClient *client = NULL;
 	GArray *sections;
 	SourceBook source_book;
 	guint ii;
 	GError *error = NULL;
 
-	book = e_load_book_source_finish (source, result, &error);
+	e_client_utils_open_new_finish (source, result, &client, &error);
 
 	if (error != NULL) {
 		g_warning (
@@ -98,9 +102,10 @@ name_selector_book_loaded_cb (ESource *source,
 		goto exit;
 	}
 
-	g_return_if_fail (E_IS_BOOK (book));
+	book_client = E_BOOK_CLIENT (client);
+	g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
 
-	source_book.book = book;
+	source_book.client = book_client;
 	source_book.is_completion_book = TRUE;
 
 	g_array_append_val (name_selector->priv->source_books, source_book);
@@ -118,7 +123,7 @@ name_selector_book_loaded_cb (ESource *source,
 		store = e_name_selector_entry_peek_contact_store (
 			section->entry);
 		if (store != NULL)
-			e_contact_store_add_book (store, book);
+			e_contact_store_add_client (store, book_client);
 	}
 
 exit:
@@ -132,7 +137,7 @@ name_selector_load_books (ENameSelector *name_selector)
 	GSList *groups;
 	GSList *iter1;
 
-	if (!e_book_get_addressbooks (&source_list, NULL)) {
+	if (!e_book_client_get_sources (&source_list, NULL)) {
 		g_warning ("ENameSelector can't find any addressbooks!");
 		return;
 	}
@@ -170,11 +175,10 @@ name_selector_load_books (ENameSelector *name_selector)
 				continue;
 
 			/* XXX Should we allow for cancellation? */
-			e_load_book_source_async (
-				source, NULL, NULL,
-				(GAsyncReadyCallback)
-				name_selector_book_loaded_cb,
-				g_object_ref (name_selector));
+			e_client_utils_open_new (
+				source, E_CLIENT_SOURCE_TYPE_CONTACTS, TRUE, NULL,
+				e_client_utils_authenticate_handler, NULL,
+				name_selector_book_loaded_cb, g_object_ref (name_selector));
 		}
 	}
 }
@@ -197,8 +201,8 @@ name_selector_dispose (GObject *object)
 
 		source_book = &g_array_index (
 			priv->source_books, SourceBook, ii);
-		if (source_book->book != NULL)
-			g_object_unref (source_book->book);
+		if (source_book->client != NULL)
+			g_object_unref (source_book->client);
 	}
 
 	for (ii = 0; ii < priv->sections->len; ii++) {
@@ -449,8 +453,8 @@ e_name_selector_peek_section_entry (ENameSelector *name_selector, const gchar *n
 		for (i = 0; i < priv->source_books->len; i++) {
 			SourceBook *source_book = &g_array_index (priv->source_books, SourceBook, i);
 
-			if (source_book->is_completion_book && source_book->book)
-				e_contact_store_add_book (contact_store, source_book->book);
+			if (source_book->is_completion_book && source_book->client)
+				e_contact_store_add_client (contact_store, source_book->client);
 		}
 
 		e_name_selector_entry_set_contact_store (section->entry, contact_store);
@@ -516,8 +520,8 @@ e_name_selector_peek_section_list (ENameSelector *name_selector, const gchar *na
 		for (i = 0; i < priv->source_books->len; i++) {
 			SourceBook *source_book = &g_array_index (priv->source_books, SourceBook, i);
 
-			if (source_book->is_completion_book && source_book->book)
-				e_contact_store_add_book (contact_store, source_book->book);
+			if (source_book->is_completion_book && source_book->client)
+				e_contact_store_add_client (contact_store, source_book->client);
 		}
 
 		e_name_selector_entry_set_contact_store (section->entry, contact_store);
@@ -526,4 +530,3 @@ e_name_selector_peek_section_list (ENameSelector *name_selector, const gchar *na
 
 	return (ENameSelectorList *) section->entry;
 }
-
diff --git a/libedataserverui/e-passwords.c b/libedataserverui/e-passwords.c
index 4e332c6..001fb5c 100644
--- a/libedataserverui/e-passwords.c
+++ b/libedataserverui/e-passwords.c
@@ -121,7 +121,7 @@ ep_keyring_uri_new (const gchar *string,
 
 	/* Make sure the URI has the required components. */
 	if (uri->user == NULL && uri->host == NULL) {
-		g_set_error (
+		g_set_error_literal (
 			error, EP_KEYRING_ERROR,
 			GNOME_KEYRING_RESULT_BAD_ARGUMENTS,
 			_("Keyring key is unusable: no user or host name"));
diff --git a/tests/libebook/Makefile.am b/tests/libebook/Makefile.am
index ac23d45..d425d8e 100644
--- a/tests/libebook/Makefile.am
+++ b/tests/libebook/Makefile.am
@@ -1,5 +1,26 @@
 SUBDIRS = vcard client
 
+if HAVE_E_BOOK_DISABLE_DEPRECATED
+
+TEST_CPPFLAGS =					\
+	$(AM_CPPFLAGS)				\
+	-I$(top_srcdir)				\
+	-I$(top_builddir)			\
+	-I$(top_srcdir)/addressbook		\
+	-I$(top_builddir)/addressbook		\
+	-DSRCDIR=\""$(srcdir)"\"		\
+	$(EVOLUTION_ADDRESSBOOK_CFLAGS)		\
+	$(NULL)
+
+TEST_LIBS =					\
+	$(top_builddir)/addressbook/libebook/libebook-1.2.la	\
+	$(EVOLUTION_ADDRESSBOOK_LIBS)				\
+	$(NULL)
+
+DEPRECATED_TESTS = $(NULL)
+
+else
+
 noinst_LTLIBRARIES = libebook-test-utils.la
 libebook_test_utils_la_SOURCES = ebook-test-utils.c ebook-test-utils.h
 
@@ -19,11 +40,26 @@ libebook_test_utils_la_LIBADD = \
 	$(EVOLUTION_ADDRESSBOOK_LIBS)                           \
 	$(NULL)
 
-TEST_LIBS =							\
-	$(libebook_test_utils_la_LIBADD) \
-	libebook-test-utils.la	         \
+TEST_CPPFLAGS =					\
+	$(libebook_test_utils_la_CPPFLAGS)	\
+	$(NULL)
+
+TEST_LIBS =					\
+	$(libebook_test_utils_la_LIBADD)	\
+	libebook-test-utils.la			\
 	$(NULL)
 
+DEPRECATED_TESTS =				\
+	test-changes				\
+	test-ebook				\
+	test-ebook-async			\
+	test-nonexistent-id			\
+	test-search				\
+	test-self				\
+	test-stress-bookviews
+
+endif
+
 # Should be kept ordered approximately from least to most difficult/complex
 TESTS = \
 	$(NULL)
@@ -50,25 +86,15 @@ TESTS = \
 #	test-ebook-stress-factory--single-book
 
 noinst_PROGRAMS = \
-	$(TESTS)				     \
-	test-changes				     \
-	test-categories				     \
-	test-date				     \
-	test-ebook				     \
-	test-ebook-async			     \
-	test-nonexistent-id			     \
-	test-photo				     \
-	test-query				     \
-	test-self				     \
-	test-string				     \
-	test-undefinedfield			     \
-	test-untyped-phones			     \
-	test-search				     \
-	test-stress-bookviews			     \
-	$(NULL)
-
-TEST_CPPFLAGS= \
-	$(libebook_test_utils_la_CPPFLAGS) \
+	$(TESTS)				\
+	$(DEPRECATED_TESTS)			\
+	test-categories				\
+	test-date				\
+	test-photo				\
+	test-query				\
+	test-string				\
+	test-undefinedfield			\
+	test-untyped-phones			\
 	$(NULL)
 
 EXTRA_DIST = \
@@ -77,10 +103,25 @@ EXTRA_DIST = \
 	$(srcdir)/data/vcards/simple-2.vcf	\
 	$(NULL)
 
-test_search_LDADD=$(TEST_LIBS)
-test_search_CPPFLAGS=$(TEST_CPPFLAGS)
+test_categories_LDADD=$(TEST_LIBS)
+test_categories_CPPFLAGS=$(TEST_CPPFLAGS)
 test_date_LDADD=$(TEST_LIBS)
 test_date_CPPFLAGS=$(TEST_CPPFLAGS)
+test_photo_LDADD=$(TEST_LIBS)
+test_photo_CPPFLAGS=$(TEST_CPPFLAGS)
+test_query_LDADD=$(TEST_LIBS)
+test_query_CPPFLAGS=$(TEST_CPPFLAGS)
+test_string_LDADD=$(TEST_LIBS)
+test_string_CPPFLAGS=$(TEST_CPPFLAGS)
+test_undefinedfield_LDADD=$(TEST_LIBS)
+test_undefinedfield_CPPFLAGS=$(TEST_CPPFLAGS)
+test_untyped_phones_LDADD=$(TEST_LIBS)
+test_untyped_phones_CPPFLAGS=$(TEST_CPPFLAGS)
+
+if !HAVE_E_BOOK_DISABLE_DEPRECATED
+
+test_search_LDADD=$(TEST_LIBS)
+test_search_CPPFLAGS=$(TEST_CPPFLAGS)
 test_ebook_LDADD=$(TEST_LIBS)
 test_ebook_CPPFLAGS=$(TEST_CPPFLAGS)
 test_ebook_async_LDADD=$(TEST_LIBS)
@@ -117,23 +158,13 @@ test_ebook_stress_factory__serial_CPPFLAGS=$(TEST_CPPFLAGS)
 test_ebook_stress_factory__single_book_CPPFLAGS=$(TEST_CPPFLAGS)
 test_changes_LDADD=$(TEST_LIBS)
 test_changes_CPPFLAGS=$(TEST_CPPFLAGS)
-test_categories_LDADD=$(TEST_LIBS)
-test_categories_CPPFLAGS=$(TEST_CPPFLAGS)
 test_nonexistent_id_LDADD=$(TEST_LIBS)
 test_nonexistent_id_CPPFLAGS=$(TEST_CPPFLAGS)
-test_photo_LDADD=$(TEST_LIBS)
-test_photo_CPPFLAGS=$(TEST_CPPFLAGS)
-test_query_LDADD=$(TEST_LIBS)
-test_query_CPPFLAGS=$(TEST_CPPFLAGS)
 test_self_LDADD=$(TEST_LIBS)
 test_self_CPPFLAGS=$(TEST_CPPFLAGS)
-test_string_LDADD=$(TEST_LIBS)
-test_string_CPPFLAGS=$(TEST_CPPFLAGS)
-test_undefinedfield_LDADD=$(TEST_LIBS)
-test_undefinedfield_CPPFLAGS=$(TEST_CPPFLAGS)
-test_untyped_phones_LDADD=$(TEST_LIBS)
-test_untyped_phones_CPPFLAGS=$(TEST_CPPFLAGS)
 test_stress_bookviews_LDADD=$(TEST_LIBS)
 test_stress_bookviews_CPPFLAGS=$(TEST_CPPFLAGS)
 
+endif
+
 -include $(top_srcdir)/git.mk
diff --git a/tests/libecal/Makefile.am b/tests/libecal/Makefile.am
index 4227613..0e38d33 100644
--- a/tests/libecal/Makefile.am
+++ b/tests/libecal/Makefile.am
@@ -1,5 +1,7 @@
 SUBDIRS = client
 
+if !HAVE_E_CAL_DISABLE_DEPRECATED
+
 noinst_LTLIBRARIES = libecal-test-utils.la
 libecal_test_utils_la_SOURCES = ecal-test-utils.c ecal-test-utils.h
 
@@ -24,14 +26,6 @@ TEST_ECAL_LIBS = \
 	libecal-test-utils.la           \
 	$(NULL)
 
-EXTRA_DIST =                          \
-	$(test_scripts)               \
-	testdata.ics
-
-test_scripts =                         \
-	test-runner.sh                 \
-	cleanup.sh
-
 # ordered by relative complexity
 TESTS = \
 	test-ecal-remove			\
@@ -154,4 +148,14 @@ test_search_LDADD =							\
 	$(LIBICAL_LIBS)							\
 	$(EVOLUTION_CALENDAR_LIBS)
 
+endif
+
+EXTRA_DIST =			\
+	$(test_scripts)		\
+	testdata.ics
+
+test_scripts =			\
+	test-runner.sh		\
+	cleanup.sh
+
 -include $(top_srcdir)/git.mk
diff --git a/tests/libedataserverui/test-client-examine-auth.c b/tests/libedataserverui/test-client-examine-auth.c
index d76bf70..0ebe70d 100644
--- a/tests/libedataserverui/test-client-examine-auth.c
+++ b/tests/libedataserverui/test-client-examine-auth.c
@@ -148,9 +148,9 @@ continue_next_source (gpointer async_data)
 
 	while (async_data && foreach_configured_source_async_next (&async_data, &source)) {
 		identify_source (source);
-		e_client_utils_open_new (source, source_type, TRUE,
+		e_client_utils_open_new (source, source_type, TRUE, NULL,
 			e_client_utils_authenticate_handler, NULL,
-			NULL, client_opened_async, async_data);
+			client_opened_async, async_data);
 		break;
 	}
 
@@ -236,7 +236,7 @@ client_opened_async (GObject *source_object, GAsyncResult *result, gpointer asyn
 	g_return_if_fail (source_object == NULL);
 	g_return_if_fail (async_data != NULL);
 
-	if (!e_client_utils_open_new_finish (result, &client, &error)) {
+	if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) {
 		report_error ("client utils open new finish", &error);
 		continue_next_source (async_data);
 		return;
@@ -265,9 +265,9 @@ foreach_async (void)
 	running_async++;
 
 	identify_source (source);
-	e_client_utils_open_new (source, source_type, TRUE,
+	e_client_utils_open_new (source, source_type, TRUE, NULL,
 		e_client_utils_authenticate_handler, NULL,
-		NULL, client_opened_async, async_data);
+		client_opened_async, async_data);
 
 	return TRUE;
 }
diff --git a/tests/libedataserverui/test-contact-store.c b/tests/libedataserverui/test-contact-store.c
index 4560801..c986662 100644
--- a/tests/libedataserverui/test-contact-store.c
+++ b/tests/libedataserverui/test-contact-store.c
@@ -64,7 +64,7 @@ start_test (const gchar *gconf_path)
 	GtkWidget *box;
 	GtkWidget *entry;
 	GtkTreeViewColumn *column;
-	EBook *book;
+	EBookClient *book_client;
 	EBookQuery *book_query;
 
 	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -94,10 +94,10 @@ start_test (const gchar *gconf_path)
 
 	gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
 
-	book = e_book_new_default_addressbook (NULL);
-	e_book_open (book, TRUE, NULL);
-	e_contact_store_add_book (contact_store, book);
-	g_object_unref (book);
+	book_client = e_book_client_new_default (NULL);
+	e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, NULL);
+	e_contact_store_add_client (contact_store, book_client);
+	g_object_unref (book_client);
 
 	book_query = e_book_query_any_field_contains ("");
 	e_contact_store_set_query (contact_store, book_query);



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