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://floralicense.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.
21 * This file implements wifi direct system popup view functions.
23 * @file wfd-app-popup-view.c
24 * @author Sungsik Jang (sungsik.jang@samsung.com)
31 #include <notification.h>
32 #include <efl_assist.h>
34 #include "wifi-direct.h"
36 #include "wfd-app-strings.h"
37 #include "wfd-app-util.h"
39 extern wfd_appdata_t *g_wfd_ad;
40 extern wfd_popup_t *g_wfd_pop;
41 extern unsigned char g_wfd_peer_mac[6];
42 extern unsigned char g_wfd_peer_name[32];
43 static Ecore_Timer *pb_timer = NULL;
47 * This function let the ug make a callback for click the button in popup
49 * @param[in] data the pointer to the main data structure
50 * @param[in] obj the pointer to the evas object
51 * @param[in] event_info the pointer to the event information
53 static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info)
55 __WDPOP_LOG_FUNC_ENTER__;
56 wfd_appdata_t *ad = wfd_get_appdata();
58 int resp = (int) data;
59 char msg[WFD_POP_STR_MAX_LEN] = {0};
61 WDPOP_LOGI( "popup resp : %d\n", resp);
64 case /* MT */ WFD_POP_RESP_APRV_CONNECT_PBC_YES:
67 "WFD_POP_RESP_APRV_CONNECT_PBC_YES\n");
70 result = wifi_direct_accept_connection(ad->peer_mac);
72 "wifi_direct_accept_connection() result=[%d]\n",
74 if (result == WIFI_DIRECT_ERROR_NONE) {
75 /* tickernoti popup */
76 notification_status_message_post(_("IDS_WFD_POP_CONNECTING"));
79 "wifi_direct_accept_connection() FAILED!!\n");
80 evas_object_hide(ad->win);
82 /* tickernoti popup */
83 snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
84 notification_status_message_post(msg);
89 case WFD_POP_RESP_APRV_CONNECT_INVITATION_YES:
91 "WFD_POP_RESP_APRV_CONNECT_INVITATION_YES [" MACSTR "]\n", MAC2STR(ad->peer_mac));
94 result = wifi_direct_connect(ad->peer_mac);
96 "wifi_direct_connect() result=[%d]\n",
98 if (result == WIFI_DIRECT_ERROR_NONE) {
99 /* tickernoti popup */
100 notification_status_message_post(_("IDS_WFD_POP_CONNECTING"));
103 "wifi_direct_connect() FAILED!!\n");
104 evas_object_hide(ad->win);
106 /* tickernoti popup */
107 snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
108 notification_status_message_post(msg);
113 case /* MT */ WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK:
118 "WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK\n");
121 if (wifi_direct_generate_wps_pin() != WIFI_DIRECT_ERROR_NONE) {
122 WDPOP_LOGD( "wifi_direct_generate_wps_pin() is failed\n");
126 if (wifi_direct_get_wps_pin(&pin) != WIFI_DIRECT_ERROR_NONE) {
127 WDPOP_LOGD( "wifi_direct_generate_wps_pin() is failed\n");
131 strncpy(ad->pin_number, pin, 64);
132 ad->pin_number[63] = '\0';
135 WDPOP_LOGD( "button ok: pin [%s]", ad->pin_number);
137 result = wifi_direct_accept_connection(ad->peer_mac);
138 if (result == WIFI_DIRECT_ERROR_NONE) {
139 wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, NULL);
142 "wifi_direct_accept_connection() failed. result=[%d]\n", result);
143 /* tickernoti popup */
144 snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
145 notification_status_message_post(msg);
150 case /* MO */ WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK:
153 "WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK\n");
157 int len = strlen(ad->pin_number);
158 WDPOP_LOGD( "button ok: pin [%s]", ad->pin_number);
162 notification_status_message_post(_("IDS_CST_BODY_PASSWORD_TOO_LONG"));
164 notification_status_message_post(_("IDS_ST_BODY_PASSWORD_TOO_SHORT"));
165 wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, (void *) NULL);
170 WDPOP_LOGD( "pin=[%s]\n", ad->pin_number);
172 result = wifi_direct_set_wps_pin(ad->pin_number);
173 if (result != WIFI_DIRECT_ERROR_NONE) {
174 /* tickernoti popup */
175 snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
176 notification_status_message_post(msg);
180 //result = wifi_direct_activate_pushbutton();
181 result = wifi_direct_accept_connection(ad->peer_mac);
183 "wifi_direct_accept_connection(%s) result=[%d]\n",
184 ad->peer_mac, result);
185 if (result != WIFI_DIRECT_ERROR_NONE) {
187 "wifi_direct_accept_connection() FAILED!!\n");
188 evas_object_hide(ad->win);
190 /* tickernoti popup */
191 snprintf(msg, WFD_POP_STR_MAX_LEN, IDS_WFD_POP_CONNECT_FAILED, ad->peer_name);
192 notification_status_message_post(msg);
197 case /* MT */ WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES:
200 "WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES\n");
203 ecore_timer_del(pb_timer);
207 wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, (void *) NULL);
211 case /* MT */ WFD_POP_RESP_APRV_CONNECT_NO:
214 "WFD_POP_RESP_APRV_CONNECT_NO: destroy_popup...\n");
218 ecore_timer_del(pb_timer);
222 result = wifi_direct_disconnect(ad->peer_mac);
224 "wifi_direct_disconnect[%s] result=[%d]\n",
225 ad->peer_mac, result);
231 WDPOP_LOGE( "Unknown respone\n");
232 evas_object_hide(ad->win);
237 __WDPOP_LOG_FUNC_EXIT__;
241 * This function let the app destroy the popup
245 void wfd_destroy_popup()
247 __WDPOP_LOG_FUNC_ENTER__;
248 wfd_appdata_t *ad = wfd_get_appdata();
251 WDPOP_LOGE( "ad is NULL\n");
256 evas_object_del(ad->popup);
260 if (ad->popup_timeout_handle > 0) {
261 g_source_remove(ad->popup_timeout_handle);
262 ad->popup_timeout_handle = 0;
265 evas_object_hide(ad->win);
267 __WDPOP_LOG_FUNC_EXIT__;
272 * This function let the app create a popup which includes no button
274 * @param[in] win the window object
275 * @param[in] pop the pointer to the prepared popup
277 static Evas_Object *wfd_draw_pop_type_a(Evas_Object * win, wfd_popup_t * pop)
279 __WDPOP_LOG_FUNC_ENTER__;
282 popup = elm_popup_add(win);
283 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_popup_back_cb, NULL);
284 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
285 elm_object_text_set(popup, pop->text);
286 elm_popup_timeout_set(popup, pop->timeout);
287 evas_object_show(popup);
288 evas_object_show(win);
290 __WDPOP_LOG_FUNC_EXIT__;
295 * This function let the app create a popup which includes one button
297 * @param[in] win the window object
298 * @param[in] pop the pointer to the prepared popup
300 static Evas_Object *wfd_draw_pop_type_b(Evas_Object * win, wfd_popup_t * pop)
302 __WDPOP_LOG_FUNC_ENTER__;
303 Evas_Object *popup = NULL;
304 Evas_Object *btn = NULL;
306 popup = elm_popup_add(win);
307 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
308 elm_object_text_set(popup, pop->text);
310 btn = elm_button_add(popup);
311 elm_object_style_set(btn, "popup_button/default");
312 elm_object_text_set(btn, pop->label1);
313 elm_object_part_content_set(popup, "button1", btn);
314 evas_object_smart_callback_add(btn, "clicked", __popup_resp_cb, (void *) pop->resp_data1);
315 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, (void*) pop->resp_data1);
317 evas_object_show(popup);
318 evas_object_show(win);
320 __WDPOP_LOG_FUNC_EXIT__;
325 * This function let the app create a popup which includes two buttons
327 * @param[in] win the window object
328 * @param[in] pop the pointer to the prepared popup
330 static Evas_Object *wfd_draw_pop_type_c(Evas_Object * win, wfd_popup_t * pop)
332 __WDPOP_LOG_FUNC_ENTER__;
333 Evas_Object *popup = NULL;
334 Evas_Object *btn1 = NULL, *btn2 = NULL;
336 popup = elm_popup_add(win);
337 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
338 elm_object_text_set(popup, pop->text);
340 btn1 = elm_button_add(popup);
341 elm_object_style_set(btn1, "popup_button/default");
342 elm_object_text_set(btn1, pop->label1);
343 elm_object_part_content_set(popup, "button1", btn1);
344 evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
345 (void*) pop->resp_data1);
347 btn2 = elm_button_add(popup);
348 elm_object_style_set(btn2, "popup_button/default");
349 elm_object_text_set(btn2, pop->label2);
350 elm_object_part_content_set(popup, "button2", btn2);
351 evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
352 (void*) pop->resp_data2);
353 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb,
354 (void*) pop->resp_data2);
356 evas_object_show(popup);
357 evas_object_show(win);
359 __WDPOP_LOG_FUNC_EXIT__;
364 * This function let the ug make a change callback for password input
366 * @param[in] data the pointer to the main data structure
367 * @param[in] obj the pointer to the evas object
368 * @param[in] event_info the pointer to the event information
370 static void _smart_ime_cb(void *data, Evas_Object * obj, void *event_info)
372 __WDPOP_LOG_FUNC_ENTER__;
373 wfd_appdata_t *ad = wfd_get_appdata();
375 Ecore_IMF_Context *imf_context = NULL;
376 imf_context = (Ecore_IMF_Context *) ad->pin_entry;
378 if (NULL == imf_context) {
379 WDPOP_LOGE( "Error!!! Ecore_IMF_Context is NULL!!");
383 const char *txt = elm_entry_markup_to_utf8(elm_entry_entry_get((const Evas_Object *) imf_context));
385 WDPOP_LOGD( "* text [%s], len=[%d]", txt, strlen(txt));
386 strncpy(ad->pin_number, txt, 64);
387 ad->pin_number[63] = '\0';
393 __WDPOP_LOG_FUNC_EXIT__;
397 * This function let the app make a change callback for password checkbox
399 * @param[in] data the pointer to the main data structure
400 * @param[in] obj the pointer to the evas object
401 * @param[in] event_info the pointer to the event information
403 static void _check_changed_cb(void *data, Evas_Object * obj, void *event_info)
405 wfd_appdata_t *ad = wfd_get_appdata();
411 Eina_Bool state = elm_check_state_get(obj);
412 elm_entry_password_set(ad->pin_entry, !state);
413 elm_entry_autocapital_type_set(ad->pin_entry, ELM_AUTOCAPITAL_TYPE_NONE);
417 * This function let the app make a callback for progressbar timer
418 * @return if stop the timer, return ECORE_CALLBACK_CANCEL, else return ECORE_CALLBACK_RENEW
419 * @param[in] data the pointer to the wps structure
421 static Eina_Bool _fn_pb_timer(void *data)
425 char time_label[32] = {0};
426 wfd_wps_display_popup_t *wps_display_popup = (wfd_wps_display_popup_t *) data;
428 if (NULL == wps_display_popup) {
429 WDPOP_LOGE( "Param is NULL.\n");
430 return ECORE_CALLBACK_CANCEL;
433 Evas_Object *progressbar = NULL;
434 Evas_Object *time = NULL;
436 progressbar = wps_display_popup->progressbar;
437 time = wps_display_popup->time;
438 value = elm_progressbar_value_get(progressbar);
441 WDPOP_LOGE( "Progress end.\n");
443 ecore_timer_del(pb_timer);
447 return ECORE_CALLBACK_CANCEL;
450 wps_display_popup->step++;
451 step = wps_display_popup->step;
452 value = ((double)step) / WFD_POP_TIMER_120;
453 elm_progressbar_value_set(progressbar, value);
454 WDPOP_LOGD( "step: %d, value: %f\n", wps_display_popup->step, value);
456 /* show the time label */
459 snprintf(time_label, 32, "00:0%d", step);
461 snprintf(time_label, 32, "00:%d", step);
465 snprintf(time_label, 32, "0%d:0%d", step/60, step%60);
467 snprintf(time_label, 32, "0%d:%d", step/60, step%60);
471 elm_object_text_set(time, time_label);
473 return ECORE_CALLBACK_RENEW;
477 * This function let the app create a edit filed
479 * @param[in] parent the parent object
480 * @param[in] title the pointer to the title of edit field
481 * @param[in] guide the pointer to the text of guide
482 * @param[in] single_line whether it can support single line
483 * @param[in] is_editable whether it is avaliable to edit
485 static Evas_Object *_add_edit_field(Evas_Object *parent, const char *title, const char *guide, Eina_Bool single_line, Eina_Bool is_editable)
487 assertm_if(NULL == parent, "parent is NULL!!");
489 Evas_Object *layout = elm_layout_add(parent);
490 assertm_if(NULL == layout, "layout is NULL!!");
492 if (title && title[0] != '\0') {
493 elm_layout_theme_set(layout, "layout", "editfield", "title");
494 elm_object_part_text_set(layout, "elm.text", title);
496 elm_layout_theme_set(layout, "layout", "editfield", "default");
499 Evas_Object *entry = elm_entry_add(parent);
500 assertm_if(NULL == entry, "entry is NULL!!");
502 elm_object_part_content_set(layout, "elm.swallow.content", entry);
503 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
505 if (guide && guide[0] != '\0') {
506 elm_object_part_text_set(layout, "elm.guidetext", guide);
509 elm_entry_single_line_set(entry, single_line);
510 elm_entry_scrollable_set(entry, single_line);
511 elm_entry_editable_set(entry, is_editable);
512 elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm");
513 evas_object_show(layout);
519 * This function let the app create a display popup
520 * @return display popup
521 * @param[in] win the window object
522 * @param[in] pop the pointer to the prepared popup
524 Evas_Object *wfd_draw_pop_type_display(Evas_Object * win, wfd_popup_t * pop)
526 __WDPOP_LOG_FUNC_ENTER__;
528 Evas_Object *popup = NULL;
529 Evas_Object *label = NULL;
530 Evas_Object *progressbar = NULL;
531 Evas_Object *time = NULL;
532 static wfd_wps_display_popup_t wps_display_popup;
534 popup = elm_popup_add(win);
535 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, 0.0);
537 Evas_Object *box = elm_box_add(popup);
539 evas_object_del(popup);
544 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
545 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
546 elm_object_part_content_set(popup, NULL, box);
547 evas_object_show(box);
550 label = elm_label_add(box);
551 elm_object_style_set(label, "popup/default");
552 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
553 elm_object_text_set(label, pop->text);
554 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
555 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, 0.0);
556 elm_box_pack_end(box, label);
557 evas_object_show(label);
559 /* add progressbar */
560 progressbar = elm_progressbar_add(box);
561 elm_object_style_set(progressbar, "list_progress");
562 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
563 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.0);
564 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, 0.0);
565 elm_progressbar_value_set(progressbar, 0.0);
566 elm_box_pack_end(box, progressbar);
567 evas_object_show(progressbar);
570 time = elm_label_add(box);
571 elm_object_style_set(time, "popup/default");
572 elm_object_text_set(time, "00:00");
573 evas_object_size_hint_weight_set(time, EVAS_HINT_EXPAND, 0.0);
574 evas_object_size_hint_align_set(time, EVAS_HINT_FILL, 0.0);
575 elm_box_pack_end(box, time);
576 evas_object_show(time);
578 /* start progressbar timer */
579 wps_display_popup.step = 0;
580 wps_display_popup.progressbar = progressbar;
581 wps_display_popup.time = time;
583 ecore_timer_del(pb_timer);
584 pb_timer = ecore_timer_add(1, _fn_pb_timer, &wps_display_popup);
587 if (pop->resp_data1 == WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES ||
588 pop->resp_data1 == WFD_POP_RESP_APRV_CONNECT_NO) {
589 Evas_Object *btn1 = NULL;
590 btn1 = elm_button_add(popup);
591 elm_object_style_set(btn1, "popup_button/default");
592 elm_object_text_set(btn1, pop->label1);
593 elm_object_part_content_set(popup, "button1", btn1);
594 evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
595 (void*) pop->resp_data1);
598 if (pop->resp_data2 == WFD_POP_RESP_APRV_CONNECT_NO) {
599 Evas_Object *btn2 = NULL;
600 btn2 = elm_button_add(popup);
601 elm_object_style_set(btn2, "popup_button/default");
602 elm_object_text_set(btn2, pop->label2);
603 elm_object_part_content_set(popup, "button2", btn2);
604 evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
605 (void*) pop->resp_data2);
606 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb,
607 (void*) pop->resp_data2);
610 elm_object_content_set(popup, box);
611 evas_object_show(popup);
612 evas_object_show(win);
614 __WDPOP_LOG_FUNC_EXIT__;
619 * This function let the app create a keypad popup
620 * @return keypad popup
621 * @param[in] win the window object
622 * @param[in] pop the pointer to the prepared popup
624 Evas_Object *wfd_draw_pop_type_keypad(Evas_Object * win, wfd_popup_t * pop)
626 __WDPOP_LOG_FUNC_ENTER__;
627 wfd_appdata_t *ad = wfd_get_appdata();
629 Evas_Object *conformant = NULL;
630 Evas_Object *layout = NULL;
631 Evas_Object *pinpopup = NULL;
632 Evas_Object *label = NULL;
633 Evas_Object *btn1 = NULL, *btn2 = NULL;
635 conformant = elm_conformant_add(win);
636 assertm_if(NULL == conformant, "conformant is NULL!!");
637 elm_win_conformant_set(win, EINA_TRUE);
638 elm_win_resize_object_add(win, conformant);
639 evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, 0.0);
640 evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, 0.0);
641 evas_object_show(conformant);
643 layout = elm_layout_add(conformant);
644 elm_object_content_set(conformant, layout);
646 pinpopup = elm_popup_add(layout);
647 assertm_if(NULL == pinpopup, "pinpopup is NULL!!");
648 evas_object_size_hint_weight_set(pinpopup, EVAS_HINT_EXPAND, 0.0);
649 elm_object_part_text_set(pinpopup, "title,text", _("IDS_WFD_POP_TITILE_CONNECTION"));
651 Evas_Object *box = elm_box_add(pinpopup);
653 evas_object_del(pinpopup);
658 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
659 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
660 elm_object_part_content_set(pinpopup, NULL, box);
661 evas_object_show(box);
664 label = elm_label_add(box);
665 elm_object_style_set(label, "popup/default");
666 elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
667 elm_object_text_set(label, pop->text);
668 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
669 evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
670 elm_box_pack_end(box, label);
671 evas_object_show(label);
674 Evas_Object *body = elm_layout_add(box);
676 evas_object_del(pinpopup);
681 elm_layout_theme_set(body, "layout", "dialogue", "1icon");
682 evas_object_size_hint_weight_set(body, EVAS_HINT_EXPAND, 0.0);
683 evas_object_size_hint_align_set(body, EVAS_HINT_FILL, 0.0);
685 Evas_Object *editfield_pin = _add_edit_field(body, NULL, NULL, EINA_TRUE, EINA_TRUE);
686 Evas_Object *entry_pin = elm_object_part_content_get(editfield_pin, "elm.swallow.content");
687 ad->pin_entry = entry_pin;
688 evas_object_smart_callback_add(ad->pin_entry, "changed", _smart_ime_cb, NULL);
689 elm_object_part_content_set(body, "elm.icon", editfield_pin);
690 elm_box_pack_end(box, body);
691 evas_object_show(body);
693 elm_entry_password_set(ad->pin_entry, TRUE);
695 Evas_Object *check = elm_check_add(box);
696 elm_object_text_set(check, _("Show password"));
697 elm_object_focus_allow_set(check, EINA_FALSE);
698 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0);
699 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, 0.0);
700 evas_object_smart_callback_add(check, "changed", _check_changed_cb, NULL);
701 evas_object_show(check);
702 elm_box_pack_end(box, check);
705 btn1 = elm_button_add(pinpopup);
706 elm_object_style_set(btn1, "popup_button/default");
707 elm_object_text_set(btn1, pop->label1);
708 elm_object_part_content_set(pinpopup, "button1", btn1);
709 evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb, (void *)pop->resp_data1);
711 btn2 = elm_button_add(pinpopup);
712 elm_object_style_set(btn2, "popup_button/default");
713 elm_object_text_set(btn2, pop->label2);
714 elm_object_part_content_set(pinpopup, "button2", btn2);
715 evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb, (void *)pop->resp_data2);
716 ea_object_event_callback_add(pinpopup, EA_CALLBACK_BACK, __popup_resp_cb,
717 (void*) pop->resp_data2);
719 elm_object_content_set(pinpopup, box);
720 evas_object_show(pinpopup);
721 evas_object_show(win);
722 elm_object_focus_set(ad->pin_entry, EINA_TRUE);
724 __WDPOP_LOG_FUNC_EXIT__;
729 * This function let the app create a popup
731 * @param[in] type the type of popup
732 * @param[in] userdata the pointer to the data which will be used
734 void wfd_prepare_popup(int type, void *userdata)
736 __WDPOP_LOG_FUNC_ENTER__;
737 wfd_appdata_t *ad = wfd_get_appdata();
738 wfd_popup_t *pop = ad->popup_data;
742 memset(pop, 0, sizeof(wfd_popup_t));
747 case /* MT */ WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ:
748 snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECT_Q,
750 snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_YES"));
751 snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_NO"));
752 pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_PBC_YES;
753 pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
755 ad->popup = wfd_draw_pop_type_c(ad->win, pop);
758 case WFD_POP_APRV_CONNECTION_INVITATION_REQ:
759 snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECT_Q,
761 snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_YES"));
762 snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_NO"));
763 pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_INVITATION_YES;
764 pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
766 ad->popup = wfd_draw_pop_type_c(ad->win, pop);
769 case /* MT */ WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ:
770 snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_ENTER_PIN_WITH_KEYPAD,
772 snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK"));
773 snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
774 pop->timeout = WFD_POP_TIMER_120;
775 pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK;
776 pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
778 ad->popup = wfd_draw_pop_type_c(ad->win, pop);
781 case /* MT */ WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ:
782 snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_ENTER_PIN,
783 ad->peer_name, WFD_POP_TIMER_120);
784 snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK"));
785 snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
786 pop->timeout = WFD_POP_TIMER_120;
787 pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES;
788 pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
790 ad->popup = wfd_draw_pop_type_c(ad->win, pop);
793 case /* MT */ WFD_POP_PROG_CONNECT:
794 snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_CONNECTING"));
795 snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
796 pop->timeout = WFD_POP_TIMER_120;
797 pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
799 ad->popup = wfd_draw_pop_type_b(ad->win, pop);
802 case /* MO */ WFD_POP_PROG_CONNECT_WITH_KEYPAD:
803 snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECTING_WITH_KEYPAD,
804 ad->peer_name, WFD_POP_TIMER_120, ad->peer_name);
805 snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK"));
806 snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
807 pop->timeout = WFD_POP_TIMER_120;
808 pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK;
809 pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
811 ad->popup = wfd_draw_pop_type_keypad(ad->win, pop);
814 case /* MO/MT */ WFD_POP_PROG_CONNECT_WITH_PIN:
815 snprintf(pop->text, sizeof(pop->text), IDS_WFD_POP_CONNECTING_WITH_PIN,
816 ad->peer_name, WFD_POP_TIMER_120, ad->pin_number);
817 snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
818 pop->timeout = WFD_POP_TIMER_120;
819 pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
821 ad->popup = wfd_draw_pop_type_display(ad->win, pop);
824 case WFD_POP_PROG_CONNECT_CANCEL:
825 snprintf(pop->text, sizeof(pop->text), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL"));
826 pop->timeout = WFD_POP_TIMER_120;
827 ad->popup = wfd_draw_pop_type_a(ad->win, pop);
834 __WDPOP_LOG_FUNC_EXIT__;