Applied changes from EFL and wifi-direct APIS
[apps/native/ug-wifi-direct.git] / ug-wifidirect / include / wfd_ug.h
1 /*
2 *  WiFi-Direct UG
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
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
9
10 * http://www.tizenopensource.org/license
11
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.
17 *
18 */
19
20
21 #ifndef __WFD_UG_H__
22 #define __WFD_UG_H__
23
24 #include <dlog.h>
25 #include <ui-gadget-module.h>
26 #include <tethering.h>
27 #include <wifi-direct.h>
28
29 #define PACKAGE "ug-setting-wifidirect-efl"
30 #define LOCALEDIR "/usr/ug/res/locale"
31
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)
35
36 #define __FUNC_ENTER__  DBG(LOG_VERBOSE, "+\n")
37 #define __FUNC_EXIT__   DBG(LOG_VERBOSE, "-\n")
38
39 #define VCONF_WFD_APNAME                        "db/setting/device_name"
40
41 #define assertm_if(expr, fmt, arg...) do { \
42         if (expr) { \
43           DBG(LOG_VERBOSE, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
44                  assert(1); \
45         } \
46 } while (0)
47
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"
50
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             "=,"
55
56 #define DEFAULT_DEV_NAME        "Tizen"
57 #define MAC_LENGTH  18
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
65
66 #define _(s)        dgettext(PACKAGE, s)
67 #define N_(s)      dgettext_noop(s)
68 #define S_(s)      dgettext("sys_string", s)
69
70 #if 1
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"
77 #endif
78
79
80 #define WFD_GLOBALIZATION_STR_LENGTH 256
81
82 typedef enum {
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;
87
88 typedef enum {
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,
95 } conn_status_e;
96
97
98 typedef struct {
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;
108 } device_type_s;
109
110 typedef struct {
111         bool dev_sel_state;
112         device_type_s peer;
113 } wfd_multi_sel_data_s;
114
115 struct ug_data {
116         Evas_Object *base;
117         ui_gadget_h ug;
118
119         Evas_Object *win;
120         Evas_Object *bg;
121         Evas_Object *naviframe;
122         Evas_Object *genlist;
123         Evas_Object *multiconn_view_genlist;
124         Evas_Object *popup;
125         Evas_Object *act_popup;
126         Evas_Object *warn_popup;
127
128         Elm_Object_Item *head;
129         Evas_Object *scan_btn;
130         Evas_Object *multi_scan_btn;
131         Evas_Object *multi_connect_btn;
132
133         Elm_Object_Item *nodevice_title_item;
134         Elm_Object_Item *nodevice_item;
135
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;
139
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;
145
146         Elm_Object_Item *multi_button_item;
147         Elm_Object_Item *multi_button_sep_item;
148
149         Elm_Object_Item *mcview_select_all_item;
150         Elm_Object_Item *mcview_title_item;
151         Elm_Object_Item *mcview_nodevice_item;
152
153         Evas_Object *back_btn;
154         Evas_Object *multi_btn;
155
156         // Notify
157         Evas_Object *notify;
158         Evas_Object *notify_layout;
159
160         int head_text_mode;
161
162         // Raw peer data
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;
167
168         // Peer data in the Genlist
169         device_type_s gl_connected_peers[MAX_PEER_NUM];
170         int gl_connected_peer_cnt;
171
172         device_type_s gl_connected_failed_peers[MAX_PEER_NUM];
173         int gl_connected_failed_peer_cnt;
174
175         device_type_s gl_available_peers[MAX_PEER_NUM];
176         int gl_available_peer_cnt;
177
178         device_type_s gl_busy_peers[MAX_PEER_NUM];
179         int gl_busy_peer_cnt;
180
181         device_type_s raw_multi_selected_peers[MAX_PEER_NUM];
182         int raw_multi_selected_peer_cnt;
183
184         device_type_s gl_multi_connect_peers[MAX_PEER_NUM];
185         int gl_multi_connect_peer_cnt;
186
187         // My status
188         bool I_am_group_owner;
189         bool I_am_connected;
190
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;
196
197         int wfd_onoff;
198         wifi_direct_state_e wfd_status;
199         char *dev_name;
200         char *dev_pass;
201
202         // For connect failed peers
203         int last_display_time;
204         Ecore_Timer *display_timer;
205
206         // Tethering
207         bool is_hotspot_off;
208         tethering_h hotspot_handle;
209
210         // Used for automatic turn off
211         int last_wfd_status;
212         int last_wfd_time;
213         Ecore_Timer *monitor_timer;
214
215         // Re-discover or not
216         bool is_re_discover;
217 };
218
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;
225
226 extern Elm_Gen_Item_Class title_conn_itc;
227 extern Elm_Gen_Item_Class peer_conn_itc;
228
229 extern Elm_Gen_Item_Class title_busy_itc;
230 extern Elm_Gen_Item_Class peer_busy_itc;
231
232 extern Elm_Gen_Item_Class title_multi_connect_itc;
233 extern Elm_Gen_Item_Class peer_multi_connect_itc;
234
235 extern Elm_Gen_Item_Class title_conn_failed_itc;
236 extern Elm_Gen_Item_Class peer_conn_failed_itc;
237
238
239 #endif  /* __WFD_UG_H__ */