[evolution-data-server/treitter-client-gdbus] Factor out the demarshalling code in the libebook gdbus bindings.
- From: Travis Reitter <treitter src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server/treitter-client-gdbus] Factor out the demarshalling code in the libebook gdbus bindings.
- Date: Thu, 10 Dec 2009 16:37:42 +0000 (UTC)
commit a1b72514e0349f2eae0657dc40d54929f1b1312c
Author: Travis Reitter <treitter gmail com>
Date: Wed Dec 9 12:24:00 2009 -0800
Factor out the demarshalling code in the libebook gdbus bindings.
addressbook/libebook/e-data-book-gdbus-bindings.h | 231 ++++++---------------
1 files changed, 68 insertions(+), 163 deletions(-)
---
diff --git a/addressbook/libebook/e-data-book-gdbus-bindings.h b/addressbook/libebook/e-data-book-gdbus-bindings.h
index 6c16567..db431d4 100644
--- a/addressbook/libebook/e-data-book-gdbus-bindings.h
+++ b/addressbook/libebook/e-data-book-gdbus-bindings.h
@@ -18,7 +18,7 @@ closure_free (Closure *closure)
}
static gboolean
-open_demarshal_retvals (GVariant *retvals)
+demarshal_retvals__VOID (GVariant *retvals)
{
gboolean success = TRUE;
@@ -31,10 +31,61 @@ open_demarshal_retvals (GVariant *retvals)
}
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;
+}
+
+static gboolean
e_data_book_gdbus_open_sync (GDBusProxy *proxy,
const gboolean IN_only_if_exists,
GError **error)
-
{
GVariant *parameters;
GVariant *retvals;
@@ -43,7 +94,7 @@ e_data_book_gdbus_open_sync (GDBusProxy *proxy,
retvals = g_dbus_proxy_invoke_method_sync (proxy, "open", parameters,
-1, NULL, error);
- return open_demarshal_retvals (retvals);
+ return demarshal_retvals__VOID (retvals);
}
typedef void (*e_data_book_gdbus_open_reply) (GDBusProxy *proxy,
@@ -61,7 +112,7 @@ open_cb (GDBusProxy *proxy,
retvals = g_dbus_proxy_invoke_method_finish (proxy, result, &error);
if (retvals) {
- if (!open_demarshal_retvals (retvals)) {
+ if (!demarshal_retvals__VOID (retvals)) {
error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, "demarshalling results for Book method 'open'");
}
}
@@ -75,7 +126,6 @@ e_data_book_gdbus_open (GDBusProxy *proxy,
const gboolean IN_only_if_exists,
e_data_book_gdbus_open_reply callback,
gpointer user_data)
-
{
GVariant *parameters;
Closure *closure;
@@ -90,22 +140,8 @@ e_data_book_gdbus_open (GDBusProxy *proxy,
}
static gboolean
-remove_demarshal_retvals (GVariant *retvals)
-{
- gboolean success = TRUE;
-
- if (retvals)
- g_variant_unref (retvals);
- else
- success = FALSE;
-
- return success;
-}
-
-static gboolean
e_data_book_gdbus_remove_sync (GDBusProxy *proxy,
GError **error)
-
{
GVariant *parameters;
GVariant *retvals;
@@ -114,7 +150,7 @@ e_data_book_gdbus_remove_sync (GDBusProxy *proxy,
retvals = g_dbus_proxy_invoke_method_sync (proxy, "remove", parameters,
-1, NULL, error);
- return remove_demarshal_retvals (retvals);
+ return demarshal_retvals__VOID (retvals);
}
typedef void (*e_data_book_gdbus_remove_reply) (GDBusProxy *proxy,
@@ -132,7 +168,7 @@ remove_cb (GDBusProxy *proxy,
retvals = g_dbus_proxy_invoke_method_finish (proxy, result, &error);
if (retvals) {
- if (!remove_demarshal_retvals (retvals)) {
+ if (!demarshal_retvals__VOID (retvals)) {
error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, "demarshalling results for Book method 'remove'");
}
}
@@ -145,7 +181,6 @@ static void
e_data_book_gdbus_remove (GDBusProxy *proxy,
e_data_book_gdbus_remove_reply callback,
gpointer user_data)
-
{
GVariant *parameters;
Closure *closure;
@@ -160,34 +195,10 @@ e_data_book_gdbus_remove (GDBusProxy *proxy,
}
static gboolean
-get_contact_demarshal_retvals (GVariant *retvals, char **OUT_vcard)
-{
- gboolean success = TRUE;
-
- if (retvals) {
- const char *vcard = NULL;
-
- g_variant_get (retvals, "(s)", &vcard);
- if (vcard) {
- *OUT_vcard = g_strdup (vcard);
- } else {
- success = FALSE;
- }
-
- g_variant_unref (retvals);
- } else {
- success = FALSE;
- }
-
- return success;
-}
-
-static gboolean
e_data_book_gdbus_get_contact_sync (GDBusProxy *proxy,
const char *IN_uid,
char **OUT_vcard,
GError **error)
-
{
GVariant *parameters;
GVariant *retvals;
@@ -195,7 +206,7 @@ e_data_book_gdbus_get_contact_sync (GDBusProxy *proxy,
parameters = g_variant_new ("(s)", IN_uid);
retvals = g_dbus_proxy_invoke_method_sync (proxy, "getContact", parameters, -1, NULL, error);
- return get_contact_demarshal_retvals (retvals, OUT_vcard);
+ return demarshal_retvals__STRING (retvals, OUT_vcard);
}
typedef void (*e_data_book_gdbus_get_contact_reply) (GDBusProxy *proxy,
@@ -215,7 +226,7 @@ get_contact_cb (GDBusProxy *proxy,
retvals = g_dbus_proxy_invoke_method_finish (proxy, result, &error);
if (retvals) {
- if (!get_contact_demarshal_retvals (retvals, &OUT_vcard)) {
+ if (!demarshal_retvals__STRING (retvals, &OUT_vcard)) {
error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, "demarshalling results for Book method 'getContact'");
}
}
@@ -243,33 +254,9 @@ 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;
@@ -277,36 +264,7 @@ e_data_book_gdbus_get_static_capabilities_sync (GDBusProxy *proxy,
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;
-
- if (retvals) {
- GVariant *vcards_variant;
- char **vcards = NULL;
- gint length;
-
- /* retvals contains a (as) with length 1; de-shell the
- * array of strings from the tuple */
- vcards_variant = g_variant_get_child_value (retvals, 0);
- vcards = g_variant_dup_strv (vcards_variant, &length);
-
- if (vcards) {
- *OUT_vcards = vcards;
- } else {
- success = FALSE;
- }
-
- g_variant_unref (retvals);
- } else {
- success = FALSE;
- }
-
- return success;
+ return demarshal_retvals__STRING (retvals, OUT_caps);
}
static gboolean
@@ -314,7 +272,6 @@ e_data_book_gdbus_get_contact_list_sync (GDBusProxy *proxy,
const char *IN_query,
char ***OUT_vcards,
GError **error)
-
{
GVariant *parameters;
GVariant *retvals;
@@ -322,7 +279,7 @@ e_data_book_gdbus_get_contact_list_sync (GDBusProxy *proxy,
parameters = g_variant_new ("(s)", IN_query);
retvals = g_dbus_proxy_invoke_method_sync (proxy, "getContactList", parameters, -1, NULL, error);
- return get_contact_list_demarshal_retvals (retvals, OUT_vcards);
+ return demarshal_retvals__STRINGVECTOR (retvals, OUT_vcards);
}
typedef void (*e_data_book_gdbus_get_contact_list_reply) (GDBusProxy *proxy,
@@ -342,7 +299,7 @@ get_contact_list_cb (GDBusProxy *proxy,
retvals = g_dbus_proxy_invoke_method_finish (proxy, result, &error);
if (retvals) {
- if (!get_contact_list_demarshal_retvals (retvals, &OUT_vcards)) {
+ if (!demarshal_retvals__STRINGVECTOR (retvals, &OUT_vcards)) {
error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, "demarshalling results for Book method 'getContactList'");
}
}
@@ -370,34 +327,10 @@ e_data_book_gdbus_get_contact_list (GDBusProxy *pr
}
static gboolean
-add_contact_demarshal_retvals (GVariant *retvals, char **OUT_uid)
-{
- gboolean success = TRUE;
-
- if (retvals) {
- const char *uid = NULL;
-
- g_variant_get (retvals, "(s)", &uid);
- if (uid) {
- *OUT_uid = g_strdup (uid);
- } else {
- success = FALSE;
- }
-
- g_variant_unref (retvals);
- } else {
- success = FALSE;
- }
-
- return success;
-}
-
-static gboolean
e_data_book_gdbus_add_contact_sync (GDBusProxy *proxy,
const char *IN_vcard,
char **OUT_uid,
GError **error)
-
{
GVariant *parameters;
GVariant *retvals;
@@ -405,7 +338,7 @@ e_data_book_gdbus_add_contact_sync (GDBusProxy *proxy,
parameters = g_variant_new ("(s)", IN_vcard);
retvals = g_dbus_proxy_invoke_method_sync (proxy, "addContact", parameters, -1, NULL, error);
- return add_contact_demarshal_retvals (retvals, OUT_uid);
+ return demarshal_retvals__STRING (retvals, OUT_uid);
}
typedef void (*e_data_book_gdbus_add_contact_reply) (GDBusProxy *proxy,
@@ -425,7 +358,7 @@ add_contact_cb (GDBusProxy *proxy,
retvals = g_dbus_proxy_invoke_method_finish (proxy, result, &error);
if (retvals) {
- if (!add_contact_demarshal_retvals (retvals, &OUT_uid)) {
+ if (!demarshal_retvals__STRING (retvals, &OUT_uid)) {
error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, "demarshalling results for Book method 'addContact'");
}
}
@@ -453,23 +386,9 @@ e_data_book_gdbus_add_contact (GDBusProxy *proxy,
}
static gboolean
-modify_contact_demarshal_retvals (GVariant *retvals)
-{
- gboolean success = TRUE;
-
- if (retvals)
- g_variant_unref (retvals);
- else
- success = FALSE;
-
- return success;
-}
-
-static gboolean
e_data_book_gdbus_modify_contact_sync (GDBusProxy *proxy,
const char *IN_vcard,
GError **error)
-
{
GVariant *parameters;
GVariant *retvals;
@@ -477,7 +396,7 @@ e_data_book_gdbus_modify_contact_sync (GDBusProxy *proxy,
parameters = g_variant_new ("(s)", IN_vcard);
retvals = g_dbus_proxy_invoke_method_sync (proxy, "modifyContact", parameters, -1, NULL, error);
- return modify_contact_demarshal_retvals (retvals);
+ return demarshal_retvals__VOID (retvals);
}
typedef void (*e_data_book_gdbus_modify_contact_reply) (GDBusProxy *proxy,
@@ -495,7 +414,7 @@ modify_contact_cb (GDBusProxy *proxy,
retvals = g_dbus_proxy_invoke_method_finish (proxy, result, &error);
if (retvals) {
- if (!modify_contact_demarshal_retvals (retvals)) {
+ if (!demarshal_retvals__VOID (retvals)) {
error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, "demarshalling results for Book method 'modifyContact'");
}
}
@@ -523,23 +442,9 @@ e_data_book_gdbus_modify_contact (GDBusProxy *proxy,
}
static gboolean
-remove_contacts_demarshal_retvals (GVariant *retvals)
-{
- gboolean success = TRUE;
-
- if (retvals)
- g_variant_unref (retvals);
- else
- success = FALSE;
-
- return success;
-}
-
-static gboolean
e_data_book_gdbus_remove_contacts_sync (GDBusProxy *proxy,
const char **IN_uids,
GError **error)
-
{
GVariant *parameters;
GVariant *retvals;
@@ -550,7 +455,7 @@ e_data_book_gdbus_remove_contacts_sync (GDBusProxy *proxy,
retvals = g_dbus_proxy_invoke_method_sync (proxy, "removeContacts", parameters, -1, NULL, error);
- return remove_contacts_demarshal_retvals (retvals);
+ return demarshal_retvals__VOID (retvals);
}
typedef void (*e_data_book_gdbus_remove_contacts_reply) (GDBusProxy *proxy,
@@ -568,7 +473,7 @@ remove_contacts_cb (GDBusProxy *proxy,
retvals = g_dbus_proxy_invoke_method_finish (proxy, result, &error);
if (retvals) {
- if (!remove_contacts_demarshal_retvals (retvals)) {
+ if (!demarshal_retvals__VOID (retvals)) {
error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, "demarshalling results for Book method 'removeContacts'");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]