예제 #1
0
파일: vtable.c 프로젝트: pybus/pybus
struct sd_bus_vtable vtab_property(const char *member, const char *sig, sd_bus_property_get_t get, sd_bus_property_set_t set, size_t off, uint64_t flags){
	if(set){
		return (struct sd_bus_vtable)SD_BUS_WRITABLE_PROPERTY(member, sig, get, set, off, flags);
	}else{
		return (struct sd_bus_vtable)SD_BUS_PROPERTY(member, sig, get, off, flags);
	}
}
예제 #2
0
static int emit_object_removed(sd_bus_message *m, void *userdata, sd_bus_error *error) {
        int r;

        assert_se(sd_bus_emit_object_removed(sd_bus_message_get_bus(m), "/value/a/x") >= 0);

        r = sd_bus_reply_method_return(m, NULL);
        assert_se(r >= 0);

        return 1;
}

static const sd_bus_vtable vtable[] = {
        SD_BUS_VTABLE_START(0),
        SD_BUS_METHOD("AlterSomething", "s", "s", something_handler, 0),
        SD_BUS_METHOD("Exit", "", "", exit_handler, 0),
        SD_BUS_WRITABLE_PROPERTY("Something", "s", get_handler, set_handler, 0, 0),
        SD_BUS_WRITABLE_PROPERTY("AutomaticStringProperty", "s", NULL, NULL, offsetof(struct context, automatic_string_property), 0),
        SD_BUS_WRITABLE_PROPERTY("AutomaticIntegerProperty", "u", NULL, NULL, offsetof(struct context, automatic_integer_property), 0),
        SD_BUS_METHOD("NoOperation", NULL, NULL, NULL, 0),
        SD_BUS_METHOD("EmitInterfacesAdded", NULL, NULL, emit_interfaces_added, 0),
        SD_BUS_METHOD("EmitInterfacesRemoved", NULL, NULL, emit_interfaces_removed, 0),
        SD_BUS_METHOD("EmitObjectAdded", NULL, NULL, emit_object_added, 0),
        SD_BUS_METHOD("EmitObjectRemoved", NULL, NULL, emit_object_removed, 0),
        SD_BUS_VTABLE_END
};

static const sd_bus_vtable vtable2[] = {
        SD_BUS_VTABLE_START(0),
        SD_BUS_METHOD("NotifyTest", "", "", notify_test, 0),
        SD_BUS_METHOD("NotifyTest2", "", "", notify_test2, 0),
        SD_BUS_PROPERTY("Value", "s", value_handler, 10, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
예제 #3
0
#include <systemd/sd-bus.h>

const sd_bus_vtable example2[] = {
    SD_BUS_VTABLE_START(0),
    SD_BUS_METHOD((const char*)1, (const char*)2, (const char*)3,
                  (sd_bus_message_handler_t)4, 0),
    SD_BUS_SIGNAL((const char*)5, (const char*)6, 0),
    SD_BUS_PROPERTY((const char*)7, (const char*)8, (sd_bus_property_get_t)9, 0,
                    SD_BUS_VTABLE_PROPERTY_CONST),
    SD_BUS_WRITABLE_PROPERTY((const char*)10, (const char*)11,
                             (sd_bus_property_get_t)12,
                             (sd_bus_property_set_t)13, 0, 0),
    SD_BUS_PROPERTY((const char*)14, (const char*)15, NULL, 16, 0),
    SD_BUS_VTABLE_END,
};

const size_t example2_size = sizeof(example2);
예제 #4
0
static int prop_get(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) {
        return -EINVAL;
}

static int prop_set(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) {
        return -EINVAL;
}

static const sd_bus_vtable vtable[] = {
        SD_BUS_VTABLE_START(0),
        SD_BUS_METHOD("Hello", "ssas", "a(uu)", NULL, 0),
        SD_BUS_METHOD("DeprecatedHello", "", "", NULL, SD_BUS_VTABLE_DEPRECATED),
        SD_BUS_METHOD("DeprecatedHelloNoReply", "", "", NULL, SD_BUS_VTABLE_DEPRECATED|SD_BUS_VTABLE_METHOD_NO_REPLY),
        SD_BUS_SIGNAL("Wowza", "sss", 0),
        SD_BUS_SIGNAL("DeprecatedWowza", "ut", SD_BUS_VTABLE_DEPRECATED),
        SD_BUS_WRITABLE_PROPERTY("AProperty", "s", prop_get, prop_set, 0, 0),
        SD_BUS_PROPERTY("AReadOnlyDeprecatedProperty", "(ut)", prop_get, 0, SD_BUS_VTABLE_DEPRECATED),
        SD_BUS_PROPERTY("ChangingProperty", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
        SD_BUS_PROPERTY("Invalidating", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
        SD_BUS_PROPERTY("Constant", "t", prop_get, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_PROPERTY_EXPLICIT),
        SD_BUS_VTABLE_END
};

int main(int argc, char *argv[]) {
        struct introspect intro;

        log_set_max_level(LOG_DEBUG);

        assert_se(introspect_begin(&intro, false) >= 0);

        fprintf(intro.f, " <interface name=\"org.foo\">\n");