[evolution-data-server/treitter-client-gdbus] Factor out common gdbus bindings boilerplate code.
- From: Travis Reitter <treitter src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server/treitter-client-gdbus] Factor out common gdbus bindings boilerplate code.
- Date: Tue, 15 Dec 2009 19:45:44 +0000 (UTC)
commit 87866b11dcf8637656fc5fe806c6c912e12a8fe3
Author: Travis Reitter <treitter gmail com>
Date: Thu Dec 10 17:29:13 2009 -0800
Factor out common gdbus bindings boilerplate code.
.../libebook/e-data-book-factory-gdbus-bindings.h | 19 +---
.../libebook/e-data-book-gdbus-bindings-common.h | 140 ++++++++++++++++++++
addressbook/libebook/e-data-book-gdbus-bindings.h | 92 +-------------
3 files changed, 145 insertions(+), 106 deletions(-)
---
diff --git a/addressbook/libebook/e-data-book-factory-gdbus-bindings.h b/addressbook/libebook/e-data-book-factory-gdbus-bindings.h
index 5aa121f..568fcd5 100644
--- a/addressbook/libebook/e-data-book-factory-gdbus-bindings.h
+++ b/addressbook/libebook/e-data-book-factory-gdbus-bindings.h
@@ -1,6 +1,8 @@
#include <glib.h>
#include <gdbus/gdbus.h>
+#include "e-data-book-gdbus-bindings-common.h"
+
G_BEGIN_DECLS
/* FIXME: These bindings were created manually; replace with generated bindings
@@ -11,27 +13,12 @@ e_data_book_factory_gdbus_get_book_sync (GDBusProxy *proxy, const char * IN_sour
{
GVariant *parameters;
GVariant *retvals;
- gboolean success = TRUE;
parameters = g_variant_new ("(s)", IN_source);
retvals = g_dbus_proxy_invoke_method_sync (proxy, "getBook", parameters,
-1, NULL, error);
- if (retvals) {
- char *const_path = NULL;
-
- g_variant_get (retvals, "(o)", &const_path);
- if (const_path) {
- *OUT_path = g_strdup (const_path);
- } else {
- success = FALSE;
- }
-
- g_variant_unref (retvals);
- } else {
- success = FALSE;
- }
- return success;
+ return demarshal_retvals__OBJPATH (retvals, OUT_path);
}
G_END_DECLS
diff --git a/addressbook/libebook/e-data-book-gdbus-bindings-common.h b/addressbook/libebook/e-data-book-gdbus-bindings-common.h
new file mode 100644
index 0000000..5c747c6
--- /dev/null
+++ b/addressbook/libebook/e-data-book-gdbus-bindings-common.h
@@ -0,0 +1,140 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Travis Reitter (travis reitter collabora co uk)
+ */
+
+#ifndef _E_DATA_BOOK_GDBUS_BINDINGS_COMMON_H
+#define _E_DATA_BOOK_GDBUS_BINDINGS_COMMON_H
+
+#include <glib.h>
+
+typedef struct {
+ GCallback cb;
+ gpointer user_data;
+} Closure;
+
+static void
+closure_free (Closure *closure)
+{
+ g_slice_free (Closure, closure);
+}
+
+static gboolean
+demarshal_retvals__VOID (GVariant *retvals)
+{
+ gboolean success = TRUE;
+
+ if (retvals)
+ g_variant_unref (retvals);
+ else
+ success = FALSE;
+
+ return success;
+}
+
+static gboolean
+demarshal_retvals__OBJPATH (GVariant *retvals, char **OUT_objpath1)
+{
+ gboolean success = TRUE;
+
+ if (retvals) {
+ const char *objpath1 = NULL;
+
+ g_variant_get (retvals, "(o)", &objpath1);
+ if (objpath1) {
+ *OUT_objpath1 = g_strdup (objpath1);
+ } else {
+ success = FALSE;
+ }
+
+ g_variant_unref (retvals);
+ } else {
+ success = FALSE;
+ }
+
+ return success;
+}
+
+static gboolean
+demarshal_retvals__STRING (GVariant *retvals, char **OUT_string1)
+{
+ gboolean success = TRUE;
+
+ if (retvals) {
+ const char *string1 = NULL;
+
+ g_variant_get (retvals, "(s)", &string1);
+ if (string1) {
+ *OUT_string1 = g_strdup (string1);
+ } else {
+ success = FALSE;
+ }
+
+ g_variant_unref (retvals);
+ } else {
+ success = FALSE;
+ }
+
+ return success;
+}
+
+static gboolean
+demarshal_retvals__STRINGVECTOR (GVariant *retvals, char ***OUT_strv1)
+{
+ gboolean success = TRUE;
+
+ if (retvals) {
+ GVariant *strv1_variant;
+ char **strv1 = NULL;
+ gint strv1_length;
+
+ /* retvals contains a (as) with length 1; de-shell the
+ * array of strings from the tuple */
+ strv1_variant = g_variant_get_child_value (retvals, 0);
+ strv1 = g_variant_dup_strv (strv1_variant, &strv1_length);
+
+ if (strv1) {
+ *OUT_strv1 = strv1;
+ } else {
+ success = FALSE;
+ }
+
+ g_variant_unref (retvals);
+ } else {
+ success = FALSE;
+ }
+
+ return success;
+}
+
+typedef void (*reply__VOID) (GDBusProxy *proxy,
+ GError *error,
+ gpointer user_data);
+
+typedef void (*reply__STRING) (GDBusProxy *proxy,
+ char *OUT_string1,
+ GError *error,
+ gpointer user_data);
+
+typedef void (*reply__STRINGVECTOR) (GDBusProxy *proxy,
+ char **OUT_strv1,
+ GError *error,
+ gpointer user_data);
+
+#endif /* _E_DATA_BOOK_GDBUS_BINDINGS_COMMON_H */
diff --git a/addressbook/libebook/e-data-book-gdbus-bindings.h b/addressbook/libebook/e-data-book-gdbus-bindings.h
index 191f0b8..2223e0c 100644
--- a/addressbook/libebook/e-data-book-gdbus-bindings.h
+++ b/addressbook/libebook/e-data-book-gdbus-bindings.h
@@ -1,101 +1,13 @@
#include <glib.h>
#include <gdbus/gdbus.h>
+#include "e-data-book-gdbus-bindings-common.h"
+
G_BEGIN_DECLS
/* FIXME: These bindings were created manually; replace with generated bindings
* when possible */
-typedef struct {
- GCallback cb;
- gpointer user_data;
-} Closure;
-
-static void
-closure_free (Closure *closure)
-{
- g_slice_free (Closure, closure);
-}
-
-static gboolean
-demarshal_retvals__VOID (GVariant *retvals)
-{
- gboolean success = TRUE;
-
- if (retvals)
- g_variant_unref (retvals);
- else
- success = FALSE;
-
- return success;
-}
-
-static gboolean
-demarshal_retvals__STRING (GVariant *retvals, char **OUT_string1)
-{
- gboolean success = TRUE;
-
- if (retvals) {
- const char *string1 = NULL;
-
- g_variant_get (retvals, "(s)", &string1);
- if (string1) {
- *OUT_string1 = g_strdup (string1);
- } else {
- success = FALSE;
- }
-
- g_variant_unref (retvals);
- } else {
- success = FALSE;
- }
-
- return success;
-}
-
-static gboolean
-demarshal_retvals__STRINGVECTOR (GVariant *retvals, char ***OUT_strv1)
-{
- gboolean success = TRUE;
-
- if (retvals) {
- GVariant *strv1_variant;
- char **strv1 = NULL;
- gint strv1_length;
-
- /* retvals contains a (as) with length 1; de-shell the
- * array of strings from the tuple */
- strv1_variant = g_variant_get_child_value (retvals, 0);
- strv1 = g_variant_dup_strv (strv1_variant, &strv1_length);
-
- if (strv1) {
- *OUT_strv1 = strv1;
- } else {
- success = FALSE;
- }
-
- g_variant_unref (retvals);
- } else {
- success = FALSE;
- }
-
- return success;
-}
-
-typedef void (*reply__VOID) (GDBusProxy *proxy,
- GError *error,
- gpointer user_data);
-
-typedef void (*reply__STRING) (GDBusProxy *proxy,
- char *OUT_string1,
- GError *error,
- gpointer user_data);
-
-typedef void (*reply__STRINGVECTOR) (GDBusProxy *proxy,
- char **OUT_strv1,
- GError *error,
- gpointer user_data);
-
static gboolean
e_data_book_gdbus_open_sync (GDBusProxy *proxy,
const gboolean IN_only_if_exists,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]