[ug-wifi-direct]Sync with Tizen 2.4
[apps/native/ug-wifi-direct.git] / ug-wifidirect / include / wfd_ug_view.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 #ifndef __WFD_UG_VIEW_H__
21 #define __WFD_UG_VIEW_H__
22
23 #include <glib.h>
24
25 #define EDJDIR "/usr/apps/setting-wifidirect-efl/res/edje/ug-setting-wifidirect-efl"
26 #define WFD_UG_EDJ_PATH  EDJDIR"/wfd_ug.edj"
27 #define WFD_IMG_DIR "/usr/apps/setting-wifidirect-efl/res/images/ug-setting-wifidirect-efl"
28
29 /* Define icons */
30 #define WFD_ICON_DEVICE_COMPUTER                        "A09_device_computer.png"
31 #define WFD_ICON_DEVICE_INPUT_DEVICE            "A09_device_input_device.png"
32 #define WFD_ICON_DEVICE_PRINTER                         "A09_device_printer.png"
33 #define WFD_ICON_DEVICE_CAMERA                          "A09_device_camera.png"
34 #define WFD_ICON_DEVICE_STORAGE                         "A09_device_storage.png"
35 #define WFD_ICON_DEVICE_NETWORK_INFRA           "A09_device_network_infrastructure.png"
36 #define WFD_ICON_DEVICE_DISPLAY                         "A09_device_display.png"
37 #define WFD_ICON_DEVICE_MULTIMEDIA                      "A09_device_multimedia.png"
38 #define WFD_ICON_DEVICE_GAMING                          "A09_device_gaming.png"
39 #define WFD_ICON_DEVICE_TELEPHONE                       "A09_device_telephone.png"
40 #define WFD_ICON_DEVICE_HEADSET                         "A09_device_headset.png"
41 #define WFD_ICON_DEVICE_UNKNOWN                         "A09_device_unknown.png"
42 #define WFD_ICON_DEVICE_BD                                      "U04_device_BD.png"
43 #define WFD_ICON_DEVICE_DONGLE                          "U04_device_Dongle.png"
44 #define WFD_ICON_DEVICE_HOME_THEATER            "U04_device_Home_Theater.png"
45 #define WFD_ICON_DEVICE_STB                                     "U04_device_STB.png"
46
47 /* Not support */
48 #define WFD_ICON_DEVICE_HEADPHONE                       "A09_device_headphone.png"
49 #define WFD_ICON_DEVICE_MEDICAL                         "A09_device_Medical.png"
50 #define WFD_ICON_DEVICE_MOUSE                           "A09_device_mouse.png"
51
52 #define WFD_ICON_DEVICE_MORE_HELP                               "A09_popup_help.png"
53
54 enum {
55         HEAD_TEXT_TYPE_DIRECT,
56         HEAD_TEXT_TYPE_DEACTIVATING,
57         HEAD_TEXT_TYPE_ACTIVATING,
58         HEAD_TEXT_TYPE_ACTIVATED,
59 };
60
61 enum {
62         TITLE_CONTENT_TYPE_NONE,
63         TITLE_CONTENT_TYPE_SCANNING,
64         TITLE_CONTENT_TYPE_FOUND,
65 };
66
67
68 enum {
69         /* User confirm */
70 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
71         POPUP_TYPE_WIFI_OFF,
72 #endif
73
74         POPUP_TYPE_HOTSPOT_OFF = 1,
75
76         /* Activation */
77         POPUP_TYPE_ACTIVATE_FAIL,
78         POPUP_TYPE_ACTIVATE_FAIL_POLICY_RESTRICTS,
79         POPUP_TYPE_DEACTIVATE_FAIL,
80
81         /* Connection */
82         POPUP_TYPE_LINK_TIMEOUT,
83         POPUP_TYPE_AUTH_FAIL,
84         POPUP_TYPE_LINK_FAIL,
85         POPUP_TYPE_UNKNOWN_ERROR,
86
87         POPUP_TYPE_INFO,
88         POPUP_TYPE_TERMINATE,
89         POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL,
90         POPUP_TYPE_TERMINATE_NOT_SUPPORT,
91
92         /* Disconnect */
93         POP_TYPE_DISCONNECT,
94
95         POP_TYPE_CANCEL_CONNECT,
96
97         POP_TYPE_ACCEPT_CONNECTION,
98
99         /* Scan again */
100         POP_TYPE_SCAN_AGAIN,
101
102         /* multi connect */
103         POP_TYPE_MULTI_CONNECT_POPUP,
104
105         /* Busy device */
106         POP_TYPE_BUSY_DEVICE_POPUP,
107
108         /* Automaticlly turn off */
109         POP_TYPE_AUTOMATIC_TURN_OFF,
110 };
111
112 struct ug_data *wfd_get_ug_data();
113
114 /**
115  *      This function let the ug create the main view
116  *      @return   void
117  *      @param[in] data the pointer to the main data structure
118  */
119 void create_wfd_ug_view(void *data);
120
121 /**
122  *      This function let the ug destroy the main view
123  *      @return   void
124  *      @param[in] data the pointer to the main data structure
125  */
126 void destroy_wfd_ug_view(void *data);
127
128 /**
129  *      This function let the ug update the genlist item
130  *      @return   void
131  *      @param[in] gl_item the pointer to genlist item
132  */
133 void wfd_ug_view_refresh_glitem(Elm_Object_Item *gl_item);
134
135 /**
136  *      This function let the ug refresh the attributes of button
137  *      @return   void
138  *      @param[in] tb_item the pointer to the toolbar button
139  *      @param[in] text the pointer to the text of button
140  *      @param[in] enable whether the button is disabled
141  */
142 void wfd_ug_view_refresh_button(Evas_Object *tb_item, const char *text,
143                 int enable);
144
145 /**
146  *      This function let the ug update the peers
147  *      @return   void
148  *      @param[in] data the pointer to the main data structure
149  */
150 void wfd_ug_view_update_peers(void *data);
151
152 /**
153  *      This function let the ug free the peers
154  *      @return   void
155  *      @param[in] data the pointer to the main data structure
156  */
157 void wfd_ug_view_free_peers(void *data);
158
159 /**
160  *      This function let the ug create a action popup
161  *      @return   void
162  *      @param[in] data the pointer to the main data structure
163  *      @param[in] message the pointer to the text of popup
164  *      @param[in] popup_type the message type
165  */
166 void wfd_ug_act_popup(void *data, const char *message, int popup_type);
167
168 /**
169  *      This function let the ug remove the action popup
170  *      @return   void
171  *      @param[in] data the pointer to the main data structure
172  */
173 void wfg_ug_act_popup_remove(void *data);
174
175 /**
176  *      This function let the ug create a warning popup
177  *      @return   void
178  *      @param[in] data the pointer to the main data structure
179  *      @param[in] message the pointer to the text of popup
180  *      @param[in] popup_type the message type
181  */
182 void wfd_ug_warn_popup(void *data, const char *message, int popup_type);
183
184 /**
185  *      This function let the ug create the view for multi connection
186  *      @return   void
187  *      @param[in] ugd the pointer to the main data structure
188  */
189 void _wifid_create_multiconnect_view(struct ug_data *ugd);
190
191 /**
192  *      This function let the ug call it when click 'back' button
193  *      @return   void
194  *      @param[in] data the pointer to the main data structure
195  *      @param[in] obj the pointer to the evas object
196  *      @param[in] event_info the pointer to the event information
197  */
198 Eina_Bool _back_btn_cb(void *data, Elm_Object_Item *it);
199
200 /**
201  *      This function let the ug call it when click 'scan' button
202  *      @return   void
203  *      @param[in] data the pointer to the main data structure
204  *      @param[in] obj the pointer to the evas object
205  *      @param[in] event_info the pointer to the event information
206  */
207 void _scan_btn_cb(void *data, Evas_Object * obj, void *event_info);
208
209 /**
210  *      This function let the ug call it when click 'disconnect' button
211  *      @return   void
212  *      @param[in] data the pointer to the main data structure
213  *      @param[in] obj the pointer to the evas object
214  *      @param[in] event_info the pointer to the event information
215  */
216 void _wfd_ug_disconnect_button_cb(void *data, Evas_Object *obj, void *event_info);
217
218 /**
219  *      This function let the ug call it when click "Cancel Connection" button
220  *      @return   void
221  *      @param[in] data the pointer to the main data structure
222  *      @param[in] obj the pointer to the evas object
223  *      @param[in] event_info the pointer to the event information
224  */
225 void _wfd_ug_cancel_connection_button_cb(void *data, Evas_Object *obj, void *event_info);
226
227 /**
228  *      This function let the ug get the found peers
229  *      @return   If success, return 0, else return -1
230  *      @param[in] ugd the pointer to the main data structure
231  */
232 int wfd_ug_get_discovered_peers(struct ug_data *ugd);
233
234 /**
235  *      This function let the ug get the connecting peer mac
236  *      @return   If success, return 0, else return -1
237  *      @param[in] ugd the pointer to the main data structure
238  */
239 int wfd_ug_get_connecting_peer(struct ug_data *ugd);
240
241 /**
242  *      This function let the ug get the connected peers
243  *      @return   If success, return 0, else return -1
244  *      @param[in] ugd the pointer to the main data structure
245  */
246 int wfd_ug_get_connected_peers(struct ug_data *ugd);
247
248 /**
249  *      This function let the ug get the device status
250  *      @return  If success, return 0-3(available: 0, connected: 1, busy: 2, connected failed: 3), else return -1
251  *      @param[in] ugd the pointer to the main data structure
252  *      @param[in] device the pointer to the number of connected failed devices
253  */
254 //int wfd_get_device_status(void *data, device_type_s *device);
255
256 /**
257  *      This function let the ug refresh current status of wi-fi direct
258  *      @return   If success, return 0, else return -1
259  *      @param[in] data the pointer to the main data structure
260  */
261 int wfd_refresh_wifi_direct_state(void *data);
262
263 /**
264  *      This function let the ug free the selected peers in multi connect view
265  *      @return   void
266  *      @param[in] data the pointer to the main data structure
267  */
268 void wfd_free_multi_selected_peers(void *data);
269
270 /**
271  *      This function let the ug stop to connect to selected peer
272  *      @return   If success, return 0, else return -1
273  *      @param[in] data the pointer to the main data structure
274  */
275 int wfd_stop_multi_connect(void *data);
276
277 /**
278  *      This function let the ug connect to the next selected peer automatically
279  *      @return   If stop the timer, return false, else return true
280  *      @param[in] data the pointer to the main data structure
281  */
282 gboolean wfd_multi_connect_next_cb(void *data);
283
284 /**
285  *      This function let the ug add a dialogue separator
286  *      @return   the separator item
287  *      @param[in] genlist the pointer to the genlist
288  *      @param[in] separator_style the style of separator
289  */
290 Elm_Object_Item *wfd_add_dialogue_separator(Evas_Object *genlist,
291                 const char *separator_style);
292
293 /**
294  *      This function let the ug free the multi connect devices
295  *      @return   0
296  *      @param[in] data the pointer to the main data structure
297  */
298 int wfd_free_multiconnect_device(struct ug_data *ugd);
299
300 /**
301  *      This function let the ug update the multi connect devices
302  *      @return   0
303  *      @param[in] ugd the pointer to the main data structure
304  *      @param[in] is_free_all_peers true to free all peers
305  */
306 int wfd_update_multiconnect_device(struct ug_data *ugd, bool is_free_all_peers);
307
308 /**
309  *      This function let the ug create the view for multi connection
310  *      @return   void
311  *      @param[in] ugd the pointer to the main data structure
312  */
313 void wfd_create_multiconnect_view(struct ug_data *ugd);
314
315 /**
316  *      This function let the ug delete search progressbar
317  *      @return   void
318  *      @param[in] user_data the pointer to the main data structure
319  */
320 int wfd_delete_progressbar_cb(void *user_data);
321
322 /**
323  *      This function let the ug insert peer item to genlist
324  *      @return   int
325  *      @param[in] genlist the pointer to genlist
326  *      @param[in] item the pointer to item to insert after
327  *      @param[in] itc Elm_Gen_Item_Class
328  *      @param[in] start_pos the pointer to the start position of peer array
329  *      @param[in] peer_for_insert the pointer to the peer to insert
330  *      @param[in] callback callback for peer select
331  */
332 int insert_gl_item(Evas_Object *genlist, Elm_Object_Item *item,
333                 Elm_Gen_Item_Class *itc, device_type_s **start_pos,
334                 device_type_s *peer_for_insert, void *callback);
335
336 /**
337  *      This function let the ug get the insert position for next item
338  *      @return  item the position to insert after
339  *      @param[in] peer the pointer to peer to search
340  *      @param[in] pre_item the title item of peer list
341  *      @param[in] peer_cnt the count of gl peers
342  */
343 Elm_Object_Item *get_insert_postion(device_type_s *peer,
344                 Elm_Object_Item *pre_item, int peer_cnt);
345
346 /**
347  *      This function let the ug find a peer in genlist
348  *      @return  peer the pointer of peer that found
349  *      @param[in] start_pos the start position of peers list
350  *      @param[in] mac_addr the mac_addr of peer for search
351  */
352 device_type_s *find_peer_in_glist(device_type_s *start_pos, const char *mac_addr);
353
354 /**
355  *      This function let the ug free gl peers
356  *      @return   void
357  *      @param[in] gl_peers_start the start pointer of peer list that for free
358  */
359 void wfd_ug_view_free_peer(device_type_s *gl_peers_start);
360
361 /**
362  *      This function let the ug exits automatically after successed connection
363  *      @return   void
364  *      @param[in] user_data the pointer to the main data structure
365  */
366 void _wfd_ug_auto_exit(void *user_data);
367
368 /**
369  *      This function let the ug update the buttons of toolbar
370  *      @return   void
371  *      @param[in] ugd the pointer to the main data structure
372  */
373 void wfd_ug_update_toolbar(struct ug_data *ugd);
374
375 /**
376  *      This function let the ug update the available and busy peers
377  *      @return   void
378  *      @param[in] data the pointer to the main data structure
379  */
380 void wfd_ug_update_available_peers(void *data);
381
382 /**
383  *      This function let the ug init the genlist
384  *      @return   void
385  *      @param[in] data the pointer to the main data structure
386  *      @param[in] is_free_all_peers true to free all peer items
387  */
388 void wfd_ug_view_init_genlist(void *data, bool is_free_all_peers);
389
390 /**
391  *      This function let the ug delete dead peers
392  *      @return   void
393  *      @param[in] ugd the pointer to the main data structure
394  *      @param[in] start_pos the pointer to start of peer list
395  *      @param[in] cnt the pointer to the number of peets in list
396  */
397 void delete_not_alive_peers(struct ug_data *ugd, device_type_s **start_pos,
398                 int *cnt);
399
400 /**
401  *      This function let the ug mark up the dead peers
402  *      @return   void
403  *      @param[in] ugd the pointer to the main data structure
404  *      @param[in] start_pos the pointer to start of peer list
405  */
406 void set_not_alive_peers(device_type_s *start_pos);
407
408 /**
409  *      This function let the ug update connected peers
410  *      @return   void
411  *      @param[in] data the pointer to the main data structure
412  */
413 void wfd_ug_update_connected_peers(void *data);
414
415 /**
416  *      This function let the ug update the multi-connect peers
417  *      @return   void
418  *      @param[in] data the pointer to the main data structure
419  */
420 void wfd_ug_view_update_multiconn_peers(void *data);
421
422 /**
423  *      This function let the ug update the failed peers
424  *      @return   void
425  *      @param[in] data the pointer to the main data structure
426  */
427 void wfd_ug_update_failed_peers(void *data);
428
429 /**
430  *      This function let the ug cancel progressbar stop timer
431  *      @return   void
432  *      @param[in] ugd the pointer to the main data structure
433  */
434 void wfd_cancel_progressbar_stop_timer(struct ug_data *ugd);
435
436 /**
437  *      This function let the ug cancel not-alive devices delete timer
438  *      @return   void
439  *      @param[in] ugd the pointer to the main data structure
440  */
441 void wfd_cancel_not_alive_delete_timer(struct ug_data *ugd);
442
443 /**
444  *      This function let the ug move ctxpopup to specified location
445  *      @return   void
446  */
447 void _ctxpopup_move();
448
449 int _create_available_dev_genlist(void *data);
450
451 Evas_Object *_create_no_device_genlist(void *data);
452
453 Evas_Object *_create_no_device_multiconnect_genlist(struct ug_data *ugd);
454
455 /**
456  *      This function let the ug create rename popup
457  *      @return   void
458  *      @param[in] data the pointer to the main data structure
459  */
460
461 void _gl_rename_device_sel(void *data, Evas_Object *obj, void *event_info);
462
463 #ifdef WFD_ON_OFF_GENLIST
464 /**
465  *      This function let the ug create on off check
466  *      @return   void
467  *      @param[in] parent the pointer to the naviframe
468  */
469 void wfd_ug_create_on_off_check(struct ug_data *ugd);
470 #endif
471 /**
472  *      This function is called after select all button is checked to select all available devices
473  *      @return   void
474  *      @param[in] data the pointer to the main data structure
475  */
476 void wfd_genlist_select_all_check_changed_cb(void *data, Evas_Object *obj,
477                 void *event_info);
478
479 #endif  /* __WFD_UG_VIEW_H__ */