diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-06-06 18:02:21 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-06-06 18:02:21 +0000 |
commit | 253d30d4f95eb6d896531a5bfb570e7d1bb1ca0c (patch) | |
tree | 4900aa3508b1c7513784186ac374bcc8ec01f489 | |
parent | a2e87ebea964817c620cef7cb0c70cdd0982232c (diff) |
Add simple introspection support
-rw-r--r-- | hcid/dbus-adapter.c | 8 | ||||
-rw-r--r-- | hcid/dbus-common.c | 24 | ||||
-rw-r--r-- | hcid/dbus-manager.c | 8 | ||||
-rw-r--r-- | hcid/dbus.h | 2 |
4 files changed, 38 insertions, 4 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c index 1d1b7762..a5f7147c 100644 --- a/hcid/dbus-adapter.c +++ b/hcid/dbus-adapter.c @@ -2257,11 +2257,15 @@ static struct service_data dev_services[] = { DBusHandlerResult msg_func_device(DBusConnection *conn, DBusMessage *msg, void *data) { - const char *iface; + const char *iface, *name; iface = dbus_message_get_interface(msg); + name = dbus_message_get_member(msg); - if (!strcmp(ADAPTER_INTERFACE, iface)) { + if (!strcmp(DBUS_INTERFACE_INTROSPECTABLE, iface) && + !strcmp("Introspect", name)) { + return simple_introspect(conn, msg, data); + } else if (!strcmp(ADAPTER_INTERFACE, iface)) { service_handler_func_t handler; handler = find_service_handler(dev_services, msg); diff --git a/hcid/dbus-common.c b/hcid/dbus-common.c index dd46ccd8..9b60b8dd 100644 --- a/hcid/dbus-common.c +++ b/hcid/dbus-common.c @@ -287,6 +287,30 @@ int name_listener_remove(DBusConnection *connection, const char *name, return 0; } +static char simple_xml[] = DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE "<node></node>"; + +DBusHandlerResult simple_introspect(DBusConnection *conn, DBusMessage *msg, void *data) +{ + DBusMessage *reply; + const char *path, *ptr = simple_xml; + + path = dbus_message_get_path(msg); + + info("Introspect path:%s", path); + + if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING)) + return error_invalid_arguments(conn, msg); + + reply = dbus_message_new_method_return(msg); + if (!reply) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + + dbus_message_append_args(reply, DBUS_TYPE_STRING, &ptr, + DBUS_TYPE_INVALID); + + return send_reply_and_unref(conn, reply); +} + service_handler_func_t find_service_handler(struct service_data *handlers, DBusMessage *msg) { struct service_data *current; diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c index 2a5b8d82..10d1a07f 100644 --- a/hcid/dbus-manager.c +++ b/hcid/dbus-manager.c @@ -218,15 +218,19 @@ DBusHandlerResult msg_func_manager(DBusConnection *conn, DBusMessage *msg, void *data) { service_handler_func_t handler; - const char *iface, *path; + const char *iface, *path, *name; iface = dbus_message_get_interface(msg); path = dbus_message_get_path(msg); + name = dbus_message_get_member(msg); if (strcmp(BASE_PATH, path)) return error_no_such_adapter(conn, msg); - if (!strcmp(iface, MANAGER_INTERFACE)) { + if (!strcmp(DBUS_INTERFACE_INTROSPECTABLE, iface) && + !strcmp("Introspect", name)) { + return simple_introspect(conn, msg, data); + } else if (!strcmp(iface, MANAGER_INTERFACE)) { handler = find_service_handler(methods, msg); if (handler) return handler(conn, msg, data); diff --git a/hcid/dbus.h b/hcid/dbus.h index 9539b922..cff5b7ee 100644 --- a/hcid/dbus.h +++ b/hcid/dbus.h @@ -170,6 +170,8 @@ DBusHandlerResult handle_rfcomm_method(DBusConnection *conn, DBusMessage *msg, v DBusHandlerResult handle_sdp_method(DBusConnection *conn, DBusMessage *msg, void *data); +DBusHandlerResult simple_introspect(DBusConnection *conn, DBusMessage *msg, void *data); + service_handler_func_t find_service_handler(struct service_data *services, DBusMessage *msg); int handle_passkey_request(DBusConnection *conn, int dev, const char *path, bdaddr_t *sba, bdaddr_t *dba); |