diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-06-06 13:35:07 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-06-06 13:35:07 +0000 |
commit | 8955dc1ce35be8c0ef70b0faa8846c2bf4b6de9f (patch) | |
tree | a0dd884d86173568a201ce011b7a352ff9d81087 /hcid | |
parent | 5a63456081d0ba9cc8bdc66f17afe003788c9b33 (diff) |
More cleanups and less casting
Diffstat (limited to 'hcid')
-rw-r--r-- | hcid/adapter.c | 3 | ||||
-rw-r--r-- | hcid/dbus-hci.c | 21 | ||||
-rw-r--r-- | hcid/device.c | 2 | ||||
-rw-r--r-- | hcid/device.h | 2 |
4 files changed, 20 insertions, 8 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c index e62508d1..d0226db5 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -2450,8 +2450,9 @@ void adapter_remove_device(DBusConnection *conn, struct adapter *adapter, device->agent = NULL; } - device_remove(device, conn); adapter->devices = g_slist_remove(adapter->devices, device); + + device_remove(conn, device); } struct device *adapter_get_device(DBusConnection *conn, diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c index 57dd14b1..71d8efa5 100644 --- a/hcid/dbus-hci.c +++ b/hcid/dbus-hci.c @@ -431,6 +431,14 @@ static void reply_pending_requests(const char *path, struct adapter *adapter) } } +static void do_unregister(gpointer data, gpointer user_data) +{ + DBusConnection *conn = user_data; + struct device *device = data; + + device_remove(conn, device); +} + int unregister_adapter_path(const char *path) { struct adapter *adapter = NULL; @@ -509,8 +517,8 @@ int unregister_adapter_path(const char *path) } if (adapter->devices) { - g_slist_foreach(adapter->devices, - (GFunc) device_remove, connection); + g_slist_foreach(adapter->devices, do_unregister, + connection); g_slist_free(adapter->devices); } @@ -520,14 +528,14 @@ int unregister_adapter_path(const char *path) g_free(adapter); unreg: - if (!g_dbus_unregister_all_interfaces(connection, path)) { + if (!g_dbus_unregister_interface(connection, path, ADAPTER_INTERFACE)) { error("D-Bus failed to unregister %s object", path); return -1; } if (hcid_dbus_use_experimental()) { const char *ptr = path + ADAPTER_PATH_INDEX; - g_dbus_unregister_all_interfaces(connection, ptr); + g_dbus_unregister_interface(connection, ptr, ADAPTER_INTERFACE); } return 0; @@ -594,8 +602,11 @@ int hcid_dbus_register_device(uint16_t id) return 0; failed: + if (hcid_dbus_use_experimental()) + g_dbus_unregister_interface(connection, ptr, ADAPTER_INTERFACE); + g_dbus_unregister_interface(connection, path, ADAPTER_INTERFACE); - g_dbus_unregister_interface(connection, ptr, ADAPTER_INTERFACE); + g_free(adapter->path); g_free(adapter); diff --git a/hcid/device.c b/hcid/device.c index 1c507329..423f35a6 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -1048,7 +1048,7 @@ struct device *device_create(DBusConnection *conn, struct adapter *adapter, return device; } -void device_remove(struct device *device, DBusConnection *conn) +void device_remove(DBusConnection *conn, struct device *device) { debug("Removing device %s", device->path); diff --git a/hcid/device.h b/hcid/device.h index 5ef524df..ff687231 100644 --- a/hcid/device.h +++ b/hcid/device.h @@ -35,7 +35,7 @@ struct device { struct device *device_create(DBusConnection *conn, struct adapter *adapter, const gchar *address, GSList *uuids); -void device_remove(struct device *device, DBusConnection *conn); +void device_remove(DBusConnection *conn, struct device *device); gint device_address_cmp(struct device *device, const gchar *address); int device_browse(struct device *device, DBusConnection *conn, DBusMessage *msg); |