summaryrefslogtreecommitdiffstats
path: root/common/dbus.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-18 01:08:40 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-18 01:08:40 +0000
commit125780a23b51802aea47920c79ee8e368d11592f (patch)
treedb761fa85a54bbed37b26ee5a364d10de38962e5 /common/dbus.c
parente3f0f970d9d2bbc0587a89b50acf88d757c12a07 (diff)
Add generic method table handling
Diffstat (limited to 'common/dbus.c')
-rw-r--r--common/dbus.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/common/dbus.c b/common/dbus.c
index 730dfb67..63e5e38f 100644
--- a/common/dbus.c
+++ b/common/dbus.c
@@ -611,7 +611,8 @@ DBusConnection *init_dbus(const char *name, void (*disconnect_cb)(void *), void
static char simple_xml[] = DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE "<node></node>";
-DBusHandlerResult simple_introspect(DBusConnection *conn, DBusMessage *msg, void *data)
+DBusHandlerResult simple_introspect(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
{
DBusMessage *reply;
const char *path, *ptr = simple_xml;
@@ -634,3 +635,29 @@ DBusHandlerResult simple_introspect(DBusConnection *conn, DBusMessage *msg, void
return send_message_and_unref(conn, reply);
}
+
+static DBusHandlerResult generic_message_function(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ struct message_table *table = user_data;
+ struct message_table *current;
+ const char *member;
+
+ if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE,
+ "Introspect") == TRUE)
+ return simple_introspect(conn, msg, user_data);
+
+ member = dbus_message_get_member(msg);
+
+ for (current = table; current->handler; current++) {
+ if (dbus_message_is_method_call(msg, current->interface, current->member) == TRUE &&
+ dbus_message_has_signature(msg, current->signature) == TRUE)
+ return current->handler(conn, msg, user_data);
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+DBusObjectPathVTable generic_object_path = {
+ .message_function = generic_message_function,
+};