4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.tizenopensource.org/license
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include <ui-gadget-module.h>
25 #include <tethering.h>
26 #include <wifi-direct.h>
28 #define PACKAGE "ug-setting-wifidirect-efl"
29 #define LOCALEDIR "/usr/ug/res/locale"
30 #define VCONF_WFD_APNAME "db/setting/device_name"
36 #define LOG_TAG "UG_WIFI_DIRECT"
38 #define WDUG_LOGV(format, args...) LOGV(format, ##args)
39 #define WDUG_LOGD(format, args...) LOGD(format, ##args)
40 #define WDUG_LOGI(format, args...) LOGI(format, ##args)
41 #define WDUG_LOGW(format, args...) LOGW(format, ##args)
42 #define WDUG_LOGE(format, args...) LOGE(format, ##args)
43 #define WDUG_LOGF(format, args...) LOGF(format, ##args)
45 #define __WDUG_LOG_FUNC_ENTER__ LOGV("Enter")
46 #define __WDUG_LOG_FUNC_EXIT__ LOGV("Quit")
48 #define assertm_if(expr, fmt, args...) do { \
50 WDUG_LOGF(" ##(%s) -> assert!!## "fmt, #expr, ##args); \
55 #else /** _DLOG_UTIL */
57 #define WDUG_LOGV(format, args...) \
58 printf("[V/UG_WIFI_DIRECT] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args)
59 #define WDUG_LOGD(format, args...) \
60 printf("[D/UG_WIFI_DIRECT] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args)
61 #define WDUG_LOGI(format, args...) \
62 printf("[I/UG_WIFI_DIRECT] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args)
63 #define WDUG_LOGW(format, args...) \
64 printf("[W/UG_WIFI_DIRECT] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args)
65 #define WDUG_LOGE(format, args...) \
66 printf("[E/UG_WIFI_DIRECT] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args)
67 #define WDUG_LOGF(format, args...) \
68 printf("[F/UG_WIFI_DIRECT] %s: %s()(%4d)> "format, __FILE__, __FUNCTION__, __LINE__, ##args)
70 #define __WDUG_LOG_FUNC_ENTER__ \
71 printf("[V/UG_WIFI_DIRECT] %s: %s()(%4d)> Enter", __FILE__, __FUNCTION__, __LINE__)
72 #define __WDUG_LOG_FUNC_EXIT__ \
73 printf("[V/UG_WIFI_DIRECT] %s: %s()(%4d)> Exit", __FILE__, __FUNCTION__, __LINE__)
75 #endif /** _DLOG_UTIL */
77 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
78 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
80 #define AP_NAME_LENGTH_MAX 32
81 #define AP_PASSWORD_LENGTH_MAX 64
82 #define AP_PASSWORD_LENGTH_MIN 8
83 #define AP_REJECT_CHAR_LIST "=,"
85 #define DEFAULT_DEV_NAME "Tizen"
87 #define SSID_LENGTH 32
88 #define MAX_PEER_NUM 10
89 #define MAX_POPUP_PEER_NUM 7
90 #define MAX_POPUP_TEXT_SIZE 256
91 #define MAX_DISPLAY_TIME_OUT 30
92 #define MAX_NO_ACTION_TIME_OUT 300 /*5min*/
93 #define MAX_SCAN_TIME_OUT 30
95 #define _(s) dgettext(PACKAGE, s)
96 #define N_(s) dgettext_noop(s)
97 #define S_(s) dgettext("sys_string", s)
100 /* To-Do : Text should be translated. */
101 #define IDS_WFD_POP_SCAN_AGAIN "Current connection will be disconnected so that scanning can start.Continue?"
102 #define IDS_WFD_POP_WARN_BUSY_DEVICE "Unavailable device. Device is connected to another device."
103 #define IDS_WFD_POP_AUTOMATIC_TURN_OFF "There has been no activity for 5 minutes since Wi-Fi Direct was enabled. To extend battery life, Wi-Fi Direct has been disabled."
104 #define IDS_WFD_BODY_FAILED_DEVICES "Failed Devices"
105 #define IDS_WFD_TITLE_ABOUT_WIFI_DIRECT "About Wi-Fi Direct"
109 #define WFD_GLOBALIZATION_STR_LENGTH 256
112 WFD_MULTI_CONNECT_MODE_NONE,
113 WFD_MULTI_CONNECT_MODE_IN_PROGRESS,
114 WFD_MULTI_CONNECT_MODE_COMPLETED,
115 } wfd_multi_connect_mode_e;
118 PEER_CONN_STATUS_DISCONNECTED,
119 PEER_CONN_STATUS_DISCONNECTING,
120 PEER_CONN_STATUS_CONNECTING = PEER_CONN_STATUS_DISCONNECTING,
121 PEER_CONN_STATUS_CONNECTED,
122 PEER_CONN_STATUS_FAILED_TO_CONNECT,
123 PEER_CONN_STATUS_WAIT_FOR_CONNECT,
128 char ssid[SSID_LENGTH];
129 unsigned int category;
130 char mac_addr[MAC_LENGTH];
131 char if_addr[MAC_LENGTH];
132 conn_status_e conn_status;
133 bool is_group_owner; /** Is an active P2P Group Owner */
134 bool is_persistent_group_owner; /** Is a stored Persistent GO */
135 bool is_connected; /** Is peer connected*/
136 Elm_Object_Item *gl_item;
142 } wfd_multi_sel_data_s;
150 Evas_Object *naviframe;
151 Evas_Object *genlist;
152 Evas_Object *multiconn_view_genlist;
154 Evas_Object *act_popup;
155 Evas_Object *warn_popup;
157 Elm_Object_Item *head;
158 Evas_Object *scan_btn;
159 Evas_Object *multi_scan_btn;
160 Evas_Object *multi_connect_btn;
162 Elm_Object_Item *nodevice_title_item;
163 Elm_Object_Item *nodevice_item;
165 Elm_Object_Item *about_wfd_item;
166 Elm_Object_Item *about_wfd_sep_high_item;
167 Elm_Object_Item *about_wfd_sep_low_item;
169 Elm_Object_Item *conn_wfd_item;
170 Elm_Object_Item *conn_failed_wfd_item;
171 Elm_Object_Item *avlbl_wfd_item;
172 Elm_Object_Item *busy_wfd_item;
173 Elm_Object_Item *multi_connect_wfd_item;
175 Elm_Object_Item *multi_button_item;
176 Elm_Object_Item *multi_button_sep_item;
178 Elm_Object_Item *mcview_select_all_item;
179 Elm_Object_Item *mcview_title_item;
180 Elm_Object_Item *mcview_nodevice_item;
182 Evas_Object *back_btn;
183 Evas_Object *multi_btn;
187 Evas_Object *notify_layout;
192 device_type_s raw_connected_peers[MAX_PEER_NUM];
193 int raw_connected_peer_cnt;
194 device_type_s raw_discovered_peers[MAX_PEER_NUM];
195 int raw_discovered_peer_cnt;
197 // Peer data in the Genlist
198 device_type_s gl_connected_peers[MAX_PEER_NUM];
199 int gl_connected_peer_cnt;
201 device_type_s gl_connected_failed_peers[MAX_PEER_NUM];
202 int gl_connected_failed_peer_cnt;
204 device_type_s gl_available_peers[MAX_PEER_NUM];
205 int gl_available_peer_cnt;
207 device_type_s gl_busy_peers[MAX_PEER_NUM];
208 int gl_busy_peer_cnt;
210 device_type_s raw_multi_selected_peers[MAX_PEER_NUM];
211 int raw_multi_selected_peer_cnt;
213 device_type_s gl_multi_connect_peers[MAX_PEER_NUM];
214 int gl_multi_connect_peer_cnt;
217 bool I_am_group_owner;
220 // Following variables are used at the Multi connect view.
221 wfd_multi_connect_mode_e multi_connect_mode;
222 wfd_multi_sel_data_s multi_conn_dev_list[MAX_PEER_NUM];
223 int gl_available_dev_cnt_at_multiconn_view;
224 int g_source_multi_connect_next;
227 wifi_direct_state_e wfd_status;
231 // For connect failed peers
232 int last_display_time;
233 Ecore_Timer *display_timer;
237 tethering_h hotspot_handle;
239 // Used for automatic turn off
242 Ecore_Timer *monitor_timer;
244 // Re-discover or not
248 extern Elm_Gen_Item_Class head_itc;
249 extern Elm_Gen_Item_Class name_itc;
250 extern Elm_Gen_Item_Class title_itc;
251 extern Elm_Gen_Item_Class peer_itc;
252 extern Elm_Gen_Item_Class noitem_itc;
253 extern Elm_Gen_Item_Class button_itc;
255 extern Elm_Gen_Item_Class title_conn_itc;
256 extern Elm_Gen_Item_Class peer_conn_itc;
258 extern Elm_Gen_Item_Class title_busy_itc;
259 extern Elm_Gen_Item_Class peer_busy_itc;
261 extern Elm_Gen_Item_Class title_multi_connect_itc;
262 extern Elm_Gen_Item_Class peer_multi_connect_itc;
264 extern Elm_Gen_Item_Class title_conn_failed_itc;
265 extern Elm_Gen_Item_Class peer_conn_failed_itc;
268 #endif /* __WFD_UG_H__ */