4 * Copyright 2012 Samsung Electronics Co., Ltd
6 * Licensed under the Flora License, Version 1.1 (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);
206 if (ugd->multiconn_scan_stop_btn)
207 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
210 elm_object_disabled_set(ugd->back_btn, TRUE);
212 ugd->is_hotspot_locally_disabled = TRUE;
215 evas_object_del(ugd->act_popup);
216 ugd->act_popup = NULL;
221 * This function let the ug call it when click 'cancel' button in hotspot action popup
223 * @param[in] data the pointer to the main data structure
224 * @param[in] obj the pointer to the evas object
225 * @param[in] event_info the pointer to the event information
227 static void _wfd_ug_act_popup_hotspot_cancel_cb(void *data, Evas_Object *obj, void *event_info)
230 struct ug_data *ugd = (struct ug_data *) data;
232 #ifdef WFD_ON_OFF_GENLIST
233 wfd_ug_refresh_on_off_check(ugd);
236 wfd_client_destroy_tethering(ugd);
238 evas_object_del(ugd->act_popup);
239 ugd->act_popup = NULL;
243 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
245 * This function let the ug call it when click 'ok' button in wifi action popup
247 * @param[in] data the pointer to the main data structure
248 * @param[in] obj the pointer to the evas object
249 * @param[in] event_info the pointer to the event information
251 static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object *obj, void *event_info)
255 struct ug_data *ugd = (struct ug_data *) data;
257 result = wfd_wifi_off(ugd);
259 #ifdef WFD_ON_OFF_GENLIST
260 /* refresh the header */
261 if (ugd->on_off_check) {
262 elm_check_state_set(ugd->on_off_check, TRUE);
263 elm_object_disabled_set(ugd->on_off_check, TRUE);
266 /* while activating/deactivating, disable the buttons */
267 if (ugd->scan_toolbar)
268 wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", FALSE);
270 if (ugd->multiconn_scan_stop_btn)
271 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
274 elm_object_disabled_set(ugd->back_btn, TRUE);
277 evas_object_del(ugd->act_popup);
278 ugd->act_popup = NULL;
283 * This function let the ug call it when click 'cancel' button in wifi action popup
285 * @param[in] data the pointer to the main data structure
286 * @param[in] obj the pointer to the evas object
287 * @param[in] event_info the pointer to the event information
289 static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object *obj, void *event_info)
292 struct ug_data *ugd = (struct ug_data *) data;
294 #ifdef WFD_ON_OFF_GENLIST
295 wfd_ug_refresh_on_off_check(ugd);
297 evas_object_del(ugd->act_popup);
298 ugd->act_popup = NULL;
302 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
304 gboolean _wfd_disconnect_idle_cb(gpointer user_data)
307 GList *iterator = NULL;
309 struct ug_data *ugd = (struct ug_data *) user_data;
311 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
314 Evas_Object *content;
315 content = elm_object_part_content_unset(ugd->button_layout, "button.next");
316 WFD_IF_DEL_OBJ(content);
318 wfd_ug_view_init_genlist(ugd, true);
320 if (0 != wfd_client_disconnect(NULL))
321 DBG(LOG_ERROR, "Disconnection Failed !!!\n");
323 ugd->wfd_discovery_status = WIFI_DIRECT_DISCOVERY_SOCIAL_CHANNEL_START;
324 discover_cb(WIFI_DIRECT_ERROR_NONE, WIFI_DIRECT_DISCOVERY_STARTED, ugd);
326 if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
327 wfd_free_multi_selected_peers(ugd);
329 /* update the connecting icon */
330 for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
331 ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_DISCONNECTED;
332 wfd_ug_view_refresh_glitem(((device_type_s *)iterator->data)->gl_item);
340 gboolean _wfd_cancel_connect_idle_cb(gpointer user_data)
345 GList *iterator = NULL;
346 struct ug_data *ugd = (struct ug_data *) user_data;
347 if (NULL == ugd || NULL == ugd->mac_addr_connecting) {
348 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
352 res = wifi_direct_cancel_connection(ugd->mac_addr_connecting);
353 if (res != WIFI_DIRECT_ERROR_NONE) {
354 DBG(LOG_ERROR, "Failed wifi_direct_cancel_connection() [%d]\n", res);
358 ugd->mac_addr_connecting = NULL;
359 if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
360 if (ugd->raw_connected_peer_cnt > 0) {
361 res = wifi_direct_disconnect_all();
362 if (res != WIFI_DIRECT_ERROR_NONE) {
363 DBG(LOG_ERROR, "Failed wifi_direct_disconnect_all() [%d]\n", res);
368 wfd_free_multi_selected_peers(ugd);
369 wfd_ug_view_init_genlist(ugd, true);
371 /* update the connecting icon */
372 for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next)
373 ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_DISCONNECTED;
375 wfd_ug_view_init_genlist(ugd, false);
383 * This function let the ug call it when click 'ok' button in cancel connection popup
385 * @param[in] data the pointer to the main data structure
386 * @param[in] obj the pointer to the evas object
387 * @param[in] event_info the pointer to the event information
389 static void _wfd_ug_act_popup_cancel_connect_ok_cb(void *data, Evas_Object *obj, void *event_info)
393 struct ug_data *ugd = (struct ug_data *) data;
395 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
399 evas_object_del(ugd->act_popup);
400 ugd->act_popup = NULL;
402 g_idle_add(_wfd_cancel_connect_idle_cb, ugd);
408 * This function let the ug call it when click 'ok' button in disconnect all popup
410 * @param[in] data the pointer to the main data structure
411 * @param[in] obj the pointer to the evas object
412 * @param[in] event_info the pointer to the event information
414 static void _wfd_ug_act_popup_disconnect_all_ok_cb(void *data, Evas_Object *obj, void *event_info)
418 struct ug_data *ugd = (struct ug_data *) data;
420 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
424 evas_object_del(ugd->act_popup);
425 ugd->act_popup = NULL;
427 g_idle_add(_wfd_disconnect_idle_cb, ugd);
433 * This function let the ug call it when click 'cancel' button in disconnect all popup
435 * @param[in] data the pointer to the main data structure
436 * @param[in] obj the pointer to the evas object
437 * @param[in] event_info the pointer to the event information
439 static void _wfd_ug_act_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
443 struct ug_data *ugd = (struct ug_data *) data;
445 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
449 evas_object_del(ugd->act_popup);
450 ugd->act_popup = NULL;
455 void act_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
459 unsigned long int popup_type = (unsigned long int)data;
460 Evas_Object *btn1 = NULL;
461 Evas_Object *btn2 = NULL;
462 struct ug_data *ugd = wfd_get_ug_data();
464 if (!ugd || !ugd->act_popup) {
465 DBG(LOG_ERROR, "NULL parameters.\n");
469 btn1 = elm_object_part_content_get(ugd->act_popup, "button1");
470 btn2 = elm_object_part_content_get(ugd->act_popup, "button2");
471 elm_object_domain_translatable_text_set(btn1, PACKAGE,
473 elm_object_domain_translatable_text_set(btn2, PACKAGE,
476 switch (popup_type) {
478 case POPUP_TYPE_HOTSPOT_OFF:
479 elm_object_domain_translatable_text_set(btn1, PACKAGE,
481 elm_object_domain_translatable_text_set(btn2, PACKAGE,
483 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
484 "IDS_WIFI_BODY_USING_WI_FI_DIRECT_WILL_DISCONNECT_CURRENT_WI_FI_TETHERING_CONTINUE_Q");
487 case POP_TYPE_DISCONNECT:
488 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
489 "IDS_WIFI_POP_CURRENT_CONNECTION_WILL_BE_DISCONNECTED_CONTINUE_Q");
491 case POP_TYPE_SCAN_AGAIN:
492 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
493 "IDS_WIFI_BODY_CURRENT_CONNECTION_WILL_BE_DISCONNECTED_SO_THAT_SCANNING_CAN_START_CONTINUE_Q");
495 case POP_TYPE_CANCEL_CONNECT:
496 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
497 "IDS_WIFI_POP_THIS_WI_FI_DIRECT_CONNECTION_WILL_BE_CANCELLED");
499 case POP_TYPE_ACCEPT_CONNECTION:
500 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
501 "IDS_WIFI_BODY_PS_IS_REQUESTING_A_WI_FI_DIRECT_CONNECTION_ALLOW_Q");
511 * This function let the ug create a action popup
513 * @param[in] data the pointer to the main data structure
514 * @param[in] message the pointer to the text of popup
515 * @param[in] popup_type the message type
517 void wfd_ug_act_popup(void *data, const char *message, int popup_type)
520 struct ug_data *ugd = (struct ug_data *) data;
521 Evas_Object *popup = NULL;
522 Evas_Object *btn1 = NULL, *btn2 = NULL;
524 WFD_IF_DEL_OBJ(ugd->act_popup);
526 popup = elm_popup_add(ugd->base);
527 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
528 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
529 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
530 elm_object_domain_translatable_part_text_set(popup, "title,text",
531 PACKAGE, D_("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
532 elm_object_domain_translatable_text_set(popup, PACKAGE, message);
533 evas_object_smart_callback_add(popup, "language,changed", act_popup_language_changed,
534 (void *) (intptr_t) popup_type);
536 btn1 = elm_button_add(popup);
537 btn2 = elm_button_add(popup);
538 elm_object_style_set(btn1, "popup");
539 elm_object_style_set(btn2, "popup");
541 /* set the different text by type */
543 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
544 popup_type == POPUP_TYPE_WIFI_OFF ||
547 popup_type == POPUP_TYPE_HOTSPOT_OFF ||
550 elm_object_domain_translatable_part_text_set(popup, "title,text",
551 PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
552 elm_object_domain_translatable_text_set(btn1, PACKAGE,
554 elm_object_domain_translatable_text_set(btn2, PACKAGE,
555 "IDS_ST_BUTTON_ENABLE");
556 } else if (popup_type == POP_TYPE_CANCEL_CONNECT) {
557 elm_object_domain_translatable_text_set(btn1, PACKAGE,
559 elm_object_domain_translatable_text_set(btn2, PACKAGE,
561 } else if (popup_type == POP_TYPE_DISCONNECT) {
562 elm_object_domain_translatable_part_text_set(popup, "title,text",
563 PACKAGE, "IDS_WIFI_SK_DISCONNECT");
564 elm_object_domain_translatable_text_set(btn1, PACKAGE,
566 elm_object_domain_translatable_text_set(btn2, PACKAGE,
569 } else if (popup_type == POP_TYPE_SCAN_AGAIN) {
570 elm_object_domain_translatable_part_text_set(popup, "title,text",
571 PACKAGE, "IDS_WIFI_SK4_SCAN");
572 elm_object_domain_translatable_text_set(btn1, PACKAGE,
574 elm_object_domain_translatable_text_set(btn2, PACKAGE,
576 } else if (popup_type == POP_TYPE_ACCEPT_CONNECTION) {
577 elm_object_domain_translatable_part_text_set(popup, "title,text",
578 PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
579 elm_object_domain_translatable_text_set(btn1, PACKAGE,
581 elm_object_domain_translatable_text_set(btn2, PACKAGE,
582 "IDS_WIFI_SK_CONNECT");
584 elm_object_domain_translatable_text_set(btn1, PACKAGE,
586 elm_object_domain_translatable_text_set(btn2, PACKAGE,
590 elm_object_part_content_set(popup, "button1", btn1);
591 elm_object_part_content_set(popup, "button2", btn2);
593 /* set the different callback by type */
594 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
595 if (popup_type == POPUP_TYPE_WIFI_OFF) {
596 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_wifi_cb, (void *)ugd);
597 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_wifi_cb, (void *)ugd);
599 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_wifi_cancel_cb, (void *)ugd);
600 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_wifi_ok_cb, (void *)ugd);
602 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
604 if (popup_type == POPUP_TYPE_HOTSPOT_OFF) {
605 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_hotspot_cb, (void *)ugd);
606 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_hotspot_cb, (void *)ugd);
608 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_hotspot_cancel_cb, (void *)ugd);
609 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_hotspot_ok_cb, (void *)ugd);
612 if (popup_type == POP_TYPE_DISCONNECT ||
613 popup_type == POP_TYPE_SCAN_AGAIN) {
614 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_disconnect_all_cb, (void *)ugd);
615 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_disconnect_all_cb, (void *)ugd);
617 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_cancel_cb, (void *)ugd);
618 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_disconnect_all_ok_cb, (void *)ugd);
619 } else if (popup_type == POP_TYPE_CANCEL_CONNECT) {
620 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_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_cancel_connect_ok_cb, (void *)ugd);
624 } else if (popup_type == POP_TYPE_ACCEPT_CONNECTION) {
625 evas_object_smart_callback_add(btn1, "clicked",
626 pushbutton_reject_connect_cb, (void *)ugd);
627 evas_object_smart_callback_add(btn2, "clicked",
628 pushbutton_accept_connect_cb, (void *)ugd);
631 evas_object_show(popup);
632 ugd->act_popup = popup;
637 * This function let the ug remove the action popup
639 * @param[in] data the pointer to the main data structure
641 void wfg_ug_act_popup_remove(void *data)
644 struct ug_data *ugd = (struct ug_data *) data;
646 if (ugd->act_popup) {
647 evas_object_del(ugd->act_popup);
648 ugd->act_popup = NULL;
654 * This function let the ug call it when click 'ok' button in warning popup of terminated problem
656 * @param[in] data the pointer to the main data structure
657 * @param[in] obj the pointer to the evas object
658 * @param[in] event_info the pointer to the event information
660 static void _wfd_ug_terminate_popup_cb(void *data, Evas_Object *obj, void *event_info)
663 struct ug_data *ugd = (struct ug_data *) data;
665 evas_object_del(ugd->warn_popup);
666 ugd->warn_popup = NULL;
668 wfd_ug_view_free_peers(ugd);
670 ug_destroy_me(ugd->ug);
675 * This function let the ug call it when click 'ok' button in warning popup of turning off WFD automatically
677 * @param[in] data the pointer to the main data structure
678 * @param[in] obj the pointer to the evas object
679 * @param[in] event_info the pointer to the event information
681 /*static void _wfd_ug_automatic_turn_off_popup_cb(void *data, Evas_Object *obj, void *event_info)
684 struct ug_data *ugd = (struct ug_data *) data;
686 evas_object_del(ugd->warn_popup);
687 ugd->warn_popup = NULL;
693 * This function let the ug call it when click 'ok' button in warning popup
695 * @param[in] data the pointer to the main data structure
696 * @param[in] obj the pointer to the evas object
697 * @param[in] event_info the pointer to the event information
699 static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info)
702 struct ug_data *ugd = (struct ug_data *) data;
704 evas_object_del(ugd->warn_popup);
705 ugd->warn_popup = NULL;
707 if (ugd->rename_entry)
708 elm_object_focus_set(ugd->rename_entry, EINA_TRUE);
713 void warn_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
717 unsigned long int popup_type = (unsigned long int)data;
718 struct ug_data *ugd = wfd_get_ug_data();
719 char popup_text[MAX_POPUP_TEXT_SIZE] = {0};
720 Evas_Object *btn = NULL;
721 char *format_str = NULL;
723 if (!ugd || !ugd->warn_popup) {
724 DBG(LOG_ERROR, "NULL parameters.\n");
728 btn = elm_object_part_content_get(ugd->warn_popup, "button1");
729 elm_object_domain_translatable_text_set(btn, PACKAGE,
732 switch (popup_type) {
733 case POPUP_TYPE_ACTIVATE_FAIL_POLICY_RESTRICTS:
734 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
735 "IDS_COM_POP_SECURITY_POLICY_RESTRICTS_USE_OF_WI_FI");
737 case POPUP_TYPE_TERMINATE:
738 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
739 "IDS_COM_POP_FAILED");
741 case POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL:
742 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
743 "IDS_WIFI_POP_DEACTIVATION_FAILED");
745 case POPUP_TYPE_TERMINATE_NOT_SUPPORT:
746 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
747 "IDS_ST_POP_NOT_SUPPORTED");
749 case POP_TYPE_BUSY_DEVICE_POPUP:
750 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
751 "IDS_ST_POP_DEVICE_CONNECTED_TO_ANOTHER_DEVICE");
753 case POP_TYPE_MULTI_CONNECT_POPUP:
754 format_str = D_("IDS_ST_POP_YOU_CAN_CONNECT_UP_TO_PD_DEVICES_AT_THE_SAME_TIME");
755 snprintf(popup_text, MAX_POPUP_TEXT_SIZE, format_str, MAX_CONNECTED_PEER_NUM);
756 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
767 * This function let the ug create a warning popup
769 * @param[in] data the pointer to the main data structure
770 * @param[in] message the pointer to the text of popup
771 * @param[in] popup_type the message type
773 void wfd_ug_warn_popup(void *data, const char *message, int popup_type)
776 struct ug_data *ugd = (struct ug_data *) data;
777 Evas_Object *popup = NULL;
778 Evas_Object *btn = NULL;
780 popup = elm_popup_add(ugd->base);
781 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
782 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
783 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
784 if (popup_type == POP_TYPE_MULTI_CONNECT_POPUP ||
785 popup_type == POP_TYPE_BUSY_DEVICE_POPUP) {
786 elm_object_domain_translatable_part_text_set(popup, "title,text",
787 PACKAGE, "IDS_WIFI_HEADER_UNABLE_TO_CONNECT_ABB2");
789 elm_object_domain_translatable_part_text_set(popup, "title,text",
790 PACKAGE, D_("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
792 elm_object_domain_translatable_text_set(popup, PACKAGE, message);
793 evas_object_smart_callback_add(popup, "language,changed", warn_popup_language_changed,
794 (void *) (intptr_t) popup_type);
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);
805 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_warn_popup_cb, (void *)ugd);
808 evas_object_show(popup);
809 ugd->warn_popup = popup;