83f038d7043b173eb7e1d2cf527372b76c62d674
[apps/home/ug-wifi-direct.git] / ug-wifidirect / src / wfd_ug_popup.c
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 #include <libintl.h>
21 #include <glib.h>
22
23 #include <Elementary.h>
24 #include <vconf.h>
25 #include <ui-gadget-module.h>
26 #include <wifi-direct.h>
27 #include "utilX.h"
28
29 #include "wfd_ug.h"
30 #include "wfd_ug_view.h"
31 #include "wfd_client.h"
32
33 static void delete_popup(void *data)
34 {
35         __FUNC_ENTER__;
36         struct ug_data *ugd = (struct ug_data *) data;
37         if (NULL == ugd) {
38                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
39                 return;
40         }
41
42         evas_object_del(ugd->act_popup);
43         ugd->act_popup = NULL;
44         __FUNC_EXIT__;
45 }
46
47 static void pushbutton_accept_connect_cb(void *data, Evas_Object * obj,
48                 void *event_info)
49 {
50         __FUNC_ENTER__;
51
52         struct ug_data *ugd = (struct ug_data *) data;
53         if (NULL == ugd) {
54                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
55                 return;
56         }
57         int result = -1;
58         result = wifi_direct_accept_connection(ugd->mac_addr_req);
59         if (result != WIFI_DIRECT_ERROR_NONE) {
60                 DBG(LOG_INFO,"Failed to connect");
61         }
62         delete_popup(ugd);
63
64         __FUNC_EXIT__;
65 }
66
67 static void pushbutton_reject_connect_cb(void *data, Evas_Object * obj,
68                 void *event_info)
69 {
70         __FUNC_ENTER__;
71
72         struct ug_data *ugd = (struct ug_data *) data;
73         if (NULL == ugd) {
74                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
75                 return;
76         }
77         int result = -1;
78         if (ugd->mac_addr_req[0] != '\0') {
79                 result = wifi_direct_reject_connection(ugd->mac_addr_req);
80                 if (result != WIFI_DIRECT_ERROR_NONE)
81                         DBG(LOG_INFO,"Failed to reject connection");
82         } else {
83                 DBG(LOG_INFO,"No Peer mac address");
84         }
85         delete_popup(ugd);
86
87         __FUNC_EXIT__;
88 }
89 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
90 static void _mouseup_wifi_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
91 {
92         Evas_Event_Mouse_Up *ev = event_info;
93         if (ev->button == 3) {
94                 struct ug_data *ugd = (struct ug_data *) data;
95
96                 evas_object_del(ugd->act_popup);
97                 ugd->act_popup = NULL;
98         }
99 }
100
101 static void _keydown_wifi_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
102 {
103         Evas_Event_Key_Down *ev = event_info;
104         if (!strcmp(ev->keyname, KEY_BACK)) {
105                 struct ug_data *ugd = (struct ug_data *) data;
106
107                 ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
108                 wfd_ug_view_refresh_glitem(ugd->head);
109
110                 evas_object_del(ugd->act_popup);
111                 ugd->act_popup = NULL;
112         }
113 }
114 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
115
116
117 static void _mouseup_hotspot_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
118 {
119         Evas_Event_Mouse_Up *ev = event_info;
120         if (ev->button == 3) {
121                 struct ug_data *ugd = (struct ug_data *) data;
122
123 #ifdef WFD_ON_OFF_GENLIST
124                 wfd_ug_refresh_on_off_check(ugd);
125 #endif
126                 evas_object_del(ugd->act_popup);
127                 ugd->act_popup = NULL;
128         }
129 }
130 static void _keydown_hotspot_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
131 {
132         Evas_Event_Key_Down *ev = event_info;
133         if (!strcmp(ev->keyname, KEY_BACK)) {
134                 struct ug_data *ugd = (struct ug_data *) data;
135
136                 ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
137                 wfd_ug_view_refresh_glitem(ugd->head);
138
139                 evas_object_del(ugd->act_popup);
140                 ugd->act_popup = NULL;
141         }
142 }
143
144 static void _mouseup_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
145 {
146         Evas_Event_Mouse_Up *ev = event_info;
147         if (ev->button == 3) {
148                 struct ug_data *ugd = (struct ug_data *) data;
149                 if (NULL == ugd) {
150                         DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
151                         return;
152                 }
153
154                 evas_object_del(ugd->act_popup);
155                 ugd->act_popup = NULL;
156         }
157 }
158
159 /*static void _keydown_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
160 {
161         Evas_Event_Key_Down *ev = event_info;
162         if (!strcmp(ev->keyname, KEY_BACK)) {
163                 struct ug_data *ugd = (struct ug_data *) data;
164                 if (NULL == ugd) {
165                         DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
166                         return;
167                 }
168
169                 evas_object_del(ugd->act_popup);
170                 ugd->act_popup = NULL;
171         }
172 }*/
173
174
175 /**
176  *      This function let the ug call it when click 'ok' button in hotspot action popup
177  *      @return   void
178  *      @param[in] data the pointer to the main data structure
179  *      @param[in] obj the pointer to the evas object
180  *      @param[in] event_info the pointer to the event information
181  */
182 static void _wfd_ug_act_popup_hotspot_ok_cb(void *data, Evas_Object *obj, void *event_info)
183 {
184         __FUNC_ENTER__;
185         int result = -1;
186         struct ug_data *ugd = (struct ug_data *) data;
187
188         result = wfd_mobile_ap_off(ugd);
189         if (0 == result) {
190 #ifdef WFD_ON_OFF_GENLIST
191                 /* refresh the header */
192                 if (ugd->on_off_check) {
193                         elm_check_state_set(ugd->on_off_check, TRUE);
194                         elm_object_disabled_set(ugd->on_off_check, TRUE);
195                 }
196 #endif
197
198                 /* while activating/deactivating, disable the buttons */
199                 if (ugd->scan_toolbar) {
200                         wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", FALSE);
201                 }
202
203                 if (ugd->multiconn_scan_stop_btn) {
204                         wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
205                 }
206
207                 if (ugd->back_btn) {
208                         elm_object_disabled_set(ugd->back_btn, TRUE);
209                 }
210                 ugd->is_hotspot_locally_disabled = TRUE;
211         }
212
213         evas_object_del(ugd->act_popup);
214         ugd->act_popup = NULL;
215         __FUNC_EXIT__;
216 }
217
218 /**
219  *      This function let the ug call it when click 'cancel' button in hotspot action popup
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 static void _wfd_ug_act_popup_hotspot_cancel_cb(void *data, Evas_Object *obj, void *event_info)
226 {
227         __FUNC_ENTER__;
228         struct ug_data *ugd = (struct ug_data *) data;
229
230 #ifdef WFD_ON_OFF_GENLIST
231         wfd_ug_refresh_on_off_check(ugd);
232 #endif
233
234         wfd_client_destroy_tethering(ugd);
235
236         evas_object_del(ugd->act_popup);
237         ugd->act_popup = NULL;
238         __FUNC_EXIT__;
239 }
240
241 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
242 /**
243  *      This function let the ug call it when click 'ok' button in wifi action popup
244  *      @return   void
245  *      @param[in] data the pointer to the main data structure
246  *      @param[in] obj the pointer to the evas object
247  *      @param[in] event_info the pointer to the event information
248  */
249 static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object *obj, void *event_info)
250 {
251         __FUNC_ENTER__;
252         int result = -1;
253         struct ug_data *ugd = (struct ug_data *) data;
254
255         result = wfd_wifi_off(ugd);
256         if (0 == result) {
257 #ifdef WFD_ON_OFF_GENLIST
258                 /* refresh the header */
259                 if (ugd->on_off_check) {
260                         elm_check_state_set(ugd->on_off_check, TRUE);
261                         elm_object_disabled_set(ugd->on_off_check, TRUE);
262                 }
263 #endif
264                 /* while activating/deactivating, disable the buttons */
265                 if (ugd->scan_toolbar) {
266                         wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", FALSE);
267                 }
268
269                 if (ugd->multiconn_scan_stop_btn) {
270                         wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
271                 }
272
273                 if (ugd->back_btn) {
274                         elm_object_disabled_set(ugd->back_btn, TRUE);
275                 }
276         }
277
278         evas_object_del(ugd->act_popup);
279         ugd->act_popup = NULL;
280         __FUNC_EXIT__;
281 }
282
283 /**
284  *      This function let the ug call it when click 'cancel' button in wifi action popup
285  *      @return   void
286  *      @param[in] data the pointer to the main data structure
287  *      @param[in] obj the pointer to the evas object
288  *      @param[in] event_info the pointer to the event information
289  */
290 static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object *obj, void *event_info)
291 {
292         __FUNC_ENTER__;
293         struct ug_data *ugd = (struct ug_data *) data;
294
295 #ifdef WFD_ON_OFF_GENLIST
296         wfd_ug_refresh_on_off_check(ugd);
297 #endif
298         evas_object_del(ugd->act_popup);
299         ugd->act_popup = NULL;
300         __FUNC_EXIT__;
301 }
302
303 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
304
305 gboolean _wfd_disconnect_idle_cb(gpointer user_data)
306 {
307         __FUNC_ENTER__;
308         GList *iterator = NULL;
309
310         struct ug_data *ugd = (struct ug_data *) user_data;
311         if (NULL == ugd) {
312                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
313                 return FALSE;
314         }
315         Evas_Object *content;
316         content = elm_object_part_content_unset(ugd->layout, "button.next");
317         WFD_IF_DEL_OBJ(content);
318
319         wfd_ug_view_init_genlist(ugd, true);
320
321         if (0 != wfd_client_disconnect(NULL)) {
322                 DBG(LOG_ERROR, "Disconnection Failed !!!\n");
323         }
324
325         ugd->wfd_discovery_status = WIFI_DIRECT_DISCOVERY_SOCIAL_CHANNEL_START;
326         discover_cb(WIFI_DIRECT_ERROR_NONE, WIFI_DIRECT_DISCOVERY_STARTED, ugd);
327
328         if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
329                 wfd_free_multi_selected_peers(ugd);
330         } else {
331                 /* update the connecting icon */
332                 for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
333                         ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_DISCONNECTED;
334                         wfd_ug_view_refresh_glitem(((device_type_s *)iterator->data)->gl_item);
335                 }
336         }
337
338         __FUNC_EXIT__;
339         return FALSE;
340 }
341
342 gboolean _wfd_cancel_connect_idle_cb(gpointer user_data)
343 {
344         __FUNC_ENTER__;
345
346         int res;
347         GList *iterator = NULL;
348         struct ug_data *ugd = (struct ug_data *) user_data;
349         if (NULL == ugd || NULL == ugd->mac_addr_connecting) {
350                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
351                 return FALSE;
352         }
353
354         res = wifi_direct_cancel_connection(ugd->mac_addr_connecting);
355         if (res != WIFI_DIRECT_ERROR_NONE) {
356                 DBG(LOG_ERROR, "Failed wifi_direct_cancel_connection() [%d]\n", res);
357                 return FALSE;
358         }
359
360         ugd->mac_addr_connecting = NULL;
361         if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
362                 if (ugd->raw_connected_peer_cnt > 0) {
363                         res = wifi_direct_disconnect_all();
364                         if (res != WIFI_DIRECT_ERROR_NONE) {
365                                 DBG(LOG_ERROR, "Failed wifi_direct_disconnect_all() [%d]\n", res);
366                                 return FALSE;
367                         }
368                 }
369
370                 wfd_free_multi_selected_peers(ugd);
371                 wfd_ug_view_init_genlist(ugd, true);
372         } else {
373                 /* update the connecting icon */
374                 for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
375                         ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_DISCONNECTED;
376                 }
377                 wfd_ug_view_init_genlist(ugd, false);
378         }
379
380         __FUNC_EXIT__;
381         return FALSE;
382 }
383
384 /**
385  *      This function let the ug call it when click 'ok' button in cancel connection popup
386  *      @return   void
387  *      @param[in] data the pointer to the main data structure
388  *      @param[in] obj the pointer to the evas object
389  *      @param[in] event_info the pointer to the event information
390  */
391 static void _wfd_ug_act_popup_cancel_connect_ok_cb(void *data, Evas_Object *obj, void *event_info)
392 {
393         __FUNC_ENTER__;
394
395         struct ug_data *ugd = (struct ug_data *) data;
396         if (NULL == ugd) {
397                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
398                 return;
399         }
400
401         evas_object_del(ugd->act_popup);
402         ugd->act_popup = NULL;
403
404         g_idle_add(_wfd_cancel_connect_idle_cb, ugd);
405
406         __FUNC_EXIT__;
407 }
408
409 /**
410  *      This function let the ug call it when click 'ok' button in disconnect all popup
411  *      @return   void
412  *      @param[in] data the pointer to the main data structure
413  *      @param[in] obj the pointer to the evas object
414  *      @param[in] event_info the pointer to the event information
415  */
416 static void _wfd_ug_act_popup_disconnect_all_ok_cb(void *data, Evas_Object *obj, void *event_info)
417 {
418         __FUNC_ENTER__;
419
420         struct ug_data *ugd = (struct ug_data *) data;
421         if (NULL == ugd) {
422                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
423                 return;
424         }
425
426         evas_object_del(ugd->act_popup);
427         ugd->act_popup = NULL;
428
429         g_idle_add(_wfd_disconnect_idle_cb, ugd);
430
431         __FUNC_EXIT__;
432 }
433
434 /**
435  *      This function let the ug call it when click 'cancel' button in disconnect all popup
436  *      @return   void
437  *      @param[in] data the pointer to the main data structure
438  *      @param[in] obj the pointer to the evas object
439  *      @param[in] event_info the pointer to the event information
440  */
441 static void _wfd_ug_act_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
442 {
443         __FUNC_ENTER__;
444
445         struct ug_data *ugd = (struct ug_data *) data;
446         if (NULL == ugd) {
447                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
448                 return;
449         }
450
451         evas_object_del(ugd->act_popup);
452         ugd->act_popup = NULL;
453
454         __FUNC_EXIT__;
455 }
456
457 void act_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
458 {
459         __FUNC_ENTER__;
460
461         int popup_type = (int)data;
462         Evas_Object *btn1 = NULL;
463         Evas_Object *btn2 = NULL;
464         struct ug_data *ugd = wfd_get_ug_data();
465
466         if (!ugd || !ugd->act_popup) {
467                 DBG(LOG_ERROR, "NULL parameters.\n");
468                 return;
469         }
470
471         btn1 = elm_object_part_content_get(ugd->act_popup, "button1");
472         btn2 = elm_object_part_content_get(ugd->act_popup, "button2");
473         elm_object_domain_translatable_text_set(btn1, PACKAGE,
474                         "IDS_BR_SK_CANCEL");
475         elm_object_domain_translatable_text_set(btn2, PACKAGE,
476                         "IDS_BR_SK_OK");
477
478         switch(popup_type) {
479
480         case POPUP_TYPE_HOTSPOT_OFF:
481                 elm_object_domain_translatable_text_set(btn1, PACKAGE,
482                                 "IDS_BR_SK_NO");
483                 elm_object_domain_translatable_text_set(btn2, PACKAGE,
484                                 "IDS_BR_SK_YES");
485                 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
486                                 "IDS_WIFI_BODY_USING_WI_FI_DIRECT_WILL_DISCONNECT_CURRENT_WI_FI_TETHERING_CONTINUE_Q");
487                 break;
488
489         case POP_TYPE_DISCONNECT:
490                 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
491                                 "IDS_WIFI_POP_CURRENT_CONNECTION_WILL_BE_DISCONNECTED_CONTINUE_Q");
492                 break;
493         case POP_TYPE_SCAN_AGAIN:
494                 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
495                                 "IDS_WIFI_BODY_CURRENT_CONNECTION_WILL_BE_DISCONNECTED_SO_THAT_SCANNING_CAN_START_CONTINUE_Q");
496                 break;
497         case POP_TYPE_CANCEL_CONNECT:
498                 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
499                                 "IDS_WIFI_POP_THIS_WI_FI_DIRECT_CONNECTION_WILL_BE_CANCELLED");
500                 break;
501         case POP_TYPE_ACCEPT_CONNECTION:
502                 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
503                                 "IDS_WIFI_BODY_PS_IS_REQUESTING_A_WI_FI_DIRECT_CONNECTION_ALLOW_Q");
504                 break;
505         default:
506                 break;
507         }
508
509         __FUNC_EXIT__;
510 }
511
512 /**
513  *      This function let the ug create a action popup
514  *      @return   void
515  *      @param[in] data the pointer to the main data structure
516  *      @param[in] message the pointer to the text of popup
517  *      @param[in] popup_type the message type
518  */
519 void wfd_ug_act_popup(void *data, const char *message, int popup_type)
520 {
521         __FUNC_ENTER__;
522         struct ug_data *ugd = (struct ug_data *) data;
523         Evas_Object *popup = NULL;
524         Evas_Object *btn1 = NULL, *btn2 = NULL;
525
526         WFD_IF_DEL_OBJ(ugd->act_popup);
527
528         popup = elm_popup_add(ugd->base);
529         elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
530         ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb, NULL);
531         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
532         elm_object_domain_translatable_part_text_set(popup, "title,text",
533                          PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
534         elm_object_domain_translatable_text_set(popup, PACKAGE, message);
535         evas_object_smart_callback_add(popup, "language,changed", act_popup_language_changed, (void *)popup_type);
536
537         btn1 = elm_button_add(popup);
538         btn2 = elm_button_add(popup);
539         elm_object_style_set(btn1, "popup");
540         elm_object_style_set(btn2, "popup");
541
542         /* set the different text by type */
543         if (
544 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
545                 popup_type == POPUP_TYPE_WIFI_OFF ||
546 #endif
547
548                 popup_type == POPUP_TYPE_HOTSPOT_OFF ||
549
550                 FALSE) {
551                 elm_object_domain_translatable_part_text_set(popup, "title,text",
552                                  PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
553                 elm_object_domain_translatable_text_set(btn1, PACKAGE,
554                                 "IDS_BR_SK_CANCEL");
555                 elm_object_domain_translatable_text_set(btn2, PACKAGE,
556                                 "IDS_ST_BUTTON_ENABLE");
557         } else if (popup_type == POP_TYPE_CANCEL_CONNECT) {
558                 elm_object_domain_translatable_text_set(btn1, PACKAGE,
559                                 "IDS_BR_SK_CANCEL");
560                 elm_object_domain_translatable_text_set(btn2, PACKAGE,
561                                 "IDS_WIFI_SK_STOP");
562         } else if (popup_type == POP_TYPE_DISCONNECT) {
563                 elm_object_domain_translatable_part_text_set(popup, "title,text",
564                                  PACKAGE, "IDS_WIFI_SK_DISCONNECT");
565                 elm_object_domain_translatable_text_set(btn1, PACKAGE,
566                                 "IDS_BR_SK_CANCEL");
567                 elm_object_domain_translatable_text_set(btn2, PACKAGE,
568                                 "IDS_BR_SK_OK");
569
570         } else if (popup_type == POP_TYPE_SCAN_AGAIN) {
571                 elm_object_domain_translatable_part_text_set(popup, "title,text",
572                                  PACKAGE, "IDS_WIFI_SK4_SCAN");
573                 elm_object_domain_translatable_text_set(btn1, PACKAGE,
574                                 "IDS_BR_SK_CANCEL");
575                 elm_object_domain_translatable_text_set(btn2, PACKAGE,
576                                 "IDS_BR_SK_OK");
577         } else if (popup_type == POP_TYPE_ACCEPT_CONNECTION) {
578                 elm_object_domain_translatable_part_text_set(popup, "title,text",
579                                  PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
580                 elm_object_domain_translatable_text_set(btn1, PACKAGE,
581                                 "IDS_BR_SK_CANCEL");
582                 elm_object_domain_translatable_text_set(btn2, PACKAGE,
583                                 "IDS_WIFI_SK_CONNECT");
584         } else {
585                 elm_object_domain_translatable_text_set(btn1, PACKAGE,
586                                 "IDS_BR_SK_CANCEL");
587                 elm_object_domain_translatable_text_set(btn2, PACKAGE,
588                                 "IDS_BR_SK_OK");
589         }
590
591         elm_object_part_content_set(popup, "button1", btn1);
592         elm_object_part_content_set(popup, "button2", btn2);
593
594         /* set the different callback by type */
595 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
596         if (popup_type == POPUP_TYPE_WIFI_OFF) {
597                 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_wifi_cb, (void *)ugd);
598 //              evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_wifi_cb, (void *)ugd);
599
600                 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_wifi_cancel_cb, (void *)ugd);
601                 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_wifi_ok_cb, (void *)ugd);
602         } else
603 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
604
605         if (popup_type == POPUP_TYPE_HOTSPOT_OFF) {
606                 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_hotspot_cb, (void *)ugd);
607 //              evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_hotspot_cb, (void *)ugd);
608
609                 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_hotspot_cancel_cb, (void *)ugd);
610                 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_hotspot_ok_cb, (void *)ugd);
611         } else
612
613         if (popup_type == POP_TYPE_DISCONNECT ||
614                 popup_type == POP_TYPE_SCAN_AGAIN) {
615                 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_disconnect_all_cb, (void *)ugd);
616 //              evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_disconnect_all_cb, (void *)ugd);
617
618                 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_cancel_cb, (void *)ugd);
619                 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_disconnect_all_ok_cb, (void *)ugd);
620         } else if (popup_type == POP_TYPE_CANCEL_CONNECT) {
621                 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_disconnect_all_cb, (void *)ugd);
622
623                 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_cancel_cb, (void *)ugd);
624                 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_cancel_connect_ok_cb, (void *)ugd);
625         } else if (popup_type == POP_TYPE_ACCEPT_CONNECTION ) {
626                 evas_object_smart_callback_add(btn1, "clicked",
627                                 pushbutton_reject_connect_cb, (void *)ugd);
628                 evas_object_smart_callback_add(btn2, "clicked",
629                                 pushbutton_accept_connect_cb, (void *)ugd);
630         }
631
632         evas_object_show(popup);
633         ugd->act_popup = popup;
634         __FUNC_EXIT__;
635 }
636
637 /**
638  *      This function let the ug remove the action popup
639  *      @return   void
640  *      @param[in] data the pointer to the main data structure
641  */
642 void wfg_ug_act_popup_remove(void *data)
643 {
644         __FUNC_ENTER__;
645         struct ug_data *ugd = (struct ug_data *) data;
646
647         if (ugd->act_popup) {
648                 evas_object_del(ugd->act_popup);
649                 ugd->act_popup = NULL;
650         }
651         __FUNC_EXIT__;
652 }
653
654 /**
655  *      This function let the ug call it when click 'ok' button in warning popup of terminated problem
656  *      @return   void
657  *      @param[in] data the pointer to the main data structure
658  *      @param[in] obj the pointer to the evas object
659  *      @param[in] event_info the pointer to the event information
660  */
661 static void _wfd_ug_terminate_popup_cb(void *data, Evas_Object *obj, void *event_info)
662 {
663         __FUNC_ENTER__;
664         struct ug_data *ugd = (struct ug_data *) data;
665
666         evas_object_del(ugd->warn_popup);
667         ugd->warn_popup = NULL;
668
669         wfd_ug_view_free_peers(ugd);
670
671         ug_destroy_me(ugd->ug);
672         __FUNC_EXIT__;
673 }
674
675 /**
676  *      This function let the ug call it when click 'ok' button in warning popup of turning off WFD automatically
677  *      @return   void
678  *      @param[in] data the pointer to the main data structure
679  *      @param[in] obj the pointer to the evas object
680  *      @param[in] event_info the pointer to the event information
681  */
682 /*static void _wfd_ug_automatic_turn_off_popup_cb(void *data, Evas_Object *obj, void *event_info)
683 {
684         __FUNC_ENTER__;
685         struct ug_data *ugd = (struct ug_data *) data;
686
687         evas_object_del(ugd->warn_popup);
688         ugd->warn_popup = NULL;
689
690         __FUNC_EXIT__;
691 }*/
692
693 /**
694  *      This function let the ug call it when click 'ok' button in warning popup
695  *      @return   void
696  *      @param[in] data the pointer to the main data structure
697  *      @param[in] obj the pointer to the evas object
698  *      @param[in] event_info the pointer to the event information
699  */
700 static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info)
701 {
702         __FUNC_ENTER__;
703         struct ug_data *ugd = (struct ug_data *) data;
704
705         evas_object_del(ugd->warn_popup);
706         ugd->warn_popup = NULL;
707
708         if (ugd->rename_entry) {
709                 elm_object_focus_set(ugd->rename_entry, EINA_TRUE);
710         }
711
712         __FUNC_EXIT__;
713 }
714
715 void warn_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
716 {
717         __FUNC_ENTER__;
718
719         int popup_type = (int)data;
720         struct ug_data *ugd = wfd_get_ug_data();
721         char popup_text[MAX_POPUP_TEXT_SIZE] = {0};
722         Evas_Object *btn = NULL;
723
724         if (!ugd || !ugd->warn_popup) {
725                 DBG(LOG_ERROR, "NULL parameters.\n");
726                 return;
727         }
728
729         btn = elm_object_part_content_get(ugd->warn_popup, "button1");
730         elm_object_domain_translatable_text_set(btn, PACKAGE,
731                         "IDS_BR_SK_OK");
732
733         switch(popup_type) {
734         case POPUP_TYPE_ACTIVATE_FAIL_POLICY_RESTRICTS:
735                 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
736                                 "IDS_COM_POP_SECURITY_POLICY_RESTRICTS_USE_OF_WI_FI");
737                 break;
738         case POPUP_TYPE_TERMINATE:
739                 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
740                                 "IDS_COM_POP_FAILED");
741                 break;
742         case POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL:
743                 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
744                                 "IDS_WIFI_POP_DEACTIVATION_FAILED");
745                 break;
746         case POPUP_TYPE_TERMINATE_NOT_SUPPORT:
747                 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
748                                 "IDS_ST_POP_NOT_SUPPORTED");
749                 break;
750         case POP_TYPE_BUSY_DEVICE_POPUP:
751                 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
752                                 "IDS_ST_POP_DEVICE_CONNECTED_TO_ANOTHER_DEVICE");
753                 break;
754         case POP_TYPE_MULTI_CONNECT_POPUP:
755                 snprintf(popup_text, MAX_POPUP_TEXT_SIZE, _("IDS_ST_POP_YOU_CAN_CONNECT_UP_TO_PD_DEVICES_AT_THE_SAME_TIME"), MAX_CONNECTED_PEER_NUM);
756                 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
757                                 popup_text);
758                 break;
759         default:
760                 break;
761         }
762
763         __FUNC_EXIT__;
764 }
765
766 /**
767  *      This function let the ug create a warning popup
768  *      @return   void
769  *      @param[in] data the pointer to the main data structure
770  *      @param[in] message the pointer to the text of popup
771  *      @param[in] popup_type the message type
772  */
773 void wfd_ug_warn_popup(void *data, const char *message, int popup_type)
774 {
775         __FUNC_ENTER__;
776         struct ug_data *ugd = (struct ug_data *) data;
777         Evas_Object *popup = NULL;
778         Evas_Object *btn = NULL;
779
780         popup = elm_popup_add(ugd->base);
781         elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
782         ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb, NULL);
783         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
784         if (popup_type == POP_TYPE_MULTI_CONNECT_POPUP ||
785                 popup_type == POP_TYPE_BUSY_DEVICE_POPUP) {
786                 elm_object_domain_translatable_part_text_set(popup, "title,text",
787                                  PACKAGE, "IDS_WIFI_HEADER_UNABLE_TO_CONNECT_ABB2");
788         } else {
789                 elm_object_domain_translatable_part_text_set(popup, "title,text",
790                                  PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
791         }
792         elm_object_domain_translatable_text_set(popup, PACKAGE, message);
793         evas_object_smart_callback_add(popup, "language,changed", warn_popup_language_changed, (void *)popup_type);
794
795         btn = elm_button_add(popup);
796         elm_object_style_set(btn, "popup");
797         elm_object_domain_translatable_text_set(btn, PACKAGE, "IDS_BR_SK_OK");
798         elm_object_part_content_set(popup, "button1", btn);
799         if (popup_type == POPUP_TYPE_TERMINATE ||
800                 popup_type == POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL ||
801                 popup_type == POPUP_TYPE_TERMINATE_NOT_SUPPORT) {
802                 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_terminate_popup_cb, (void *)ugd);
803         } else {
804                 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_warn_popup_cb, (void *)ugd);
805         }
806
807         evas_object_show(popup);
808         ugd->warn_popup = popup;
809         __FUNC_EXIT__;
810 }
811