diff options
author | Havoc Pennington <hp@redhat.com> | 2003-04-03 21:56:22 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-04-03 21:56:22 +0000 |
commit | f216e81432ddf04889202c33a6e68113f94d7611 (patch) | |
tree | bb8386366d183e43dc3471219ec627a21c65a639 /dbus/dbus-message.c | |
parent | fe9f3b45cc7e2e84d180c433f1ab5f8fd0a0c619 (diff) |
2003-04-03 Havoc Pennington <hp@redhat.com>
* bus/activation.c (load_directory): fix up memleaks
(bus_activation_entry_free): free the entry
* dbus/dbus-bus.c (dbus_bus_acquire_service): return an error if
we get one from the message bus; fix memleaks.
* dbus/dbus-message.c (dbus_set_error_from_message): new function
Diffstat (limited to 'dbus/dbus-message.c')
-rw-r--r-- | dbus/dbus-message.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 39ed3942..46c4c406 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -2381,6 +2381,45 @@ dbus_message_sender_is (DBusMessage *message, return FALSE; } +/** + * Sets a #DBusError based on the contents of the given + * message. The error is only set if the message + * is an error message, as in dbus_message_get_is_error(). + * The name of the error is set to the name of the message, + * and the error message is set to the first argument + * if the argument exists and is a string. + * + * The return value indicates whether the error was set (the error is + * set if and only if the message is an error message). + * So you can check for an error reply and convert it to DBusError + * in one go. + * + * @param error the error to set + * @param message the message to set it from + * @returns #TRUE if dbus_message_get_is_error() returns #TRUE for the message + */ +dbus_bool_t +dbus_set_error_from_message (DBusError *error, + DBusMessage *message) +{ + char *str; + + if (!dbus_message_get_is_error (message)) + return FALSE; + + str = NULL; + dbus_message_get_args (message, NULL, + DBUS_TYPE_STRING, &str, + DBUS_TYPE_INVALID); + + dbus_set_error (error, dbus_message_get_name (message), + str ? "%s" : NULL, str); + + dbus_free (str); + + return TRUE; +} + /** @} */ /** |