summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--dbus/dbus-message.c39
2 files changed, 47 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 08af5331..b7ecd85d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-12-02 Richard Hult <richard@imendio.com>
+
+ * dbus/dbus-message.c (dbus_message_iter_append_dict): Set
+ wrote_dict_key to FALSE on the iter that the dict is appended to,
+ just like when appending other types. Fixes a bug where a dict
+ couldn't be put inside a dict.
+ (dbus_message_iter_append_dict_key): Fix typo in warning message.
+ (message_iter_test, _dbus_message_test): Add test case for dict
+ inside dict.
+
2003-12-01 David Zeuthen <david@fubar.dk>
* python/dbus.py: Add the actual message when calling the reciever
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index 2e4ef0be..2bf63a16 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -3874,7 +3874,7 @@ dbus_message_iter_append_dict_key (DBusMessageIter *iter,
if (real->wrote_dict_key)
{
- _dbus_warn ("Appendinging multiple dict key names\n");
+ _dbus_warn ("Appending multiple dict key names\n");
return FALSE;
}
@@ -4082,6 +4082,8 @@ dbus_message_iter_append_dict (DBusMessageIter *iter,
dbus_message_iter_append_done (dict_real);
+ real->wrote_dict_key = FALSE;
+
return TRUE;
}
@@ -5800,7 +5802,7 @@ dbus_message_type_from_string (const char *type_str)
static void
message_iter_test (DBusMessage *message)
{
- DBusMessageIter iter, dict, array, array2;
+ DBusMessageIter iter, dict, dict2, array, array2;
char *str;
unsigned char *data;
dbus_int32_t *our_int_array;
@@ -5899,6 +5901,32 @@ message_iter_test (DBusMessage *message)
if (dbus_message_iter_get_uint32 (&dict) != 0xDEADBEEF)
_dbus_assert_not_reached ("wrong dict entry value");
+ /* dict (in dict) */
+
+ if (!dbus_message_iter_next (&dict))
+ _dbus_assert_not_reached ("reached end of dict");
+
+ if (dbus_message_iter_get_arg_type (&dict) != DBUS_TYPE_DICT)
+ _dbus_assert_not_reached ("not dict type");
+
+ dbus_message_iter_init_dict_iterator (&dict, &dict2);
+
+ str = dbus_message_iter_get_dict_key (&dict2);
+ if (str == NULL || strcmp (str, "dictkey") != 0)
+ _dbus_assert_not_reached ("wrong dict key");
+ dbus_free (str);
+
+ if (dbus_message_iter_get_arg_type (&dict2) != DBUS_TYPE_STRING)
+ _dbus_assert_not_reached ("wrong dict entry type");
+
+ str = dbus_message_iter_get_string (&dict2);
+ if (str == NULL || strcmp (str, "dictvalue") != 0)
+ _dbus_assert_not_reached ("wrong dict entry value");
+ dbus_free (str);
+
+ if (dbus_message_iter_next (&dict2))
+ _dbus_assert_not_reached ("didn't reach end of dict");
+
if (!dbus_message_iter_next (&dict))
_dbus_assert_not_reached ("reached end of dict");
@@ -7107,6 +7135,13 @@ _dbus_message_test (const char *test_data_dir)
dbus_message_iter_append_dict_key (&child_iter, "test");
dbus_message_iter_append_uint32 (&child_iter, 0xDEADBEEF);
+ /* dict (in dict) */
+ dbus_message_iter_append_dict_key (&child_iter, "testdict");
+ dbus_message_iter_append_dict (&child_iter, &child_iter2);
+
+ dbus_message_iter_append_dict_key (&child_iter2, "dictkey");
+ dbus_message_iter_append_string (&child_iter2, "dictvalue");
+
/* array of array of int32 (in dict) */
dbus_message_iter_append_dict_key (&child_iter, "array");
dbus_message_iter_append_array (&child_iter, &child_iter2, DBUS_TYPE_ARRAY);