[evolution-data-server/treitter-client-gdbus] Port the e-book 'getStaticCapabilities' method to gdbus and add a regression test
- From: Travis Reitter <treitter src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server/treitter-client-gdbus] Port the e-book 'getStaticCapabilities' method to gdbus and add a regression test
- Date: Thu, 10 Dec 2009 16:37:37 +0000 (UTC)
commit b0616e930c561581013c97f047683f606614084f
Author: Travis Reitter <treitter gmail com>
Date: Wed Dec 9 11:40:22 2009 -0800
Port the e-book 'getStaticCapabilities' method to gdbus and add a regression test
addressbook/libebook/e-book.c | 2 +-
addressbook/libebook/e-data-book-gdbus-bindings.h | 38 ++++++++++++++++++++
addressbook/tests/ebook/Makefile.am | 3 ++
addressbook/tests/ebook/ebook-test-utils.c | 18 +++++++++
addressbook/tests/ebook/ebook-test-utils.h | 3 ++
.../ebook/test-ebook-get-static-capabilities.c | 32 ++++++++++++++++
6 files changed, 95 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index cf96430..feb6598 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -1882,7 +1882,7 @@ e_book_get_static_capabilities (EBook *book,
gchar *cap = NULL;
LOCK_CONN ();
- if (!org_gnome_evolution_dataserver_addressbook_Book_get_static_capabilities (book->priv->proxy, &cap, error)) {
+ if (!e_data_book_gdbus_get_static_capabilities_sync (book->priv->gdbus_proxy, &cap, error)) {
UNLOCK_CONN ();
return NULL;
}
diff --git a/addressbook/libebook/e-data-book-gdbus-bindings.h b/addressbook/libebook/e-data-book-gdbus-bindings.h
index 1f4a7f8..6c16567 100644
--- a/addressbook/libebook/e-data-book-gdbus-bindings.h
+++ b/addressbook/libebook/e-data-book-gdbus-bindings.h
@@ -243,6 +243,44 @@ e_data_book_gdbus_get_contact (GDBusProxy *proxy,
}
static gboolean
+get_static_capabilities_demarshal_retvals (GVariant *retvals, char **OUT_caps)
+{
+ gboolean success = TRUE;
+
+ if (retvals) {
+ const char *caps = NULL;
+
+ g_variant_get (retvals, "(s)", &caps);
+ if (caps) {
+ *OUT_caps = g_strdup (caps);
+ } else {
+ success = FALSE;
+ }
+
+ g_variant_unref (retvals);
+ } else {
+ success = FALSE;
+ }
+
+ return success;
+}
+
+static gboolean
+e_data_book_gdbus_get_static_capabilities_sync (GDBusProxy *proxy,
+ char **OUT_caps,
+ GError **error)
+
+{
+ GVariant *parameters;
+ GVariant *retvals;
+
+ parameters = g_variant_new ("()");
+ retvals = g_dbus_proxy_invoke_method_sync (proxy, "getStaticCapabilities", parameters, -1, NULL, error);
+
+ return get_static_capabilities_demarshal_retvals (retvals, OUT_caps);
+}
+
+static gboolean
get_contact_list_demarshal_retvals (GVariant *retvals, char ***OUT_vcards)
{
gboolean success = TRUE;
diff --git a/addressbook/tests/ebook/Makefile.am b/addressbook/tests/ebook/Makefile.am
index 171b5f3..cc892a2 100644
--- a/addressbook/tests/ebook/Makefile.am
+++ b/addressbook/tests/ebook/Makefile.am
@@ -30,6 +30,7 @@ noinst_PROGRAMS = \
test-ebook-add-contact \
test-ebook-commit-contact \
test-ebook-get-contact \
+ test-ebook-get-static-capabilities \
test-ebook-remove \
test-ebook-remove-contact \
test-ebook-remove-contact-by-id \
@@ -64,6 +65,8 @@ test_ebook_commit_contact_LDADD=$(TEST_LIBS)
test_ebook_commit_contact_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_get_contact_LDADD=$(TEST_LIBS)
test_ebook_get_contact_CPPFLAGS=$(TEST_CPPFLAGS)
+test_ebook_get_static_capabilities_LDADD=$(TEST_LIBS)
+test_ebook_get_static_capabilities_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_remove_LDADD=$(TEST_LIBS)
test_ebook_remove_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_remove_contact_LDADD=$(TEST_LIBS)
diff --git a/addressbook/tests/ebook/ebook-test-utils.c b/addressbook/tests/ebook/ebook-test-utils.c
index 1385c7b..634396a 100644
--- a/addressbook/tests/ebook/ebook-test-utils.c
+++ b/addressbook/tests/ebook/ebook-test-utils.c
@@ -260,6 +260,24 @@ ebook_test_utils_book_async_get_contact (EBook *book,
}
}
+const char*
+ebook_test_utils_book_get_static_capabilities (EBook *book)
+{
+ GError *error = NULL;
+ const char *caps;
+
+ if (!(caps = e_book_get_static_capabilities (book, &error))) {
+ const char *uri;
+
+ uri = e_book_get_uri (book);
+ g_warning ("failed to get capabilities for addressbook: `%s': "
+ "%s", uri, error->message);
+ exit(1);
+ }
+
+ return caps;
+}
+
void
ebook_test_utils_book_remove_contact (EBook *book,
const char *uid)
diff --git a/addressbook/tests/ebook/ebook-test-utils.h b/addressbook/tests/ebook/ebook-test-utils.h
index d76d126..3b0b963 100644
--- a/addressbook/tests/ebook/ebook-test-utils.h
+++ b/addressbook/tests/ebook/ebook-test-utils.h
@@ -78,6 +78,9 @@ ebook_test_utils_book_async_get_contact (EBook *book,
GSourceFunc callback,
gpointer user_data);
+const char*
+ebook_test_utils_book_get_static_capabilities (EBook *book);
+
void
ebook_test_utils_book_remove_contact (EBook *book,
const char *uid);
diff --git a/addressbook/tests/ebook/test-ebook-get-static-capabilities.c b/addressbook/tests/ebook/test-ebook-get-static-capabilities.c
new file mode 100644
index 0000000..ccc0ea6
--- /dev/null
+++ b/addressbook/tests/ebook/test-ebook-get-static-capabilities.c
@@ -0,0 +1,32 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <libebook/e-book.h>
+
+#include "ebook-test-utils.h"
+
+gint
+main (gint argc, gchar **argv)
+{
+ EBook *book;
+ const char *caps;
+
+ g_type_init ();
+
+ /*
+ * Setup
+ */
+ book = ebook_test_utils_book_new_temp (NULL);
+ ebook_test_utils_book_open (book, FALSE);
+
+ /*
+ * Sync version
+ */
+ caps = ebook_test_utils_book_get_static_capabilities (book);
+
+ g_print ("successfully retrieved static capabilities: '%s'\n", caps);
+
+ ebook_test_utils_book_remove (book);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]