summaryrefslogtreecommitdiff
path: root/plugins/bluetooth.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-07-25 16:24:37 +0200
committerMarcel Holtmann <marcel@holtmann.org>2011-07-26 01:23:07 +0200
commit2c349f0457259d9fa670b61525570723f7563bdd (patch)
tree0500420167dd42ee57dc1f0b6c2060a8cf248d86 /plugins/bluetooth.c
parentba045ac4c9bf8d84d9ec2679be505bb51d098ab6 (diff)
downloadconnman-2c349f0457259d9fa670b61525570723f7563bdd.tar.gz
connman-2c349f0457259d9fa670b61525570723f7563bdd.tar.bz2
connman-2c349f0457259d9fa670b61525570723f7563bdd.zip
bluetooth: Fix remove device/network
Diffstat (limited to 'plugins/bluetooth.c')
-rw-r--r--plugins/bluetooth.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 39833a04..cdb20ff2 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -599,6 +599,36 @@ static gboolean device_changed(DBusConnection *connection,
return TRUE;
}
+static void remove_device_networks(struct connman_device *device)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+ GSList *key_list = NULL;
+ GSList *list;
+
+ if (bluetooth_networks == NULL)
+ return;
+
+ g_hash_table_iter_init(&iter, bluetooth_networks);
+
+ while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+ struct connman_network *network = value;
+
+ if (connman_network_get_device(network) != device)
+ continue;
+
+ key_list = g_slist_append(key_list, key);
+ }
+
+ for (list = key_list; list != NULL; list = list->next) {
+ const char *network_path = list->data;
+
+ g_hash_table_remove(bluetooth_networks, network_path);
+ }
+
+ g_slist_free(key_list);
+}
+
static void adapter_properties_reply(DBusPendingCall *call, void *user_data)
{
char *path = user_data;
@@ -665,6 +695,8 @@ update:
if (powered == TRUE)
check_networks(device, &networks);
+ else
+ remove_device_networks(device);
done:
dbus_message_unref(reply);
@@ -781,6 +813,8 @@ static void unregister_device(gpointer data)
DBG("");
+ remove_device_networks(device);
+
connman_device_unregister(device);
connman_device_unref(device);
}
@@ -844,6 +878,7 @@ static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
return;
g_hash_table_destroy(bluetooth_networks);
+ bluetooth_networks = NULL;
g_hash_table_destroy(bluetooth_devices);
bluetooth_devices = NULL;
}