int wlan_manager_start()
{
	__COMMON_FUNC_ENTER__;

	int ret = WLAN_MANAGER_ERR_NONE;
	char profile_name[NET_PROFILE_NAME_LEN_MAX+1] = "";

	ret = connman_request_register();
	if (ret != WLAN_MANAGER_ERR_NONE) {
		ERROR_LOG(UG_NAME_ERR, "[Failed] Register");
		return ret;
	}

	int state = wlan_manager_state_get(profile_name);
	switch (state) {
	case WLAN_MANAGER_OFF:
		INFO_LOG(UG_NAME_NORMAL, "WIFI_OFF\n");
		break;
	case WLAN_MANAGER_UNCONNECTED:
		INFO_LOG(UG_NAME_NORMAL, "WIFI_ON\n");

		ret = wlan_manager_request_scan();
		if (ret == WLAN_MANAGER_ERR_NONE) {
			INFO_LOG(UG_NAME_NORMAL, "Scan [OK]");
		} else {
			ERROR_LOG(UG_NAME_NORMAL, "Scan [FAIL]");
		}
		break;
	case WLAN_MANAGER_CONNECTED:
		INFO_LOG(UG_NAME_NORMAL, "WIFI_CONNECTED\n");

		if (!connman_profile_manager_connected_ssid_set((const char *)profile_name))
			ERROR_LOG(UG_NAME_NORMAL, "Fail to get profile_name of connected AP\n");

		ret = wlan_manager_request_scan();
		if (ret == WLAN_MANAGER_ERR_NONE) {
			INFO_LOG(UG_NAME_NORMAL, "Scan [OK]");
		} else {
			ERROR_LOG(UG_NAME_NORMAL, "Scan [FAIL]");
		}
		break;
	case WLAN_MANAGER_CONNECTING:
		INFO_LOG(UG_NAME_NORMAL, "WIFI_CONNECTING\n");

		ret = wlan_manager_request_scan();
		if (ret == WLAN_MANAGER_ERR_NONE) {
			INFO_LOG(UG_NAME_NORMAL, "Scan [OK]");
		} else {
			ERROR_LOG(UG_NAME_NORMAL, "Scan [FAIL]");
		}
		break;
	default:
		INFO_LOG(UG_NAME_NORMAL, "WIFI STATE ERROR\n");
	}
	
	return WLAN_MANAGER_ERR_NONE;
}
Eina_Bool viewer_manager_refresh(void)
{
	INFO_LOG(UG_NAME_SCAN, "UI update start");
	int profile_state;

	if (manager_object == NULL)
		return EINA_FALSE;

	/* Remove the list */
	viewer_list_item_clear();

	char profile_name[NET_PROFILE_NAME_LEN_MAX+1] = "";
	profile_state = wlan_manager_state_get(profile_name);
	if (WLAN_MANAGER_ERROR == profile_state || WLAN_MANAGER_OFF == profile_state) {
		/* Some body requested to refresh the list while the WLAN manager is OFF or Unable to get the profile state */
		INFO_LOG(UG_NAME_ERR, "Refresh requested in wrong state or Unable to get the state !!! ");

		Elm_Object_Item* target_item = item_get_for_profile_name(profile_name);
		viewer_manager_header_mode_set(HEADER_MODE_OFF);
		viewer_manager_item_radio_mode_set(NULL, target_item, VIEWER_ITEM_RADIO_MODE_OFF);
		return EINA_FALSE;
	}

	viewer_manager_update_list_all();

	if (WLAN_MANAGER_CONNECTING == profile_state) {
		INFO_LOG(UG_NAME_NORMAL, "Profile is connecting...");
		Elm_Object_Item* target_item = item_get_for_profile_name(profile_name);
		viewer_manager_header_mode_set(HEADER_MODE_CONNECTING);
		viewer_manager_item_radio_mode_set(NULL, target_item, VIEWER_ITEM_RADIO_MODE_CONNECTING);
	} else if (WLAN_MANAGER_CONNECTED == profile_state) {
		INFO_LOG(UG_NAME_NORMAL, "Profile is connected");
		Elm_Object_Item* target_item = item_get_for_profile_name(profile_name);
		target_item = viewer_manager_move_item_to_top(target_item);
		viewer_manager_header_mode_set(HEADER_MODE_CONNECTED);
		viewer_manager_item_radio_mode_set(NULL, target_item, VIEWER_ITEM_RADIO_MODE_CONNECTED);
	} else if (WLAN_MANAGER_DISCONNECTING == profile_state) {
		INFO_LOG(UG_NAME_NORMAL, "Profile is disconnecting");
		Elm_Object_Item* target_item = item_get_for_profile_name(profile_name);
		viewer_manager_header_mode_set(HEADER_MODE_DISCONNECTING);
		viewer_manager_item_radio_mode_set(NULL, target_item, VIEWER_ITEM_RADIO_MODE_DISCONNECTING);
	} else {
		INFO_LOG(UG_NAME_NORMAL, "Profile state = %d", profile_state);
		viewer_manager_header_mode_set(HEADER_MODE_ON);
	}

	INFO_LOG(UG_NAME_SCAN, "UI update finish");

	return EINA_TRUE;
}
示例#3
0
gboolean view_main_show(void *data)
{
	__COMMON_FUNC_ENTER__;

	int i;
	wifi_device_info_t *wifi_device = NULL;
	GList* list_of_device = NULL;

	int state = wlan_manager_state_get();
	if (WLAN_MANAGER_ERROR == state || WLAN_MANAGER_OFF == state) {
		INFO_LOG(SP_NAME_NORMAL, "Wi-Fi state is OFF");
		view_main_create_empty_layout();
		goto exit;
	} else if (WLAN_MANAGER_CONNECTED == state) {
		__COMMON_FUNC_EXIT__;
		return FALSE;
	}

	wifi_devpkr_enable_scan_btn();

	/* If previous profile list exists then just clear the genlist */
	if (profiles_list_size) {
		view_main_scan_ui_clear();
		view_main_add_group_title();
	} else {
		view_main_create_main_list();
	}

	view_main_state_set(ITEM_CONNECTION_MODE_OFF);

	profiles_list_size = 0;

	wifi_foreach_found_aps(view_main_wifi_found_ap_cb, &profiles_list_size);
	INFO_LOG(SP_NAME_NORMAL, "profiles list count [%d]\n", profiles_list_size);

	list_of_device = wifi_device_list;
	for (i = 0; i < profiles_list_size && list_of_device != NULL; i++) {
		wifi_device = (wifi_device_info_t*)list_of_device->data;

		view_main_wifi_insert_found_ap(wifi_device);

		list_of_device = list_of_device->next;
	}

	if (wifi_device_list != NULL) {
		g_list_free(wifi_device_list);
		wifi_device_list = NULL;
	}

	if (profiles_list_size <= 0)
		view_main_create_empty_layout();
	else
		evas_object_show(list);

exit:
	wifi_devpkr_redraw();

	evas_object_show(devpkr_app_state->popup);
	evas_object_show(devpkr_app_state->win_main);

	__COMMON_FUNC_EXIT__;
	return FALSE;
}