From df4e1db5d41c903ae57fd880acc76a0ad84aa7b2 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Wed, 17 Dec 2014 13:26:16 +0100 Subject: sbus: use hard coded getters instead of generated Properties are single value of a small number of predefined D-Bus types. There is no need to generate them with codegen. Actually, the source generator for property getters is already quite mess with branching for array, strings and object paths. Adding any more complex type in the future (such as dictionary) would require even more branching or creating a separate path for it. Hard coding the getters will simplify creating new ones for more complex types. This patch also reduces lots of code duplication and creates a simple function for GetAll. Reviewed-by: Jakub Hrozek --- src/monitor/monitor_iface_generated.c | 57 ++--------------------------------- 1 file changed, 3 insertions(+), 54 deletions(-) (limited to 'src/monitor') diff --git a/src/monitor/monitor_iface_generated.c b/src/monitor/monitor_iface_generated.c index 0eee10cae..171cef7e6 100644 --- a/src/monitor/monitor_iface_generated.c +++ b/src/monitor/monitor_iface_generated.c @@ -3,6 +3,7 @@ #include "util/util.h" #include "sbus/sssd_dbus.h" #include "sbus/sssd_dbus_meta.h" +#include "sbus/sssd_dbus_invokers.h" #include "monitor_iface_generated.h" /* methods for org.freedesktop.sssd.monitor */ @@ -24,39 +25,13 @@ const struct sbus_method_meta mon_srv_iface__methods[] = { { NULL, } }; -/* invokes GetAll for the 'org.freedesktop.sssd.monitor' interface */ -static int invoke_mon_srv_iface_get_all(struct sbus_request *dbus_req, void *function_ptr) -{ - DBusMessage *reply; - dbus_bool_t dbret; - DBusMessageIter iter; - DBusMessageIter iter_dict; - - reply = dbus_message_new_method_return(dbus_req->message); - if (!reply) return ENOMEM; - dbus_message_iter_init_append(reply, &iter); - dbret = dbus_message_iter_open_container( - &iter, DBUS_TYPE_ARRAY, - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING - DBUS_TYPE_STRING_AS_STRING - DBUS_TYPE_VARIANT_AS_STRING - DBUS_DICT_ENTRY_END_CHAR_AS_STRING, - &iter_dict); - if (!dbret) return ENOMEM; - - dbret = dbus_message_iter_close_container(&iter, &iter_dict); - if (!dbret) return ENOMEM; - - return sbus_request_finish(dbus_req, reply); -} - /* interface info for org.freedesktop.sssd.monitor */ const struct sbus_interface_meta mon_srv_iface_meta = { "org.freedesktop.sssd.monitor", /* name */ mon_srv_iface__methods, NULL, /* no signals */ NULL, /* no properties */ - invoke_mon_srv_iface_get_all, /* GetAll invoker */ + sbus_invoke_get_all, /* GetAll invoker */ }; /* methods for org.freedesktop.sssd.service */ @@ -127,37 +102,11 @@ const struct sbus_method_meta mon_cli_iface__methods[] = { { NULL, } }; -/* invokes GetAll for the 'org.freedesktop.sssd.service' interface */ -static int invoke_mon_cli_iface_get_all(struct sbus_request *dbus_req, void *function_ptr) -{ - DBusMessage *reply; - dbus_bool_t dbret; - DBusMessageIter iter; - DBusMessageIter iter_dict; - - reply = dbus_message_new_method_return(dbus_req->message); - if (!reply) return ENOMEM; - dbus_message_iter_init_append(reply, &iter); - dbret = dbus_message_iter_open_container( - &iter, DBUS_TYPE_ARRAY, - DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING - DBUS_TYPE_STRING_AS_STRING - DBUS_TYPE_VARIANT_AS_STRING - DBUS_DICT_ENTRY_END_CHAR_AS_STRING, - &iter_dict); - if (!dbret) return ENOMEM; - - dbret = dbus_message_iter_close_container(&iter, &iter_dict); - if (!dbret) return ENOMEM; - - return sbus_request_finish(dbus_req, reply); -} - /* interface info for org.freedesktop.sssd.service */ const struct sbus_interface_meta mon_cli_iface_meta = { "org.freedesktop.sssd.service", /* name */ mon_cli_iface__methods, NULL, /* no signals */ NULL, /* no properties */ - invoke_mon_cli_iface_get_all, /* GetAll invoker */ + sbus_invoke_get_all, /* GetAll invoker */ }; -- cgit