[dconf] dbus-1/: fix transmission of byte arrays
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf] dbus-1/: fix transmission of byte arrays
- Date: Mon, 16 Jul 2012 16:32:36 +0000 (UTC)
commit 339efbf55e1099d4277a4d7e3336e1f1e599fa4e
Author: Ryan Lortie <desrt desrt ca>
Date: Mon Jul 16 12:30:19 2012 -0400
dbus-1/: fix transmission of byte arrays
Add a test case that would have caught this problem.
dbus-1/dconf-libdbus-1.c | 5 ++++-
tests/dbus.c | 9 +++++++++
2 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/dbus-1/dconf-libdbus-1.c b/dbus-1/dconf-libdbus-1.c
index aedc2cf..8269e1a 100644
--- a/dbus-1/dconf-libdbus-1.c
+++ b/dbus-1/dconf-libdbus-1.c
@@ -65,13 +65,16 @@ dconf_libdbus_1_new_method_call (const gchar *bus_name,
else
{
+ DBusMessageIter subiter;
const guint8 *bytes;
gsize n_elements;
g_assert (g_variant_is_of_type (child, G_VARIANT_TYPE_BYTESTRING));
bytes = g_variant_get_fixed_array (child, &n_elements, sizeof (guint8));
- dbus_message_iter_append_fixed_array (&dbus_iter, DBUS_TYPE_BYTE, &bytes, n_elements);
+ dbus_message_iter_open_container (&dbus_iter, DBUS_TYPE_ARRAY, "y", &subiter);
+ dbus_message_iter_append_fixed_array (&subiter, DBUS_TYPE_BYTE, &bytes, n_elements);
+ dbus_message_iter_close_container (&dbus_iter, &subiter);
}
g_variant_unref (child);
diff --git a/tests/dbus.c b/tests/dbus.c
index d411c06..434b752 100644
--- a/tests/dbus.c
+++ b/tests/dbus.c
@@ -278,6 +278,15 @@ test_sync_call_error (void)
g_assert (strstr (error->message, "org.freedesktop.DBus.Error.InvalidArgs"));
g_clear_error (&error);
+ /* Test with 'ay' to make sure transmitting that works as well */
+ reply = dconf_engine_dbus_call_sync_func (G_BUS_TYPE_SESSION,
+ "org.freedesktop.DBus", "/", "org.freedesktop.DBus", "GetId",
+ g_variant_new ("(ay)", NULL), G_VARIANT_TYPE_UNIT, &error);
+ g_assert (reply == NULL);
+ g_assert (error != NULL);
+ g_assert (strstr (error->message, "org.freedesktop.DBus.Error.InvalidArgs"));
+ g_clear_error (&error);
+
/* Test reply type errors */
reply = dconf_engine_dbus_call_sync_func (G_BUS_TYPE_SESSION,
"org.freedesktop.DBus", "/", "org.freedesktop.DBus", "GetId",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]