wifi: Set device powered from the interface create callback
authorSamuel Ortiz <sameo@linux.intel.com>
Tue, 29 Nov 2011 14:00:52 +0000 (15:00 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 29 Nov 2011 14:00:52 +0000 (15:00 +0100)
As interface_added can potentially show up before the interface creation
callback, the device powered flag can be set from the latter.

gsupplicant/gsupplicant.h
gsupplicant/supplicant.c
plugins/wifi.c

index c710679..8e96e02 100644 (file)
@@ -197,6 +197,7 @@ const void *g_supplicant_interface_get_wps_ssid(GSupplicantInterface *interface,
                                                        unsigned int *ssid_len);
 GSupplicantWpsState g_supplicant_interface_get_wps_state(GSupplicantInterface *interface);
 unsigned int g_supplicant_interface_get_mode(GSupplicantInterface *interface);
+dbus_bool_t g_supplicant_interface_get_ready(GSupplicantInterface *interface);
 unsigned int g_supplicant_interface_get_max_scan_ssids(
                                        GSupplicantInterface *interface);
 
index 1c360fb..b8e939d 100644 (file)
@@ -766,6 +766,14 @@ int g_supplicant_interface_enable_selected_network(GSupplicantInterface *interfa
                                set_network_enabled, NULL, &enable);
 }
 
+dbus_bool_t g_supplicant_interface_get_ready(GSupplicantInterface *interface)
+{
+       if (interface == NULL)
+               return FALSE;
+
+       return interface->ready;
+}
+
 GSupplicantInterface *g_supplicant_network_get_interface(
                                        GSupplicantNetwork *network)
 {
index 2070bb9..745c2cb 100644 (file)
@@ -213,6 +213,18 @@ static void interface_create_callback(int result,
 
        wifi->interface = interface;
        g_supplicant_interface_set_data(interface, wifi);
+
+       if (g_supplicant_interface_get_ready(interface) == FALSE)
+               return;
+
+       DBG("interface is ready wifi %p tethering %d", wifi, wifi->tethering);
+
+       if (wifi->device == NULL) {
+               connman_error("WiFi device not set");
+               return;
+       }
+
+       connman_device_set_powered(wifi->device, TRUE);
 }
 
 static void interface_remove_callback(int result,