changed to support multi-languages.
[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
28 #define PACKAGE "ug-setting-wifidirect-efl"
29 #define LOCALEDIR "/opt/ug/res/locale"
30
31 #define DIRECT_TAG  "wfd_ug"
32 #define DBG(log_level, format, args...) \
33        LOG(log_level, DIRECT_TAG, "[%s()][%d] " format, __FUNCTION__, __LINE__, ##args)
34
35 #define __FUNC_ENTER__  DBG(LOG_VERBOSE, "+\n")
36 #define __FUNC_EXIT__   DBG(LOG_VERBOSE, "-\n")
37
38 #define VCONF_WFD_APNAME                        "db/setting/device_name"
39
40 #define assertm_if(expr, fmt, arg...) do { \
41    if(expr) { \
42           DBG(LOG_VERBOSE, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \
43                  assert(1); \
44    } \
45 } while (0)                     // retvm if
46
47 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
48 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
49
50 #define AP_NAME_LENGTH_MAX              32      //allowed lenght is 31 + '\0'
51 #define AP_PASSWORD_LENGTH_MAX  64      //allowed lenght is 63 + '\0'
52 #define AP_PASSWORD_LENGTH_MIN  8       //min limit
53 #define AP_REJECT_CHAR_LIST             "=,"
54
55 #define DEFAULT_DEV_NAME        "GT_I9500"
56 #define MAC_LENGTH  18
57 #define SSID_LENGTH 32
58 #define MAX_PEER_NUM 10
59 #define MAX_POPUP_PEER_NUM 7
60 #define MAX_POPUP_TEXT_SIZE 256
61 #define MAX_DISPLAY_TIME_OUT    30
62
63 #define _(s)        dgettext(PACKAGE, s)
64 #define N_(s)      dgettext_noop(s)
65 #define S_(s)      dgettext("sys_string", s)
66
67
68 #if 1   //To-Do : Text should be translated.
69
70 #define IDS_WFD_POP_SCAN_AGAIN "To start new scanning,<br>current connection will be<br>ended.Continue?"
71 #define IDS_WFD_POP_WARN_BUSY_DEVICE "Unavailable device. Device is connected to another device."
72 #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."
73 #define IDS_WFD_BODY_FAILED_DEVICES "Failed Devices"
74  
75 #endif
76
77
78 #define WFD_GLOBALIZATION_STR_LENGTH 256
79
80 typedef enum {
81         WFD_MULTI_CONNECT_MODE_NONE,
82         WFD_MULTI_CONNECT_MODE_IN_PROGRESS,
83         WFD_MULTI_CONNECT_MODE_COMPLETED,
84 } wfd_multi_connect_mode_e;
85
86 typedef enum
87 {
88     PEER_CONN_STATUS_DISCONNECTED,
89     PEER_CONN_STATUS_DISCONNECTING,
90     PEER_CONN_STATUS_CONNECTING = PEER_CONN_STATUS_DISCONNECTING,
91     PEER_CONN_STATUS_CONNECTED,
92     PEER_CONN_STATUS_FAILED_TO_CONNECT,
93     PEER_CONN_STATUS_WAIT_FOR_CONNECT,
94 } conn_status_e;
95
96
97 typedef struct
98 {
99     char ssid[SSID_LENGTH];    // 31 + 1('\0')
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 {
112     bool dev_sel_state;
113     device_type_s peer;
114 } wfd_multi_sel_data_s;
115
116 struct ug_data
117 {
118     Evas_Object *base;
119     ui_gadget_h ug;
120
121     Evas_Object *win;
122     Evas_Object *bg;
123     Evas_Object *naviframe;
124     Evas_Object *genlist;
125     Evas_Object *multiconn_view_genlist;
126     Evas_Object *popup;
127     Evas_Object *act_popup;
128     Evas_Object *warn_popup;
129
130     Elm_Object_Item *head;
131     Elm_Object_Item *scan_btn;
132     Elm_Object_Item *multi_scan_btn;
133     Elm_Object_Item *multi_connect_btn;
134
135     Elm_Object_Item *nodevice_title_item;
136     Elm_Object_Item *nodevice_item;
137     Elm_Object_Item *nodevice_sep_low_item;
138
139     Elm_Object_Item *about_wfd_item;
140     Elm_Object_Item *about_wfdsp_sep_end_item;
141
142     Elm_Object_Item *conn_wfd_item;
143
144     Elm_Object_Item *conn_failed_wfd_item;
145     Elm_Object_Item *conn_failed_wfd_sep_item;
146
147     Elm_Object_Item *avlbl_wfd_item;
148
149     Elm_Object_Item *busy_wfd_item;
150     Elm_Object_Item *busy_wfd_sep_item;
151
152     Elm_Object_Item *multi_connect_wfd_item;
153
154     Elm_Object_Item *multi_button_item;
155     Elm_Object_Item *multi_button_sep_high_item;
156     Elm_Object_Item *multi_button_sep_low_item;
157
158
159     Elm_Object_Item *mcview_select_all_item;
160     Elm_Object_Item *mcview_title_item;
161     Elm_Object_Item *mcview_nodevice_item;
162
163
164     Evas_Object *multi_btn;
165
166     int head_text_mode;
167
168     // Raw peer data
169     device_type_s raw_connected_peers[MAX_PEER_NUM];
170     int raw_connected_peer_cnt;
171     device_type_s raw_discovered_peers[MAX_PEER_NUM];
172     int raw_discovered_peer_cnt;
173
174     // Peer data in the Genlist
175     device_type_s gl_connected_peers[MAX_PEER_NUM];
176     int gl_connected_peer_cnt;
177
178     device_type_s gl_connected_failed_peers[MAX_PEER_NUM];
179     int gl_connected_failed_peer_cnt;
180
181     device_type_s gl_available_peers[MAX_PEER_NUM];
182     int gl_available_peer_cnt;
183
184     device_type_s gl_busy_peers[MAX_PEER_NUM];
185     int gl_busy_peer_cnt;
186
187     device_type_s raw_multi_selected_peers[MAX_PEER_NUM];
188     int raw_multi_selected_peer_cnt;
189
190     device_type_s gl_multi_connect_peers[MAX_PEER_NUM];
191     int gl_multi_connect_peer_cnt;
192
193     // My status
194     bool I_am_group_owner;
195     bool I_am_connected;
196
197     // Following variables are used at the Multi connect view.
198     wfd_multi_connect_mode_e multi_connect_mode;
199     wfd_multi_sel_data_s multi_conn_dev_list[MAX_PEER_NUM];
200     int gl_available_dev_cnt_at_multiconn_view;
201     int g_source_multi_connect_next;
202
203     int wfd_onoff;
204     int wfd_status;
205     char *dev_name;
206     char *dev_pass;
207
208     // For connect failed peers
209     int last_display_time;
210     Ecore_Timer *display_timer;
211
212     //tethering
213     tethering_h hotspot_handle;
214     
215 };
216
217 extern Elm_Gen_Item_Class sep_itc;
218 extern Elm_Gen_Item_Class sep_itc_end;
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 help_itc;
225 extern Elm_Gen_Item_Class button_itc;
226
227 extern Elm_Gen_Item_Class title_conn_itc;
228 extern Elm_Gen_Item_Class peer_conn_itc;
229
230 extern Elm_Gen_Item_Class title_busy_itc;
231 extern Elm_Gen_Item_Class peer_busy_itc;
232
233 extern Elm_Gen_Item_Class title_multi_connect_itc;
234 extern Elm_Gen_Item_Class peer_multi_connect_itc;
235
236 extern Elm_Gen_Item_Class title_conn_failed_itc;
237 extern Elm_Gen_Item_Class peer_conn_failed_itc;
238
239
240 #endif  /* __WFD_UG_H__ */