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)
126 #elif defined HAVE_WAYLAND
133 w = elm_win_xwindow_get(data);
134 #elif defined HAVE_WAYLAND
135 w = elm_win_wl_window_get(data);
139 evas_object_del(obj);
143 ecore_x_window_prop_card32_set
144 (win, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
146 fprintf(stderr, "TODO: workaround: disabled code from "
147 __FILE__ ":%d:", __LINE__);
154 ea_screen_reader_support_set(Evas_Object *win, Eina_Bool support)
158 #elif defined HAVE_WAYLAND
167 if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &tts_val) != 0)
170 if (!tts_val) return EINA_FALSE;
172 if (!win) return EINA_FALSE;
175 w = elm_win_wl_window_get(win);
177 w = elm_win_xwindow_get(win);
180 if (!w) return EINA_FALSE;
185 elm_config_access_set(EINA_TRUE);
187 ecore_x_window_prop_card32_set
188 (w, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
190 fprintf(stderr, "TODO: workaround: disabled code from "
191 __FILE__ ":%d:", __LINE__);
196 elm_config_access_set(EINA_FALSE);
198 popup = elm_popup_add(win);
199 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
200 elm_object_text_set(popup, UNAVAILABLE_TEXT);
201 elm_popup_timeout_set(popup, 12.0);
202 evas_object_smart_callback_add(popup, "timeout", _timeout_cb, win);
205 evas_object_show(popup);
212 ea_screen_reader_support_get()
214 return elm_config_access_get();