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>
30 #include "wfd_ug_view.h"
31 #include "wfd_client.h"
33 #define KEY_BACK "XF86Back"
35 static void delete_popup(void *data)
38 struct ug_data *ugd = (struct ug_data *) data;
40 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
44 evas_object_del(ugd->act_popup);
45 ugd->act_popup = NULL;
49 static void pushbutton_accept_connect_cb(void *data, Evas_Object * obj,
54 struct ug_data *ugd = (struct ug_data *) data;
56 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
60 result = wifi_direct_accept_connection(ugd->mac_addr_req);
61 if (result != WIFI_DIRECT_ERROR_NONE) {
62 DBG(LOG_INFO,"Failed to connect");
69 static void pushbutton_reject_connect_cb(void *data, Evas_Object * obj,
74 struct ug_data *ugd = (struct ug_data *) data;
76 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
80 if (ugd->mac_addr_req[0] != '\0') {
81 result = wifi_direct_reject_connection(ugd->mac_addr_req);
82 if (result != WIFI_DIRECT_ERROR_NONE)
83 DBG(LOG_INFO,"Failed to reject connection");
85 DBG(LOG_INFO,"No Peer mac address");
91 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
92 static void _mouseup_wifi_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
94 Evas_Event_Mouse_Up *ev = event_info;
95 if (ev->button == 3) {
96 struct ug_data *ugd = (struct ug_data *) data;
98 evas_object_del(ugd->act_popup);
99 ugd->act_popup = NULL;
103 static void _keydown_wifi_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
106 Evas_Event_Key_Down *ev = event_info;
107 if (!strcmp(ev->keyname, KEY_BACK)) {
108 struct ug_data *ugd = (struct ug_data *) data;
110 ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
111 wfd_ug_view_refresh_glitem(ugd->head);
113 evas_object_del(ugd->act_popup);
114 ugd->act_popup = NULL;
117 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
120 static void _mouseup_hotspot_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
122 Evas_Event_Mouse_Up *ev = event_info;
123 if (ev->button == 3) {
124 struct ug_data *ugd = (struct ug_data *) data;
126 #ifdef WFD_ON_OFF_GENLIST
127 wfd_ug_refresh_on_off_check(ugd);
129 evas_object_del(ugd->act_popup);
130 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;
147 static void _mouseup_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
149 Evas_Event_Mouse_Up *ev = event_info;
150 if (ev->button == 3) {
151 struct ug_data *ugd = (struct ug_data *) data;
153 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
157 evas_object_del(ugd->act_popup);
158 ugd->act_popup = NULL;
162 /*static void _keydown_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
164 Evas_Event_Key_Down *ev = event_info;
165 if (!strcmp(ev->keyname, KEY_BACK)) {
166 struct ug_data *ugd = (struct ug_data *) data;
168 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
172 evas_object_del(ugd->act_popup);
173 ugd->act_popup = NULL;
179 * This function let the ug call it when click 'ok' button in hotspot action popup
181 * @param[in] data the pointer to the main data structure
182 * @param[in] obj the pointer to the evas object
183 * @param[in] event_info the pointer to the event information
185 static void _wfd_ug_act_popup_hotspot_ok_cb(void *data, Evas_Object *obj, void *event_info)
189 struct ug_data *ugd = (struct ug_data *) data;
191 result = wfd_mobile_ap_off(ugd);
193 #ifdef WFD_ON_OFF_GENLIST
194 /* refresh the header */
195 if (ugd->on_off_check) {
196 elm_check_state_set(ugd->on_off_check, TRUE);
197 elm_object_disabled_set(ugd->on_off_check, TRUE);
201 /* while activating/deactivating, disable the buttons */
202 if (ugd->scan_toolbar) {
203 wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", FALSE);
206 if (ugd->multiconn_scan_stop_btn) {
207 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
211 elm_object_disabled_set(ugd->back_btn, TRUE);
213 ugd->is_hotspot_locally_disabled = TRUE;
216 evas_object_del(ugd->act_popup);
217 ugd->act_popup = NULL;
222 * This function let the ug call it when click 'cancel' button in hotspot action popup
224 * @param[in] data the pointer to the main data structure
225 * @param[in] obj the pointer to the evas object
226 * @param[in] event_info the pointer to the event information
228 static void _wfd_ug_act_popup_hotspot_cancel_cb(void *data, Evas_Object *obj, void *event_info)
231 struct ug_data *ugd = (struct ug_data *) data;
233 #ifdef WFD_ON_OFF_GENLIST
234 wfd_ug_refresh_on_off_check(ugd);
237 wfd_client_destroy_tethering(ugd);
239 evas_object_del(ugd->act_popup);
240 ugd->act_popup = NULL;
244 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
246 * This function let the ug call it when click 'ok' button in wifi action popup
248 * @param[in] data the pointer to the main data structure
249 * @param[in] obj the pointer to the evas object
250 * @param[in] event_info the pointer to the event information
252 static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object *obj, void *event_info)
256 struct ug_data *ugd = (struct ug_data *) data;
258 result = wfd_wifi_off(ugd);
260 #ifdef WFD_ON_OFF_GENLIST
261 /* refresh the header */
262 if (ugd->on_off_check) {
263 elm_check_state_set(ugd->on_off_check, TRUE);
264 elm_object_disabled_set(ugd->on_off_check, TRUE);
267 /* while activating/deactivating, disable the buttons */
268 if (ugd->scan_toolbar) {
269 wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", FALSE);
272 if (ugd->multiconn_scan_stop_btn) {
273 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
277 elm_object_disabled_set(ugd->back_btn, TRUE);
281 evas_object_del(ugd->act_popup);
282 ugd->act_popup = NULL;
287 * This function let the ug call it when click 'cancel' button in wifi action popup
289 * @param[in] data the pointer to the main data structure
290 * @param[in] obj the pointer to the evas object
291 * @param[in] event_info the pointer to the event information
293 static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object *obj, void *event_info)
296 struct ug_data *ugd = (struct ug_data *) data;
298 #ifdef WFD_ON_OFF_GENLIST
299 wfd_ug_refresh_on_off_check(ugd);
301 evas_object_del(ugd->act_popup);
302 ugd->act_popup = NULL;
306 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
308 gboolean _wfd_disconnect_idle_cb(gpointer user_data)
311 GList *iterator = NULL;
313 struct ug_data *ugd = (struct ug_data *) user_data;
315 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
318 Evas_Object *content;
319 content = elm_object_part_content_unset(ugd->layout, "button.next");
320 WFD_IF_DEL_OBJ(content);
322 wfd_ug_view_init_genlist(ugd, true);
324 if (0 != wfd_client_disconnect(NULL)) {
325 DBG(LOG_ERROR, "Disconnection Failed !!!\n");
328 ugd->wfd_discovery_status = WIFI_DIRECT_DISCOVERY_SOCIAL_CHANNEL_START;
329 discover_cb(WIFI_DIRECT_ERROR_NONE, WIFI_DIRECT_DISCOVERY_STARTED, ugd);
331 if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
332 wfd_free_multi_selected_peers(ugd);
334 /* update the connecting icon */
335 for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
336 ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_DISCONNECTED;
337 wfd_ug_view_refresh_glitem(((device_type_s *)iterator->data)->gl_item);
345 gboolean _wfd_cancel_connect_idle_cb(gpointer user_data)
350 GList *iterator = NULL;
351 struct ug_data *ugd = (struct ug_data *) user_data;
352 if (NULL == ugd || NULL == ugd->mac_addr_connecting) {
353 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
357 res = wifi_direct_cancel_connection(ugd->mac_addr_connecting);
358 if (res != WIFI_DIRECT_ERROR_NONE) {
359 DBG(LOG_ERROR, "Failed wifi_direct_cancel_connection() [%d]\n", res);
363 ugd->mac_addr_connecting = NULL;
364 if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
365 if (ugd->raw_connected_peer_cnt > 0) {
366 res = wifi_direct_disconnect_all();
367 if (res != WIFI_DIRECT_ERROR_NONE) {
368 DBG(LOG_ERROR, "Failed wifi_direct_disconnect_all() [%d]\n", res);
373 wfd_free_multi_selected_peers(ugd);
374 wfd_ug_view_init_genlist(ugd, true);
376 /* update the connecting icon */
377 for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
378 ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_DISCONNECTED;
380 wfd_ug_view_init_genlist(ugd, false);
388 * This function let the ug call it when click 'ok' button in cancel connection popup
390 * @param[in] data the pointer to the main data structure
391 * @param[in] obj the pointer to the evas object
392 * @param[in] event_info the pointer to the event information
394 static void _wfd_ug_act_popup_cancel_connect_ok_cb(void *data, Evas_Object *obj, void *event_info)
398 struct ug_data *ugd = (struct ug_data *) data;
400 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
404 evas_object_del(ugd->act_popup);
405 ugd->act_popup = NULL;
407 g_idle_add(_wfd_cancel_connect_idle_cb, ugd);
413 * This function let the ug call it when click 'ok' button in disconnect all popup
415 * @param[in] data the pointer to the main data structure
416 * @param[in] obj the pointer to the evas object
417 * @param[in] event_info the pointer to the event information
419 static void _wfd_ug_act_popup_disconnect_all_ok_cb(void *data, Evas_Object *obj, void *event_info)
423 struct ug_data *ugd = (struct ug_data *) data;
425 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
429 evas_object_del(ugd->act_popup);
430 ugd->act_popup = NULL;
432 g_idle_add(_wfd_disconnect_idle_cb, ugd);
438 * This function let the ug call it when click 'cancel' button in disconnect all popup
440 * @param[in] data the pointer to the main data structure
441 * @param[in] obj the pointer to the evas object
442 * @param[in] event_info the pointer to the event information
444 static void _wfd_ug_act_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
448 struct ug_data *ugd = (struct ug_data *) data;
450 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
454 evas_object_del(ugd->act_popup);
455 ugd->act_popup = NULL;
460 void act_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
464 int popup_type = (int)data;
465 Evas_Object *btn1 = NULL;
466 Evas_Object *btn2 = NULL;
467 struct ug_data *ugd = wfd_get_ug_data();
469 if (!ugd || !ugd->act_popup) {
470 DBG(LOG_ERROR, "NULL parameters.\n");
474 btn1 = elm_object_part_content_get(ugd->act_popup, "button1");
475 btn2 = elm_object_part_content_get(ugd->act_popup, "button2");
476 elm_object_domain_translatable_text_set(btn1, PACKAGE,
478 elm_object_domain_translatable_text_set(btn2, PACKAGE,
483 case POPUP_TYPE_HOTSPOT_OFF:
484 elm_object_domain_translatable_text_set(btn1, PACKAGE,
486 elm_object_domain_translatable_text_set(btn2, PACKAGE,
488 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
489 "IDS_WIFI_BODY_USING_WI_FI_DIRECT_WILL_DISCONNECT_CURRENT_WI_FI_TETHERING_CONTINUE_Q");
492 case POP_TYPE_DISCONNECT:
493 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
494 "IDS_WIFI_POP_CURRENT_CONNECTION_WILL_BE_DISCONNECTED_CONTINUE_Q");
496 case POP_TYPE_SCAN_AGAIN:
497 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
498 "IDS_WIFI_BODY_CURRENT_CONNECTION_WILL_BE_DISCONNECTED_SO_THAT_SCANNING_CAN_START_CONTINUE_Q");
500 case POP_TYPE_CANCEL_CONNECT:
501 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
502 "IDS_WIFI_POP_THIS_WI_FI_DIRECT_CONNECTION_WILL_BE_CANCELLED");
504 case POP_TYPE_ACCEPT_CONNECTION:
505 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
506 "IDS_WIFI_BODY_PS_IS_REQUESTING_A_WI_FI_DIRECT_CONNECTION_ALLOW_Q");
516 * This function let the ug create a action popup
518 * @param[in] data the pointer to the main data structure
519 * @param[in] message the pointer to the text of popup
520 * @param[in] popup_type the message type
522 void wfd_ug_act_popup(void *data, const char *message, int popup_type)
525 struct ug_data *ugd = (struct ug_data *) data;
526 Evas_Object *popup = NULL;
527 Evas_Object *btn1 = NULL, *btn2 = NULL;
529 WFD_IF_DEL_OBJ(ugd->act_popup);
531 popup = elm_popup_add(ugd->base);
532 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
533 eext_object_event_callback_add(popup, EA_CALLBACK_BACK, eext_popup_back_cb, NULL);
534 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
535 elm_object_domain_translatable_part_text_set(popup, "title,text",
536 PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
537 elm_object_domain_translatable_text_set(popup, PACKAGE, message);
538 evas_object_smart_callback_add(popup, "language,changed", act_popup_language_changed, (void *)popup_type);
540 btn1 = elm_button_add(popup);
541 btn2 = elm_button_add(popup);
542 elm_object_style_set(btn1, "popup");
543 elm_object_style_set(btn2, "popup");
545 /* set the different text by type */
547 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
548 popup_type == POPUP_TYPE_WIFI_OFF ||
551 popup_type == POPUP_TYPE_HOTSPOT_OFF ||
554 elm_object_domain_translatable_part_text_set(popup, "title,text",
555 PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
556 elm_object_domain_translatable_text_set(btn1, PACKAGE,
558 elm_object_domain_translatable_text_set(btn2, PACKAGE,
559 "IDS_ST_BUTTON_ENABLE");
560 } else if (popup_type == POP_TYPE_CANCEL_CONNECT) {
561 elm_object_domain_translatable_text_set(btn1, PACKAGE,
563 elm_object_domain_translatable_text_set(btn2, PACKAGE,
565 } else if (popup_type == POP_TYPE_DISCONNECT) {
566 elm_object_domain_translatable_part_text_set(popup, "title,text",
567 PACKAGE, "IDS_WIFI_SK_DISCONNECT");
568 elm_object_domain_translatable_text_set(btn1, PACKAGE,
570 elm_object_domain_translatable_text_set(btn2, PACKAGE,
573 } else if (popup_type == POP_TYPE_SCAN_AGAIN) {
574 elm_object_domain_translatable_part_text_set(popup, "title,text",
575 PACKAGE, "IDS_WIFI_SK4_SCAN");
576 elm_object_domain_translatable_text_set(btn1, PACKAGE,
578 elm_object_domain_translatable_text_set(btn2, PACKAGE,
580 } else if (popup_type == POP_TYPE_ACCEPT_CONNECTION) {
581 elm_object_domain_translatable_part_text_set(popup, "title,text",
582 PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
583 elm_object_domain_translatable_text_set(btn1, PACKAGE,
585 elm_object_domain_translatable_text_set(btn2, PACKAGE,
586 "IDS_WIFI_SK_CONNECT");
588 elm_object_domain_translatable_text_set(btn1, PACKAGE,
590 elm_object_domain_translatable_text_set(btn2, PACKAGE,
594 elm_object_part_content_set(popup, "button1", btn1);
595 elm_object_part_content_set(popup, "button2", btn2);
597 /* set the different callback by type */
598 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
599 if (popup_type == POPUP_TYPE_WIFI_OFF) {
600 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_wifi_cb, (void *)ugd);
601 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_wifi_cb, (void *)ugd);
603 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_wifi_cancel_cb, (void *)ugd);
604 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_wifi_ok_cb, (void *)ugd);
606 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
608 if (popup_type == POPUP_TYPE_HOTSPOT_OFF) {
609 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_hotspot_cb, (void *)ugd);
610 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_hotspot_cb, (void *)ugd);
612 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_hotspot_cancel_cb, (void *)ugd);
613 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_hotspot_ok_cb, (void *)ugd);
616 if (popup_type == POP_TYPE_DISCONNECT ||
617 popup_type == POP_TYPE_SCAN_AGAIN) {
618 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_disconnect_all_cb, (void *)ugd);
619 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_disconnect_all_cb, (void *)ugd);
621 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_cancel_cb, (void *)ugd);
622 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_disconnect_all_ok_cb, (void *)ugd);
623 } else if (popup_type == POP_TYPE_CANCEL_CONNECT) {
624 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_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_cancel_connect_ok_cb, (void *)ugd);
628 } else if (popup_type == POP_TYPE_ACCEPT_CONNECTION ) {
629 evas_object_smart_callback_add(btn1, "clicked",
630 pushbutton_reject_connect_cb, (void *)ugd);
631 evas_object_smart_callback_add(btn2, "clicked",
632 pushbutton_accept_connect_cb, (void *)ugd);
635 evas_object_show(popup);
636 ugd->act_popup = popup;
641 * This function let the ug remove the action popup
643 * @param[in] data the pointer to the main data structure
645 void wfg_ug_act_popup_remove(void *data)
648 struct ug_data *ugd = (struct ug_data *) data;
650 if (ugd->act_popup) {
651 evas_object_del(ugd->act_popup);
652 ugd->act_popup = NULL;
658 * This function let the ug call it when click 'ok' button in warning popup of terminated problem
660 * @param[in] data the pointer to the main data structure
661 * @param[in] obj the pointer to the evas object
662 * @param[in] event_info the pointer to the event information
664 static void _wfd_ug_terminate_popup_cb(void *data, Evas_Object *obj, void *event_info)
667 struct ug_data *ugd = (struct ug_data *) data;
669 evas_object_del(ugd->warn_popup);
670 ugd->warn_popup = NULL;
672 wfd_ug_view_free_peers(ugd);
674 ug_destroy_me(ugd->ug);
679 * This function let the ug call it when click 'ok' button in warning popup of turning off WFD automatically
681 * @param[in] data the pointer to the main data structure
682 * @param[in] obj the pointer to the evas object
683 * @param[in] event_info the pointer to the event information
685 /*static void _wfd_ug_automatic_turn_off_popup_cb(void *data, Evas_Object *obj, void *event_info)
688 struct ug_data *ugd = (struct ug_data *) data;
690 evas_object_del(ugd->warn_popup);
691 ugd->warn_popup = NULL;
697 * This function let the ug call it when click 'ok' button in warning popup
699 * @param[in] data the pointer to the main data structure
700 * @param[in] obj the pointer to the evas object
701 * @param[in] event_info the pointer to the event information
703 static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info)
706 struct ug_data *ugd = (struct ug_data *) data;
708 evas_object_del(ugd->warn_popup);
709 ugd->warn_popup = NULL;
711 if (ugd->rename_entry) {
712 elm_object_focus_set(ugd->rename_entry, EINA_TRUE);
718 void warn_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
722 int popup_type = (int)data;
723 struct ug_data *ugd = wfd_get_ug_data();
724 char popup_text[MAX_POPUP_TEXT_SIZE] = {0};
725 Evas_Object *btn = NULL;
727 if (!ugd || !ugd->warn_popup) {
728 DBG(LOG_ERROR, "NULL parameters.\n");
732 btn = elm_object_part_content_get(ugd->warn_popup, "button1");
733 elm_object_domain_translatable_text_set(btn, PACKAGE,
737 case POPUP_TYPE_ACTIVATE_FAIL_POLICY_RESTRICTS:
738 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
739 "IDS_COM_POP_SECURITY_POLICY_RESTRICTS_USE_OF_WI_FI");
741 case POPUP_TYPE_TERMINATE:
742 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
743 "IDS_COM_POP_FAILED");
745 case POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL:
746 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
747 "IDS_WIFI_POP_DEACTIVATION_FAILED");
749 case POPUP_TYPE_TERMINATE_NOT_SUPPORT:
750 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
751 "IDS_ST_POP_NOT_SUPPORTED");
753 case POP_TYPE_BUSY_DEVICE_POPUP:
754 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
755 "IDS_ST_POP_DEVICE_CONNECTED_TO_ANOTHER_DEVICE");
757 case POP_TYPE_MULTI_CONNECT_POPUP:
758 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);
759 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
770 * This function let the ug create a warning popup
772 * @param[in] data the pointer to the main data structure
773 * @param[in] message the pointer to the text of popup
774 * @param[in] popup_type the message type
776 void wfd_ug_warn_popup(void *data, const char *message, int popup_type)
779 struct ug_data *ugd = (struct ug_data *) data;
780 Evas_Object *popup = NULL;
781 Evas_Object *btn = NULL;
783 popup = elm_popup_add(ugd->base);
784 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
785 eext_object_event_callback_add(popup, EA_CALLBACK_BACK, eext_popup_back_cb, NULL);
786 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
787 if (popup_type == POP_TYPE_MULTI_CONNECT_POPUP ||
788 popup_type == POP_TYPE_BUSY_DEVICE_POPUP) {
789 elm_object_domain_translatable_part_text_set(popup, "title,text",
790 PACKAGE, "IDS_WIFI_HEADER_UNABLE_TO_CONNECT_ABB2");
792 elm_object_domain_translatable_part_text_set(popup, "title,text",
793 PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
795 elm_object_domain_translatable_text_set(popup, PACKAGE, message);
796 evas_object_smart_callback_add(popup, "language,changed", warn_popup_language_changed, (void *)popup_type);
798 btn = elm_button_add(popup);
799 elm_object_style_set(btn, "popup");
800 elm_object_domain_translatable_text_set(btn, PACKAGE, "IDS_BR_SK_OK");
801 elm_object_part_content_set(popup, "button1", btn);
802 if (popup_type == POPUP_TYPE_TERMINATE ||
803 popup_type == POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL ||
804 popup_type == POPUP_TYPE_TERMINATE_NOT_SUPPORT) {
805 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_terminate_popup_cb, (void *)ugd);
807 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_warn_popup_cb, (void *)ugd);
810 evas_object_show(popup);
811 ugd->warn_popup = popup;