4 * Copyright 2012 Samsung Electronics Co., Ltd
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
10 * http://www.tizenopensource.org/license
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.
23 #include <Elementary.h>
25 #include <ui-gadget-module.h>
26 #include <efl_extension.h>
29 #include "wfd_ug_view.h"
30 #include "wfd_client.h"
32 #define KEY_BACK "XF86Back"
34 static void delete_popup(void *data)
37 struct ug_data *ugd = (struct ug_data *) data;
39 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
43 evas_object_del(ugd->act_popup);
44 ugd->act_popup = NULL;
48 static void pushbutton_accept_connect_cb(void *data, Evas_Object * obj,
53 struct ug_data *ugd = (struct ug_data *) data;
55 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
59 result = wifi_direct_accept_connection(ugd->mac_addr_req);
60 if (result != WIFI_DIRECT_ERROR_NONE) {
61 DBG(LOG_INFO,"Failed to connect");
68 static void pushbutton_reject_connect_cb(void *data, Evas_Object * obj,
73 struct ug_data *ugd = (struct ug_data *) data;
75 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
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");
84 DBG(LOG_INFO,"No Peer mac address");
90 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
91 static void _mouseup_wifi_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
93 Evas_Event_Mouse_Up *ev = event_info;
94 if (ev->button == 3) {
95 struct ug_data *ugd = (struct ug_data *) data;
97 evas_object_del(ugd->act_popup);
98 ugd->act_popup = NULL;
102 static void _keydown_wifi_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
104 Evas_Event_Key_Down *ev = event_info;
105 if (!strcmp(ev->keyname, KEY_BACK)) {
106 struct ug_data *ugd = (struct ug_data *) data;
108 ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
109 wfd_ug_view_refresh_glitem(ugd->head);
111 evas_object_del(ugd->act_popup);
112 ugd->act_popup = NULL;
115 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
118 static void _mouseup_hotspot_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
120 Evas_Event_Mouse_Up *ev = event_info;
121 if (ev->button == 3) {
122 struct ug_data *ugd = (struct ug_data *) data;
124 #ifdef WFD_ON_OFF_GENLIST
125 wfd_ug_refresh_on_off_check(ugd);
127 evas_object_del(ugd->act_popup);
128 ugd->act_popup = NULL;
133 static void _keydown_hotspot_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
135 Evas_Event_Key_Down *ev = event_info;
136 if (!strcmp(ev->keyname, KEY_BACK)) {
137 struct ug_data *ugd = (struct ug_data *) data;
139 ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
140 wfd_ug_view_refresh_glitem(ugd->head);
142 evas_object_del(ugd->act_popup);
143 ugd->act_popup = NULL;
148 static void _mouseup_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
150 Evas_Event_Mouse_Up *ev = event_info;
151 if (ev->button == 3) {
152 struct ug_data *ugd = (struct ug_data *) data;
154 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
158 evas_object_del(ugd->act_popup);
159 ugd->act_popup = NULL;
163 /*static void _keydown_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
165 Evas_Event_Key_Down *ev = event_info;
166 if (!strcmp(ev->keyname, KEY_BACK)) {
167 struct ug_data *ugd = (struct ug_data *) data;
169 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
173 evas_object_del(ugd->act_popup);
174 ugd->act_popup = NULL;
180 * This function let the ug call it when click 'ok' button in hotspot action popup
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
186 static void _wfd_ug_act_popup_hotspot_ok_cb(void *data, Evas_Object *obj, void *event_info)
190 struct ug_data *ugd = (struct ug_data *) data;
192 result = wfd_mobile_ap_off(ugd);
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);
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);
207 if (ugd->multiconn_scan_stop_btn) {
208 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
212 elm_object_disabled_set(ugd->back_btn, TRUE);
214 ugd->is_hotspot_locally_disabled = TRUE;
217 evas_object_del(ugd->act_popup);
218 ugd->act_popup = NULL;
223 * This function let the ug call it when click 'cancel' button in hotspot action popup
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
229 static void _wfd_ug_act_popup_hotspot_cancel_cb(void *data, Evas_Object *obj, void *event_info)
232 struct ug_data *ugd = (struct ug_data *) data;
234 #ifdef WFD_ON_OFF_GENLIST
235 wfd_ug_refresh_on_off_check(ugd);
238 wfd_client_destroy_tethering(ugd);
240 evas_object_del(ugd->act_popup);
241 ugd->act_popup = NULL;
245 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
247 * This function let the ug call it when click 'ok' button in wifi action popup
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
253 static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object *obj, void *event_info)
257 struct ug_data *ugd = (struct ug_data *) data;
259 result = wfd_wifi_off(ugd);
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);
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);
273 if (ugd->multiconn_scan_stop_btn) {
274 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
278 elm_object_disabled_set(ugd->back_btn, TRUE);
282 evas_object_del(ugd->act_popup);
283 ugd->act_popup = NULL;
288 * This function let the ug call it when click 'cancel' button in wifi action popup
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
294 static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object *obj, void *event_info)
297 struct ug_data *ugd = (struct ug_data *) data;
299 #ifdef WFD_ON_OFF_GENLIST
300 wfd_ug_refresh_on_off_check(ugd);
302 evas_object_del(ugd->act_popup);
303 ugd->act_popup = NULL;
307 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
309 gboolean _wfd_disconnect_idle_cb(gpointer user_data)
312 GList *iterator = NULL;
314 struct ug_data *ugd = (struct ug_data *) user_data;
316 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
319 Evas_Object *content;
320 content = elm_object_part_content_unset(ugd->button_layout, "button.next");
321 WFD_IF_DEL_OBJ(content);
323 wfd_ug_view_init_genlist(ugd, true);
325 if (0 != wfd_client_disconnect(NULL)) {
326 DBG(LOG_ERROR, "Disconnection Failed !!!\n");
329 ugd->wfd_discovery_status = WIFI_DIRECT_DISCOVERY_SOCIAL_CHANNEL_START;
330 discover_cb(WIFI_DIRECT_ERROR_NONE, WIFI_DIRECT_DISCOVERY_STARTED, ugd);
332 if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
333 wfd_free_multi_selected_peers(ugd);
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);
346 gboolean _wfd_cancel_connect_idle_cb(gpointer user_data)
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");
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);
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);
374 wfd_free_multi_selected_peers(ugd);
375 wfd_ug_view_init_genlist(ugd, true);
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;
381 wfd_ug_view_init_genlist(ugd, false);
389 * This function let the ug call it when click 'ok' button in cancel connection popup
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
395 static void _wfd_ug_act_popup_cancel_connect_ok_cb(void *data, Evas_Object *obj, void *event_info)
399 struct ug_data *ugd = (struct ug_data *) data;
401 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
405 evas_object_del(ugd->act_popup);
406 ugd->act_popup = NULL;
408 g_idle_add(_wfd_cancel_connect_idle_cb, ugd);
414 * This function let the ug call it when click 'ok' button in disconnect all popup
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
420 static void _wfd_ug_act_popup_disconnect_all_ok_cb(void *data, Evas_Object *obj, void *event_info)
424 struct ug_data *ugd = (struct ug_data *) data;
426 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
430 evas_object_del(ugd->act_popup);
431 ugd->act_popup = NULL;
433 g_idle_add(_wfd_disconnect_idle_cb, ugd);
439 * This function let the ug call it when click 'cancel' button in disconnect all popup
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
445 static void _wfd_ug_act_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
449 struct ug_data *ugd = (struct ug_data *) data;
451 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
455 evas_object_del(ugd->act_popup);
456 ugd->act_popup = NULL;
461 void act_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
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();
470 if (!ugd || !ugd->act_popup) {
471 DBG(LOG_ERROR, "NULL parameters.\n");
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,
479 elm_object_domain_translatable_text_set(btn2, PACKAGE,
484 case POPUP_TYPE_HOTSPOT_OFF:
485 elm_object_domain_translatable_text_set(btn1, PACKAGE,
487 elm_object_domain_translatable_text_set(btn2, PACKAGE,
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");
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");
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");
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");
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");
517 * This function let the ug create a action popup
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
523 void wfd_ug_act_popup(void *data, const char *message, int popup_type)
526 struct ug_data *ugd = (struct ug_data *) data;
527 Evas_Object *popup = NULL;
528 Evas_Object *btn1 = NULL, *btn2 = NULL;
530 WFD_IF_DEL_OBJ(ugd->act_popup);
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);
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");
546 /* set the different text by type */
548 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
549 popup_type == POPUP_TYPE_WIFI_OFF ||
552 popup_type == POPUP_TYPE_HOTSPOT_OFF ||
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,
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,
564 elm_object_domain_translatable_text_set(btn2, PACKAGE,
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,
571 elm_object_domain_translatable_text_set(btn2, PACKAGE,
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,
579 elm_object_domain_translatable_text_set(btn2, PACKAGE,
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,
586 elm_object_domain_translatable_text_set(btn2, PACKAGE,
587 "IDS_WIFI_SK_CONNECT");
589 elm_object_domain_translatable_text_set(btn1, PACKAGE,
591 elm_object_domain_translatable_text_set(btn2, PACKAGE,
595 elm_object_part_content_set(popup, "button1", btn1);
596 elm_object_part_content_set(popup, "button2", btn2);
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);
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);
607 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
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);
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);
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);
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);
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);
636 evas_object_show(popup);
637 ugd->act_popup = popup;
642 * This function let the ug remove the action popup
644 * @param[in] data the pointer to the main data structure
646 void wfg_ug_act_popup_remove(void *data)
649 struct ug_data *ugd = (struct ug_data *) data;
651 if (ugd->act_popup) {
652 evas_object_del(ugd->act_popup);
653 ugd->act_popup = NULL;
659 * This function let the ug call it when click 'ok' button in warning popup of terminated problem
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
665 static void _wfd_ug_terminate_popup_cb(void *data, Evas_Object *obj, void *event_info)
668 struct ug_data *ugd = (struct ug_data *) data;
670 evas_object_del(ugd->warn_popup);
671 ugd->warn_popup = NULL;
673 wfd_ug_view_free_peers(ugd);
675 ug_destroy_me(ugd->ug);
680 * This function let the ug call it when click 'ok' button in warning popup of turning off WFD automatically
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
686 /*static void _wfd_ug_automatic_turn_off_popup_cb(void *data, Evas_Object *obj, void *event_info)
689 struct ug_data *ugd = (struct ug_data *) data;
691 evas_object_del(ugd->warn_popup);
692 ugd->warn_popup = NULL;
698 * This function let the ug call it when click 'ok' button in warning popup
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
704 static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info)
707 struct ug_data *ugd = (struct ug_data *) data;
709 evas_object_del(ugd->warn_popup);
710 ugd->warn_popup = NULL;
712 if (ugd->rename_entry) {
713 elm_object_focus_set(ugd->rename_entry, EINA_TRUE);
719 void warn_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
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;
728 if (!ugd || !ugd->warn_popup) {
729 DBG(LOG_ERROR, "NULL parameters.\n");
733 btn = elm_object_part_content_get(ugd->warn_popup, "button1");
734 elm_object_domain_translatable_text_set(btn, PACKAGE,
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");
742 case POPUP_TYPE_TERMINATE:
743 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
744 "IDS_COM_POP_FAILED");
746 case POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL:
747 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
748 "IDS_WIFI_POP_DEACTIVATION_FAILED");
750 case POPUP_TYPE_TERMINATE_NOT_SUPPORT:
751 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
752 "IDS_ST_POP_NOT_SUPPORTED");
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");
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,
771 * This function let the ug create a warning popup
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
777 void wfd_ug_warn_popup(void *data, const char *message, int popup_type)
780 struct ug_data *ugd = (struct ug_data *) data;
781 Evas_Object *popup = NULL;
782 Evas_Object *btn = NULL;
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");
793 elm_object_domain_translatable_part_text_set(popup, "title,text",
794 PACKAGE, D_("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
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);
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);
808 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_warn_popup_cb, (void *)ugd);
811 evas_object_show(popup);
812 ugd->warn_popup = popup;