2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "wifi-ui-list-callbacks.h"
21 #include "wlan_manager.h"
22 #include "view_detail.h"
23 #include "viewer_list.h"
24 #include "view_ime_password.h"
29 void radio_button_cb(void *data, Evas_Object *obj, void *event_info)
31 __COMMON_FUNC_ENTER__;
33 int ret = WLAN_MANAGER_ERR_UNKNOWN;
35 ERROR_LOG(UG_NAME_NORMAL, "Error!!! Invalid argument device_info");
36 goto radio_button_cb_process_end;
39 //selected UI and it`s data
40 Elm_Object_Item *it = (Elm_Object_Item *)event_info;
41 wifi_device_info_t *device_info = (wifi_device_info_t *)data;
43 if (device_info->ssid == NULL) {
44 ERROR_LOG(UG_NAME_NORMAL, "Error!!! Invalid argument device_info ssid");
45 goto radio_button_cb_process_end;
48 viewer_manager_set_enabled_list_update(EINA_FALSE);
49 viewer_manager_current_selected_item_set(it);
51 genlist_data* gdata = (genlist_data*) viewer_list_item_data_get((Elm_Object_Item*)it, "data");
53 ERROR_LOG(UG_NAME_NORMAL, "Error!!! list item data null");
54 goto radio_button_cb_process_end;
57 int item_state = gdata->radio_mode;
59 INFO_LOG(UG_NAME_NORMAL, "ssid --- %s", device_info->ssid);
60 INFO_LOG(UG_NAME_NORMAL, "current item_state state is --- %d\n", item_state);
61 INFO_LOG(UG_NAME_NORMAL, "selected item_state %d", item_state);
64 case VIEWER_ITEM_RADIO_MODE_NULL: //this is OFF too. of course, NULL should be un-state
65 case VIEWER_ITEM_RADIO_MODE_OFF:
67 case VIEWER_ITEM_RADIO_MODE_CONNECTED:
68 INFO_LOG(UG_NAME_NORMAL, "want to disconnect for connected item");
69 viewer_manager_item_radio_mode_set(NULL, it, VIEWER_ITEM_RADIO_MODE_DISCONNECTING);
70 ret = wlan_manager_request_disconnection(device_info);
71 if(ret == WLAN_MANAGER_ERR_NONE){
72 viewer_manager_item_radio_mode_set(NULL, it, VIEWER_ITEM_RADIO_MODE_DISCONNECTING);
73 viewer_manager_header_mode_set(HEADER_MODE_DISCONNECTING);
74 viewer_manager_item_radio_mode_set(NULL, it, VIEWER_ITEM_RADIO_MODE_DISCONNECTING);
77 viewer_manager_item_radio_mode_set(NULL, it , VIEWER_ITEM_RADIO_MODE_OFF);
80 goto radio_button_cb_process_end;
82 case VIEWER_ITEM_RADIO_MODE_CONNECTING:
83 INFO_LOG(UG_NAME_NORMAL, "want to cancel connecting for connected item");
85 ret = wlan_manager_request_cancel_connecting(device_info->profile_name);
86 if(ret == WLAN_MANAGER_ERR_NONE){
87 viewer_manager_item_radio_mode_set(NULL, it, VIEWER_ITEM_RADIO_MODE_CANCEL_CONNECTING);
88 viewer_manager_header_mode_set(HEADER_MODE_CANCEL_CONNECTING);
89 viewer_manager_item_radio_mode_set(NULL, it, VIEWER_ITEM_RADIO_MODE_CANCEL_CONNECTING);
91 goto radio_button_cb_process_end;
94 ret = WLAN_MANAGER_ERR_UNKNOWN;
95 goto radio_button_cb_process_end;
98 int current_state = -1;
99 current_state = viewer_manager_header_mode_get();
101 INFO_LOG(UG_NAME_NORMAL, "Clicked AP`s information\n");
102 INFO_LOG(UG_NAME_NORMAL, "header mode [%d]", current_state);
104 switch (current_state) {
105 case HEADER_MODE_OFF:
106 INFO_LOG(UG_NAME_NORMAL, "you can not connect when header off");
108 case HEADER_MODE_CONNECTED:
109 INFO_LOG(UG_NAME_NORMAL, "header mode connected. disconnect and connect needed");
111 viewer_manager_item_radio_mode_set(NULL, it, VIEWER_ITEM_RADIO_MODE_CONNECTING);
113 ret = wlan_manager_request_connection(device_info);
114 if (ret == WLAN_MANAGER_ERR_NONE) {
115 Elm_Object_Item* target_item = viewer_manager_current_selected_item_get();
116 viewer_manager_item_radio_mode_set(NULL, target_item, VIEWER_ITEM_RADIO_MODE_CONNECTING);
117 viewer_manager_header_mode_set(HEADER_MODE_CONNECTING);
118 viewer_manager_item_radio_mode_set(NULL, target_item, VIEWER_ITEM_RADIO_MODE_CONNECTING);
120 viewer_manager_item_radio_mode_set(NULL, it, VIEWER_ITEM_RADIO_MODE_OFF);
124 case HEADER_MODE_SEARCHING:
125 case HEADER_MODE_ACTIVATING:
126 case HEADER_MODE_CONNECTING:
127 case HEADER_MODE_DISCONNECTING:
128 case HEADER_MODE_DEACTIVATING:
129 viewer_manager_set_enabled_list_update(EINA_TRUE);
130 viewer_manager_current_selected_item_set(NULL);
131 INFO_LOG(UG_NAME_NORMAL, "Disable input");
135 INFO_LOG(UG_NAME_NORMAL, "default");
139 radio_button_cb_process_end:
142 case WLAN_MANAGER_ERR_NONE:
143 INFO_LOG(UG_NAME_NORMAL, "ERROR_NONE");
145 case WLAN_MANAGER_ERR_CONNECT_PASSWORD_NEEDED:
146 view_ime_password(device_info);
148 case WLAN_MANAGER_ERR_CONNECT_EAP_SEC_TYPE:
149 view_eap(device_info);
151 case WLAN_MANAGER_ERR_NOSERVICE:
152 viewer_manager_set_enabled_list_update(EINA_TRUE);
153 wlan_manager_scanned_profile_refresh(TRUE);
156 viewer_manager_set_enabled_list_update(EINA_TRUE);
157 winset_popup_mode_set(NULL, POPUP_MODE_CONNECTING_FAILED, POPUP_OPTION_CONNECTING_FAILED_INVALID_OPERATION);
158 ERROR_LOG(UG_NAME_NORMAL, "errro code [%d]", ret);
162 __COMMON_FUNC_EXIT__;
165 void list_select_cb(void *data, Evas_Object *obj, void *event_info)
167 __COMMON_FUNC_ENTER__;
169 INFO_LOG(UG_NAME_NORMAL,"=================\n");
170 INFO_LOG(UG_NAME_NORMAL," %s %d\n", __func__ ,__LINE__);
171 INFO_LOG(UG_NAME_NORMAL,"=================\n");
174 __COMMON_FUNC_EXIT__;
178 wifi_device_info_t *device_info = (wifi_device_info_t *)data;
180 DEBUG_LOG(UG_NAME_NORMAL, "ssid [%s]", device_info->ssid);
182 viewer_manager_current_selected_item_set((Elm_Object_Item *)obj);
184 view_detail(device_info);
186 __COMMON_FUNC_EXIT__;