diff options
author | Havoc Pennington <hp@redhat.com> | 2003-10-16 06:34:51 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-10-16 06:34:51 +0000 |
commit | d6e1b2adb3d8e51ce1bb47295cef12d9fe1a15a8 (patch) | |
tree | d94b220a2886b384ddc4f55df4689d79430a6399 /dbus/dbus-message.c | |
parent | 9b9dd4b80eb2753fc67bed1f48eef89674ba968e (diff) |
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
Diffstat (limited to 'dbus/dbus-message.c')
-rw-r--r-- | dbus/dbus-message.c | 126 |
1 files changed, 120 insertions, 6 deletions
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index c7e0b8cf..4c21946a 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -1870,6 +1870,9 @@ dbus_message_append_args_valist (DBusMessage *message, if (!dbus_message_iter_append_string (&iter, va_arg (var_args, const char *))) goto errorout; break; + case DBUS_TYPE_OBJECT_PATH: + + break; case DBUS_TYPE_NAMED: { const char *name; @@ -2540,7 +2543,10 @@ dbus_message_iter_get_arg_type (DBusMessageIter *iter) _dbus_return_val_if_fail (dbus_message_iter_check (real), DBUS_TYPE_INVALID); if (real->pos >= real->end) - return DBUS_TYPE_INVALID; + { + _dbus_verbose (" iterator at or beyond end of message\n"); + return DBUS_TYPE_INVALID; + } pos = dbus_message_iter_get_data_start (real, &type); @@ -2645,6 +2651,36 @@ dbus_message_iter_get_string (DBusMessageIter *iter) pos, NULL); } +#if 0 +/** + * @todo FIXME to finish this _dbus_demarshal_object_path() needs + * to not explode the path. + * + * Returns the object path value that an iterator may point to. + * Note that you need to check that the iterator points to + * an object path value before using this function. + * + * @see dbus_message_iter_get_arg_type + * @param iter the message iter + * @returns the path + */ +char * +dbus_message_iter_get_object_path (DBusMessageIter *iter) +{ + DBusMessageRealIter *real = (DBusMessageRealIter *)iter; + int type, pos; + + _dbus_return_val_if_fail (dbus_message_iter_check (real), NULL); + + pos = dbus_message_iter_get_data_start (real, &type); + + _dbus_assert (type == DBUS_TYPE_OBJECT_PATH); + + return _dbus_demarshal_object_path (&real->message->body, real->message->byte_order, + pos, NULL); +} +#endif + /** * Returns the name and data from a named type that an * iterator may point to. Note that you need to check that @@ -3226,7 +3262,7 @@ dbus_message_iter_get_double_array (DBusMessageIter *iter, /** * Returns the string array that the iterator may point to. * Note that you need to check that the iterator points - * to a byte array prior to using this function. + * to a string array prior to using this function. * * The returned value is a #NULL-terminated array of strings. * Each string is a separate malloc block, and the array @@ -3262,6 +3298,50 @@ dbus_message_iter_get_string_array (DBusMessageIter *iter, return TRUE; } +#if 0 +/** + * @todo FIXME to implement this _dbus_demarshal_object_path_array() + * needs implementing + * + * Returns the object path array that the iterator may point to. + * Note that you need to check that the iterator points + * to an object path array prior to using this function. + * + * The returned value is a #NULL-terminated array of strings. + * Each string is a separate malloc block, and the array + * itself is a malloc block. You can free this type of + * array with dbus_free_string_array(). + * + * @param iter the iterator + * @param value return location for string values + * @param len return location for length of byte array + * @returns #TRUE on success + */ +dbus_bool_t +dbus_message_iter_get_object_path_array (DBusMessageIter *iter, + char ***value, + int *len) +{ + DBusMessageRealIter *real = (DBusMessageRealIter *)iter; + int type, pos; + + _dbus_return_val_if_fail (dbus_message_iter_check (real), FALSE); + + pos = dbus_message_iter_get_data_start (real, &type); + + _dbus_assert (type == DBUS_TYPE_ARRAY); + + type = iter_get_array_type (real, NULL); + _dbus_assert (type == DBUS_TYPE_OBJECT_PATH); + + if (!_dbus_demarshal_object_path_array (&real->message->body, real->message->byte_order, + pos, NULL, value, len)) + return FALSE; + else + return TRUE; +} +#endif + /** * Returns the key name fot the dict entry that an iterator * may point to. Note that you need to check that the iterator @@ -3664,6 +3744,8 @@ dbus_message_iter_append_double (DBusMessageIter *iter, /** * Appends a UTF-8 string to the message. * + * @todo add return_val_if_fail(UTF-8 is valid) + * * @param iter an iterator pointing to the end of the message * @param value the string * @returns #TRUE on success @@ -3675,7 +3757,7 @@ dbus_message_iter_append_string (DBusMessageIter *iter, DBusMessageRealIter *real = (DBusMessageRealIter *)iter; _dbus_return_val_if_fail (dbus_message_iter_append_check (real), FALSE); - + if (!dbus_message_iter_append_type (real, DBUS_TYPE_STRING)) return FALSE; @@ -4971,7 +5053,11 @@ decode_header_data (const DBusString *data, fields[field].name_offset = pos; fields[field].value_offset = _DBUS_ALIGN_VALUE (pos, 4); - _dbus_verbose ("Found reply serial at offset %d\n", + _dbus_verbose ("Found reply serial %u at offset %d\n", + _dbus_demarshal_uint32 (data, + byte_order, + fields[field].value_offset, + NULL), fields[field].value_offset); break; @@ -6751,6 +6837,8 @@ _dbus_message_test (const char *test_data_dir) const unsigned char our_boolean_array[] = { TRUE, FALSE, TRUE, TRUE, FALSE }; char sig[64]; const char *s; + char *t; + DBusError error; _dbus_assert (sizeof (DBusMessageRealIter) <= sizeof (DBusMessageIter)); @@ -6952,7 +7040,7 @@ _dbus_message_test (const char *test_data_dir) _dbus_assert (strcmp (name1, name2) == 0); - dbus_message_unref (message); + dbus_message_unref (message); dbus_message_unref (copy); message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService", @@ -6999,7 +7087,7 @@ _dbus_message_test (const char *test_data_dir) "data", 5); message_iter_test (message); - + /* Message loader test */ _dbus_message_lock (message); loader = _dbus_message_loader_new (); @@ -7030,6 +7118,7 @@ _dbus_message_test (const char *test_data_dir) _dbus_message_loader_return_buffer (loader, buffer, 1); } + copy = dbus_message_copy (message); /* save for tests below */ dbus_message_unref (message); /* Now pop back the message */ @@ -7051,6 +7140,31 @@ _dbus_message_test (const char *test_data_dir) dbus_message_unref (message); _dbus_message_loader_unref (loader); + message = dbus_message_new_method_return (copy); + if (message == NULL) + _dbus_assert_not_reached ("out of memory\n"); + dbus_message_unref (copy); + + if (!dbus_message_append_args (message, + DBUS_TYPE_STRING, "hello", + DBUS_TYPE_INVALID)) + _dbus_assert_not_reached ("no memory"); + + if (!dbus_message_has_signature (message, "s")) + _dbus_assert_not_reached ("method return has wrong signature"); + + dbus_error_init (&error); + if (!dbus_message_get_args (message, &error, DBUS_TYPE_STRING, + &t, DBUS_TYPE_INVALID)) + + { + _dbus_warn ("Failed to get expected string arg: %s\n", error.message); + exit (1); + } + dbus_free (t); + + dbus_message_unref (message); + /* Now load every message in test_data_dir if we have one */ if (test_data_dir == NULL) return TRUE; |