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