Use the exported D-Bus service name instead of hardcoded string
[connman] / plugins / dhclient.c
index 8847a1d..bdf877a 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2008  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
@@ -40,6 +40,7 @@
 
 #include <connman/plugin.h>
 #include <connman/dhcp.h>
+#include <connman/dbus.h>
 
 #define DHCLIENT_INTF "org.isc.dhclient"
 #define DHCLIENT_PATH "/org/isc/dhclient"
@@ -85,27 +86,14 @@ static struct dhclient_task *find_task_by_index(int index)
 
 static void kill_task(struct dhclient_task *task)
 {
-       char pathname[PATH_MAX];
-
        if (task->pid > 0)
                kill(task->pid, SIGTERM);
-
-       snprintf(pathname, sizeof(pathname) - 1,
-                       "%s/dhclient.%s.pid", STATEDIR, task->ifname);
-       unlink(pathname);
-
-       snprintf(pathname, sizeof(pathname) - 1,
-                       "%s/dhclient.%s.leases", STATEDIR, task->ifname);
-       unlink(pathname);
-
-       free(task->ifname);
-
-       g_free(task);
 }
 
 static void task_died(GPid pid, gint status, gpointer data)
 {
        struct dhclient_task *task = data;
+       char pathname[PATH_MAX];
 
        if (WIFEXITED(status))
                printf("[DHCP] exit status %d for %s\n",
@@ -119,7 +107,17 @@ static void task_died(GPid pid, gint status, gpointer data)
 
        tasks = g_slist_remove(tasks, task);
 
-       kill_task(task);
+       snprintf(pathname, sizeof(pathname) - 1,
+                       "%s/dhclient.%s.pid", STATEDIR, task->ifname);
+       unlink(pathname);
+
+       snprintf(pathname, sizeof(pathname) - 1,
+                       "%s/dhclient.%s.leases", STATEDIR, task->ifname);
+       unlink(pathname);
+
+       free(task->ifname);
+
+       g_free(task);
 }
 
 static void task_setup(gpointer data)
@@ -317,8 +315,7 @@ static int plugin_init(void)
        connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
 
        busname = dbus_bus_get_unique_name(connection);
-
-       busname = "org.freedesktop.connman";
+       busname = CONNMAN_SERVICE;
 
        dbus_connection_add_filter(connection, dhclient_filter, NULL, NULL);