From ec4ebd543107fc705d36a7f7b085bd8b6479cf39 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 30 Jun 2008 09:40:59 +0200 Subject: [PATCH] Use new signal callback function from libgdbus --- plugins/bluetooth.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c index 167878b..6d41fb2 100644 --- a/plugins/bluetooth.c +++ b/plugins/bluetooth.c @@ -23,7 +23,7 @@ #include #endif -#include +#include #include #include @@ -58,12 +58,20 @@ static void create_element(DBusConnection *conn, const char *path) g_static_mutex_unlock(&element_mutex); } -static DBusHandlerResult bluetooth_filter(DBusConnection *conn, - DBusMessage *msg, void *data) +static gboolean bluetooth_signal(DBusConnection *conn, + DBusMessage *msg, void *data) { + const char *sender, *interface, *member; + DBG("conn %p msg %p", conn, msg); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + sender = dbus_message_get_sender(msg); + interface = dbus_message_get_interface(msg); + member = dbus_message_get_member(msg); + + DBG("sender %s name %s.%s", sender, interface, member); + + return TRUE; } static void list_adapters(DBusConnection *conn) @@ -122,26 +130,18 @@ static struct connman_driver bluetooth_driver = { }; static DBusConnection *connection; +static guint signal; static int bluetooth_init(void) { - gchar *match; int err; connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); if (connection == NULL) return -EIO; - if (dbus_connection_add_filter(connection, bluetooth_filter, - NULL, NULL) == FALSE) - connman_error("Can't add D-Bus filter for Bluetooth"); - - match = g_strdup_printf("sender=%s,interface=%s", "org.bluez", - "org.bluez.Manager"); - - dbus_bus_add_match(connection, match, NULL); - - g_free(match); + signal = g_dbus_add_signal_watch(connection, "sender=org.bluez", + bluetooth_signal, NULL, NULL); err = connman_driver_register(&bluetooth_driver); if (err < 0) { @@ -158,6 +158,8 @@ static void bluetooth_exit(void) { connman_driver_unregister(&bluetooth_driver); + g_dbus_remove_watch(connection, signal); + dbus_connection_unref(connection); } -- 2.7.4