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