diff options
author | Luiz Augusto Von Dentz <luiz.dentz-von@nokia.com> | 2009-12-29 13:46:17 +0200 |
---|---|---|
committer | Luiz Augusto Von Dentz <luiz.dentz-von@nokia.com> | 2009-12-31 11:11:34 +0200 |
commit | 5930881f7e0b6a48404b63be4221a5898b369156 (patch) | |
tree | b239a1e0ddd62cec0d110dbb76e328a52745bcdf /plugins/udhcp.c | |
parent | 8526308d7387b5c91767b2eebd2e1ec2abb5fb03 (diff) | |
download | connman-5930881f7e0b6a48404b63be4221a5898b369156.tar.gz connman-5930881f7e0b6a48404b63be4221a5898b369156.tar.bz2 connman-5930881f7e0b6a48404b63be4221a5898b369156.zip |
Port udhcp driver to use g_dbus_add_signal_watch
Diffstat (limited to 'plugins/udhcp.c')
-rw-r--r-- | plugins/udhcp.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/plugins/udhcp.c b/plugins/udhcp.c index 6ee0ac8c..df0143c3 100644 --- a/plugins/udhcp.c +++ b/plugins/udhcp.c @@ -26,6 +26,8 @@ #include <stdio.h> #include <unistd.h> +#include <gdbus.h> + #define CONNMAN_API_SUBJECT_TO_CHANGE #include <connman/plugin.h> #include <connman/driver.h> @@ -161,25 +163,25 @@ static void udhcp_bound(DBusMessage *msg, gboolean renew) connman_element_unref(element); } -static DBusHandlerResult udhcp_filter(DBusConnection *conn, +static gboolean udhcp_filter(DBusConnection *conn, DBusMessage *msg, void *data) { if (dbus_message_is_method_call(msg, UDHCPC_INTF, "bound") == TRUE) { udhcp_bound(msg, FALSE); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + return TRUE; } if (dbus_message_is_method_call(msg, UDHCPC_INTF, "renew") == TRUE) { udhcp_bound(msg, TRUE); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + return TRUE; } - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + return TRUE; } static DBusConnection *connection; -static const char *udhcp_rule = "path=" UDHCPC_PATH ",interface=" UDHCPC_INTF; +static guint watch; static int udhcp_init(void) { @@ -187,9 +189,11 @@ static int udhcp_init(void) connection = connman_dbus_get_connection(); - dbus_connection_add_filter(connection, udhcp_filter, NULL, NULL); - - dbus_bus_add_match(connection, udhcp_rule, NULL); + watch = g_dbus_add_signal_watch(connection, NULL, UDHCPC_PATH, + UDHCPC_INTF, NULL, udhcp_filter, + NULL, NULL); + if (watch == 0) + return -EIO; err = connman_driver_register(&udhcp_driver); if (err < 0) { @@ -204,9 +208,7 @@ static void udhcp_exit(void) { connman_driver_unregister(&udhcp_driver); - dbus_bus_remove_match(connection, udhcp_rule, NULL); - - dbus_connection_remove_filter(connection, udhcp_filter, NULL); + g_dbus_remove_watch(connection, watch); dbus_connection_unref(connection); } |