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 <wifi-direct.h>
27 #include <efl_extension.h>
33 #include "wfd_ug_view.h"
34 #include "wfd_client.h"
36 static void delete_popup(void *data)
39 struct ug_data *ugd = (struct ug_data *) data;
41 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
45 evas_object_del(ugd->act_popup);
46 ugd->act_popup = NULL;
50 static void pushbutton_accept_connect_cb(void *data, Evas_Object * obj,
55 struct ug_data *ugd = (struct ug_data *) data;
57 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
61 result = wifi_direct_accept_connection(ugd->mac_addr_req);
62 if (result != WIFI_DIRECT_ERROR_NONE) {
63 DBG(LOG_INFO,"Failed to connect");
70 static void pushbutton_reject_connect_cb(void *data, Evas_Object * obj,
75 struct ug_data *ugd = (struct ug_data *) data;
77 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
81 if (ugd->mac_addr_req[0] != '\0') {
82 result = wifi_direct_reject_connection(ugd->mac_addr_req);
83 if (result != WIFI_DIRECT_ERROR_NONE)
84 DBG(LOG_INFO,"Failed to reject connection");
86 DBG(LOG_INFO,"No Peer mac address");
92 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
93 static void _mouseup_wifi_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
95 Evas_Event_Mouse_Up *ev = event_info;
96 if (ev->button == 3) {
97 struct ug_data *ugd = (struct ug_data *) data;
99 evas_object_del(ugd->act_popup);
100 ugd->act_popup = NULL;
104 static void _keydown_wifi_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
108 Evas_Event_Key_Down *ev = event_info;
109 if (!strcmp(ev->keyname, KEY_BACK)) {
110 struct ug_data *ugd = (struct ug_data *) data;
112 ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
113 wfd_ug_view_refresh_glitem(ugd->head);
115 evas_object_del(ugd->act_popup);
116 ugd->act_popup = NULL;
120 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
123 static void _mouseup_hotspot_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
125 Evas_Event_Mouse_Up *ev = event_info;
126 if (ev->button == 3) {
127 struct ug_data *ugd = (struct ug_data *) data;
129 #ifdef WFD_ON_OFF_GENLIST
130 wfd_ug_refresh_on_off_check(ugd);
132 evas_object_del(ugd->act_popup);
133 ugd->act_popup = NULL;
136 static void _keydown_hotspot_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
139 Evas_Event_Key_Down *ev = event_info;
140 if (!strcmp(ev->keyname, KEY_BACK)) {
141 struct ug_data *ugd = (struct ug_data *) data;
143 ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
144 wfd_ug_view_refresh_glitem(ugd->head);
146 evas_object_del(ugd->act_popup);
147 ugd->act_popup = NULL;
152 static void _mouseup_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
154 Evas_Event_Mouse_Up *ev = event_info;
155 if (ev->button == 3) {
156 struct ug_data *ugd = (struct ug_data *) data;
158 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
162 evas_object_del(ugd->act_popup);
163 ugd->act_popup = NULL;
167 /*static void _keydown_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
169 Evas_Event_Key_Down *ev = event_info;
170 if (!strcmp(ev->keyname, KEY_BACK)) {
171 struct ug_data *ugd = (struct ug_data *) data;
173 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
177 evas_object_del(ugd->act_popup);
178 ugd->act_popup = NULL;
184 * This function let the ug call it when click 'ok' button in hotspot action popup
186 * @param[in] data the pointer to the main data structure
187 * @param[in] obj the pointer to the evas object
188 * @param[in] event_info the pointer to the event information
190 static void _wfd_ug_act_popup_hotspot_ok_cb(void *data, Evas_Object *obj, void *event_info)
194 struct ug_data *ugd = (struct ug_data *) data;
196 result = wfd_mobile_ap_off(ugd);
198 #ifdef WFD_ON_OFF_GENLIST
199 /* refresh the header */
200 if (ugd->on_off_check) {
201 elm_check_state_set(ugd->on_off_check, TRUE);
202 elm_object_disabled_set(ugd->on_off_check, TRUE);
206 /* while activating/deactivating, disable the buttons */
207 if (ugd->scan_toolbar) {
208 wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", FALSE);
211 if (ugd->multiconn_scan_stop_btn) {
212 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
216 elm_object_disabled_set(ugd->back_btn, TRUE);
218 ugd->is_hotspot_locally_disabled = TRUE;
221 evas_object_del(ugd->act_popup);
222 ugd->act_popup = NULL;
227 * This function let the ug call it when click 'cancel' button in hotspot action popup
229 * @param[in] data the pointer to the main data structure
230 * @param[in] obj the pointer to the evas object
231 * @param[in] event_info the pointer to the event information
233 static void _wfd_ug_act_popup_hotspot_cancel_cb(void *data, Evas_Object *obj, void *event_info)
236 struct ug_data *ugd = (struct ug_data *) data;
238 #ifdef WFD_ON_OFF_GENLIST
239 wfd_ug_refresh_on_off_check(ugd);
242 wfd_client_destroy_tethering(ugd);
244 evas_object_del(ugd->act_popup);
245 ugd->act_popup = NULL;
249 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
251 * This function let the ug call it when click 'ok' button in wifi action popup
253 * @param[in] data the pointer to the main data structure
254 * @param[in] obj the pointer to the evas object
255 * @param[in] event_info the pointer to the event information
257 static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object *obj, void *event_info)
261 struct ug_data *ugd = (struct ug_data *) data;
263 result = wfd_wifi_off(ugd);
265 #ifdef WFD_ON_OFF_GENLIST
266 /* refresh the header */
267 if (ugd->on_off_check) {
268 elm_check_state_set(ugd->on_off_check, TRUE);
269 elm_object_disabled_set(ugd->on_off_check, TRUE);
272 /* while activating/deactivating, disable the buttons */
273 if (ugd->scan_toolbar) {
274 wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", FALSE);
277 if (ugd->multiconn_scan_stop_btn) {
278 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
282 elm_object_disabled_set(ugd->back_btn, TRUE);
286 evas_object_del(ugd->act_popup);
287 ugd->act_popup = NULL;
292 * This function let the ug call it when click 'cancel' button in wifi action popup
294 * @param[in] data the pointer to the main data structure
295 * @param[in] obj the pointer to the evas object
296 * @param[in] event_info the pointer to the event information
298 static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object *obj, void *event_info)
301 struct ug_data *ugd = (struct ug_data *) data;
303 #ifdef WFD_ON_OFF_GENLIST
304 wfd_ug_refresh_on_off_check(ugd);
306 evas_object_del(ugd->act_popup);
307 ugd->act_popup = NULL;
311 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
313 gboolean _wfd_disconnect_idle_cb(gpointer user_data)
316 GList *iterator = NULL;
318 struct ug_data *ugd = (struct ug_data *) user_data;
320 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
323 Evas_Object *content;
324 content = elm_object_part_content_unset(ugd->layout, "button.next");
325 WFD_IF_DEL_OBJ(content);
327 wfd_ug_view_init_genlist(ugd, true);
329 if (0 != wfd_client_disconnect(NULL)) {
330 DBG(LOG_ERROR, "Disconnection Failed !!!\n");
333 ugd->wfd_discovery_status = WIFI_DIRECT_DISCOVERY_SOCIAL_CHANNEL_START;
334 discover_cb(WIFI_DIRECT_ERROR_NONE, WIFI_DIRECT_DISCOVERY_STARTED, ugd);
336 if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
337 wfd_free_multi_selected_peers(ugd);
339 /* update the connecting icon */
340 for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
341 ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_DISCONNECTED;
342 wfd_ug_view_refresh_glitem(((device_type_s *)iterator->data)->gl_item);
350 gboolean _wfd_cancel_connect_idle_cb(gpointer user_data)
355 GList *iterator = NULL;
356 struct ug_data *ugd = (struct ug_data *) user_data;
357 if (NULL == ugd || NULL == ugd->mac_addr_connecting) {
358 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
362 res = wifi_direct_cancel_connection(ugd->mac_addr_connecting);
363 if (res != WIFI_DIRECT_ERROR_NONE) {
364 DBG(LOG_ERROR, "Failed wifi_direct_cancel_connection() [%d]\n", res);
368 ugd->mac_addr_connecting = NULL;
369 if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
370 if (ugd->raw_connected_peer_cnt > 0) {
371 res = wifi_direct_disconnect_all();
372 if (res != WIFI_DIRECT_ERROR_NONE) {
373 DBG(LOG_ERROR, "Failed wifi_direct_disconnect_all() [%d]\n", res);
378 wfd_free_multi_selected_peers(ugd);
379 wfd_ug_view_init_genlist(ugd, true);
381 /* update the connecting icon */
382 for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
383 ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_DISCONNECTED;
385 wfd_ug_view_init_genlist(ugd, false);
393 * This function let the ug call it when click 'ok' button in cancel connection popup
395 * @param[in] data the pointer to the main data structure
396 * @param[in] obj the pointer to the evas object
397 * @param[in] event_info the pointer to the event information
399 static void _wfd_ug_act_popup_cancel_connect_ok_cb(void *data, Evas_Object *obj, void *event_info)
403 struct ug_data *ugd = (struct ug_data *) data;
405 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
409 evas_object_del(ugd->act_popup);
410 ugd->act_popup = NULL;
412 g_idle_add(_wfd_cancel_connect_idle_cb, ugd);
418 * This function let the ug call it when click 'ok' button in disconnect all popup
420 * @param[in] data the pointer to the main data structure
421 * @param[in] obj the pointer to the evas object
422 * @param[in] event_info the pointer to the event information
424 static void _wfd_ug_act_popup_disconnect_all_ok_cb(void *data, Evas_Object *obj, void *event_info)
428 struct ug_data *ugd = (struct ug_data *) data;
430 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
434 evas_object_del(ugd->act_popup);
435 ugd->act_popup = NULL;
437 g_idle_add(_wfd_disconnect_idle_cb, ugd);
443 * This function let the ug call it when click 'cancel' button in disconnect all popup
445 * @param[in] data the pointer to the main data structure
446 * @param[in] obj the pointer to the evas object
447 * @param[in] event_info the pointer to the event information
449 static void _wfd_ug_act_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
453 struct ug_data *ugd = (struct ug_data *) data;
455 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
459 evas_object_del(ugd->act_popup);
460 ugd->act_popup = NULL;
465 void act_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
469 int popup_type = (int)data;
470 Evas_Object *btn1 = NULL;
471 Evas_Object *btn2 = NULL;
472 struct ug_data *ugd = wfd_get_ug_data();
474 if (!ugd || !ugd->act_popup) {
475 DBG(LOG_ERROR, "NULL parameters.\n");
479 btn1 = elm_object_part_content_get(ugd->act_popup, "button1");
480 btn2 = elm_object_part_content_get(ugd->act_popup, "button2");
481 elm_object_domain_translatable_text_set(btn1, PACKAGE,
483 elm_object_domain_translatable_text_set(btn2, PACKAGE,
488 case POPUP_TYPE_HOTSPOT_OFF:
489 elm_object_domain_translatable_text_set(btn1, PACKAGE,
491 elm_object_domain_translatable_text_set(btn2, PACKAGE,
493 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
494 "IDS_WIFI_BODY_USING_WI_FI_DIRECT_WILL_DISCONNECT_CURRENT_WI_FI_TETHERING_CONTINUE_Q");
497 case POP_TYPE_DISCONNECT:
498 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
499 "IDS_WIFI_POP_CURRENT_CONNECTION_WILL_BE_DISCONNECTED_CONTINUE_Q");
501 case POP_TYPE_SCAN_AGAIN:
502 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
503 "IDS_WIFI_BODY_CURRENT_CONNECTION_WILL_BE_DISCONNECTED_SO_THAT_SCANNING_CAN_START_CONTINUE_Q");
505 case POP_TYPE_CANCEL_CONNECT:
506 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
507 "IDS_WIFI_POP_THIS_WI_FI_DIRECT_CONNECTION_WILL_BE_CANCELLED");
509 case POP_TYPE_ACCEPT_CONNECTION:
510 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
511 "IDS_WIFI_BODY_PS_IS_REQUESTING_A_WI_FI_DIRECT_CONNECTION_ALLOW_Q");
521 * This function let the ug create a action popup
523 * @param[in] data the pointer to the main data structure
524 * @param[in] message the pointer to the text of popup
525 * @param[in] popup_type the message type
527 void wfd_ug_act_popup(void *data, const char *message, int popup_type)
530 struct ug_data *ugd = (struct ug_data *) data;
531 Evas_Object *popup = NULL;
532 Evas_Object *btn1 = NULL, *btn2 = NULL;
534 WFD_IF_DEL_OBJ(ugd->act_popup);
536 popup = elm_popup_add(ugd->base);
537 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
538 eext_object_event_callback_add(popup, EA_CALLBACK_BACK, eext_popup_back_cb, NULL);
539 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
540 elm_object_domain_translatable_part_text_set(popup, "title,text",
541 PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
542 elm_object_domain_translatable_text_set(popup, PACKAGE, message);
543 evas_object_smart_callback_add(popup, "language,changed", act_popup_language_changed, (void *)popup_type);
545 btn1 = elm_button_add(popup);
546 btn2 = elm_button_add(popup);
547 elm_object_style_set(btn1, "popup");
548 elm_object_style_set(btn2, "popup");
550 /* set the different text by type */
552 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
553 popup_type == POPUP_TYPE_WIFI_OFF ||
556 popup_type == POPUP_TYPE_HOTSPOT_OFF ||
559 elm_object_domain_translatable_part_text_set(popup, "title,text",
560 PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
561 elm_object_domain_translatable_text_set(btn1, PACKAGE,
563 elm_object_domain_translatable_text_set(btn2, PACKAGE,
564 "IDS_ST_BUTTON_ENABLE");
565 } else if (popup_type == POP_TYPE_CANCEL_CONNECT) {
566 elm_object_domain_translatable_text_set(btn1, PACKAGE,
568 elm_object_domain_translatable_text_set(btn2, PACKAGE,
570 } else if (popup_type == POP_TYPE_DISCONNECT) {
571 elm_object_domain_translatable_part_text_set(popup, "title,text",
572 PACKAGE, "IDS_WIFI_SK_DISCONNECT");
573 elm_object_domain_translatable_text_set(btn1, PACKAGE,
575 elm_object_domain_translatable_text_set(btn2, PACKAGE,
578 } else if (popup_type == POP_TYPE_SCAN_AGAIN) {
579 elm_object_domain_translatable_part_text_set(popup, "title,text",
580 PACKAGE, "IDS_WIFI_SK4_SCAN");
581 elm_object_domain_translatable_text_set(btn1, PACKAGE,
583 elm_object_domain_translatable_text_set(btn2, PACKAGE,
585 } else if (popup_type == POP_TYPE_ACCEPT_CONNECTION) {
586 elm_object_domain_translatable_part_text_set(popup, "title,text",
587 PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
588 elm_object_domain_translatable_text_set(btn1, PACKAGE,
590 elm_object_domain_translatable_text_set(btn2, PACKAGE,
591 "IDS_WIFI_SK_CONNECT");
593 elm_object_domain_translatable_text_set(btn1, PACKAGE,
595 elm_object_domain_translatable_text_set(btn2, PACKAGE,
599 elm_object_part_content_set(popup, "button1", btn1);
600 elm_object_part_content_set(popup, "button2", btn2);
602 /* set the different callback by type */
603 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
604 if (popup_type == POPUP_TYPE_WIFI_OFF) {
605 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_wifi_cb, (void *)ugd);
606 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_wifi_cb, (void *)ugd);
608 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_wifi_cancel_cb, (void *)ugd);
609 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_wifi_ok_cb, (void *)ugd);
611 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
613 if (popup_type == POPUP_TYPE_HOTSPOT_OFF) {
614 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_hotspot_cb, (void *)ugd);
615 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_hotspot_cb, (void *)ugd);
617 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_hotspot_cancel_cb, (void *)ugd);
618 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_hotspot_ok_cb, (void *)ugd);
621 if (popup_type == POP_TYPE_DISCONNECT ||
622 popup_type == POP_TYPE_SCAN_AGAIN) {
623 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_disconnect_all_cb, (void *)ugd);
624 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_disconnect_all_cb, (void *)ugd);
626 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_cancel_cb, (void *)ugd);
627 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_disconnect_all_ok_cb, (void *)ugd);
628 } else if (popup_type == POP_TYPE_CANCEL_CONNECT) {
629 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_disconnect_all_cb, (void *)ugd);
631 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_cancel_cb, (void *)ugd);
632 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_cancel_connect_ok_cb, (void *)ugd);
633 } else if (popup_type == POP_TYPE_ACCEPT_CONNECTION ) {
634 evas_object_smart_callback_add(btn1, "clicked",
635 pushbutton_reject_connect_cb, (void *)ugd);
636 evas_object_smart_callback_add(btn2, "clicked",
637 pushbutton_accept_connect_cb, (void *)ugd);
640 evas_object_show(popup);
641 ugd->act_popup = popup;
646 * This function let the ug remove the action popup
648 * @param[in] data the pointer to the main data structure
650 void wfg_ug_act_popup_remove(void *data)
653 struct ug_data *ugd = (struct ug_data *) data;
655 if (ugd->act_popup) {
656 evas_object_del(ugd->act_popup);
657 ugd->act_popup = NULL;
663 * This function let the ug call it when click 'ok' button in warning popup of terminated problem
665 * @param[in] data the pointer to the main data structure
666 * @param[in] obj the pointer to the evas object
667 * @param[in] event_info the pointer to the event information
669 static void _wfd_ug_terminate_popup_cb(void *data, Evas_Object *obj, void *event_info)
672 struct ug_data *ugd = (struct ug_data *) data;
674 evas_object_del(ugd->warn_popup);
675 ugd->warn_popup = NULL;
677 wfd_ug_view_free_peers(ugd);
679 ug_destroy_me(ugd->ug);
684 * This function let the ug call it when click 'ok' button in warning popup of turning off WFD automatically
686 * @param[in] data the pointer to the main data structure
687 * @param[in] obj the pointer to the evas object
688 * @param[in] event_info the pointer to the event information
690 /*static void _wfd_ug_automatic_turn_off_popup_cb(void *data, Evas_Object *obj, void *event_info)
693 struct ug_data *ugd = (struct ug_data *) data;
695 evas_object_del(ugd->warn_popup);
696 ugd->warn_popup = NULL;
702 * This function let the ug call it when click 'ok' button in warning popup
704 * @param[in] data the pointer to the main data structure
705 * @param[in] obj the pointer to the evas object
706 * @param[in] event_info the pointer to the event information
708 static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info)
711 struct ug_data *ugd = (struct ug_data *) data;
713 evas_object_del(ugd->warn_popup);
714 ugd->warn_popup = NULL;
716 if (ugd->rename_entry) {
717 elm_object_focus_set(ugd->rename_entry, EINA_TRUE);
723 void warn_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
727 int popup_type = (int)data;
728 struct ug_data *ugd = wfd_get_ug_data();
729 char popup_text[MAX_POPUP_TEXT_SIZE] = {0};
730 Evas_Object *btn = NULL;
732 if (!ugd || !ugd->warn_popup) {
733 DBG(LOG_ERROR, "NULL parameters.\n");
737 btn = elm_object_part_content_get(ugd->warn_popup, "button1");
738 elm_object_domain_translatable_text_set(btn, PACKAGE,
742 case POPUP_TYPE_ACTIVATE_FAIL_POLICY_RESTRICTS:
743 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
744 "IDS_COM_POP_SECURITY_POLICY_RESTRICTS_USE_OF_WI_FI");
746 case POPUP_TYPE_TERMINATE:
747 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
748 "IDS_COM_POP_FAILED");
750 case POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL:
751 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
752 "IDS_WIFI_POP_DEACTIVATION_FAILED");
754 case POPUP_TYPE_TERMINATE_NOT_SUPPORT:
755 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
756 "IDS_ST_POP_NOT_SUPPORTED");
758 case POP_TYPE_BUSY_DEVICE_POPUP:
759 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
760 "IDS_ST_POP_DEVICE_CONNECTED_TO_ANOTHER_DEVICE");
762 case POP_TYPE_MULTI_CONNECT_POPUP:
763 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);
764 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
775 * This function let the ug create a warning popup
777 * @param[in] data the pointer to the main data structure
778 * @param[in] message the pointer to the text of popup
779 * @param[in] popup_type the message type
781 void wfd_ug_warn_popup(void *data, const char *message, int popup_type)
784 struct ug_data *ugd = (struct ug_data *) data;
785 Evas_Object *popup = NULL;
786 Evas_Object *btn = NULL;
788 popup = elm_popup_add(ugd->base);
789 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
790 eext_object_event_callback_add(popup, EA_CALLBACK_BACK, eext_popup_back_cb, NULL);
791 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
792 if (popup_type == POP_TYPE_MULTI_CONNECT_POPUP ||
793 popup_type == POP_TYPE_BUSY_DEVICE_POPUP) {
794 elm_object_domain_translatable_part_text_set(popup, "title,text",
795 PACKAGE, "IDS_WIFI_HEADER_UNABLE_TO_CONNECT_ABB2");
797 elm_object_domain_translatable_part_text_set(popup, "title,text",
798 PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
800 elm_object_domain_translatable_text_set(popup, PACKAGE, message);
801 evas_object_smart_callback_add(popup, "language,changed", warn_popup_language_changed, (void *)popup_type);
803 btn = elm_button_add(popup);
804 elm_object_style_set(btn, "popup");
805 elm_object_domain_translatable_text_set(btn, PACKAGE, "IDS_BR_SK_OK");
806 elm_object_part_content_set(popup, "button1", btn);
807 if (popup_type == POPUP_TYPE_TERMINATE ||
808 popup_type == POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL ||
809 popup_type == POPUP_TYPE_TERMINATE_NOT_SUPPORT) {
810 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_terminate_popup_cb, (void *)ugd);
812 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_warn_popup_cb, (void *)ugd);
815 evas_object_show(popup);
816 ugd->warn_popup = popup;