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