1 #include "efl_assist.h"
2 #include "efl_assist_private.h"
6 #define UNAVAILABLE_TEXT "Screen reader is unavailable during using this application. You can press home or back key to go back to home screen."
8 static tts_h tts = NULL;
10 static void _tts_shutdown(void)
15 /* check current state */
17 tts_get_state(tts, &state);
18 if (state == TTS_STATE_PLAYING || state == TTS_STATE_PAUSED)
21 if (TTS_ERROR_NONE != ret)
23 fprintf(stderr, "Fail to stop handle : result(%d)", ret);
28 /* it is possible to try to shutdown before the state is ready,
29 because tts_prepare(); works Asynchronously. see elm_modapi_init(): */
30 if (state == TTS_STATE_READY)
32 ret = tts_unprepare(tts);
33 if (TTS_ERROR_NONE != ret)
35 fprintf(stderr, "Fail to unprepare handle : result(%d)", ret);
39 ret = tts_unset_state_changed_cb(tts);
40 if (TTS_ERROR_NONE != ret)
42 fprintf(stderr, "Fail to set callback : result(%d)", ret);
47 ret = tts_destroy(tts);
48 if (TTS_ERROR_NONE != ret)
50 fprintf(stderr, "Fail to destroy handle : result(%d)", ret);
58 void _tts_state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* data)
63 if (TTS_STATE_CREATED == previous && TTS_STATE_READY == current)
65 ret = tts_add_text(tts, UNAVAILABLE_TEXT, NULL, TTS_VOICE_TYPE_AUTO,
66 TTS_SPEED_AUTO, &u_id);
67 if (TTS_ERROR_NONE != ret)
69 fprintf(stderr, "Fail to add kept text : ret(%d)\n", ret);
73 if (TTS_ERROR_NONE != ret)
75 fprintf(stderr, "Fail to play TTS : ret(%d)\n", ret);
80 static void _tts_init(void)
84 ret = tts_create(&tts);
85 if (TTS_ERROR_NONE != ret)
87 fprintf(stderr, "Fail to get handle : result(%d)", ret);
91 ret = tts_set_state_changed_cb(tts, _tts_state_changed_cb, NULL);
92 if (TTS_ERROR_NONE != ret)
94 fprintf(stderr, "Fail to set callback : result(%d)", ret);
98 ret = tts_set_mode(tts, TTS_MODE_SCREEN_READER);
99 if (TTS_ERROR_NONE != ret)
101 fprintf(stderr, "Fail to set mode : result(%d)", ret);
105 ret = tts_prepare(tts);
106 if (TTS_ERROR_NONE != ret)
108 fprintf(stderr, "Fail to prepare handle : result(%d)", ret);
113 static void _timeout_cb(void *data, Evas_Object *obj, void *event_info)
118 xwin = elm_win_xwindow_get(data);
121 evas_object_del(obj);
124 ecore_x_window_prop_card32_set
125 (xwin, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
131 ea_screen_reader_support_set(Evas_Object *win, Eina_Bool support)
140 if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &tts_val) != 0)
143 if (!tts_val) return EINA_FALSE;
145 if (!win) return EINA_FALSE;
147 xwin = elm_win_xwindow_get(win);
148 if (!xwin) return EINA_FALSE;
153 elm_config_access_set(EINA_TRUE);
155 ecore_x_window_prop_card32_set
156 (xwin, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
160 elm_config_access_set(EINA_FALSE);
162 popup = elm_popup_add(win);
163 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
164 elm_object_text_set(popup, UNAVAILABLE_TEXT);
165 elm_popup_timeout_set(popup, 12.0);
166 evas_object_smart_callback_add(popup, "timeout", _timeout_cb, win);
169 evas_object_show(popup);
176 ea_screen_reader_support_get()
178 return elm_config_access_get();