+ if (c->vtable->method.handler)
+ return c->vtable->method.handler(bus, m, u);
+
+ /* If the method callback is NULL, make this a successful NOP */
+ r = sd_bus_reply_method_return(bus, m, NULL);
+ if (r < 0)
+ return r;
+
+ return 1;
+}
+
+static int invoke_property_get(
+ sd_bus *bus,
+ const sd_bus_vtable *v,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *m,
+ sd_bus_error *error,
+ void *userdata) {
+
+ int r;
+ void *p;
+
+ assert(bus);
+ assert(v);
+
+ if (v->property.get)
+ return v->property.get(bus, path, interface, property, m, error, userdata);
+
+ /* Automatic handling if no callback is defined. */
+
+ assert(bus_type_is_basic(v->property.signature[0]));
+
+ switch (v->property.signature[0]) {
+
+ case SD_BUS_TYPE_STRING:
+ case SD_BUS_TYPE_OBJECT_PATH:
+ case SD_BUS_TYPE_SIGNATURE:
+ p = *(char**) userdata;
+ break;
+
+ default:
+ p = userdata;
+ break;
+ }
+
+ r = sd_bus_message_append_basic(m, v->property.signature[0], p);
+ if (r < 0)
+ return r;
+
+ return 1;
+}
+
+static int invoke_property_set(
+ sd_bus *bus,
+ const sd_bus_vtable *v,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *value,
+ sd_bus_error *error,
+ void *userdata) {
+
+ int r;
+
+ assert(bus);
+ assert(v);
+
+ if (v->property.set)
+ return v->property.set(bus, path, interface, property, value, error, userdata);
+
+ /* Automatic handling if no callback is defined. */
+
+ assert(signature_is_single(v->property.signature, false));
+ assert(bus_type_is_basic(v->property.signature[0]));
+
+ switch (v->property.signature[0]) {
+
+ case SD_BUS_TYPE_STRING:
+ case SD_BUS_TYPE_OBJECT_PATH:
+ case SD_BUS_TYPE_SIGNATURE: {
+ const char *p;
+ char *n;
+
+ r = sd_bus_message_read_basic(value, v->property.signature[0], &p);
+ if (r < 0)
+ return r;
+
+ n = strdup(p);
+ if (!n)
+ return -ENOMEM;
+
+ free(*(char**) userdata);
+ *(char**) userdata = n;
+
+ break;
+ }
+
+ default:
+ r = sd_bus_message_read_basic(value, v->property.signature[0], userdata);
+ if (r < 0)
+ return r;
+
+ break;
+ }
+
+ return 1;