X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fdbus-common.h;h=1dc0f591d09cda9fb2f4d2f81acc9e89cf739f7a;hp=aab65639c16cc6813894d8eb7ec951352d0a31bd;hb=9612f07cbf2b0ec54c5dc6ed7e521e181cc3612d;hpb=7e2bb92dcae6ee785ff7462aadc8c369fd93715b diff --git a/src/dbus-common.h b/src/dbus-common.h index aab65639c..1dc0f591d 100644 --- a/src/dbus-common.h +++ b/src/dbus-common.h @@ -93,17 +93,25 @@ int bus_connect_system_polkit(DBusConnection **_bus, DBusError *error); const char *bus_error_message(const DBusError *error); typedef int (*BusPropertyCallback)(DBusMessageIter *iter, const char *property, void *data); -typedef int (*BusPropertySetCallback)(DBusMessageIter *iter, const char *property); +typedef int (*BusPropertySetCallback)(DBusMessageIter *iter, const char *property, void *data); typedef struct BusProperty { - const char *interface; /* interface of the property */ const char *property; /* name of the property */ BusPropertyCallback append; /* Function that is called to serialize this property */ const char *signature; - const void *data; /* The data of this property */ + const uint16_t offset; /* Offset from BusBoundProperties::base address to the property data. + * uint16_t is sufficient, because we have no structs too big. + * -Werror=overflow will catch it if this does not hold. */ + bool indirect; /* data is indirect, ie. not base+offset, but *(base+offset) */ BusPropertySetCallback set; /* Optional: Function that is called to set this property */ } BusProperty; +typedef struct BusBoundProperties { + const char *interface; /* interface of the properties */ + const BusProperty *properties; /* array of properties, ended by a NULL-filled element */ + const void *const base; /* base pointer to which the offset must be added to reach data */ +} BusBoundProperties; + DBusHandlerResult bus_send_error_reply( DBusConnection *c, DBusMessage *message, @@ -115,11 +123,12 @@ DBusHandlerResult bus_default_message_handler( DBusMessage *message, const char *introspection, const char *interfaces, - const BusProperty *properties); + const BusBoundProperties *bound_properties); int bus_property_append_string(DBusMessageIter *i, const char *property, void *data); int bus_property_append_strv(DBusMessageIter *i, const char *property, void *data); int bus_property_append_bool(DBusMessageIter *i, const char *property, void *data); +int bus_property_append_tristate_false(DBusMessageIter *i, const char *property, void *data); int bus_property_append_int32(DBusMessageIter *i, const char *property, void *data); int bus_property_append_uint32(DBusMessageIter *i, const char *property, void *data); int bus_property_append_uint64(DBusMessageIter *i, const char *property, void *data); @@ -167,4 +176,8 @@ int bus_iter_get_basic_and_next(DBusMessageIter *iter, int type, void *data, boo int generic_print_property(const char *name, DBusMessageIter *iter, bool all); +void bus_async_unregister_and_exit(DBusConnection *bus, const char *name); + +DBusHandlerResult bus_exit_idle_filter(DBusConnection *bus, DBusMessage *m, void *userdata); + #endif