1 #include "efl_assist.h"
2 #include "efl_assist_private.h"
10 #include <Ecore_Wayland.h>
15 #define UNAVAILABLE_TEXT "Screen reader is unavailable during using this application. You can press home or back key to go back to home screen."
17 static tts_h tts = NULL;
19 static void _tts_shutdown(void)
24 /* check current state */
26 tts_get_state(tts, &state);
27 if (state == TTS_STATE_PLAYING || state == TTS_STATE_PAUSED)
30 if (TTS_ERROR_NONE != ret)
32 fprintf(stderr, "Fail to stop handle : result(%d)", ret);
37 /* it is possible to try to shutdown before the state is ready,
38 because tts_prepare(); works Asynchronously. see elm_modapi_init(): */
39 if (state == TTS_STATE_READY)
41 ret = tts_unprepare(tts);
42 if (TTS_ERROR_NONE != ret)
44 fprintf(stderr, "Fail to unprepare handle : result(%d)", ret);
48 ret = tts_unset_state_changed_cb(tts);
49 if (TTS_ERROR_NONE != ret)
51 fprintf(stderr, "Fail to set callback : result(%d)", ret);
56 ret = tts_destroy(tts);
57 if (TTS_ERROR_NONE != ret)
59 fprintf(stderr, "Fail to destroy handle : result(%d)", ret);
67 void _tts_state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* data)
72 if (TTS_STATE_CREATED == previous && TTS_STATE_READY == current)
74 ret = tts_add_text(tts, UNAVAILABLE_TEXT, NULL, TTS_VOICE_TYPE_AUTO,
75 TTS_SPEED_AUTO, &u_id);
76 if (TTS_ERROR_NONE != ret)
78 fprintf(stderr, "Fail to add kept text : ret(%d)\n", ret);
82 if (TTS_ERROR_NONE != ret)
84 fprintf(stderr, "Fail to play TTS : ret(%d)\n", ret);
89 static void _tts_init(void)
93 ret = tts_create(&tts);
94 if (TTS_ERROR_NONE != ret)
96 fprintf(stderr, "Fail to get handle : result(%d)", ret);
100 ret = tts_set_state_changed_cb(tts, _tts_state_changed_cb, NULL);
101 if (TTS_ERROR_NONE != ret)
103 fprintf(stderr, "Fail to set callback : result(%d)", ret);
107 ret = tts_set_mode(tts, TTS_MODE_SCREEN_READER);
108 if (TTS_ERROR_NONE != ret)
110 fprintf(stderr, "Fail to set mode : result(%d)", ret);
114 ret = tts_prepare(tts);
115 if (TTS_ERROR_NONE != ret)
117 fprintf(stderr, "Fail to prepare handle : result(%d)", ret);
122 static void _timeout_cb(void *data, Evas_Object *obj, void *event_info)
125 Ecore_X_Window xwin=0;
128 Ecore_Wl_Window *wwin=0;
133 xwin = elm_win_xwindow_get(data);
135 evas_object_del(obj); obj=0;
137 ecore_x_window_prop_card32_set
138 (xwin, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
143 wwin = elm_win_wl_window_get(data);
145 evas_object_del(obj); obj=0;
147 fprintf(stderr, "TODO: workaround: disabled code from "
148 __FILE__ ":%d:", __LINE__);
156 ea_screen_reader_support_set(Evas_Object *win, Eina_Bool support)
160 #elif defined HAVE_WAYLAND
161 Ecore_Wl_Window *w=0;
169 if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &tts_val) != 0)
172 if (!tts_val) return EINA_FALSE;
174 if (!win) return EINA_FALSE;
177 w = elm_win_wl_window_get(win);
179 w = elm_win_xwindow_get(win);
182 if (!w) return EINA_FALSE;
187 elm_config_access_set(EINA_TRUE);
189 ecore_x_window_prop_card32_set
190 (w, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
192 fprintf(stderr, "TODO: workaround: disabled code from "
193 __FILE__ ":%d:", __LINE__);
198 elm_config_access_set(EINA_FALSE);
200 popup = elm_popup_add(win);
201 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
202 elm_object_text_set(popup, UNAVAILABLE_TEXT);
203 elm_popup_timeout_set(popup, 12.0);
204 evas_object_smart_callback_add(popup, "timeout", _timeout_cb, win);
207 evas_object_show(popup);
214 ea_screen_reader_support_get()
216 return elm_config_access_get();