printf removed
[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.1 (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://floralicense.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 <ui-gadget-module.h>
25 #include <tethering.h>
26 #include <wifi-direct.h>
27
28 #define PACKAGE "ug-setting-wifidirect-efl"
29 #define LOCALEDIR "/usr/ug/res/locale"
30 #define VCONF_WFD_APNAME "db/setting/device_name"
31
32 #ifdef USE_DLOG
33 #include <dlog.h>
34
35 #undef LOG_TAG
36 #define LOG_TAG "UG_WIFI_DIRECT"
37
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)
44
45 #define __WDUG_LOG_FUNC_ENTER__ LOGV("Enter")
46 #define __WDUG_LOG_FUNC_EXIT__ LOGV("Quit")
47
48 #define assertm_if(expr, fmt, args...) do { \
49         if (expr) { \
50           WDUG_LOGF(" ##(%s) -> assert!!## "fmt, #expr, ##args); \
51                  assert(1); \
52         } \
53 } while (0)
54
55 #else /** _DLOG_UTIL */
56
57 #define WDUG_LOGV(format, args...)
58 #define WDUG_LOGD(format, args...)
59 #define WDUG_LOGI(format, args...)
60 #define WDUG_LOGW(format, args...)
61 #define WDUG_LOGE(format, args...)
62 #define WDUG_LOGF(format, args...)
63
64 #define __WDUG_LOG_FUNC_ENTER__
65 #define __WDUG_LOG_FUNC_EXIT__
66
67 #endif /** _DLOG_UTIL */
68
69 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
70 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
71
72 #define AP_NAME_LENGTH_MAX              32
73 #define AP_PASSWORD_LENGTH_MAX  64
74 #define AP_PASSWORD_LENGTH_MIN  8
75 #define AP_REJECT_CHAR_LIST             "=,"
76
77 #define DEFAULT_DEV_NAME        "Tizen"
78 #define MAC_LENGTH  18
79 #define SSID_LENGTH 32
80 #define MAX_PEER_NUM 10
81 #define MAX_POPUP_PEER_NUM 7
82 #define MAX_POPUP_TEXT_SIZE 256
83 #define MAX_DISPLAY_TIME_OUT    30
84 #define MAX_NO_ACTION_TIME_OUT  300            /*5min*/
85 #define MAX_SCAN_TIME_OUT 30
86
87 #define _(s)        dgettext(PACKAGE, s)
88 #define N_(s)      dgettext_noop(s)
89 #define S_(s)      dgettext("sys_string", s)
90
91 #if 1
92 /* To-Do : Text should be translated. */
93 #define IDS_WFD_POP_SCAN_AGAIN "Current connection will be disconnected so that scanning can start.Continue?"
94 #define IDS_WFD_POP_WARN_BUSY_DEVICE "Unavailable device. Device is connected to another device."
95 #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."
96 #define IDS_WFD_BODY_FAILED_DEVICES "Failed Devices"
97 #define IDS_WFD_TITLE_ABOUT_WIFI_DIRECT "About Wi-Fi Direct"
98 #endif
99
100
101 #define WFD_GLOBALIZATION_STR_LENGTH 256
102
103 typedef enum {
104         WFD_MULTI_CONNECT_MODE_NONE,
105         WFD_MULTI_CONNECT_MODE_IN_PROGRESS,
106         WFD_MULTI_CONNECT_MODE_COMPLETED,
107 } wfd_multi_connect_mode_e;
108
109 typedef enum {
110         PEER_CONN_STATUS_DISCONNECTED,
111         PEER_CONN_STATUS_DISCONNECTING,
112         PEER_CONN_STATUS_CONNECTING = PEER_CONN_STATUS_DISCONNECTING,
113         PEER_CONN_STATUS_CONNECTED,
114         PEER_CONN_STATUS_FAILED_TO_CONNECT,
115         PEER_CONN_STATUS_WAIT_FOR_CONNECT,
116 } conn_status_e;
117
118
119 typedef struct {
120         char ssid[SSID_LENGTH];
121         unsigned int category;
122         char mac_addr[MAC_LENGTH];
123         char if_addr[MAC_LENGTH];
124         conn_status_e conn_status;
125         bool is_group_owner;  /** Is an active P2P Group Owner */
126         bool is_persistent_group_owner;  /** Is a stored Persistent GO */
127         bool is_connected;  /** Is peer connected*/
128         Elm_Object_Item *gl_item;
129 } device_type_s;
130
131 typedef struct {
132         bool dev_sel_state;
133         device_type_s peer;
134 } wfd_multi_sel_data_s;
135
136 struct ug_data {
137         Evas_Object *base;
138         ui_gadget_h ug;
139
140         Evas_Object *win;
141         Evas_Object *bg;
142         Evas_Object *naviframe;
143         Evas_Object *genlist;
144         Evas_Object *multiconn_view_genlist;
145         Evas_Object *popup;
146         Evas_Object *act_popup;
147         Evas_Object *warn_popup;
148
149         Elm_Object_Item *head;
150         Evas_Object *scan_btn;
151         Evas_Object *multi_scan_btn;
152         Evas_Object *multi_connect_btn;
153
154         Elm_Object_Item *nodevice_title_item;
155         Elm_Object_Item *nodevice_item;
156
157         Elm_Object_Item *about_wfd_item;
158         Elm_Object_Item *about_wfd_sep_high_item;
159         Elm_Object_Item *about_wfd_sep_low_item;
160
161         Elm_Object_Item *conn_wfd_item;
162         Elm_Object_Item *conn_failed_wfd_item;
163         Elm_Object_Item *avlbl_wfd_item;
164         Elm_Object_Item *busy_wfd_item;
165         Elm_Object_Item *multi_connect_wfd_item;
166
167         Elm_Object_Item *multi_button_item;
168         Elm_Object_Item *multi_button_sep_item;
169
170         Elm_Object_Item *mcview_select_all_item;
171         Elm_Object_Item *mcview_title_item;
172         Elm_Object_Item *mcview_nodevice_item;
173
174         Evas_Object *back_btn;
175         Evas_Object *multi_btn;
176
177         // Notify
178         Evas_Object *notify;
179         Evas_Object *notify_layout;
180
181         int head_text_mode;
182
183         // Raw peer data
184         device_type_s raw_connected_peers[MAX_PEER_NUM];
185         int raw_connected_peer_cnt;
186         device_type_s raw_discovered_peers[MAX_PEER_NUM];
187         int raw_discovered_peer_cnt;
188
189         // Peer data in the Genlist
190         device_type_s gl_connected_peers[MAX_PEER_NUM];
191         int gl_connected_peer_cnt;
192
193         device_type_s gl_connected_failed_peers[MAX_PEER_NUM];
194         int gl_connected_failed_peer_cnt;
195
196         device_type_s gl_available_peers[MAX_PEER_NUM];
197         int gl_available_peer_cnt;
198
199         device_type_s gl_busy_peers[MAX_PEER_NUM];
200         int gl_busy_peer_cnt;
201
202         device_type_s raw_multi_selected_peers[MAX_PEER_NUM];
203         int raw_multi_selected_peer_cnt;
204
205         device_type_s gl_multi_connect_peers[MAX_PEER_NUM];
206         int gl_multi_connect_peer_cnt;
207
208         // My status
209         bool I_am_group_owner;
210         bool I_am_connected;
211
212         // Following variables are used at the Multi connect view.
213         wfd_multi_connect_mode_e multi_connect_mode;
214         wfd_multi_sel_data_s multi_conn_dev_list[MAX_PEER_NUM];
215         int gl_available_dev_cnt_at_multiconn_view;
216         int g_source_multi_connect_next;
217
218         int wfd_onoff;
219         wifi_direct_state_e wfd_status;
220         char *dev_name;
221         char *dev_pass;
222
223         // For connect failed peers
224         int last_display_time;
225         Ecore_Timer *display_timer;
226
227         // Tethering
228         bool is_hotspot_off;
229         tethering_h hotspot_handle;
230
231         // Used for automatic turn off
232         int last_wfd_status;
233         int last_wfd_time;
234         Ecore_Timer *monitor_timer;
235
236         // Re-discover or not
237         bool is_re_discover;
238 };
239
240 extern Elm_Gen_Item_Class head_itc;
241 extern Elm_Gen_Item_Class name_itc;
242 extern Elm_Gen_Item_Class title_itc;
243 extern Elm_Gen_Item_Class peer_itc;
244 extern Elm_Gen_Item_Class noitem_itc;
245 extern Elm_Gen_Item_Class button_itc;
246
247 extern Elm_Gen_Item_Class title_conn_itc;
248 extern Elm_Gen_Item_Class peer_conn_itc;
249
250 extern Elm_Gen_Item_Class title_busy_itc;
251 extern Elm_Gen_Item_Class peer_busy_itc;
252
253 extern Elm_Gen_Item_Class title_multi_connect_itc;
254 extern Elm_Gen_Item_Class peer_multi_connect_itc;
255
256 extern Elm_Gen_Item_Class title_conn_failed_itc;
257 extern Elm_Gen_Item_Class peer_conn_failed_itc;
258
259
260 #endif  /* __WFD_UG_H__ */