summaryrefslogtreecommitdiff
path: root/src/systemd
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemd')
-rw-r--r--src/systemd/sd-bus-protocol.h39
-rw-r--r--src/systemd/sd-bus-vtable.h127
-rw-r--r--src/systemd/sd-bus.h54
3 files changed, 201 insertions, 19 deletions
diff --git a/src/systemd/sd-bus-protocol.h b/src/systemd/sd-bus-protocol.h
index a26d27c31a..568005b3bd 100644
--- a/src/systemd/sd-bus-protocol.h
+++ b/src/systemd/sd-bus-protocol.h
@@ -108,6 +108,21 @@ enum {
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
+#define SD_BUS_INTROSPECT_INTERFACE_PEER \
+ " <interface name=\"org.freedesktop.DBus.Peer\">\n" \
+ " <method name=\"Ping\"/>\n" \
+ " <method name=\"GetMachineId\">\n" \
+ " <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
+ " </method>\n" \
+ " </interface>\n"
+
+#define SD_BUS_INTROSPECT_INTERFACE_INTROSPECTABLE \
+ " <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \
+ " <method name=\"Introspect\">\n" \
+ " <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" \
+ " </method>\n" \
+ " </interface>\n"
+
#define SD_BUS_INTROSPECT_INTERFACE_PROPERTIES \
" <interface name=\"org.freedesktop.DBus.Properties\">\n" \
" <method name=\"Get\">\n" \
@@ -131,21 +146,21 @@ enum {
" </signal>\n" \
" </interface>\n"
-#define SD_BUS_INTROSPECT_INTERFACE_INTROSPECTABLE \
- " <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \
- " <method name=\"Introspect\">\n" \
- " <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" \
+#define SD_BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER \
+ " <interface name=\"org.freedesktop.DBus.ObjectManager\">\n" \
+ " <method name=\"GetManagedObjects\">\n" \
+ " <arg type=\"a{oa{sa{sv}}}\" name=\"object_paths_interfaces_and_properties\" direction=\"out\"/>\n" \
" </method>\n" \
+ " <signal name=\"InterfacesAdded\">\n" \
+ " <arg type=\"o\" name=\"object_path\"/>\n" \
+ " <arg type=\"a{sa{sv}}\" name=\"interfaces_and_properties\"/>\n" \
+ " </signal>\n" \
+ " <signal name=\"InterfacesRemoved\">\n" \
+ " <arg type=\"o\" name=\"object_path\"/>\n" \
+ " <arg type=\"as\" name=\"interfaces\"/>\n" \
+ " </signal>\n" \
" </interface>\n"
-#define SD_BUS_INTROSPECT_INTERFACE_PEER \
- "<interface name=\"org.freedesktop.DBus.Peer\">\n" \
- " <method name=\"Ping\"/>\n" \
- " <method name=\"GetMachineId\">\n" \
- " <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
- " </method>\n" \
- "</interface>\n"
-
#ifdef __cplusplus
}
#endif
diff --git a/src/systemd/sd-bus-vtable.h b/src/systemd/sd-bus-vtable.h
new file mode 100644
index 0000000000..a1f078e540
--- /dev/null
+++ b/src/systemd/sd-bus-vtable.h
@@ -0,0 +1,127 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#ifndef foosdbusvtablehfoo
+#define foosdbusvtablehfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2013 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+typedef struct sd_bus_vtable sd_bus_vtable;
+
+#include "sd-bus.h"
+
+enum {
+ _SD_BUS_VTABLE_START = '<',
+ _SD_BUS_VTABLE_END = '>',
+ _SD_BUS_VTABLE_METHOD = 'M',
+ _SD_BUS_VTABLE_SIGNAL = 'S',
+ _SD_BUS_VTABLE_PROPERTY = 'P',
+ _SD_BUS_VTABLE_WRITABLE_PROPERTY = 'W',
+ _SD_BUS_VTABLE_CHILDREN = 'C'
+};
+
+enum {
+ SD_BUS_VTABLE_DEPRECATED = 1,
+ SD_BUS_VTABLE_METHOD_NO_REPLY = 2,
+ SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE = 4,
+ SD_BUS_VTABLE_PROPERTY_INVALIDATE_ONLY = 8,
+};
+
+struct sd_bus_vtable {
+ /* Please do not initialize this structure directly, use the
+ * macros below instead */
+
+ int type;
+ int flags;
+ union {
+ struct {
+ size_t element_size;
+ } start;
+ struct {
+ const char *member;
+ const char *signature;
+ const char *result;
+ sd_bus_message_handler_t handler;
+ } method;
+ struct {
+ const char *member;
+ const char *signature;
+ } signal;
+ struct {
+ const char *member;
+ const char *signature;
+ sd_bus_property_get_t get;
+ sd_bus_property_set_t set;
+ size_t offset;
+ } property;
+ };
+};
+
+#define SD_BUS_VTABLE_START(_flags) \
+ { \
+ .type = _SD_BUS_VTABLE_START, \
+ .flags = _flags, \
+ .start.element_size = sizeof(sd_bus_vtable), \
+ }
+
+#define SD_BUS_METHOD(_member, _signature, _result, _flags, _handler) \
+ { \
+ .type = _SD_BUS_VTABLE_METHOD, \
+ .flags = _flags, \
+ .method.member = _member, \
+ .method.signature = _signature, \
+ .method.result = _result, \
+ .method.handler = _handler, \
+ }
+
+#define SD_BUS_SIGNAL(_member, _signature, _flags) \
+ { \
+ .type = _SD_BUS_VTABLE_SIGNAL, \
+ .flags = _flags, \
+ .signal.member = _member, \
+ .signal.signature = _signature, \
+ }
+
+#define SD_BUS_PROPERTY(_member, _signature, _get, _offset, _flags) \
+ { \
+ .type = _SD_BUS_VTABLE_PROPERTY, \
+ .flags = _flags, \
+ .property.member = _member, \
+ .property.signature = _signature, \
+ .property.get = _get, \
+ .property.offset = _offset, \
+ }
+
+#define SD_BUS_WRITABLE_PROPERTY(_member, _signature, _get, _set, _offset, _flags) \
+ { \
+ .type = _SD_BUS_VTABLE_WRITABLE_PROPERTY, \
+ .flags = _flags, \
+ .property.member = _member, \
+ .property.signature = _signature, \
+ .property.get = _get, \
+ .property.set = _set, \
+ .property.offset = _offset, \
+ }
+
+#define SD_BUS_VTABLE_END \
+ { \
+ .type = _SD_BUS_VTABLE_END, \
+ }
+
+#endif
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 878001ccb5..101e75131e 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -26,8 +26,6 @@
#include <sys/types.h>
#include <sd-id128.h>
-#include "sd-bus-protocol.h"
-#include "sd-memfd.h"
#ifdef __cplusplus
extern "C" {
@@ -41,6 +39,8 @@ extern "C" {
# endif
#endif
+/* Types */
+
typedef struct sd_bus sd_bus;
typedef struct sd_bus_message sd_bus_message;
@@ -50,8 +50,21 @@ typedef struct {
int need_free;
} sd_bus_error;
+/* Callbacks */
+
typedef int (*sd_bus_message_handler_t)(sd_bus *bus, sd_bus_message *m, void *userdata);
+typedef int (*sd_bus_property_get_t) (sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, sd_bus_error *error, void *userdata);
+typedef int (*sd_bus_property_set_t) (sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *value, sd_bus_error *error, void *userdata);
+
+typedef int (*sd_bus_object_find_t) (sd_bus *bus, const char *path, const char *interface, void **found, void *userdata);
+
+typedef int (*sd_bus_node_enumerator_t) (sd_bus *bus, const char *path, char ***nodes, void *userdata);
+
+#include "sd-bus-protocol.h"
+#include "sd-bus-vtable.h"
+#include "sd-memfd.h"
+
/* Connections */
int sd_bus_open_system(sd_bus **ret);
@@ -98,21 +111,33 @@ int sd_bus_flush(sd_bus *bus);
int sd_bus_add_filter(sd_bus *bus, sd_bus_message_handler_t callback, void *userdata);
int sd_bus_remove_filter(sd_bus *bus, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_add_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_remove_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
+
int sd_bus_add_object(sd_bus *bus, const char *path, sd_bus_message_handler_t callback, void *userdata);
int sd_bus_remove_object(sd_bus *bus, const char *path, sd_bus_message_handler_t callback, void *userdata);
int sd_bus_add_fallback(sd_bus *bus, const char *prefix, sd_bus_message_handler_t callback, void *userdata);
int sd_bus_remove_fallback(sd_bus *bus, const char *prefix, sd_bus_message_handler_t callback, void *userdata);
-int sd_bus_add_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
-int sd_bus_remove_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_add_object_vtable(sd_bus *bus, const char *path, const char *interface, const sd_bus_vtable *vtable, void *userdata);
+int sd_bus_remove_object_vtable(sd_bus *bus, const char *path, const char *interface);
-/* Message object */
+int sd_bus_add_fallback_vtable(sd_bus *bus, const char *path, const char *interface, const sd_bus_vtable *vtable, sd_bus_object_find_t find, void *userdata);
+int sd_bus_remove_fallback_vtable(sd_bus *bus, const char *path, const char *interface);
+int sd_bus_add_node_enumerator(sd_bus *bus, const char *path, sd_bus_node_enumerator_t callback, void *userdata);
+int sd_bus_remove_node_enumerator(sd_bus *bus, const char *path, sd_bus_node_enumerator_t callback, void *userdata);
+
+int sd_bus_add_object_manager(sd_bus *bus, const char *path);
+int sd_bus_remove_object_manager(sd_bus *bus, const char *path);
+
+/* Message object */
int sd_bus_message_new_signal(sd_bus *bus, const char *path, const char *interface, const char *member, sd_bus_message **m);
int sd_bus_message_new_method_call(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_message **m);
int sd_bus_message_new_method_return(sd_bus *bus, sd_bus_message *call, sd_bus_message **m);
int sd_bus_message_new_method_error(sd_bus *bus, sd_bus_message *call, const sd_bus_error *e, sd_bus_message **m);
+int sd_bus_message_new_method_errorf(sd_bus *bus, sd_bus_message *call, sd_bus_message **m, const char *name, const char *format, ...);
sd_bus_message* sd_bus_message_ref(sd_bus_message *m);
sd_bus_message* sd_bus_message_unref(sd_bus_message *m);
@@ -175,12 +200,26 @@ int sd_bus_message_exit_container(sd_bus_message *m);
int sd_bus_message_peek_type(sd_bus_message *m, char *type, const char **contents);
int sd_bus_message_rewind(sd_bus_message *m, int complete);
+int sd_bus_message_get_signature(sd_bus_message *m, int complete, const char **signature);
+
/* Convenience calls */
-int sd_bus_emit_signal(sd_bus *bus, const char *path, const char *interface, const char *member, const char *types, ...);
int sd_bus_call_method(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *error, sd_bus_message **reply, const char *types, ...);
+int sd_bus_get_property(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *error, sd_bus_message **reply, const char *type);
+int sd_bus_set_property(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *error, const char *type, ...);
int sd_bus_reply_method_return(sd_bus *bus, sd_bus_message *call, const char *types, ...);
int sd_bus_reply_method_error(sd_bus *bus, sd_bus_message *call, const sd_bus_error *e);
+int sd_bus_reply_method_errorf(sd_bus *bus, sd_bus_message *call, const char *name, const char *format, ...);
+
+int sd_bus_emit_signal(sd_bus *bus, const char *path, const char *interface, const char *member, const char *types, ...);
+
+int sd_bus_emit_properties_changed_strv(sd_bus *bus, const char *path, const char *interface, char **names);
+int sd_bus_emit_properties_changed(sd_bus *bus, const char *path, const char *interface, const char *name, ...);
+
+int sd_bus_emit_interfaces_added_strv(sd_bus *bus, const char *path, char **interfaces); /* MISSING */
+int sd_bus_emit_interfaces_added(sd_bus *bus, const char *path, const char *interface, ...); /* MISSING */
+int sd_bus_emit_interfaces_removed_strv(sd_bus *bus, const char *path, char **interfaces); /* MISSING */
+int sd_bus_emit_interfaces_removed(sd_bus *bus, const char *path, const char *interface, ...); /* MISSING */
/* Bus management */
@@ -199,7 +238,8 @@ int sd_bus_get_owner_machine_id(sd_bus *bus, const char *name, sd_id128_t *machi
#define SD_BUS_ERROR_MAKE(name, message) ((sd_bus_error) {(name), (message), 0})
void sd_bus_error_free(sd_bus_error *e);
-int sd_bus_error_set(sd_bus_error *e, const char *name, const char *format, ...) _sd_printf_attr_(3, 0);
+int sd_bus_error_setf(sd_bus_error *e, const char *name, const char *format, ...) _sd_printf_attr_(3, 0);
+int sd_bus_error_set(sd_bus_error *e, const char *name, const char *message);
void sd_bus_error_set_const(sd_bus_error *e, const char *name, const char *message);
int sd_bus_error_copy(sd_bus_error *dest, const sd_bus_error *e);
int sd_bus_error_is_set(const sd_bus_error *e);