summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2012-07-16 12:30:19 -0400
committerRyan Lortie <desrt@desrt.ca>2012-07-16 12:30:19 -0400
commit339efbf55e1099d4277a4d7e3336e1f1e599fa4e (patch)
tree5c326f375c3ba918c056d5843b3169d9523ee4a9
parent4b3d04fba7ad39d7d465feca67eb81e68a4b6123 (diff)
downloaddconf-339efbf55e1099d4277a4d7e3336e1f1e599fa4e.tar.gz
dbus-1/: fix transmission of byte arrays
Add a test case that would have caught this problem.
-rw-r--r--dbus-1/dconf-libdbus-1.c5
-rw-r--r--tests/dbus.c9
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",