From 25d3519e6874c51ee5893e6f33dfa31600a19eac 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 org.freedesktop.DBus. --- bus/driver.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-internals.c | 10 +++++++ dbus/dbus-internals.h | 2 ++ 3 files changed, 84 insertions(+) diff --git a/bus/driver.c b/bus/driver.c index 952061c..a4c7b09 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1668,6 +1668,70 @@ bus_driver_handle_reload_config (DBusConnection *connection, } 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; +} + +static dbus_bool_t bus_driver_handle_get_id (DBusConnection *connection, BusTransaction *transaction, DBusMessage *message, @@ -1806,6 +1870,14 @@ static const MessageHandler dbus_message_handlers[] = { "", "", bus_driver_handle_reload_config }, + { "EnableVerbose", + "", + "", + bus_driver_handle_enable_verbose}, + { "DisableVerbose", + "", + "", + bus_driver_handle_disable_verbose}, { "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