chiark / gitweb /
udev: keymap - remove weird 'c2 a0' character sequences which break the check
[elogind.git] / src / dbus-common.h
index 9368f75123f23fc2e2aa4c226c88574f406a96ce..38d8e6538cc7d8430d0d86cef617b1a199acfe5a 100644 (file)
@@ -9,16 +9,16 @@
   Copyright 2010 Lennart Poettering
 
   systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
   (at your option) any later version.
 
   systemd is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  General Public License for more details.
+  Lesser General Public License for more details.
 
-  You should have received a copy of the GNU General Public License
+  You should have received a copy of the GNU Lesser General Public License
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
@@ -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);
@@ -151,6 +160,21 @@ int bus_property_append_long(DBusMessageIter *i, const char *property, void *dat
                 return 0;                                               \
         }
 
+#define DEFINE_BUS_PROPERTY_SET_ENUM(function,name,type)                \
+        int function(DBusMessageIter *i, const char *property, void *data) { \
+                const char *value;                                      \
+                type *field = data;                                     \
+                                                                        \
+                assert(i);                                              \
+                assert(property);                                       \
+                                                                        \
+                dbus_message_iter_get_basic(i, &value);                 \
+                                                                        \
+                *field = name##_from_string(value);                     \
+                                                                        \
+                return 0;                                               \
+        }
+
 const char *bus_errno_to_dbus(int error);
 
 DBusMessage* bus_properties_changed_new(const char *path, const char *interface, const char *properties);
@@ -161,4 +185,14 @@ unsigned bus_events_to_flags(uint32_t events);
 int bus_parse_strv(DBusMessage *m, char ***_l);
 int bus_parse_strv_iter(DBusMessageIter *iter, char ***_l);
 
+int bus_append_strv_iter(DBusMessageIter *iter, char **l);
+
+int bus_iter_get_basic_and_next(DBusMessageIter *iter, int type, void *data, bool next);
+
+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