ENUMS
=============================================================================*/
-/**
-* @enum net_wifi_state_t
-* This enum indicates wifi state
-*/
-typedef enum {
- /** Unknown state */
- WIFI_UNKNOWN = 0x00,
- /** Wi-Fi is Off */
- WIFI_OFF,
- /** Wi-Fi is On(idle/failure) */
- WIFI_ON,
- /** Trying to connect(association/configuration) */
- WIFI_CONNECTING,
- /** Wi-Fi is connected to an AP(ready/online) */
- WIFI_CONNECTED,
- /** Trying to disconnect(connected,
- * but disconnecting process is on going)
- */
- WIFI_DISCONNECTING,
-} net_wifi_state_t;
-
/**
*@enum net_wifi_background_scan_mode_t
* This enum indicates background scanning mode.
#include <vconf/vconf.h>
#include <winet-wifi.h>
#include <connman-lib.h>
+#include <connman-technology.h>
#include "net_connection_private.h"
static GSList *prof_handle_list = NULL;
return false;
}
-
bool _connection_libnet_get_wifi_state(connection_wifi_state_e *state)
{
- net_wifi_state_t wlan_state = WIFI_OFF;
- /*
- net_profile_name_t profile_name;
- TODO:
- if (net_get_wifi_state(&wlan_state, &profile_name) != NET_ERR_NONE) {
- CONNECTION_LOG(CONNECTION_ERROR, "Error!! net_get_wifi_state() failed.\n");
- return false;
- }
- */
- switch (wlan_state) {
- case WIFI_OFF:
- *state = CONNECTION_WIFI_STATE_DEACTIVATED;
- break;
- case WIFI_ON:
- case WIFI_CONNECTING:
- *state = CONNECTION_WIFI_STATE_DISCONNECTED;
- break;
- case WIFI_CONNECTED:
- case WIFI_DISCONNECTING:
- *state = CONNECTION_WIFI_STATE_CONNECTED;
- break;
- default :
- CONNECTION_LOG(CONNECTION_ERROR, "Error!! Unknown state\n");
+ struct connman_technology *technology;
+ bool powered;
+ bool tethering;
+ bool connected;
+
+ technology = connman_get_technology(TECH_TYPE_WIFI);
+ if (technology == NULL)
return false;
+
+ *state = CONNECTION_WIFI_STATE_DEACTIVATED;
+ powered = connman_get_technology_powered(technology);
+ tethering = connman_get_technology_tethering(technology);
+
+ if (powered) {
+ if (!tethering) {
+ connected = connman_get_technology_connected(
+ technology);
+ if (connected)
+ *state = CONNECTION_WIFI_STATE_CONNECTED;
+ else
+ *state = CONNECTION_WIFI_STATE_DISCONNECTED;
+ }
}
return true;