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.
25 #include <ui-gadget-module.h>
26 #include <tethering.h>
27 #include <wifi-direct.h>
29 #define PACKAGE "ug-setting-wifidirect-efl"
30 #define LOCALEDIR "/usr/ug/res/locale"
32 #define DIRECT_TAG "wfd_ug"
33 #define DBG(log_level, format, args...) \
34 LOG(log_level, DIRECT_TAG, "[%s()][%d] " format, __FUNCTION__, __LINE__, ##args)
36 #define __FUNC_ENTER__ DBG(LOG_VERBOSE, "+\n")
37 #define __FUNC_EXIT__ DBG(LOG_VERBOSE, "-\n")
39 #define VCONF_WFD_APNAME "db/setting/device_name"
41 #define assertm_if(expr, fmt, arg...) do { \
43 DBG(LOG_VERBOSE, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
48 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
49 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
51 #define AP_NAME_LENGTH_MAX 32
52 #define AP_PASSWORD_LENGTH_MAX 64
53 #define AP_PASSWORD_LENGTH_MIN 8
54 #define AP_REJECT_CHAR_LIST "=,"
56 #define DEFAULT_DEV_NAME "Tizen"
58 #define SSID_LENGTH 32
59 #define MAX_PEER_NUM 10
60 #define MAX_POPUP_PEER_NUM 7
61 #define MAX_POPUP_TEXT_SIZE 256
62 #define MAX_DISPLAY_TIME_OUT 30
63 #define MAX_NO_ACTION_TIME_OUT 300 /*5min*/
64 #define MAX_SCAN_TIME_OUT 30
66 #define _(s) dgettext(PACKAGE, s)
67 #define N_(s) dgettext_noop(s)
68 #define S_(s) dgettext("sys_string", s)
71 /* To-Do : Text should be translated. */
72 #define IDS_WFD_POP_SCAN_AGAIN "Current connection will be disconnected so that scanning can start.Continue?"
73 #define IDS_WFD_POP_WARN_BUSY_DEVICE "Unavailable device. Device is connected to another device."
74 #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."
75 #define IDS_WFD_BODY_FAILED_DEVICES "Failed Devices"
76 #define IDS_WFD_TITLE_ABOUT_WIFI_DIRECT "About Wi-Fi Direct"
80 #define WFD_GLOBALIZATION_STR_LENGTH 256
83 WFD_MULTI_CONNECT_MODE_NONE,
84 WFD_MULTI_CONNECT_MODE_IN_PROGRESS,
85 WFD_MULTI_CONNECT_MODE_COMPLETED,
86 } wfd_multi_connect_mode_e;
89 PEER_CONN_STATUS_DISCONNECTED,
90 PEER_CONN_STATUS_DISCONNECTING,
91 PEER_CONN_STATUS_CONNECTING = PEER_CONN_STATUS_DISCONNECTING,
92 PEER_CONN_STATUS_CONNECTED,
93 PEER_CONN_STATUS_FAILED_TO_CONNECT,
94 PEER_CONN_STATUS_WAIT_FOR_CONNECT,
99 char ssid[SSID_LENGTH];
100 unsigned int category;
101 char mac_addr[MAC_LENGTH];
102 char if_addr[MAC_LENGTH];
103 conn_status_e conn_status;
104 bool is_group_owner; /** Is an active P2P Group Owner */
105 bool is_persistent_group_owner; /** Is a stored Persistent GO */
106 bool is_connected; /** Is peer connected*/
107 Elm_Object_Item *gl_item;
113 } wfd_multi_sel_data_s;
121 Evas_Object *naviframe;
122 Evas_Object *genlist;
123 Evas_Object *multiconn_view_genlist;
125 Evas_Object *act_popup;
126 Evas_Object *warn_popup;
128 Elm_Object_Item *head;
129 Evas_Object *scan_btn;
130 Evas_Object *multi_scan_btn;
131 Evas_Object *multi_connect_btn;
133 Elm_Object_Item *nodevice_title_item;
134 Elm_Object_Item *nodevice_item;
136 Elm_Object_Item *about_wfd_item;
137 Elm_Object_Item *about_wfd_sep_high_item;
138 Elm_Object_Item *about_wfd_sep_low_item;
140 Elm_Object_Item *conn_wfd_item;
141 Elm_Object_Item *conn_failed_wfd_item;
142 Elm_Object_Item *avlbl_wfd_item;
143 Elm_Object_Item *busy_wfd_item;
144 Elm_Object_Item *multi_connect_wfd_item;
146 Elm_Object_Item *multi_button_item;
147 Elm_Object_Item *multi_button_sep_item;
149 Elm_Object_Item *mcview_select_all_item;
150 Elm_Object_Item *mcview_title_item;
151 Elm_Object_Item *mcview_nodevice_item;
153 Evas_Object *back_btn;
154 Evas_Object *multi_btn;
158 Evas_Object *notify_layout;
163 device_type_s raw_connected_peers[MAX_PEER_NUM];
164 int raw_connected_peer_cnt;
165 device_type_s raw_discovered_peers[MAX_PEER_NUM];
166 int raw_discovered_peer_cnt;
168 // Peer data in the Genlist
169 device_type_s gl_connected_peers[MAX_PEER_NUM];
170 int gl_connected_peer_cnt;
172 device_type_s gl_connected_failed_peers[MAX_PEER_NUM];
173 int gl_connected_failed_peer_cnt;
175 device_type_s gl_available_peers[MAX_PEER_NUM];
176 int gl_available_peer_cnt;
178 device_type_s gl_busy_peers[MAX_PEER_NUM];
179 int gl_busy_peer_cnt;
181 device_type_s raw_multi_selected_peers[MAX_PEER_NUM];
182 int raw_multi_selected_peer_cnt;
184 device_type_s gl_multi_connect_peers[MAX_PEER_NUM];
185 int gl_multi_connect_peer_cnt;
188 bool I_am_group_owner;
191 // Following variables are used at the Multi connect view.
192 wfd_multi_connect_mode_e multi_connect_mode;
193 wfd_multi_sel_data_s multi_conn_dev_list[MAX_PEER_NUM];
194 int gl_available_dev_cnt_at_multiconn_view;
195 int g_source_multi_connect_next;
198 wifi_direct_state_e wfd_status;
202 // For connect failed peers
203 int last_display_time;
204 Ecore_Timer *display_timer;
208 tethering_h hotspot_handle;
210 // Used for automatic turn off
213 Ecore_Timer *monitor_timer;
215 // Re-discover or not
219 extern Elm_Gen_Item_Class head_itc;
220 extern Elm_Gen_Item_Class name_itc;
221 extern Elm_Gen_Item_Class title_itc;
222 extern Elm_Gen_Item_Class peer_itc;
223 extern Elm_Gen_Item_Class noitem_itc;
224 extern Elm_Gen_Item_Class button_itc;
226 extern Elm_Gen_Item_Class title_conn_itc;
227 extern Elm_Gen_Item_Class peer_conn_itc;
229 extern Elm_Gen_Item_Class title_busy_itc;
230 extern Elm_Gen_Item_Class peer_busy_itc;
232 extern Elm_Gen_Item_Class title_multi_connect_itc;
233 extern Elm_Gen_Item_Class peer_multi_connect_itc;
235 extern Elm_Gen_Item_Class title_conn_failed_itc;
236 extern Elm_Gen_Item_Class peer_conn_failed_itc;
239 #endif /* __WFD_UG_H__ */