doc: Add a new type and argument to agent RequestInput method call
[framework/connectivity/connman.git] / plugins / wifi.c
index 526bb9e..3cd2be2 100644 (file)
@@ -238,6 +238,10 @@ static void wifi_remove(struct connman_device *device)
 
        stop_autoscan(device);
 
+       /* In case of a user scan, device is still referenced */
+       if (connman_device_get_scanning(device) == TRUE)
+               connman_device_unref(wifi->device);
+
        iface_list = g_list_remove(iface_list, wifi);
 
        remove_networks(device, wifi);
@@ -401,6 +405,9 @@ static int throw_wifi_scan(struct connman_device *device,
        if (wifi->tethering == TRUE)
                return 0;
 
+       if (connman_device_get_scanning(device) == TRUE)
+               return -EALREADY;
+
        connman_device_ref(device);
 
        ret = g_supplicant_interface_scan(wifi->interface, NULL,
@@ -818,6 +825,11 @@ static int wifi_scan_fast(struct connman_device *device)
        if (wifi->tethering == TRUE)
                return 0;
 
+       stop_autoscan(device);
+
+       if (connman_device_get_scanning(device) == TRUE)
+               return -EALREADY;
+
        driver_max_ssids = g_supplicant_interface_get_max_scan_ssids(
                                                        wifi->interface);
        DBG("max ssids %d", driver_max_ssids);
@@ -834,8 +846,6 @@ static int wifi_scan_fast(struct connman_device *device)
                return wifi_scan(device);
        }
 
-       stop_autoscan(device);
-
        connman_device_ref(device);
        ret = g_supplicant_interface_scan(wifi->interface, scan_params,
                                                scan_callback, device);
@@ -871,6 +881,11 @@ static int wifi_scan_hidden(struct connman_device *device,
        if (ssid == NULL || ssid_len == 0 || ssid_len > 32)
                return -EINVAL;
 
+       stop_autoscan(device);
+
+       if (connman_device_get_scanning(device) == TRUE)
+               return -EALREADY;
+
        scan_params = g_try_malloc0(sizeof(GSupplicantScanParams));
        if (scan_params == NULL)
                return -ENOMEM;
@@ -898,8 +913,6 @@ static int wifi_scan_hidden(struct connman_device *device,
        hidden->passphrase = g_strdup(passphrase);
        wifi->hidden = hidden;
 
-       stop_autoscan(device);
-
        connman_device_ref(device);
        ret = g_supplicant_interface_scan(wifi->interface, scan_params,
                        scan_callback, device);