Add option for selecting Bluetooth support
[connman] / plugins / dhclient.c
index 2cb4930..cb0e875 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
@@ -27,6 +27,7 @@
 #include <sys/wait.h>
 #include <glib/gstdio.h>
 
+#define CONNMAN_API_SUBJECT_TO_CHANGE
 #include <connman/plugin.h>
 #include <connman/driver.h>
 #include <connman/dbus.h>
@@ -313,9 +314,11 @@ static DBusHandlerResult dhclient_filter(DBusConnection *conn,
 
 static DBusConnection *connection;
 
+static const char *dhclient_rule = "path=" DHCLIENT_PATH
+                                               ",interface=" DHCLIENT_INTF;
+
 static int dhclient_init(void)
 {
-       gchar *filter;
        int err;
 
        connection = connman_dbus_get_connection();
@@ -325,12 +328,7 @@ static int dhclient_init(void)
 
        dbus_connection_add_filter(connection, dhclient_filter, NULL, NULL);
 
-       filter = g_strdup_printf("interface=%s,path=%s",
-                                               DHCLIENT_INTF, DHCLIENT_PATH);
-
-       dbus_bus_add_match(connection, filter, NULL);
-
-       g_free(filter);
+       dbus_bus_add_match(connection, dhclient_rule, NULL);
 
        err = connman_driver_register(&dhclient_driver);
        if (err < 0) {
@@ -358,6 +356,10 @@ static void dhclient_exit(void)
 
        connman_driver_unregister(&dhclient_driver);
 
+       dbus_bus_remove_match(connection, dhclient_rule, NULL);
+
+       dbus_connection_remove_filter(connection, dhclient_filter, NULL);
+
        dbus_connection_unref(connection);
 }