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>
30 #include "wfd_ug_view.h"
31 #include "wfd_client.h"
33 static void delete_popup(void *data)
36 struct ug_data *ugd = (struct ug_data *) data;
38 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
42 evas_object_del(ugd->act_popup);
43 ugd->act_popup = NULL;
47 static void pushbutton_accept_connect_cb(void *data, Evas_Object * obj,
52 struct ug_data *ugd = (struct ug_data *) data;
54 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
58 result = wifi_direct_accept_connection(ugd->mac_addr_req);
59 if (result != WIFI_DIRECT_ERROR_NONE) {
60 DBG(LOG_INFO,"Failed to connect");
67 static void pushbutton_reject_connect_cb(void *data, Evas_Object * obj,
72 struct ug_data *ugd = (struct ug_data *) data;
74 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
78 if (ugd->mac_addr_req[0] != '\0') {
79 result = wifi_direct_reject_connection(ugd->mac_addr_req);
80 if (result != WIFI_DIRECT_ERROR_NONE)
81 DBG(LOG_INFO,"Failed to reject connection");
83 DBG(LOG_INFO,"No Peer mac address");
89 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
90 static void _mouseup_wifi_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
92 Evas_Event_Mouse_Up *ev = event_info;
93 if (ev->button == 3) {
94 struct ug_data *ugd = (struct ug_data *) data;
96 evas_object_del(ugd->act_popup);
97 ugd->act_popup = NULL;
101 static void _keydown_wifi_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
103 Evas_Event_Key_Down *ev = event_info;
104 if (!strcmp(ev->keyname, KEY_BACK)) {
105 struct ug_data *ugd = (struct ug_data *) data;
107 ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
108 wfd_ug_view_refresh_glitem(ugd->head);
110 evas_object_del(ugd->act_popup);
111 ugd->act_popup = NULL;
114 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
117 static void _mouseup_hotspot_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
119 Evas_Event_Mouse_Up *ev = event_info;
120 if (ev->button == 3) {
121 struct ug_data *ugd = (struct ug_data *) data;
123 #ifdef WFD_ON_OFF_GENLIST
124 wfd_ug_refresh_on_off_check(ugd);
126 evas_object_del(ugd->act_popup);
127 ugd->act_popup = NULL;
130 static void _keydown_hotspot_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
132 Evas_Event_Key_Down *ev = event_info;
133 if (!strcmp(ev->keyname, KEY_BACK)) {
134 struct ug_data *ugd = (struct ug_data *) data;
136 ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT;
137 wfd_ug_view_refresh_glitem(ugd->head);
139 evas_object_del(ugd->act_popup);
140 ugd->act_popup = NULL;
144 static void _mouseup_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
146 Evas_Event_Mouse_Up *ev = event_info;
147 if (ev->button == 3) {
148 struct ug_data *ugd = (struct ug_data *) data;
150 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
154 evas_object_del(ugd->act_popup);
155 ugd->act_popup = NULL;
159 /*static void _keydown_disconnect_all_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
161 Evas_Event_Key_Down *ev = event_info;
162 if (!strcmp(ev->keyname, KEY_BACK)) {
163 struct ug_data *ugd = (struct ug_data *) data;
165 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
169 evas_object_del(ugd->act_popup);
170 ugd->act_popup = NULL;
176 * This function let the ug call it when click 'ok' button in hotspot action popup
178 * @param[in] data the pointer to the main data structure
179 * @param[in] obj the pointer to the evas object
180 * @param[in] event_info the pointer to the event information
182 static void _wfd_ug_act_popup_hotspot_ok_cb(void *data, Evas_Object *obj, void *event_info)
186 struct ug_data *ugd = (struct ug_data *) data;
188 result = wfd_mobile_ap_off(ugd);
190 #ifdef WFD_ON_OFF_GENLIST
191 /* refresh the header */
192 if (ugd->on_off_check) {
193 elm_check_state_set(ugd->on_off_check, TRUE);
194 elm_object_disabled_set(ugd->on_off_check, TRUE);
198 /* while activating/deactivating, disable the buttons */
199 if (ugd->scan_toolbar) {
200 wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", FALSE);
203 if (ugd->multiconn_scan_stop_btn) {
204 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
208 elm_object_disabled_set(ugd->back_btn, TRUE);
210 ugd->is_hotspot_locally_disabled = TRUE;
213 evas_object_del(ugd->act_popup);
214 ugd->act_popup = NULL;
219 * This function let the ug call it when click 'cancel' button in hotspot action popup
221 * @param[in] data the pointer to the main data structure
222 * @param[in] obj the pointer to the evas object
223 * @param[in] event_info the pointer to the event information
225 static void _wfd_ug_act_popup_hotspot_cancel_cb(void *data, Evas_Object *obj, void *event_info)
228 struct ug_data *ugd = (struct ug_data *) data;
230 #ifdef WFD_ON_OFF_GENLIST
231 wfd_ug_refresh_on_off_check(ugd);
234 wfd_client_destroy_tethering(ugd);
236 evas_object_del(ugd->act_popup);
237 ugd->act_popup = NULL;
241 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
243 * This function let the ug call it when click 'ok' button in wifi action popup
245 * @param[in] data the pointer to the main data structure
246 * @param[in] obj the pointer to the evas object
247 * @param[in] event_info the pointer to the event information
249 static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object *obj, void *event_info)
253 struct ug_data *ugd = (struct ug_data *) data;
255 result = wfd_wifi_off(ugd);
257 #ifdef WFD_ON_OFF_GENLIST
258 /* refresh the header */
259 if (ugd->on_off_check) {
260 elm_check_state_set(ugd->on_off_check, TRUE);
261 elm_object_disabled_set(ugd->on_off_check, TRUE);
264 /* while activating/deactivating, disable the buttons */
265 if (ugd->scan_toolbar) {
266 wfd_ug_view_refresh_button(ugd->scan_toolbar, "IDS_WIFI_SK4_SCAN", FALSE);
269 if (ugd->multiconn_scan_stop_btn) {
270 wfd_ug_view_refresh_button(ugd->multiconn_scan_stop_btn, "IDS_WIFI_SK4_SCAN", FALSE);
274 elm_object_disabled_set(ugd->back_btn, TRUE);
278 evas_object_del(ugd->act_popup);
279 ugd->act_popup = NULL;
284 * This function let the ug call it when click 'cancel' button in wifi action popup
286 * @param[in] data the pointer to the main data structure
287 * @param[in] obj the pointer to the evas object
288 * @param[in] event_info the pointer to the event information
290 static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object *obj, void *event_info)
293 struct ug_data *ugd = (struct ug_data *) data;
295 #ifdef WFD_ON_OFF_GENLIST
296 wfd_ug_refresh_on_off_check(ugd);
298 evas_object_del(ugd->act_popup);
299 ugd->act_popup = NULL;
303 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
305 gboolean _wfd_disconnect_idle_cb(gpointer user_data)
308 GList *iterator = NULL;
310 struct ug_data *ugd = (struct ug_data *) user_data;
312 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
315 Evas_Object *content;
316 content = elm_object_part_content_unset(ugd->layout, "button.next");
317 WFD_IF_DEL_OBJ(content);
319 wfd_ug_view_init_genlist(ugd, true);
321 if (0 != wfd_client_disconnect(NULL)) {
322 DBG(LOG_ERROR, "Disconnection Failed !!!\n");
325 ugd->wfd_discovery_status = WIFI_DIRECT_DISCOVERY_SOCIAL_CHANNEL_START;
326 discover_cb(WIFI_DIRECT_ERROR_NONE, WIFI_DIRECT_DISCOVERY_STARTED, ugd);
328 if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
329 wfd_free_multi_selected_peers(ugd);
331 /* update the connecting icon */
332 for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
333 ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_DISCONNECTED;
334 wfd_ug_view_refresh_glitem(((device_type_s *)iterator->data)->gl_item);
342 gboolean _wfd_cancel_connect_idle_cb(gpointer user_data)
347 GList *iterator = NULL;
348 struct ug_data *ugd = (struct ug_data *) user_data;
349 if (NULL == ugd || NULL == ugd->mac_addr_connecting) {
350 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
354 res = wifi_direct_cancel_connection(ugd->mac_addr_connecting);
355 if (res != WIFI_DIRECT_ERROR_NONE) {
356 DBG(LOG_ERROR, "Failed wifi_direct_cancel_connection() [%d]\n", res);
360 ugd->mac_addr_connecting = NULL;
361 if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) {
362 if (ugd->raw_connected_peer_cnt > 0) {
363 res = wifi_direct_disconnect_all();
364 if (res != WIFI_DIRECT_ERROR_NONE) {
365 DBG(LOG_ERROR, "Failed wifi_direct_disconnect_all() [%d]\n", res);
370 wfd_free_multi_selected_peers(ugd);
371 wfd_ug_view_init_genlist(ugd, true);
373 /* update the connecting icon */
374 for (iterator = ugd->raw_discovered_peer_list; iterator; iterator = iterator->next) {
375 ((device_type_s *)iterator->data)->conn_status = PEER_CONN_STATUS_DISCONNECTED;
377 wfd_ug_view_init_genlist(ugd, false);
385 * This function let the ug call it when click 'ok' button in cancel connection popup
387 * @param[in] data the pointer to the main data structure
388 * @param[in] obj the pointer to the evas object
389 * @param[in] event_info the pointer to the event information
391 static void _wfd_ug_act_popup_cancel_connect_ok_cb(void *data, Evas_Object *obj, void *event_info)
395 struct ug_data *ugd = (struct ug_data *) data;
397 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
401 evas_object_del(ugd->act_popup);
402 ugd->act_popup = NULL;
404 g_idle_add(_wfd_cancel_connect_idle_cb, ugd);
410 * This function let the ug call it when click 'ok' button in disconnect all popup
412 * @param[in] data the pointer to the main data structure
413 * @param[in] obj the pointer to the evas object
414 * @param[in] event_info the pointer to the event information
416 static void _wfd_ug_act_popup_disconnect_all_ok_cb(void *data, Evas_Object *obj, void *event_info)
420 struct ug_data *ugd = (struct ug_data *) data;
422 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
426 evas_object_del(ugd->act_popup);
427 ugd->act_popup = NULL;
429 g_idle_add(_wfd_disconnect_idle_cb, ugd);
435 * This function let the ug call it when click 'cancel' button in disconnect all popup
437 * @param[in] data the pointer to the main data structure
438 * @param[in] obj the pointer to the evas object
439 * @param[in] event_info the pointer to the event information
441 static void _wfd_ug_act_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
445 struct ug_data *ugd = (struct ug_data *) data;
447 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
451 evas_object_del(ugd->act_popup);
452 ugd->act_popup = NULL;
457 void act_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
461 int popup_type = (int)data;
462 Evas_Object *btn1 = NULL;
463 Evas_Object *btn2 = NULL;
464 struct ug_data *ugd = wfd_get_ug_data();
466 if (!ugd || !ugd->act_popup) {
467 DBG(LOG_ERROR, "NULL parameters.\n");
471 btn1 = elm_object_part_content_get(ugd->act_popup, "button1");
472 btn2 = elm_object_part_content_get(ugd->act_popup, "button2");
473 elm_object_domain_translatable_text_set(btn1, PACKAGE,
475 elm_object_domain_translatable_text_set(btn2, PACKAGE,
480 case POPUP_TYPE_HOTSPOT_OFF:
481 elm_object_domain_translatable_text_set(btn1, PACKAGE,
483 elm_object_domain_translatable_text_set(btn2, PACKAGE,
485 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
486 "IDS_WIFI_BODY_USING_WI_FI_DIRECT_WILL_DISCONNECT_CURRENT_WI_FI_TETHERING_CONTINUE_Q");
489 case POP_TYPE_DISCONNECT:
490 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
491 "IDS_WIFI_POP_CURRENT_CONNECTION_WILL_BE_DISCONNECTED_CONTINUE_Q");
493 case POP_TYPE_SCAN_AGAIN:
494 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
495 "IDS_WIFI_BODY_CURRENT_CONNECTION_WILL_BE_DISCONNECTED_SO_THAT_SCANNING_CAN_START_CONTINUE_Q");
497 case POP_TYPE_CANCEL_CONNECT:
498 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
499 "IDS_WIFI_POP_THIS_WI_FI_DIRECT_CONNECTION_WILL_BE_CANCELLED");
501 case POP_TYPE_ACCEPT_CONNECTION:
502 elm_object_domain_translatable_text_set(ugd->act_popup, PACKAGE,
503 "IDS_WIFI_BODY_PS_IS_REQUESTING_A_WI_FI_DIRECT_CONNECTION_ALLOW_Q");
513 * This function let the ug create a action popup
515 * @param[in] data the pointer to the main data structure
516 * @param[in] message the pointer to the text of popup
517 * @param[in] popup_type the message type
519 void wfd_ug_act_popup(void *data, const char *message, int popup_type)
522 struct ug_data *ugd = (struct ug_data *) data;
523 Evas_Object *popup = NULL;
524 Evas_Object *btn1 = NULL, *btn2 = NULL;
526 WFD_IF_DEL_OBJ(ugd->act_popup);
528 popup = elm_popup_add(ugd->base);
529 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
530 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb, NULL);
531 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
532 elm_object_domain_translatable_part_text_set(popup, "title,text",
533 PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
534 elm_object_domain_translatable_text_set(popup, PACKAGE, message);
535 evas_object_smart_callback_add(popup, "language,changed", act_popup_language_changed, (void *)popup_type);
537 btn1 = elm_button_add(popup);
538 btn2 = elm_button_add(popup);
539 elm_object_style_set(btn1, "popup");
540 elm_object_style_set(btn2, "popup");
542 /* set the different text by type */
544 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
545 popup_type == POPUP_TYPE_WIFI_OFF ||
548 popup_type == POPUP_TYPE_HOTSPOT_OFF ||
551 elm_object_domain_translatable_part_text_set(popup, "title,text",
552 PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
553 elm_object_domain_translatable_text_set(btn1, PACKAGE,
555 elm_object_domain_translatable_text_set(btn2, PACKAGE,
556 "IDS_ST_BUTTON_ENABLE");
557 } else if (popup_type == POP_TYPE_CANCEL_CONNECT) {
558 elm_object_domain_translatable_text_set(btn1, PACKAGE,
560 elm_object_domain_translatable_text_set(btn2, PACKAGE,
562 } else if (popup_type == POP_TYPE_DISCONNECT) {
563 elm_object_domain_translatable_part_text_set(popup, "title,text",
564 PACKAGE, "IDS_WIFI_SK_DISCONNECT");
565 elm_object_domain_translatable_text_set(btn1, PACKAGE,
567 elm_object_domain_translatable_text_set(btn2, PACKAGE,
570 } else if (popup_type == POP_TYPE_SCAN_AGAIN) {
571 elm_object_domain_translatable_part_text_set(popup, "title,text",
572 PACKAGE, "IDS_WIFI_SK4_SCAN");
573 elm_object_domain_translatable_text_set(btn1, PACKAGE,
575 elm_object_domain_translatable_text_set(btn2, PACKAGE,
577 } else if (popup_type == POP_TYPE_ACCEPT_CONNECTION) {
578 elm_object_domain_translatable_part_text_set(popup, "title,text",
579 PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
580 elm_object_domain_translatable_text_set(btn1, PACKAGE,
582 elm_object_domain_translatable_text_set(btn2, PACKAGE,
583 "IDS_WIFI_SK_CONNECT");
585 elm_object_domain_translatable_text_set(btn1, PACKAGE,
587 elm_object_domain_translatable_text_set(btn2, PACKAGE,
591 elm_object_part_content_set(popup, "button1", btn1);
592 elm_object_part_content_set(popup, "button2", btn2);
594 /* set the different callback by type */
595 #ifndef MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE
596 if (popup_type == POPUP_TYPE_WIFI_OFF) {
597 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_wifi_cb, (void *)ugd);
598 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_wifi_cb, (void *)ugd);
600 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_wifi_cancel_cb, (void *)ugd);
601 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_wifi_ok_cb, (void *)ugd);
603 #endif /* MODEL_BUILD_FEATURE_WLAN_CONCURRENT_MODE */
605 if (popup_type == POPUP_TYPE_HOTSPOT_OFF) {
606 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_hotspot_cb, (void *)ugd);
607 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_hotspot_cb, (void *)ugd);
609 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_hotspot_cancel_cb, (void *)ugd);
610 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_hotspot_ok_cb, (void *)ugd);
613 if (popup_type == POP_TYPE_DISCONNECT ||
614 popup_type == POP_TYPE_SCAN_AGAIN) {
615 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_disconnect_all_cb, (void *)ugd);
616 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _keydown_disconnect_all_cb, (void *)ugd);
618 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_cancel_cb, (void *)ugd);
619 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_disconnect_all_ok_cb, (void *)ugd);
620 } else if (popup_type == POP_TYPE_CANCEL_CONNECT) {
621 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, _mouseup_disconnect_all_cb, (void *)ugd);
623 evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_cancel_cb, (void *)ugd);
624 evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_cancel_connect_ok_cb, (void *)ugd);
625 } else if (popup_type == POP_TYPE_ACCEPT_CONNECTION ) {
626 evas_object_smart_callback_add(btn1, "clicked",
627 pushbutton_reject_connect_cb, (void *)ugd);
628 evas_object_smart_callback_add(btn2, "clicked",
629 pushbutton_accept_connect_cb, (void *)ugd);
632 evas_object_show(popup);
633 ugd->act_popup = popup;
638 * This function let the ug remove the action popup
640 * @param[in] data the pointer to the main data structure
642 void wfg_ug_act_popup_remove(void *data)
645 struct ug_data *ugd = (struct ug_data *) data;
647 if (ugd->act_popup) {
648 evas_object_del(ugd->act_popup);
649 ugd->act_popup = NULL;
655 * This function let the ug call it when click 'ok' button in warning popup of terminated problem
657 * @param[in] data the pointer to the main data structure
658 * @param[in] obj the pointer to the evas object
659 * @param[in] event_info the pointer to the event information
661 static void _wfd_ug_terminate_popup_cb(void *data, Evas_Object *obj, void *event_info)
664 struct ug_data *ugd = (struct ug_data *) data;
666 evas_object_del(ugd->warn_popup);
667 ugd->warn_popup = NULL;
669 wfd_ug_view_free_peers(ugd);
671 ug_destroy_me(ugd->ug);
676 * This function let the ug call it when click 'ok' button in warning popup of turning off WFD automatically
678 * @param[in] data the pointer to the main data structure
679 * @param[in] obj the pointer to the evas object
680 * @param[in] event_info the pointer to the event information
682 /*static void _wfd_ug_automatic_turn_off_popup_cb(void *data, Evas_Object *obj, void *event_info)
685 struct ug_data *ugd = (struct ug_data *) data;
687 evas_object_del(ugd->warn_popup);
688 ugd->warn_popup = NULL;
694 * This function let the ug call it when click 'ok' button in warning popup
696 * @param[in] data the pointer to the main data structure
697 * @param[in] obj the pointer to the evas object
698 * @param[in] event_info the pointer to the event information
700 static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info)
703 struct ug_data *ugd = (struct ug_data *) data;
705 evas_object_del(ugd->warn_popup);
706 ugd->warn_popup = NULL;
708 if (ugd->rename_entry) {
709 elm_object_focus_set(ugd->rename_entry, EINA_TRUE);
715 void warn_popup_language_changed(void *data, Evas_Object *obj, void *event_info)
719 int popup_type = (int)data;
720 struct ug_data *ugd = wfd_get_ug_data();
721 char popup_text[MAX_POPUP_TEXT_SIZE] = {0};
722 Evas_Object *btn = NULL;
724 if (!ugd || !ugd->warn_popup) {
725 DBG(LOG_ERROR, "NULL parameters.\n");
729 btn = elm_object_part_content_get(ugd->warn_popup, "button1");
730 elm_object_domain_translatable_text_set(btn, PACKAGE,
734 case POPUP_TYPE_ACTIVATE_FAIL_POLICY_RESTRICTS:
735 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
736 "IDS_COM_POP_SECURITY_POLICY_RESTRICTS_USE_OF_WI_FI");
738 case POPUP_TYPE_TERMINATE:
739 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
740 "IDS_COM_POP_FAILED");
742 case POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL:
743 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
744 "IDS_WIFI_POP_DEACTIVATION_FAILED");
746 case POPUP_TYPE_TERMINATE_NOT_SUPPORT:
747 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
748 "IDS_ST_POP_NOT_SUPPORTED");
750 case POP_TYPE_BUSY_DEVICE_POPUP:
751 elm_object_domain_translatable_text_set(ugd->warn_popup, PACKAGE,
752 "IDS_ST_POP_DEVICE_CONNECTED_TO_ANOTHER_DEVICE");
754 case POP_TYPE_MULTI_CONNECT_POPUP:
755 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);
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 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_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, _("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, (void *)popup_type);
795 btn = elm_button_add(popup);
796 elm_object_style_set(btn, "popup");
797 elm_object_domain_translatable_text_set(btn, PACKAGE, "IDS_BR_SK_OK");
798 elm_object_part_content_set(popup, "button1", btn);
799 if (popup_type == POPUP_TYPE_TERMINATE ||
800 popup_type == POPUP_TYPE_TERMINATE_DEACTIVATE_FAIL ||
801 popup_type == POPUP_TYPE_TERMINATE_NOT_SUPPORT) {
802 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_terminate_popup_cb, (void *)ugd);
804 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_warn_popup_cb, (void *)ugd);
807 evas_object_show(popup);
808 ugd->warn_popup = popup;