diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-07-21 11:25:38 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-07-21 11:25:38 +0200 |
commit | fe4e8ee4be3e071561e8df12dc7e36311ed95c71 (patch) | |
tree | e1ea701333d4ec9c587f600083431165f93154f8 /plugins | |
parent | 066ce14426bb50ec33bbc74688381ce93d8dd797 (diff) | |
download | connman-fe4e8ee4be3e071561e8df12dc7e36311ed95c71.tar.gz connman-fe4e8ee4be3e071561e8df12dc7e36311ed95c71.tar.bz2 connman-fe4e8ee4be3e071561e8df12dc7e36311ed95c71.zip |
Fix the problems with scan result from unknown triggers
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/supplicant.c | 69 |
1 files changed, 32 insertions, 37 deletions
diff --git a/plugins/supplicant.c b/plugins/supplicant.c index a94893ef..9dbe2dd7 100644 --- a/plugins/supplicant.c +++ b/plugins/supplicant.c @@ -182,7 +182,7 @@ struct supplicant_task { char *netpath; gboolean created; enum supplicant_state state; - gboolean noscan; + gboolean scanning; GSList *scan_results; struct iw_range *range; gboolean disconnecting; @@ -1373,8 +1373,10 @@ static void get_properties(struct supplicant_task *task) return; noscan: - if (task->noscan == FALSE) + if (task->scanning == TRUE) { connman_device_set_scanning(task->device, FALSE); + task->scanning = FALSE; + } } static void scan_results_reply(DBusPendingCall *call, void *user_data) @@ -1431,8 +1433,10 @@ done: dbus_message_unref(reply); noscan: - if (task->noscan == FALSE) + if (task->scanning == TRUE) { connman_device_set_scanning(task->device, FALSE); + task->scanning = FALSE; + } } static void scan_results_available(struct supplicant_task *task) @@ -1456,14 +1460,14 @@ static void scan_results_available(struct supplicant_task *task) goto done; } - if (task->noscan == FALSE) - connman_device_set_scanning(task->device, TRUE); - if (call == NULL) { connman_error("D-Bus connection not available"); goto done; } + if (task->scanning == TRUE) + connman_device_set_scanning(task->device, TRUE); + dbus_pending_call_set_notify(call, scan_results_reply, task, NULL); done: @@ -1497,6 +1501,7 @@ static int task_connect(struct supplicant_task *task) const char *address, *security, *passphrase; const void *ssid; unsigned int ssid_len; + int err; address = connman_network_get_string(task->network, "Address"); security = connman_network_get_string(task->network, "WiFi.Security"); @@ -1520,7 +1525,9 @@ static int task_connect(struct supplicant_task *task) set_network(task, ssid, ssid_len, address, security, passphrase); - enable_network(task); + err = enable_network(task); + if (err < 0) + return err; return -EINPROGRESS; } @@ -1552,31 +1559,13 @@ static void state_change(struct supplicant_task *task, DBusMessage *msg) if (state == WPA_INVALID) return; - task->state = state; - - switch (task->state) { - case WPA_SCANNING: - task->noscan = TRUE; - connman_device_set_scanning(task->device, TRUE); - break; - case WPA_ASSOCIATING: - case WPA_ASSOCIATED: - case WPA_4WAY_HANDSHAKE: - case WPA_GROUP_HANDSHAKE: - task->noscan = TRUE; - break; - case WPA_COMPLETED: - case WPA_DISCONNECTED: - task->noscan = FALSE; - break; - case WPA_INACTIVE: - task->noscan = FALSE; + if (task->scanning == TRUE && state != WPA_SCANNING) { connman_device_set_scanning(task->device, FALSE); - break; - case WPA_INVALID: - break; + task->scanning = FALSE; } + task->state = state; + if (task->network == NULL) return; @@ -1588,14 +1577,15 @@ static void state_change(struct supplicant_task *task, DBusMessage *msg) /* carrier on */ connman_network_set_connected(task->network, TRUE); - connman_device_set_scanning(task->device, FALSE); break; case WPA_DISCONNECTED: disable_network(task); + /* carrier off */ + connman_network_set_connected(task->network, FALSE); + if (task->disconnecting == TRUE) { - connman_network_set_connected(task->network, FALSE); connman_network_unref(task->network); task->disconnecting = FALSE; @@ -1604,10 +1594,6 @@ static void state_change(struct supplicant_task *task, DBusMessage *msg) task->pending_network = NULL; task_connect(task); } - } else { - /* carrier off */ - connman_network_set_connected(task->network, FALSE); - connman_device_set_scanning(task->device, FALSE); } break; @@ -1618,8 +1604,9 @@ static void state_change(struct supplicant_task *task, DBusMessage *msg) case WPA_INACTIVE: remove_network(task); + connman_network_set_connected(task->network, FALSE); + if (task->disconnecting == TRUE) { - connman_network_set_connected(task->network, FALSE); connman_network_unref(task->network); task->disconnecting = FALSE; @@ -1701,7 +1688,7 @@ int supplicant_start(struct connman_device *device) task->device = connman_device_ref(device); task->created = FALSE; - task->noscan = FALSE; + task->scanning = FALSE; task->state = WPA_INVALID; task->disconnecting = FALSE; task->pending_network = NULL; @@ -1764,7 +1751,15 @@ int supplicant_scan(struct connman_device *device) break; } + task->scanning = TRUE; + err = initiate_scan(task); + if (err < 0) { + task->scanning = FALSE; + return err; + } + + connman_device_set_scanning(task->device, TRUE); return 0; } |