*
* Copyright 2012 Samsung Electronics Co., Ltd
-* Licensed under the Flora License, Version 1.0 (the "License");
+* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
void _update_tethering_enabling_item(mh_appdata_t *ad, tethering_type_e type, mh_state_e state)
{
- switch(type) {
+ switch (type) {
case TETHERING_TYPE_WIFI:
_update_wifi_item(ad, MH_STATE_NONE);
ad->is_wifi_teth_enabling = false;
break;
-
case TETHERING_TYPE_BT:
_update_bt_item(ad, MH_STATE_NONE);
ad->is_bt_teth_enabling = false;
break;
-
case TETHERING_TYPE_USB:
_update_usb_item(ad, MH_STATE_NONE);
ad->is_usb_teth_enabling = false;
break;
-
- default :
+ default:
ERR("invalid type \n");
break;
}
void _update_tethering_item(mh_appdata_t * ad, mh_state_e state)
{
ERR("type : %d state : %d\n", ad->type, state);
- switch(ad->type) {
- case TETHERING_TYPE_WIFI:
- _update_wifi_item(ad, state);
- break;
- case TETHERING_TYPE_BT:
- _update_bt_item(ad, state);
- break;
- case TETHERING_TYPE_USB:
- _update_usb_item(ad, state);
- break;
- default:
- break;
+ switch (ad->type) {
+ case TETHERING_TYPE_WIFI:
+ _update_wifi_item(ad, state);
+ break;
+ case TETHERING_TYPE_BT:
+ _update_bt_item(ad, state);
+ break;
+ case TETHERING_TYPE_USB:
+ _update_usb_item(ad, state);
+ break;
+ default:
+ break;
}
}
DBG("Re-Check cellular state (%d)\n", recheck_count);
- if(cellular_state == CONNECTION_CELLULAR_STATE_FLIGHT_MODE) {
+ if (cellular_state == CONNECTION_CELLULAR_STATE_FLIGHT_MODE) {
_update_tethering_item(ad, MH_STATE_NONE);
recheck_count = 0;
return FALSE;
recheck_count = 0;
return FALSE;
}
- _send_signal_qp(QP_SIGNAL_PROGRESS_ON);
} else if (ad->type == TETHERING_TYPE_BT && _create_bt_tethering_on_popup(ad) < 0) {
ERR("_create_bt_tethering_on_popup fail\n");
_update_tethering_item(ad, MH_STATE_NONE);
return FALSE;
}
} else {
- if(++recheck_count >= PS_RECHECK_COUNT_MAX) {
+ if (++recheck_count >= PS_RECHECK_COUNT_MAX) {
DBG("Cellular network is not connected : %d\n", cellular_state);
_update_tethering_item(ad, MH_STATE_NONE);
_prepare_popup(MH_POPUP_NETWORK_OUT_OF_RANGE, STR_NO_DATA_SERVICE);
ret = connection_get_wifi_state(ad->conn_handle, &wifi_state);
if (ret != CONNECTION_ERROR_NONE) {
- ERR("connection_get_wifi_state() is failed : %d\n");
+ ERR("connection_get_wifi_state() is failed : %d\n", ret);
return false;
}
ret = connection_get_ethernet_state(ad->conn_handle, ðernet_state);
if (ret != CONNECTION_ERROR_NONE) {
- ERR("connection_get_ethernet_state() is failed : %d\n");
+ ERR("connection_get_ethernet_state() is failed : %d\n", ret);
return false;
}
/* Check SIM state */
if (_get_sim_state() != VCONFKEY_TELEPHONY_SIM_INSERTED) {
- if(ad->type == TETHERING_TYPE_WIFI)
+ if (ad->type == TETHERING_TYPE_WIFI)
_prepare_popup(MH_POPUP_NO_SIM, STR_INSERT_SIM_TO_USE_TETH);
else
_prepare_popup(MH_POPUP_NO_SIM, STR_CONN_MOBILE_DATA_TO_USE_TETH);
} else {
if (vconf_get_bool(VCONFKEY_3G_ENABLE , &dnet_state) < 0) {
ERR("vconf_get_bool is failed\n");
- } else if(dnet_state == 0) {
+ } else if (dnet_state == 0) {
DBG("Data Network is not connected");
_prepare_popup(MH_POPUP_MOBILE_DATA_OFF, STR_NO_NET_CONN_MSG);
_create_popup(ad);
}
if (cellular_state != CONNECTION_CELLULAR_STATE_CONNECTED &&
cellular_state != CONNECTION_CELLULAR_STATE_AVAILABLE) {
- if(ad->ps_recheck_timer_id > 0) {
+ if (ad->ps_recheck_timer_id > 0) {
g_source_remove(ad->ps_recheck_timer_id);
ad->ps_recheck_timer_id = 0;
- if (ad->is_wifi_teth_enabling == true && ad->type != TETHERING_TYPE_WIFI) {
- _update_tethering_enabling_item(ad, TETHERING_TYPE_WIFI, MH_STATE_NONE);
- }
- if (ad->is_bt_teth_enabling == true && ad->type != TETHERING_TYPE_BT) {
- _update_tethering_enabling_item(ad, TETHERING_TYPE_BT, MH_STATE_NONE);
- }
- if (ad->is_usb_teth_enabling == true && ad->type != TETHERING_TYPE_USB) {
- _update_tethering_enabling_item(ad, TETHERING_TYPE_USB, MH_STATE_NONE);
- }
+ if (ad->is_wifi_teth_enabling == true
+ && ad->type != TETHERING_TYPE_WIFI)
+ _update_tethering_enabling_item(ad, TETHERING_TYPE_WIFI,
+ MH_STATE_NONE);
+ if (ad->is_bt_teth_enabling == true
+ && ad->type != TETHERING_TYPE_BT)
+ _update_tethering_enabling_item(ad, TETHERING_TYPE_BT,
+ MH_STATE_NONE);
+ if (ad->is_usb_teth_enabling == true
+ && ad->type != TETHERING_TYPE_USB)
+ _update_tethering_enabling_item(ad, TETHERING_TYPE_USB,
+ MH_STATE_NONE);
}
- ad->ps_recheck_timer_id = g_timeout_add(PS_RECHECK_INTERVAL, _ps_recheck_timeout_cb, (void*)ad);
+ ad->ps_recheck_timer_id = g_timeout_add(PS_RECHECK_INTERVAL,
+ _ps_recheck_timeout_cb, (void*)ad);
return 0;
}
}
- DBG("Cellular network is connected\n");
DBG("-\n");
return 1;
}
bool wifi_state = false;
int value = 0;
- wifi_is_activated(&wifi_state);
+ wifi_manager_is_activated(ad->wifi_handle, &wifi_state);
_set_vconf_prev_wifi_state(wifi_state);
value = _get_checkbox_status(TETHERING_TYPE_WIFI);
if (0 == value) {
- if (wifi_state == true || _is_wifi_direct_on() == true) {
+ if (wifi_state == true || _is_wifi_direct_on() == true)
fmt = STR_TETH_ON_DESC_1;
- } else {
+ else
fmt = STR_TETH_ON_DESC_2;
- }
+
str = g_malloc0(MH_LABEL_LENGTH_MAX);
if (str == NULL) {
ERR("memory allocation is failed\n");
break;
case TETHERING_DISABLED_BY_OTHERS:
- if (ad->main.wifi_item && _get_vconf_prev_wifi_state() == true) {
+ if (ad->main.wifi_item && _get_vconf_prev_wifi_state() == true)
elm_object_item_disabled_set(ad->main.wifi_item, EINA_TRUE);
- }
break;
case TETHERING_DISABLED_BY_LOW_BATTERY:
return;
}
-/* Wi-Fi callbacks */
-static void __wifi_activated_cb(wifi_error_e result, void *user_data)
-{
- DBG("+\n");
-
- return;
-}
-
/* Tethering callbacks */
void _enabled_cb(tethering_error_e result, tethering_type_e type, bool is_requested, void *user_data)
{
ad->popup = NULL;
}
_update_main_view(ad, type);
- if (type == TETHERING_TYPE_RESERVED) {
- DBG("MobileAP is turned on\n");
- _prepare_popup(MH_POPUP_WIFI_AP_OFF, STR_WIFI_AP_CONTROLLED_ANOTHER_APP);
- _create_popup(ad);
- }
return;
}
- if (result != TETHERING_ERROR_NONE) {
- }
_update_main_view(ad, type);
return;
return;
}
- if (ad->main.wifi_item && type == TETHERING_TYPE_WIFI && _get_vconf_prev_wifi_state() == true) {
+ if (ad->main.wifi_item && type == TETHERING_TYPE_WIFI && _get_vconf_prev_wifi_state() == true)
elm_object_item_disabled_set(ad->main.wifi_item, EINA_TRUE);
- }
_update_main_view(ad, type);
_append_list_client_handle(ad, client);
#ifdef TETHERING_DATA_USAGE_SUPPORT
- if (ad->is_foreground && _get_list_clients_count(ad) == 1) {
+ if (ad->is_foreground && _get_list_clients_count(ad) == 1)
_start_update_data_packet_usage(ad);
- }
#endif
} else {
tethering_client_get_mac_address(client, &mac_addr);
return;
}
-void _wifi_state_changed_cb(wifi_device_state_e state, void *user_data)
+void _wifi_state_changed_cb(wifi_manager_device_state_e state, void *user_data)
{
if (user_data == NULL) {
ERR("user_data is NULL\n");
DBG("+\n");
- mh_appdata_t *ad= (mh_appdata_t *)user_data;
+ mh_appdata_t *ad = (mh_appdata_t *)user_data;
char *str = NULL;
char *fmt = NULL;
- if (state == WIFI_DEVICE_STATE_ACTIVATED) {
+ if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED) {
if (ad->main.wifi_item && elm_object_item_disabled_get(ad->main.wifi_item))
elm_object_item_disabled_set(ad->main.wifi_item, EINA_FALSE);
_set_vconf_prev_wifi_state(false);
- } else if (state == WIFI_DEVICE_STATE_DEACTIVATED){
+ } else if (state == WIFI_MANAGER_DEVICE_STATE_DEACTIVATED) {
_set_vconf_prev_wifi_state(true);
}
ad->popup_checkbox = NULL;
evas_object_del(ad->popup);
ad->popup = NULL;
- if (state == WIFI_DEVICE_STATE_ACTIVATED) {
+ if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED)
fmt = STR_TETH_ON_DESC_1;
- } else {
+ else
fmt = STR_TETH_ON_DESC_2;
- }
+
str = g_malloc0(MH_LABEL_LENGTH_MAX);
if (str == NULL) {
ERR("memory allocation is failed\n");
return;
}
- if (!g_strcmp0(passphrase, ad->setup.wifi_passphrase)) {
+ if (!g_strcmp0(passphrase, ad->setup.wifi_passphrase))
goto DONE;
- }
g_strlcpy(ad->setup.wifi_passphrase, passphrase,
sizeof(ad->setup.wifi_passphrase));
_prepare_popup(MH_POPUP_WIFI_OFF, STR_CLOSE_INTERNET_Q);
_create_popup(ad);
} else {
+#ifndef TIZEN_FEATURE_EMULATOR
ret = tethering_disable(ad->handle, TETHERING_TYPE_WIFI);
if (ret != TETHERING_ERROR_NONE) {
ERR("wifi tethering off is failed : %d\n", ret);
return -1;
}
- _send_signal_qp(QP_SIGNAL_PROGRESS_OFF);
+#endif
}
return 0;
}
/* Turn off Bluetooth tethering */
if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_BT) {
+#ifndef TIZEN_FEATURE_EMULATOR
ret = tethering_disable(ad->handle, TETHERING_TYPE_BT);
if (ret) {
ERR("Error disable bt tethering [%d]\n", ret);
return -1;
}
+#endif
return 0;
}
/* Turn off USB tethering */
if (ad->main.hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_USB) {
+#ifndef TIZEN_FEATURE_EMULATOR
ret = tethering_disable(ad->handle, TETHERING_TYPE_USB);
if (ret) {
ERR("Error disable usb tethering : %d\n", ret);
return -1;
}
+#endif
return 0;
}
return 0;
}
-int _turn_on_wifi(void)
-{
- int ret;
-
- ret = wifi_activate(__wifi_activated_cb, NULL);
- if (ret != WIFI_ERROR_NONE) {
- ERR("wifi_activate() is failed : %d\n", ret);
- return -1;
- }
-
- return 0;
-}
-
bool _is_wifi_direct_on(void)
{
int wifi_direct_state = 0;