From 06cbcbc9bbdb593f1f24f72513498e17d057f28e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 25 Nov 2008 14:24:35 +0100 Subject: [PATCH] dbus: add match bindings Signed-off-by: Julien Danjou --- dbus.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/dbus.c b/dbus.c index 4de5a7be2..92e4f9fc9 100644 --- a/dbus.c +++ b/dbus.c @@ -454,10 +454,43 @@ luaA_dbus_release_name(lua_State *L) return 1; } +/** Add a match rule to match messages going through the message bus. + * \param L The Lua VM state. + * \return The number of elements pushed on stack. + * \luastack + * \lparam A string with the name of the match rule. + */ +static int +luaA_dbus_add_match(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + dbus_bus_add_match(dbus_connection, name, NULL); + dbus_connection_flush(dbus_connection); + return 0; +} + +/** Remove a previously added match rule "by value" + * (the most recently-added identical rule gets removed). + * \param L The Lua VM state. + * \return The number of elements pushed on stack. + * \luastack + * \lparam A string with the name of the match rule. + */ +static int +luaA_dbus_remove_match(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + dbus_bus_remove_match(dbus_connection, name, NULL); + dbus_connection_flush(dbus_connection); + return 0; +} + const struct luaL_reg awesome_dbus_lib[] = { { "request_name", luaA_dbus_request_name }, { "release_name", luaA_dbus_release_name }, + { "add_match", luaA_dbus_add_match }, + { "remove_match", luaA_dbus_remove_match }, { NULL, NULL } }; @@ -485,6 +518,8 @@ const struct luaL_reg awesome_dbus_lib[] = { { "request_name", luaA_donothing }, { "release_name", luaA_donothing }, + { "add_match", luaA_donothing }, + { "remove_match", luaA_donothing }, { NULL, NULL } };