From 672a2f2a0e3022988764a89c4a626cfd7c39ecda Mon Sep 17 00:00:00 2001 From: Patrik Flykt Date: Mon, 28 Jan 2013 17:44:40 +0200 Subject: bluetooth_legacy: Check network in probe function The network probed can belong to the new Bluez 5 bluetooth plugin or to this plugin. Check if this plugin created the network and proceed accordingly. --- plugins/bluetooth_legacy.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/bluetooth_legacy.c b/plugins/bluetooth_legacy.c index f03f2a00..62002eff 100644 --- a/plugins/bluetooth_legacy.c +++ b/plugins/bluetooth_legacy.c @@ -73,9 +73,22 @@ static GHashTable *pending_networks = NULL; static int pan_probe(struct connman_network *network) { - DBG("network %p", network); + GHashTableIter iter; + gpointer key, val; - return 0; + g_hash_table_iter_init(&iter, bluetooth_networks); + while (g_hash_table_iter_next(&iter, &key, &val) == TRUE) { + struct connman_network *known = val; + + if (network != known) + continue; + + DBG("network %p", network); + + return 0; + } + + return -EOPNOTSUPP; } static void pan_remove(struct connman_network *network) @@ -266,6 +279,7 @@ static int pan_disconnect(struct connman_network *network) static struct connman_network_driver pan_driver = { .name = "bluetooth_legacy-pan", .type = CONNMAN_NETWORK_TYPE_BLUETOOTH_PAN, + .priority = CONNMAN_NETWORK_PRIORITY_LOW, .probe = pan_probe, .remove = pan_remove, .connect = pan_connect, @@ -443,12 +457,12 @@ static void network_properties_reply(DBusPendingCall *call, void *user_data) connman_network_set_name(network, name); + g_hash_table_replace(bluetooth_networks, g_strdup(path), network); + connman_device_add_network(device, network); connman_network_set_group(network, ident); - g_hash_table_replace(bluetooth_networks, g_strdup(path), network); - done: dbus_message_unref(reply); -- cgit v1.2.3