From f39b032ea23c1faf969dc386896f5df0511580d5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sun, 1 Feb 2015 14:52:27 +0100 Subject: [PATCH] Add methods 'EnableVerbose' and 'DisableVerbose' to dbus-daemon org.freedesktop.DBus interface when compiled with DBUS_ENABLE_VERBOSE_MODE. --- bus/driver.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-internals.c | 10 +++++++ dbus/dbus-internals.h | 2 ++ 3 files changed, 88 insertions(+) diff --git a/bus/driver.c b/bus/driver.c index 952061c..0f24274 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1667,6 +1667,72 @@ bus_driver_handle_reload_config (DBusConnection *connection, return FALSE; } +#ifdef DBUS_ENABLE_VERBOSE_MODE +static dbus_bool_t +bus_driver_handle_enable_verbose(DBusConnection *connection, + BusTransaction *transaction, + DBusMessage *message, + DBusError *error) +{ + DBusMessage *reply = NULL; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + reply = dbus_message_new_method_return (message); + if (reply == NULL) + goto oom; + + if (! bus_transaction_send_from_driver (transaction, connection, reply)) + goto oom; + + _dbus_set_verbose(TRUE); + + dbus_message_unref (reply); + return TRUE; + + oom: + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + BUS_SET_OOM (error); + + if (reply) + dbus_message_unref (reply); + return FALSE; +} + +static dbus_bool_t +bus_driver_handle_disable_verbose(DBusConnection *connection, + BusTransaction *transaction, + DBusMessage *message, + DBusError *error) +{ + DBusMessage *reply = NULL; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + reply = dbus_message_new_method_return (message); + if (reply == NULL) + goto oom; + + if (! bus_transaction_send_from_driver (transaction, connection, reply)) + goto oom; + + _dbus_set_verbose(FALSE); + + dbus_message_unref (reply); + return TRUE; + + oom: + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + BUS_SET_OOM (error); + + if (reply) + dbus_message_unref (reply); + return FALSE; +} +#endif + static dbus_bool_t bus_driver_handle_get_id (DBusConnection *connection, BusTransaction *transaction, @@ -1806,6 +1872,16 @@ static const MessageHandler dbus_message_handlers[] = { "", "", bus_driver_handle_reload_config }, +#ifdef DBUS_ENABLE_VERBOSE_MODE + { "EnableVerbose", + "", + "", + bus_driver_handle_enable_verbose}, + { "DisableVerbose", + "", + "", + bus_driver_handle_disable_verbose}, +#endif { "GetId", "", DBUS_TYPE_STRING_AS_STRING, diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 575a087..92a108c 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -363,6 +363,16 @@ _dbus_is_verbose_real (void) return verbose; } +void _dbus_set_verbose (dbus_bool_t state) +{ + verbose = state; +} + +dbus_bool_t _dbus_get_verbose (void) +{ + return verbose; +} + /** * Prints a warning message to stderr * if the user has enabled verbose mode. diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 4658b67..f8487c6 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -99,6 +99,8 @@ void _dbus_verbose_real (const char *format, #endif void _dbus_verbose_reset_real (void); dbus_bool_t _dbus_is_verbose_real (void); +dbus_bool_t _dbus_get_verbose (void); +void _dbus_set_verbose (dbus_bool_t state); # define _dbus_verbose_reset _dbus_verbose_reset_real # define _dbus_is_verbose _dbus_is_verbose_real -- 1.8.4.5