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;
131 static void _keydown_hotspot_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
133 Evas_Event_Key_Down *ev = event_info;
134 if (!strcmp(ev->keyname, KEY_BACK)) {
135 struct ug_data *ugd = (struct ug_data *) data;
137 ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
138 wfd_ug_view_refresh_glitem(ugd->head);
140 evas_object_del(ugd->act_popup);
141 ugd->act_popup = NULL;
145 static void _mouseup_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
147 Evas_Event_Mouse_Up *ev = event_info;
148 if (ev->button == 3) {
149 struct ug_data *ugd = (struct ug_data *) data;
151 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
155 evas_object_del(ugd->act_popup);
156 ugd->act_popup = NULL;
160 /*static void _keydown_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
162 Evas_Event_Key_Down *ev = event_info;
163 if (!strcmp(ev->keyname, KEY_BACK)) {
164 struct ug_data *ugd = (struct ug_data *) data;
166 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
170 evas_object_del(ugd->act_popup);
171 ugd->act_popup = NULL;
177 * This function let the ug call it when click 'ok' button in hotspot action popup
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
183 static void _wfd_ug_act_popup_hotspot_ok_cb(void *data, Evas_Object *obj, void *event_info)
187 struct ug_data *ugd = (struct ug_data *) data;
189 result = wfd_mobile_ap_off(ugd);
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);
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);
204 if (ugd->multiconn_scan_stop_btn) {
205 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
209 elm_object_disabled_set(ugd->back_btn, TRUE);
211 ugd->is_hotspot_locally_disabled = TRUE;
214 evas_object_del(ugd->act_popup);
215 ugd->act_popup = NULL;
220 * This function let the ug call it when click 'cancel' button in hotspot action popup
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
226 static void _wfd_ug_act_popup_hotspot_cancel_cb(void *data, Evas_Object *obj, void *event_info)
229 struct ug_data *ugd = (struct ug_data *) data;
231 #ifdef WFD_ON_OFF_GENLIST
232 wfd_ug_refresh_on_off_check(ugd);
235 wfd_client_destroy_tethering(ugd);
237 evas_object_del(ugd->act_popup);
238 ugd->act_popup = NULL;
242 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
244 * This function let the ug call it when click 'ok' button in wifi action popup
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
250 static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object *obj, void *event_info)
254 struct ug_data *ugd = (struct ug_data *) data;
256 result = wfd_wifi_off(ugd);
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);
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);
270 if (ugd->multiconn_scan_stop_btn) {
271 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
275 elm_object_disabled_set(ugd->back_btn, TRUE);
279 evas_object_del(ugd->act_popup);
280 ugd->act_popup = NULL;
285 * This function let the ug call it when click 'cancel' button in wifi action popup
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
291 static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object *obj, void *event_info)
294 struct ug_data *ugd = (struct ug_data *) data;
296 #ifdef WFD_ON_OFF_GENLIST
297 wfd_ug_refresh_on_off_check(ugd);
299 evas_object_del(ugd->act_popup);
300 ugd->act_popup = NULL;
304 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
306 gboolean _wfd_disconnect_idle_cb(gpointer user_data)
309 GList *iterator = NULL;
311 struct ug_data *ugd = (struct ug_data *) user_data;
313 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
316 Evas_Object *content;
317 content = elm_object_part_content_unset(ugd->button_layout, "button.next");
318 WFD_IF_DEL_OBJ(content);
320 wfd_ug_view_init_genlist(ugd, true);
322 if (0 != wfd_client_disconnect(NULL)) {
323 DBG(LOG_ERROR, "Disconnection Failed !!!\n");
326 ugd->wfd_discovery_status = WIFI_DIRECT_DISCOVERY_SOCIAL_CHANNEL_START;
327 discover_cb(WIFI_DIRECT_ERROR_NONE, WIFI_DIRECT_DISCOVERY_STARTED, ugd);
329 if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
330 wfd_free_multi_selected_peers(ugd);
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);
343 gboolean _wfd_cancel_connect_idle_cb(gpointer user_data)
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");
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);
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);
371 wfd_free_multi_selected_peers(ugd);
372 wfd_ug_view_init_genlist(ugd, true);
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;
378 wfd_ug_view_init_genlist(ugd, false);
386 * This function let the ug call it when click 'ok' button in cancel connection popup
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
392 static void _wfd_ug_act_popup_cancel_connect_ok_cb(void *data, Evas_Object *obj, void *event_info)
396 struct ug_data *ugd = (struct ug_data *) data;
398 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
402 evas_object_del(ugd->act_popup);
403 ugd->act_popup = NULL;
405 g_idle_add(_wfd_cancel_connect_idle_cb, ugd);
411 * This function let the ug call it when click 'ok' button in disconnect all popup
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
417 static void _wfd_ug_act_popup_disconnect_all_ok_cb(void *data, Evas_Object *obj, void *event_info)
421 struct ug_data *ugd = (struct ug_data *) data;
423 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
427 evas_object_del(ugd->act_popup);
428 ugd->act_popup = NULL;
430 g_idle_add(_wfd_disconnect_idle_cb, ugd);
436 * This function let the ug call it when click 'cancel' button in disconnect all popup
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
442 static void _wfd_ug_act_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
446 struct ug_data *ugd = (struct ug_data *) data;
448 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
452 evas_object_del(ugd->act_popup);
453 ugd->act_popup = NULL;
458 void act_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
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();
467 if (!ugd || !ugd->act_popup) {
468 DBG(LOG_ERROR, "NULL parameters.\n");
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,
476 elm_object_domain_translatable_text_set(btn2, PACKAGE,
481 case POPUP_TYPE_HOTSPOT_OFF:
482 elm_object_domain_translatable_text_set(btn1, PACKAGE,
484 elm_object_domain_translatable_text_set(btn2, PACKAGE,
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");
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");
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");
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");
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");
514 * This function let the ug create a action popup
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
520 void wfd_ug_act_popup(void *data, const char *message, int popup_type)
523 struct ug_data *ugd = (struct ug_data *) data;
524 Evas_Object *popup = NULL;
525 Evas_Object *btn1 = NULL, *btn2 = NULL;
527 WFD_IF_DEL_OBJ(ugd->act_popup);
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);
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");
543 /* set the different text by type */
545 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
546 popup_type == POPUP_TYPE_WIFI_OFF ||
549 popup_type == POPUP_TYPE_HOTSPOT_OFF ||
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,
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,
561 elm_object_domain_translatable_text_set(btn2, PACKAGE,
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,
568 elm_object_domain_translatable_text_set(btn2, PACKAGE,
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,
576 elm_object_domain_translatable_text_set(btn2, PACKAGE,
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,
583 elm_object_domain_translatable_text_set(btn2, PACKAGE,
584 "IDS_WIFI_SK_CONNECT");
586 elm_object_domain_translatable_text_set(btn1, PACKAGE,
588 elm_object_domain_translatable_text_set(btn2, PACKAGE,
592 elm_object_part_content_set(popup, "button1", btn1);
593 elm_object_part_content_set(popup, "button2", btn2);
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);
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);
604 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
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);
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);
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);
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);
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);
633 evas_object_show(popup);
634 ugd->act_popup = popup;
639 * This function let the ug remove the action popup
641 * @param[in] data the pointer to the main data structure
643 void wfg_ug_act_popup_remove(void *data)
646 struct ug_data *ugd = (struct ug_data *) data;
648 if (ugd->act_popup) {
649 evas_object_del(ugd->act_popup);
650 ugd->act_popup = NULL;
656 * This function let the ug call it when click 'ok' button in warning popup of terminated problem
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
662 static void _wfd_ug_terminate_popup_cb(void *data, Evas_Object *obj, void *event_info)
665 struct ug_data *ugd = (struct ug_data *) data;
667 evas_object_del(ugd->warn_popup);
668 ugd->warn_popup = NULL;
670 wfd_ug_view_free_peers(ugd);
672 ug_destroy_me(ugd->ug);
677 * This function let the ug call it when click 'ok' button in warning popup of turning off WFD automatically
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
683 /*static void _wfd_ug_automatic_turn_off_popup_cb(void *data, Evas_Object *obj, void *event_info)
686 struct ug_data *ugd = (struct ug_data *) data;
688 evas_object_del(ugd->warn_popup);
689 ugd->warn_popup = NULL;
695 * This function let the ug call it when click 'ok' button in warning popup
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
701 static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info)
704 struct ug_data *ugd = (struct ug_data *) data;
706 evas_object_del(ugd->warn_popup);
707 ugd->warn_popup = NULL;
709 if (ugd->rename_entry) {
710 elm_object_focus_set(ugd->rename_entry, EINA_TRUE);
716 void warn_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
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;
725 if (!ugd || !ugd->warn_popup) {
726 DBG(LOG_ERROR, "NULL parameters.\n");
730 btn = elm_object_part_content_get(ugd->warn_popup, "button1");
731 elm_object_domain_translatable_text_set(btn, PACKAGE,
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");
739 case POPUP_TYPE_TERMINATE:
740 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
741 "IDS_COM_POP_FAILED");
743 case POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL:
744 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
745 "IDS_WIFI_POP_DEACTIVATION_FAILED");
747 case POPUP_TYPE_TERMINATE_NOT_SUPPORT:
748 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
749 "IDS_ST_POP_NOT_SUPPORTED");
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");
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,
768 * This function let the ug create a warning popup
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
774 void wfd_ug_warn_popup(void *data, const char *message, int popup_type)
777 struct ug_data *ugd = (struct ug_data *) data;
778 Evas_Object *popup = NULL;
779 Evas_Object *btn = NULL;
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");
790 elm_object_domain_translatable_part_text_set(popup, "title,text",
791 PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
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);
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;