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.
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 <Elementary.h>
32 #include <efl-assist/efl_assist.h>
35 #include <X11/Xatom.h>
36 #include <X11/Xutil.h>
40 #include <notification.h>
42 #include <wifi-direct.h>
43 #include <efl_extension.h>
46 #include "wfd-app-strings.h"
47 #include "wfd-app-util.h"
48 #include "wfd-app-popup-view.h"
50 extern wfd_appdata_t *g_wfd_ad;
51 extern wfd_popup_t *g_wfd_pop;
52 extern unsigned char g_wfd_peer_mac[6];
53 extern unsigned char g_wfd_peer_name[32];
54 static Ecore_Timer *pb_timer = NULL;
55 static Ecore_Timer *keypad_popup_timer = NULL;
56 static int keypad_popup_timeout = 0;
58 void _replace_1PS_2PD(char *buf, int buf_len, char *format_str, char* SD_1, int PD_2);
60 static void mouseup_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
62 Evas_Event_Mouse_Up *ev = event_info;
63 if (ev->button == 3) {
68 /*static void keydown_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
70 Evas_Event_Key_Down *ev = event_info;
71 if (!strcmp(ev->keyname, KEY_BACK)) {
75 static Eina_Bool __rotate(void *data, int type, void *event)
77 __WFD_APP_FUNC_ENTER__;
78 wfd_appdata_t *ad = (wfd_appdata_t *)data;
80 Ecore_X_Event_Client_Message *ev = event;
82 int rots[4] = {0, 90, 180, 270};
84 if (ad == NULL || ad->win == NULL) {
85 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Parameter NULL");
90 if (ev->message_type == ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE) {
91 WFD_APP_LOG(WFD_APP_LOG_LOW, "ev->message_type: [%d]\n", ev->message_type);
92 elm_win_wm_rotation_available_rotations_set(ad->win, rots, 1);
96 __WFD_APP_FUNC_EXIT__;
101 * This function let the ug make a callback for click the button in popup
103 * @param[in] data the pointer to the main data structure
104 * @param[in] obj the pointer to the evas object
105 * @param[in] event_info the pointer to the event information
107 static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info)
109 __WFD_APP_FUNC_ENTER__;
110 wfd_appdata_t *ad = wfd_get_appdata();
111 wfd_connection_info_s *connection = ad->connection;
113 int resp = (int) data;
114 char msg[WFD_POP_STR_MAX_LEN] = {0};
116 WFD_APP_LOG(WFD_APP_LOG_HIGH, "popup resp : %d\n", resp);
118 if (ad->rotate_event_handler) {
119 ecore_event_handler_del(ad->rotate_event_handler);
120 ad->rotate_event_handler = NULL;
124 case /* MT */ WFD_POP_RESP_APRV_CONNECT_PBC_YES:
126 WFD_APP_LOG(WFD_APP_LOG_HIGH,
127 "WFD_POP_RESP_APRV_CONNECT_PBC_YES\n");
130 result = wifi_direct_accept_connection(connection->peer_addr);
131 if (result != WIFI_DIRECT_ERROR_NONE) {
132 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to accept connection(%d)", result);
133 evas_object_hide(ad->win);
135 /* tickernoti popup */
136 snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WIFI_POP_FAILED_TO_CONNECT_TO_PS"),
137 connection->peer_name);
138 notification_status_message_post(msg);
140 WFD_APP_LOG(WFD_APP_LOG_LOW, "Succeeded to accept connection");
144 case /* MT */ WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK:
146 WFD_APP_LOG(WFD_APP_LOG_HIGH,
147 "WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK\n");
150 result = wifi_direct_accept_connection(connection->peer_addr);
151 if (result == WIFI_DIRECT_ERROR_NONE) {
152 wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, NULL);
154 WFD_APP_LOG(WFD_APP_LOG_LOW,
155 "wifi_direct_accept_connection() failed. result=[%d]\n", result);
156 /* tickernoti popup */
157 notification_status_message_post(_("IDS_WIFI_POP_FAILED_TO_CONNECT_TO_PS"));
162 case /* MO */ WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK:
165 WFD_APP_LOG(WFD_APP_LOG_HIGH,
166 "WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK\n");
170 int len = strlen(connection->wps_pin);
171 WFD_APP_LOGSECURE(WFD_APP_LOG_LOW, "PIN [%s]", connection->wps_pin);
173 if (len < 8 || len > 64) {
174 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error, Incorrect PIN!!\n");
175 keypad_popup_timeout--;
176 /* tickernoti popup */
177 notification_status_message_post(_("IDS_COM_BODY_PINS_DO_NOT_MATCH"));
179 /* redraw the popup */
180 wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, (void *) NULL);
183 keypad_popup_timeout = 0;
185 result = wifi_direct_set_wps_pin(connection->wps_pin);
186 if (result != WIFI_DIRECT_ERROR_NONE) {
187 /* tickernoti popup */
188 snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WIFI_POP_FAILED_TO_CONNECT_TO_PS"),
189 connection->peer_name);
190 notification_status_message_post(msg);
194 result = wifi_direct_accept_connection(connection->peer_addr);
195 if (result != WIFI_DIRECT_ERROR_NONE) {
196 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to accept connection(%d)", result);
197 evas_object_hide(ad->win);
199 /* tickernoti popup */
200 snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WIFI_POP_FAILED_TO_CONNECT_TO_PS"),
201 connection->peer_name);
202 notification_status_message_post(msg);
204 WFD_APP_LOG(WFD_APP_LOG_LOW, "Succeeded to connect with [%s]", connection->peer_addr);
208 case /* MT */ WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES:
210 WFD_APP_LOG(WFD_APP_LOG_HIGH,
211 "WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES\n");
214 ecore_timer_del(pb_timer);
218 wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, (void *) NULL);
222 case /* MT */ WFD_POP_RESP_APRV_CONNECT_NO:
224 WFD_APP_LOG(WFD_APP_LOG_HIGH,
225 "WFD_POP_RESP_APRV_CONNECT_NO: destroy_popup...\n");
227 if (connection->peer_addr[0] != '\0') {
228 result = wifi_direct_reject_connection(connection->peer_addr);
229 if (result != WIFI_DIRECT_ERROR_NONE)
230 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to reject connection(%d)", result);
232 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Peer's address is Zero MAC");
236 ecore_timer_del(pb_timer);
241 keypad_popup_timeout = 0;
247 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Unknown respone\n");
253 __WFD_APP_FUNC_EXIT__;
257 * This function let the app destroy the popup
261 void wfd_destroy_popup()
263 __WFD_APP_FUNC_ENTER__;
264 wfd_appdata_t *ad = wfd_get_appdata();
267 WFD_APP_LOG(WFD_APP_LOG_ERROR, "ad is NULL\n");
271 if (keypad_popup_timer) {
272 ecore_timer_del(keypad_popup_timer);
273 keypad_popup_timer = NULL;
277 evas_object_del(ad->popup);
281 if (ad->popup_timeout_handle > 0) {
282 g_source_remove(ad->popup_timeout_handle);
283 ad->popup_timeout_handle = 0;
287 evas_object_hide(ad->win);
291 ecore_timer_del(pb_timer);
294 __WFD_APP_FUNC_EXIT__;
298 static int __get_window_property(Display *dpy, Window win, Atom atom,
299 Atom type, unsigned int *val, unsigned int len)
301 __WFD_APP_FUNC_ENTER__;
302 unsigned char *prop_ret = NULL;
304 unsigned long bytes_after = 0;
305 unsigned long num_ret = -1;
311 if (XGetWindowProperty(dpy, win, atom, 0, 0x7fffffff, False,
312 type, &type_ret, &format_ret, &num_ret,
313 &bytes_after, &prop_ret) != Success) {
317 if (type_ret != type || format_ret != 32) {
319 } else if (num_ret == 0 || !prop_ret) {
325 for (i = 0; i < len; i++) {
326 val[i] = ((unsigned long *)prop_ret)[i];
335 __WFD_APP_FUNC_EXIT__;
339 static int __x_rotation_get(Display *dpy, void* win)
341 __WFD_APP_FUNC_ENTER__;
342 Window active_win = 0;
347 Atom atom_active_win;
348 Atom atom_win_rotate_angle;
350 root_win = XDefaultRootWindow(dpy);
352 atom_active_win = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
353 ret = __get_window_property(dpy, root_win, atom_active_win,
354 XA_WINDOW, (unsigned int *)&active_win, 1);
360 atom_win_rotate_angle =
361 XInternAtom(dpy, "_E_ILLUME_ROTATE_WINDOW_ANGLE", False);
362 ret = __get_window_property(dpy, active_win ,
363 atom_win_rotate_angle, XA_CARDINAL,
364 (unsigned int *)&rotation, 1);
366 __WFD_APP_FUNC_EXIT__;
374 void __set_parent_rotate_angle(wfd_appdata_t *ad)
376 __WFD_APP_FUNC_ENTER__;
378 int rotate_angle = 0;
380 int rots2[4] = {0, 90, 180, 270};
382 if (ad == NULL || ad->win == NULL) {
383 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Parameter NULL");
387 rotate_angle = __x_rotation_get(ecore_x_display_get(), NULL);
389 WFD_APP_LOG(WFD_APP_LOG_LOW, "rotate_angle: [%d]\n", rotate_angle);
391 if (rotate_angle < 0) {
395 if (rotate_angle == 0) {
396 elm_win_wm_rotation_available_rotations_set(ad->win, rots1, 1);
398 elm_win_wm_rotation_available_rotations_set(ad->win, rots2, 1);
401 __WFD_APP_FUNC_EXIT__;
406 * This function let the app create a popup which includes no button
408 * @param[in] win the window object
409 * @param[in] pop the pointer to the prepared popup
411 static Evas_Object *wfd_draw_pop_type_a(Evas_Object * win, wfd_popup_t * pop)
413 __WFD_APP_FUNC_ENTER__;
415 wfd_appdata_t *ad = wfd_get_appdata();
418 popup = elm_popup_add(win);
419 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
420 eext_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, NULL);
421 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, mouseup_cb, ad);
422 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, keydown_cb, ad);
423 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
424 elm_object_domain_translatable_text_set(popup, PACKAGE, pop->text);
425 elm_popup_timeout_set(popup, pop->timeout);
427 __set_parent_rotate_angle(ad);
429 evas_object_show(popup);
430 evas_object_show(win);
432 ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __rotate, ad);
435 __WFD_APP_FUNC_EXIT__;
440 * This function let the app create a popup which includes one button
442 * @param[in] win the window object
443 * @param[in] pop the pointer to the prepared popup
445 static Evas_Object *wfd_draw_pop_type_b(Evas_Object * win, wfd_popup_t * pop)
447 __WFD_APP_FUNC_ENTER__;
448 Evas_Object *popup = NULL;
449 Evas_Object *btn = NULL;
450 wfd_appdata_t *ad = wfd_get_appdata();
452 popup = elm_popup_add(win);
453 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
454 eext_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, (void *) pop->resp_data1);
455 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, mouseup_cb, ad);
456 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, keydown_cb, ad);
457 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
458 elm_object_domain_translatable_text_set(popup, PACKAGE, pop->text);
460 btn = elm_button_add(popup);
461 elm_object_style_set(btn, "popup");
462 elm_object_domain_translatable_text_set(btn, PACKAGE, pop->label1);
463 elm_object_part_content_set(popup, "button1", btn);
464 evas_object_smart_callback_add(btn, "clicked", __popup_resp_cb, (void *) pop->resp_data1);
467 __set_parent_rotate_angle(ad);
469 evas_object_show(popup);
470 evas_object_show(win);
472 ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __rotate, ad);
475 __WFD_APP_FUNC_EXIT__;
480 * This function let the app create a popup which includes two buttons
482 * @param[in] win the window object
483 * @param[in] pop the pointer to the prepared popup
485 static Evas_Object *wfd_draw_pop_type_c(Evas_Object * win, wfd_popup_t * pop)
487 __WFD_APP_FUNC_ENTER__;
488 Evas_Object *popup = NULL;
489 Evas_Object *btn1 = NULL, *btn2 = NULL;
490 wfd_appdata_t *ad = wfd_get_appdata();
492 popup = elm_popup_add(win);
493 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
494 eext_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, (void *) pop->resp_data2);
495 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, mouseup_cb, ad);
496 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, keydown_cb, ad);
497 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
498 elm_object_domain_translatable_part_text_set(popup, "title,text",
499 PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
500 elm_object_domain_translatable_text_set(popup, PACKAGE, pop->text);
502 btn1 = elm_button_add(popup);
503 elm_object_style_set(btn1, "popup");
504 elm_object_domain_translatable_text_set(btn1, PACKAGE, pop->label2);
505 elm_object_part_content_set(popup, "button1", btn1);
506 evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
507 (void *) pop->resp_data2);
509 btn2 = elm_button_add(popup);
510 elm_object_style_set(btn2, "popup");
511 elm_object_domain_translatable_text_set(btn2, PACKAGE, pop->label1);
512 elm_object_part_content_set(popup, "button2", btn2);
513 evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
514 (void *) pop->resp_data1);
517 __set_parent_rotate_angle(ad);
519 evas_object_show(popup);
520 evas_object_show(win);
522 ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __rotate, ad);
525 __WFD_APP_FUNC_EXIT__;
529 static void _wfd_ug_automatic_turn_off_popup_cb(void *data, Evas_Object *obj, void *event_info)
531 __WFD_APP_FUNC_ENTER__;
532 wfd_appdata_t *ad = wfd_get_appdata();
535 evas_object_del(ad->popup);
539 if (ad->rotate_event_handler) {
540 ecore_event_handler_del(ad->rotate_event_handler);
541 ad->rotate_event_handler = NULL;
545 evas_object_hide(ad->win);
548 __WFD_APP_FUNC_EXIT__;
551 Evas_Object *wfd_draw_pop_type_auto_deactivation(Evas_Object *win, void *userdata)
553 __WFD_APP_FUNC_ENTER__;
555 Evas_Object *popup = NULL;
556 Evas_Object *btn = NULL;
557 char popup_text[MAX_POPUP_TEXT_SIZE] = {0};
558 wfd_appdata_t *ad = wfd_get_appdata();
560 popup = elm_popup_add(win);
561 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
562 eext_object_event_callback_add(popup, EA_CALLBACK_BACK, _wfd_ug_automatic_turn_off_popup_cb, userdata);
563 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, mouseup_cb, ad);
564 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, keydown_cb, ad);
565 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
566 elm_object_domain_translatable_part_text_set(popup, "title,text",
567 PACKAGE, "IDS_WIFI_BODY_WI_FI_DIRECT_ABB");
568 snprintf(popup_text, MAX_POPUP_TEXT_SIZE,
569 "IDS_WIFI_POP_THERE_HAS_BEEN_NO_ACTIVITY_FOR_PD_MINUTES_SINCE_WI_FI_DIRECT_WAS_ENABLED_MSG", 5);
570 elm_object_domain_translatable_text_set(popup, PACKAGE, popup_text);
572 btn = elm_button_add(popup);
573 elm_object_style_set(btn, "popup");
574 elm_object_domain_translatable_text_set(btn, PACKAGE, "IDS_BR_SK_OK");
575 elm_object_part_content_set(popup, "button1", btn);
576 evas_object_smart_callback_add(btn, "clicked", _wfd_ug_automatic_turn_off_popup_cb, userdata);
579 __set_parent_rotate_angle(ad);
581 evas_object_show(popup);
582 evas_object_show(win);
584 ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __rotate, ad);
587 __WFD_APP_FUNC_EXIT__;
592 * This function let the ug make a change callback for password input
594 * @param[in] data the pointer to the main data structure
595 * @param[in] obj the pointer to the evas object
596 * @param[in] event_info the pointer to the event information
598 static void _smart_ime_cb(void *data, Evas_Object * obj, void *event_info)
600 __WFD_APP_FUNC_ENTER__;
601 wfd_appdata_t *ad = wfd_get_appdata();
602 wfd_connection_info_s *connection = ad->connection;
604 Ecore_IMF_Context *imf_context = NULL;
605 imf_context = (Ecore_IMF_Context *) ad->pin_entry;
607 if (NULL == imf_context) {
608 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error!!! Ecore_IMF_Context is NULL!!");
612 char *txt = elm_entry_markup_to_utf8(elm_entry_entry_get((const Evas_Object *) imf_context));
614 WFD_APP_LOG(WFD_APP_LOG_LOW, "* text [%s], len=[%d]", txt, strlen(txt));
615 strncpy(connection->wps_pin, txt, sizeof(connection->wps_pin) - 1);
616 WFD_IF_FREE_MEM(txt);
618 WFD_APP_LOG(WFD_APP_LOG_LOW, "Err!");
621 __WFD_APP_FUNC_EXIT__;
625 * This function let the app make a callback for progressbar timer
626 * @return if stop the timer, return ECORE_CALLBACK_CANCEL, else return ECORE_CALLBACK_RENEW
627 * @param[in] data the pointer to the wps structure
629 static Eina_Bool _fn_pb_timer(void *data)
633 char time_label[32] = {0};
634 wfd_wps_display_popup_t *wps_display_popup = (wfd_wps_display_popup_t *) data;
636 if (NULL == wps_display_popup) {
637 WFD_APP_LOG(WFD_APP_LOG_ERROR, "Param is NULL.\n");
638 return ECORE_CALLBACK_CANCEL;
641 Evas_Object *progressbar = NULL;
642 Evas_Object *time = NULL;
644 progressbar = wps_display_popup->progressbar;
645 time = wps_display_popup->time;
646 value = elm_progressbar_value_get(progressbar);
648 wps_display_popup->step++;
649 step = wps_display_popup->step;
650 value = ((double)step) / WFD_POP_TIMER_120;
653 WFD_APP_LOG(WFD_APP_LOG_LOW, "Progress end.\n");
655 ecore_timer_del(pb_timer);
659 return ECORE_CALLBACK_CANCEL;
662 elm_progressbar_value_set(progressbar, value);
663 WFD_APP_LOG(WFD_APP_LOG_LOW, "step: %d, value: %f\n", wps_display_popup->step, value);
665 /* show the time label */
668 snprintf(time_label, 32, "00:0%d", step);
670 snprintf(time_label, 32, "00:%d", step);
674 snprintf(time_label, 32, "0%d:0%d", step/60, step%60);
676 snprintf(time_label, 32, "0%d:%d", step/60, step%60);
680 char *remaining_time_str = g_strdup_printf(
681 "<font_size=40><align=center>%s</align></font_size>", time_label);
682 elm_object_text_set(time, remaining_time_str);
683 g_free(remaining_time_str);
685 return ECORE_CALLBACK_RENEW;
688 static Eina_Bool _keypad_popup_timer_cb(void *data)
690 __WFD_APP_FUNC_ENTER__;
692 char msg1[WFD_POP_STR_MAX_LEN] = {0};
693 char msg2[WFD_POP_STR_MAX_LEN] = {0};
695 Evas_Object *label = (Evas_Object*) data;
696 wfd_appdata_t *ad = wfd_get_appdata();
697 wfd_connection_info_s *connection = ad->connection;
698 WFD_RETV_IF(NULL == ad, FALSE, "NULL parameters(ad)\n");
699 WFD_RETV_IF(NULL == label, FALSE, "NULL parameters(label)\n");
700 if (NULL == ad->popup) {
701 keypad_popup_timeout = 0;
702 return ECORE_CALLBACK_CANCEL;
705 keypad_popup_timeout --;
707 if (keypad_popup_timeout > 0) {
708 _replace_1PS_2PD((char *)msg1, sizeof(msg1),
709 _("IDS_ST_BODY_CONNECT_WITH_PS_IN_PD_SECS_ABB"),
710 connection->peer_name, keypad_popup_timeout);
713 snprintf(msg2, sizeof(msg2), _("IDS_WIFI_POP_ENTER_PIN_TO_CONNECT_TO_PS"),
714 connection->peer_name);
716 elm_object_domain_translatable_text_set(label, PACKAGE, msg1);
720 if (keypad_popup_timeout <= 0) {
722 keypad_popup_timeout = 0;
723 __WFD_APP_FUNC_EXIT__;
724 return ECORE_CALLBACK_CANCEL;
727 __WFD_APP_FUNC_EXIT__;
728 return ECORE_CALLBACK_RENEW;
731 /* This callback is for showing(hiding) X marked button. */
732 /*static void _changed_cb(void *data, Evas_Object *obj, void *event_info)
734 if (elm_object_focus_get(obj)) {
735 if (elm_entry_is_empty(obj))
736 elm_object_signal_emit(data, "elm,state,eraser,hide", "");
738 elm_object_signal_emit(data, "elm,state,eraser,show", "");
742 /* Focused callback will show X marked button and hide guidetext. */
743 /*static void _focused_cb(void *data, Evas_Object *obj, void *event_info)
745 if (!elm_entry_is_empty(obj))
746 elm_object_signal_emit(data, "elm,state,eraser,show", "");
747 elm_object_signal_emit(data, "elm,state,rename,hide", "");
750 /* Unfocused callback will show guidetext and hide X marked button. */
751 /*static void _unfocused_cb(void *data, Evas_Object *obj, void *event_info)
753 elm_object_signal_emit(data, "elm,state,eraser,hide", "");
754 elm_object_signal_emit(data, "elm,state,rename,show", "");
757 /* When X marked button clicked, make string as empty. */
758 /*static void _eraser_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
760 elm_object_focus_set(data, EINA_TRUE);
761 elm_entry_entry_set(data, "");
765 * This function let the app create a edit filed
767 * @param[in] parent the parent object
768 * @param[in] title the pointer to the title of edit field
769 * @param[in] guide the pointer to the text of guide
770 * @param[in] single_line whether it can support single line
771 * @param[in] is_editable whether it is avaliable to edit
773 /*static Evas_Object *_add_edit_field(Evas_Object *parent, const char *title, const char *guide, Eina_Bool single_line, Eina_Bool is_editable)
775 assertm_if(NULL == parent, "parent is NULL!!");
777 Evas_Object *layout = elm_layout_add(parent);
778 assertm_if(NULL == layout, "layout is NULL!!");
780 if (title && title[0] != '\0') {
781 elm_layout_theme_set(layout, "layout", "dialogue/editfield/title", "default");
782 elm_object_part_text_set(layout, "elm.text", title);
784 elm_layout_theme_set(layout, "layout", "dialogue/editfield", "default");
787 Evas_Object *entry = elm_entry_add(layout);
788 assertm_if(NULL == entry, "entry is NULL!!");
790 if (guide && guide[0] != '\0') {
791 elm_object_part_text_set(layout, "elm.guidetext", guide);
794 evas_object_smart_callback_add(entry, "changed", _changed_cb, layout);
795 evas_object_smart_callback_add(entry, "focused", _focused_cb, layout);
796 evas_object_smart_callback_add(entry, "unfocused", _unfocused_cb, layout);
798 elm_object_part_content_set(layout, "elm.icon.entry", entry);
799 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
800 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
802 elm_entry_single_line_set(entry, single_line);
803 elm_entry_scrollable_set(entry, single_line);
805 Evas_Object *button = elm_button_add(parent);
806 elm_object_style_set(button, "editfield_clear");
807 elm_object_part_content_set(layout, "elm.icon.eraser", button);
808 evas_object_smart_callback_add(button, "clicked", _eraser_btn_clicked_cb, entry);
813 * This function let the app create a display popup
814 * @return display popup
815 * @param[in] win the window object
816 * @param[in] pop the pointer to the prepared popup
818 Evas_Object *wfd_draw_pop_type_display(Evas_Object * win, wfd_popup_t * pop)
820 __WFD_APP_FUNC_ENTER__;
821 WFD_APP_LOG(WFD_APP_LOG_LOW, "wfd_draw_pop_type_display\n");
823 Evas_Object *popup = NULL;
824 Evas_Object *progressbar = NULL;
825 Evas_Object *time = NULL;
827 static wfd_wps_display_popup_t wps_display_popup;
828 wfd_appdata_t *ad = wfd_get_appdata();
830 popup = elm_popup_add(win);
831 elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
832 evas_object_event_callback_add(popup, EVAS_CALLBACK_MOUSE_UP, mouseup_cb, ad);
833 // evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, keydown_cb, ad);
834 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, 0.0);
835 elm_object_domain_translatable_part_text_set(popup, "title,text",
836 PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
838 layout = elm_layout_add(popup);
839 if (layout == NULL) {
840 WFD_APP_LOG(WFD_APP_LOG_LOW, "Layout failed so returning !!");
844 elm_layout_file_set(layout, WFD_EDJ_POPUP_PATH, "popup_wps_pin_layout");
845 elm_object_domain_translatable_part_text_set(layout, "elm.text.description",
847 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
849 /* add progressbar */
850 progressbar = elm_progressbar_add(layout);
851 elm_object_style_set(progressbar, "list_progress");
852 elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
853 evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
854 evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
855 elm_progressbar_value_set(progressbar, 0.0);
856 evas_object_show(progressbar);
859 time = elm_label_add(layout);
860 elm_label_line_wrap_set(time, ELM_WRAP_MIXED);
861 elm_object_text_set(time, _("<font_size=40><align=center>00:00</align></font_size>"));
862 evas_object_size_hint_weight_set(time, EVAS_HINT_EXPAND, 0.0);
863 evas_object_size_hint_align_set(time, EVAS_HINT_FILL, EVAS_HINT_FILL);
864 evas_object_show(time);
866 elm_object_part_content_set(layout, "slider", progressbar);
867 elm_object_part_content_set(layout, "timer_label", time);
870 /* start progressbar timer */
871 wps_display_popup.step = 0;
872 wps_display_popup.progressbar = progressbar;
873 wps_display_popup.time = time;
874 pb_timer = ecore_timer_add(1, _fn_pb_timer, &wps_display_popup);
877 if (pop->resp_data2 == WFD_POP_RESP_APRV_CONNECT_NO) {
878 Evas_Object *btn2 = NULL;
879 btn2 = elm_button_add(popup);
880 elm_object_style_set(btn2, "popup");
881 elm_object_domain_translatable_text_set(btn2, PACKAGE, pop->label2);
882 elm_object_part_content_set(popup, "button1", btn2);
883 evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
884 (void *) pop->resp_data2);
885 eext_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, (void *) pop->resp_data2);
888 if (pop->resp_data1 == WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES || pop->resp_data1 == WFD_POP_RESP_APRV_CONNECT_PBC_YES ) {
889 Evas_Object *btn1 = NULL;
890 btn1 = elm_button_add(popup);
891 elm_object_style_set(btn1, "popup");
892 elm_object_domain_translatable_text_set(btn1, PACKAGE, pop->label1);
893 elm_object_part_content_set(popup, "button2", btn1);
894 evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
895 (void *) pop->resp_data1);
896 eext_object_event_callback_add(popup, EA_CALLBACK_BACK, __popup_resp_cb, (void *) pop->resp_data1);
899 elm_object_content_set(popup, layout);
901 __set_parent_rotate_angle(ad);
903 evas_object_show(popup);
904 evas_object_show(win);
906 ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __rotate, ad);
909 __WFD_APP_FUNC_EXIT__;
913 static void __popup_eraser_clicked_cb(void *data, Evas_Object *obj, void *event_info)
915 __WFD_APP_FUNC_ENTER__;
916 elm_entry_entry_set(data, "");
917 __WFD_APP_FUNC_EXIT__;
920 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
922 __WFD_APP_FUNC_ENTER__;
923 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
924 if (elm_object_focus_get(obj)) {
925 if (elm_entry_is_empty(obj))
926 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
928 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
931 __WFD_APP_FUNC_EXIT__;
934 static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
936 __WFD_APP_FUNC_ENTER__;
938 if (elm_object_part_content_get(obj, "elm.swallow.clear")) {
939 if (!elm_entry_is_empty(obj))
940 elm_object_signal_emit(obj, "elm,state,clear,visible", "");
942 elm_object_signal_emit(obj, "elm,state,clear,hidden", "");
944 elm_object_signal_emit(obj, "elm,state,focus,on", "");
945 __WFD_APP_FUNC_EXIT__;
948 static void _entry_keydown_cb(void *data, Evas *e, Evas_Object *obj,
951 __WFD_APP_FUNC_ENTER__;
953 Evas_Event_Key_Down *ev;
954 Evas_Object *entry = obj;
956 WFD_RET_IF(data == NULL, "Incorrect parameter data(NULL)\n");
957 WFD_RET_IF(event_info == NULL, "Incorrect parameter event_info(NULL)\n");
958 WFD_RET_IF(entry == NULL, "Incorrect parameter entry(NULL)\n");
960 ev = (Evas_Event_Key_Down *)event_info;
962 if (g_strcmp0(ev->key, "KP_Enter") == 0 || g_strcmp0(ev->key, "Return") == 0) {
963 Ecore_IMF_Context *imf_context;
965 imf_context = (Ecore_IMF_Context*)elm_entry_imf_context_get(entry);
967 ecore_imf_context_input_panel_hide(imf_context);
970 elm_object_focus_set(entry, EINA_FALSE);
974 static char *__wfd_main_desc_label_get(void *data, Evas_Object *obj,
977 __WFD_APP_FUNC_ENTER__;
978 if (obj == NULL || part == NULL) {
981 WFD_APP_LOG(WFD_APP_LOG_LOW, "wfd_rename desc\n");
982 char msg1[WFD_POP_STR_MAX_LEN] = {0, };
983 char msg2[WFD_POP_STR_MAX_LEN] = {0, };
984 wfd_appdata_t *ad = wfd_get_appdata();
985 WFD_RETV_IF(ad == NULL, NULL, "Incorrect parameter(NULL)\n");
986 wfd_connection_info_s *connection = ad->connection;
987 WFD_RETV_IF(connection == NULL, NULL, "Incorrect parameter(NULL)\n");
989 if (!g_strcmp0(part, "elm.text.multiline")) {
990 if (keypad_popup_timeout > 0) {
991 ad->timeout = keypad_popup_timeout;
993 _replace_1PS_2PD((char *)msg1, sizeof(msg1),
994 _("IDS_ST_BODY_CONNECT_WITH_PS_IN_PD_SECS_ABB"),
995 connection->peer_name, ad->timeout);
998 snprintf(msg2, sizeof(msg2),
999 _("IDS_WIFI_POP_ENTER_PIN_TO_CONNECT_TO_PS"),
1000 connection->peer_name);
1002 WFD_APP_LOG(WFD_APP_LOG_LOW, "string %s", msg1);
1003 __WFD_APP_FUNC_EXIT__;
1004 return g_strdup(msg1);
1006 __WFD_APP_FUNC_EXIT__;
1010 static Evas_Object *__wfd_pin_entry_icon_get(void *data, Evas_Object *obj,
1013 __WFD_APP_FUNC_ENTER__;
1014 if (obj == NULL || part == NULL) {
1017 wfd_appdata_t *ad = wfd_get_appdata();
1018 WFD_RETV_IF(ad == NULL, NULL, "Incorrect parameter(NULL)\n");
1019 Evas_Object *entry = NULL;
1020 Evas_Object *button = NULL;
1021 Ecore_IMF_Context *imf_context;
1022 if (g_strcmp0(part, "elm.icon.entry")) {
1023 __WFD_APP_FUNC_EXIT__;
1026 static Elm_Entry_Filter_Accept_Set accept_set = {"0123456789", NULL};
1027 entry = elm_entry_add(obj);
1028 elm_entry_single_line_set(entry, EINA_TRUE);
1029 elm_object_style_set(entry, "editfield");
1030 elm_entry_scrollable_set(entry, EINA_TRUE);
1032 eext_entry_selection_back_event_allow_set(entry, EINA_TRUE);
1033 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1034 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1035 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
1036 elm_entry_password_set(entry, EINA_TRUE);
1037 elm_entry_prediction_allow_set(entry, EINA_FALSE);
1039 elm_entry_markup_filter_append(entry,
1040 elm_entry_filter_accept_set,&accept_set);
1041 elm_entry_input_panel_layout_set(entry,
1042 ELM_INPUT_PANEL_LAYOUT_DATETIME);
1043 elm_object_signal_emit(entry, "elm,action,hide,search_icon", "");
1044 elm_object_domain_translatable_part_text_set(entry, "elm.guide",
1045 PACKAGE, _("IDS_WIFI_POP_PIN"));
1046 elm_entry_input_panel_return_key_autoenabled_set(entry,EINA_TRUE);
1047 elm_entry_input_panel_return_key_type_set(entry,
1048 ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
1050 ad->pin_entry = entry;
1051 imf_context = (Ecore_IMF_Context*)elm_entry_imf_context_get(entry);
1053 ecore_imf_context_input_panel_return_key_type_set(imf_context,
1054 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
1057 button = elm_button_add(obj);
1058 elm_object_style_set(button, "search_clear");
1059 elm_object_focus_allow_set(button, EINA_FALSE);
1060 elm_object_part_content_set(entry, "elm.swallow.clear", button);
1061 evas_object_smart_callback_add(button, "clicked",
1062 __popup_eraser_clicked_cb, entry);
1064 elm_object_signal_emit (entry, "elm,action,hide,search_icon", "");
1065 evas_object_smart_callback_add(entry, "changed",
1066 _entry_changed_cb, NULL);
1067 evas_object_smart_callback_add(entry, "preedit,changed",
1068 _entry_changed_cb, NULL);
1069 evas_object_smart_callback_add(entry, "focused",
1070 _entry_focused_cb, NULL);
1071 evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN,
1072 _entry_keydown_cb, ad);
1074 elm_object_content_set(obj,entry);
1075 evas_object_show(entry);
1076 evas_object_smart_callback_add(entry, "changed", _smart_ime_cb, NULL);
1077 elm_object_focus_set(entry, EINA_TRUE);
1078 __WFD_APP_FUNC_EXIT__;
1082 static void _chk_changed_cb(void *data, Evas_Object *obj, void *ei)
1084 __WFD_APP_FUNC_ENTER__;
1085 if (obj == NULL || data == NULL) {
1088 Eina_Bool state = elm_check_state_get(obj);
1090 elm_entry_password_set((Evas_Object *)data, EINA_FALSE);
1092 elm_entry_password_set((Evas_Object *)data, EINA_TRUE);
1094 __WFD_APP_FUNC_EXIT__;
1097 static void _gl_pswd_check_box_sel(void *data, Evas_Object *obj, void *ei)
1099 __WFD_APP_FUNC_ENTER__;
1100 Elm_Object_Item *item = NULL;
1101 item = (Elm_Object_Item *)ei;
1105 wfd_appdata_t *ad = wfd_get_appdata();
1107 WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter(NULL)\n");
1110 Evas_Object *ck = elm_object_item_part_content_get(ei, "elm.icon.left");
1111 elm_genlist_item_selected_set(item, EINA_FALSE);
1112 Eina_Bool state = elm_check_state_get(ck);
1113 elm_check_state_set(ck, !state);
1115 _chk_changed_cb(ad->pin_entry, ck, NULL);
1117 __WFD_APP_FUNC_EXIT__;
1120 static char *__wfd_password_label(void *data, Evas_Object *obj, const char *part)
1122 __WFD_APP_FUNC_ENTER__;
1124 if (data == NULL || part == NULL) {
1127 WFD_APP_LOG(WFD_APP_LOG_LOW, "Part %s", part);
1129 if (!g_strcmp0(part, "elm.text.main.right")) {
1130 __WFD_APP_FUNC_EXIT__;
1131 return g_strdup(" Show password");
1133 __WFD_APP_FUNC_EXIT__;
1137 static Evas_Object *__wfd_password_check(void *data, Evas_Object *obj,
1140 __WFD_APP_FUNC_ENTER__;
1141 if (obj == NULL || part == NULL) {
1144 wfd_appdata_t *ad = wfd_get_appdata();
1145 WFD_RETV_IF(ad == NULL, NULL, "Incorrect parameter(NULL)\n");
1146 Evas_Object *check = NULL;
1148 WFD_APP_LOG(WFD_APP_LOG_LOW, "Part %s", part);
1150 if (!g_strcmp0(part, "elm.icon.left")) {
1151 check = elm_check_add(obj);
1152 evas_object_propagate_events_set(check, EINA_FALSE);
1153 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
1154 evas_object_size_hint_weight_set(check,
1155 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1156 evas_object_smart_callback_add(check, "changed",
1157 _chk_changed_cb, ad->pin_entry);
1158 elm_object_focus_allow_set(check, EINA_FALSE);
1159 __WFD_APP_FUNC_EXIT__;
1162 __WFD_APP_FUNC_EXIT__;
1168 * This function let the app create a keypad popup
1169 * @return keypad popup
1170 * @param[in] win the window object
1171 * @param[in] pop the pointer to the prepared popup
1173 Evas_Object *wfd_draw_pop_type_keypad(Evas_Object * win, wfd_popup_t * pop)
1175 __WFD_APP_FUNC_ENTER__;
1176 wfd_appdata_t *ad = wfd_get_appdata();
1177 WFD_RETV_IF(ad == NULL, NULL, "Incorrect parameter(NULL)\n");
1178 wfd_connection_info_s *connection = ad->connection;
1179 WFD_RETV_IF(connection == NULL, NULL, "Incorrect parameter(NULL)\n");
1181 Evas_Object *pinpopup = NULL;
1182 Evas_Object *btn1 = NULL, *btn2 = NULL;
1183 Evas_Object *genlist = NULL;
1184 Elm_Object_Item *git = NULL;
1186 ad->timeout = pop->timeout;
1188 pinpopup = elm_popup_add(ad->layout);
1189 elm_popup_align_set(pinpopup, ELM_NOTIFY_ALIGN_FILL, 1.0);
1190 eext_object_event_callback_add(pinpopup, EA_CALLBACK_BACK, eext_popup_back_cb,
1192 evas_object_size_hint_weight_set(pinpopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1193 elm_object_domain_translatable_part_text_set(pinpopup, "title,text",
1194 PACKAGE, _("IDS_WIFI_HEADER_WI_FI_DIRECT_CONNECTION_ABB"));
1196 genlist = elm_genlist_add(pinpopup);
1197 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1198 evas_object_size_hint_weight_set(genlist,
1199 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1200 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1201 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1202 elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE);
1204 /* Entry genlist item */
1205 ad->pin_desc_itc = elm_genlist_item_class_new();
1206 if(ad->pin_desc_itc != NULL) {
1207 ad->pin_desc_itc->item_style = "multiline_main";
1208 ad->pin_desc_itc->func.text_get = __wfd_main_desc_label_get;
1209 ad->pin_desc_itc->func.content_get = NULL;
1210 ad->pin_desc_itc->func.state_get = NULL;
1211 ad->pin_desc_itc->func.del = NULL;
1213 git = elm_genlist_item_append(genlist, ad->pin_desc_itc, ad, NULL,
1214 ELM_GENLIST_ITEM_NONE, NULL, NULL);
1216 elm_genlist_item_select_mode_set(git,
1217 ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1219 keypad_popup_timeout = pop->timeout;
1220 keypad_popup_timer = ecore_timer_add(1, _keypad_popup_timer_cb,
1224 ad->pin_entry_itc = elm_genlist_item_class_new();
1225 if(ad->pin_entry_itc != NULL) {
1226 ad->pin_entry_itc->item_style = "entry";
1227 ad->pin_entry_itc->func.text_get = NULL;
1228 ad->pin_entry_itc->func.content_get = __wfd_pin_entry_icon_get;
1229 ad->pin_entry_itc->func.state_get = NULL;
1230 ad->pin_entry_itc->func.del = NULL;
1232 elm_genlist_item_append(genlist, ad->pin_entry_itc, pinpopup,
1233 NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
1236 ad->paswd_itc = elm_genlist_item_class_new();
1237 if(ad->paswd_itc != NULL) {
1238 ad->paswd_itc->item_style = "1line";
1239 ad->paswd_itc->func.text_get = __wfd_password_label;
1240 ad->paswd_itc->func.content_get = __wfd_password_check;
1241 ad->paswd_itc->func.state_get = NULL;
1242 ad->paswd_itc->func.del = NULL;
1244 elm_genlist_item_append(genlist, ad->paswd_itc, pinpopup,
1245 NULL, ELM_GENLIST_ITEM_NONE, _gl_pswd_check_box_sel, (void *)ad );
1248 btn1 = elm_button_add(pinpopup);
1249 elm_object_style_set(btn1, "popup");
1250 elm_object_domain_translatable_text_set(btn1, PACKAGE, pop->label2);
1251 elm_object_part_content_set(pinpopup, "button1", btn1);
1252 evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb,
1253 (void *)pop->resp_data2);
1255 btn2 = elm_button_add(pinpopup);
1256 elm_object_style_set(btn2, "popup");
1257 elm_object_domain_translatable_text_set(btn2, PACKAGE, pop->label1);
1258 elm_object_part_content_set(pinpopup, "button2", btn2);
1259 evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb,
1260 (void *)pop->resp_data1);
1261 #if defined(GENLIST_REALIZATION_MOTE_SET)
1262 elm_genlist_realization_mode_set(genlist, EINA_TRUE);
1264 evas_object_show(genlist);
1265 elm_object_content_set(pinpopup, genlist);
1268 __set_parent_rotate_angle(ad);
1270 evas_object_show(pinpopup);
1271 evas_object_show(win);
1272 elm_object_focus_set(ad->pin_entry, EINA_TRUE);
1274 ad->rotate_event_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
1278 __WFD_APP_FUNC_EXIT__;
1283 void _replace_int(char *haystack, int size, char *niddle, int value)
1285 __WFD_APP_FUNC_ENTER__;
1290 if (haystack == NULL || niddle == NULL || size <= 1)
1293 buf = g_strdup(haystack);
1294 p = strstr(buf, niddle);
1299 q = p + strlen(niddle);
1302 snprintf(haystack, size-1, "%s%d%s", buf, value, q);
1304 __WFD_APP_FUNC_EXIT__;
1307 void _replace_1PS_2PD(char *buf, int buf_len, char *format_str, char* SD_1, int PD_2)
1309 __WFD_APP_FUNC_ENTER__;
1310 char text[WFD_POP_STR_MAX_LEN] = {0, };
1312 strncpy(text, format_str, WFD_POP_STR_MAX_LEN-1);
1313 _replace_int(text, WFD_POP_STR_MAX_LEN, "%d", PD_2);
1314 _replace_int(text, WFD_POP_STR_MAX_LEN, "%2$d", PD_2);
1315 snprintf(buf, buf_len-1, text, SD_1);
1316 __WFD_APP_FUNC_EXIT__;
1321 * This function let the app create a popup
1323 * @param[in] type the type of popup
1324 * @param[in] userdata the pointer to the data which will be used
1326 void wfd_prepare_popup(int type, void *user_data)
1328 __WFD_APP_FUNC_ENTER__;
1329 wfd_appdata_t *ad = wfd_get_appdata();
1330 wfd_popup_t *pop = ad->popup_data;
1331 wfd_connection_info_s *connection = ad->connection;
1332 char text[WFD_POP_STR_MAX_LEN+1] = {0, };
1333 char text1[WFD_POP_STR_MAX_LEN+1] = {0, };
1334 wfd_destroy_popup();
1336 peer_name = elm_entry_utf8_to_markup(connection->peer_name);
1338 memset(pop, 0, sizeof(wfd_popup_t));
1342 switch (pop->type) {
1343 case /* MT */ WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ:
1345 _replace_1PS_2PD((char *)pop->text, sizeof(pop->text),
1346 _("IDS_WIFI_POP_CONNECT_TO_PS_IN_PD_SECONDS"),
1347 peer_name, WFD_POP_TIMER_120);
1349 snprintf(pop->label1, sizeof(pop->label1), "%s", _("IDS_WIFI_SK2_OK"));
1350 snprintf(pop->label2, sizeof(pop->label2), "%s", _("IDS_WIFI_SK_CANCEL"));
1351 pop->timeout = WFD_POP_TIMER_120;
1352 pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_PBC_YES;
1353 pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
1355 ad->popup = wfd_draw_pop_type_display(ad->win, pop);
1358 case /* MT */ WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ:
1359 snprintf(pop->text, sizeof(pop->text),
1360 _("IDS_WIFI_BODY_PS_IS_REQUESTING_A_WI_FI_DIRECT_CONNECTION_ALLOW_Q"),
1362 snprintf(pop->label1, sizeof(pop->label1), "%s", _("IDS_WIFI_BUTTON_ALLOW"));
1363 snprintf(pop->label2, sizeof(pop->label2), "%s", _("IDS_BR_SK_CANCEL"));
1364 pop->timeout = WFD_POP_TIMER_120;
1365 pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_DISPLAY_OK;
1366 pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
1368 ad->popup = wfd_draw_pop_type_c(ad->win, pop);
1371 case /* MT */ WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ:
1372 _replace_1PS_2PD((char *)pop->text, sizeof(pop->text),
1373 _("IDS_WIFI_POP_CONNECT_TO_PS_IN_PD_SECONDS"),
1374 peer_name, WFD_POP_TIMER_120);
1375 snprintf(pop->label1, sizeof(pop->label1), "%s", _("IDS_BR_SK_OK"));
1376 snprintf(pop->label2, sizeof(pop->label2), "%s", _("IDS_BR_SK_CANCEL"));
1377 pop->timeout = WFD_POP_TIMER_120;
1378 pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES;
1379 pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
1381 ad->popup = wfd_draw_pop_type_display(ad->win, pop);
1384 case /* MT */ WFD_POP_PROG_CONNECT:
1385 snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WIFI_BODY_CONNECTING_ING"));
1386 snprintf(pop->label1, sizeof(pop->label1), "%s", _("IDS_BR_SK_CANCEL"));
1387 pop->timeout = WFD_POP_TIMER_120;
1388 pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_NO;
1390 ad->popup = wfd_draw_pop_type_b(ad->win, pop);
1393 case /* MO */ WFD_POP_PROG_CONNECT_WITH_KEYPAD:
1394 _replace_1PS_2PD((char *)text, sizeof(text),
1395 _("IDS_WIFI_POP_CONNECT_TO_PS_IN_PD_SECONDS"),
1396 peer_name, WFD_POP_TIMER_120);
1398 snprintf(text1, WFD_POP_STR_MAX_LEN, "%s %s",
1399 text, _("IDS_WIFI_POP_ENTER_PIN_TO_CONNECT_TO_PS"));
1401 snprintf(pop->text, sizeof(pop->text), text1, connection->peer_name);
1403 snprintf(pop->label1, sizeof(pop->label1), "%s", _("IDS_WIFI_SK_CONNECT"));
1404 snprintf(pop->label2, sizeof(pop->label2), "%s", _("IDS_BR_SK_CANCEL"));
1405 pop->timeout = WFD_POP_TIMER_120;
1406 pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK;
1407 pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
1409 ad->popup = wfd_draw_pop_type_keypad(ad->win, pop);
1412 case /* MO/MT */ WFD_POP_PROG_CONNECT_WITH_PIN:
1413 _replace_1PS_2PD((char *)text, sizeof(text),
1414 _("IDS_WIFI_POP_CONNECT_TO_PS_IN_PD_SECONDS"),
1415 peer_name, WFD_POP_TIMER_120);
1417 snprintf(text1, WFD_POP_STR_MAX_LEN, "%s %s %s",
1420 _("IDS_WIFI_POP_PIN_CODE_PS"));
1421 snprintf(pop->text, sizeof(pop->text), text1, connection->wps_pin);
1423 snprintf(pop->label2, sizeof(pop->label2), "%s", _("IDS_BR_SK_CANCEL"));
1424 pop->timeout = WFD_POP_TIMER_120;
1425 pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO;
1427 ad->popup = wfd_draw_pop_type_display(ad->win, pop);
1430 case WFD_POP_PROG_CONNECT_CANCEL:
1431 snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_BR_SK_CANCEL"));
1432 pop->timeout = WFD_POP_TIMER_120;
1433 ad->popup = wfd_draw_pop_type_a(ad->win, pop);
1442 ret = feedback_play(FEEDBACK_PATTERN_GENERAL);
1443 if (ret != FEEDBACK_ERROR_NONE) {
1444 WFD_APP_LOG(WFD_APP_LOG_ERROR,"feedback_play error : %d\n", ret);
1446 WFD_IF_FREE_MEM(peer_name);
1447 __WFD_APP_FUNC_EXIT__;