[evolution-data-server/openismus-work] Added e_book_client_connect_direct_sync()
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work] Added e_book_client_connect_direct_sync()
- Date: Wed, 20 Feb 2013 12:22:25 +0000 (UTC)
commit 39a724d2a125dae6f80f885a9641af066bcd479f
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Wed Feb 20 21:20:49 2013 +0900
Added e_book_client_connect_direct_sync()
This is a shim for the proper API to use in EDS 3.8, since
e_book_client_new() is deprecated in favor of e_book_client_connect[_sync]().
addressbook/libebook/e-book-client.c | 35 +++++++++++++++++++++++++
addressbook/libebook/e-book-client.h | 1 +
tests/test-server-utils/e-test-server-utils.c | 19 ++++++++-----
3 files changed, 48 insertions(+), 7 deletions(-)
---
diff --git a/addressbook/libebook/e-book-client.c b/addressbook/libebook/e-book-client.c
index a5d709c..7c66828 100644
--- a/addressbook/libebook/e-book-client.c
+++ b/addressbook/libebook/e-book-client.c
@@ -625,6 +625,41 @@ e_book_client_new_direct (ESourceRegistry *registry,
return client;
}
+/**
+ * e_book_client_connect_direct_sync:
+ * @registry: an #ESourceRegistry object
+ * @source: an #ESource
+ * @cancellable: (allow-none): optional #GCancellable object, or %NULL
+ * @error: (allow-none): return location for a #GError, or %NULL
+ *
+ * Like e_book_client_connect_sync(), except creates the book client for
+ * direct read access to the underlying addressbook.
+ *
+ * Returns: a new but unopened #EBookClient.
+ *
+ * Since: 3.8
+ **/
+EClient *
+e_book_client_connect_direct_sync (ESourceRegistry *registry,
+ ESource *source,
+ GCancellable *cancellable,
+ GError **error)
+{
+ EBookClient *client;
+
+ client = e_book_client_new_direct (registry, source, error);
+ if (!client)
+ return NULL;
+
+ if (!e_client_open_sync (E_CLIENT (client),
+ FALSE, cancellable, error)) {
+ g_object_unref (client);
+ return NULL;
+ }
+
+ return (EClient *)client;
+}
+
#define SELF_UID_PATH_ID "org.gnome.evolution-data-server.addressbook"
#define SELF_UID_KEY "self-contact-uid"
diff --git a/addressbook/libebook/e-book-client.h b/addressbook/libebook/e-book-client.h
index 985cf5d..ceece10 100644
--- a/addressbook/libebook/e-book-client.h
+++ b/addressbook/libebook/e-book-client.h
@@ -96,6 +96,7 @@ GType e_book_client_get_type (void);
EBookClient * e_book_client_new (ESource *source, GError **error);
EBookClient * e_book_client_new_direct (ESourceRegistry *registry, ESource *source,
GError **error);
+EClient * e_book_client_connect_direct_sync (ESourceRegistry *registry, ESource *source,
GCancellable *cancellable, GError **error);
/* Identity */
gboolean e_book_client_get_self (ESourceRegistry *registry, EContact
**contact, EBookClient **client, GError **error);
diff --git a/tests/test-server-utils/e-test-server-utils.c b/tests/test-server-utils/e-test-server-utils.c
index 156c69a..48c6348 100644
--- a/tests/test-server-utils/e-test-server-utils.c
+++ b/tests/test-server-utils/e-test-server-utils.c
@@ -114,19 +114,24 @@ e_test_server_utils_source_added (ESourceRegistry *registry,
if (g_strcmp0 (e_source_get_uid (source), ADDRESS_BOOK_SOURCE_UID) != 0)
return;
- if (g_getenv ("DEBUG_DIRECT") != NULL)
- pair->fixture->service.book_client =
- e_book_client_new_direct (pair->fixture->registry, source, &error);
- else
+ if (g_getenv ("DEBUG_DIRECT") != NULL) {
+
+ pair->fixture->service.book_client = (EBookClient *)
+ e_book_client_connect_direct_sync (pair->fixture->registry, source, NULL,
&error);
+
+ } else {
pair->fixture->service.book_client =
e_book_client_new (source, &error);
+ if (!e_client_open_sync (E_CLIENT (pair->fixture->service.book_client),
+ FALSE, NULL, &error))
+ g_error ("Unable to open book client: %s", error->message);
+
+ }
+
if (!pair->fixture->service.book_client)
g_error ("Unable to create the test book: %s", error->message);
- if (!e_client_open_sync (E_CLIENT (pair->fixture->service.book_client), FALSE, NULL, &error))
- g_error ("Unable to open book client: %s", error->message);
-
break;
case E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]