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