2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "efl_assist.h"
20 #include "efl_assist_private.h"
28 #include <Ecore_Wayland.h>
33 #define UNAVAILABLE_TEXT "Screen reader is unavailable during using this application. You can press home or back key to go back to home screen."
35 static tts_h tts = NULL;
37 static void _tts_shutdown(void)
42 /* check current state */
44 tts_get_state(tts, &state);
45 if (state == TTS_STATE_PLAYING || state == TTS_STATE_PAUSED)
48 if (TTS_ERROR_NONE != ret)
50 fprintf(stderr, "Fail to stop handle : result(%d)", ret);
55 /* it is possible to try to shutdown before the state is ready,
56 because tts_prepare(); works Asynchronously. see elm_modapi_init(): */
57 if (state == TTS_STATE_READY)
59 ret = tts_unprepare(tts);
60 if (TTS_ERROR_NONE != ret)
62 fprintf(stderr, "Fail to unprepare handle : result(%d)", ret);
66 ret = tts_unset_state_changed_cb(tts);
67 if (TTS_ERROR_NONE != ret)
69 fprintf(stderr, "Fail to set callback : result(%d)", ret);
74 ret = tts_destroy(tts);
75 if (TTS_ERROR_NONE != ret)
77 fprintf(stderr, "Fail to destroy handle : result(%d)", ret);
85 void _tts_state_changed_cb(tts_h tts, tts_state_e previous, tts_state_e current, void* data)
90 if (TTS_STATE_CREATED == previous && TTS_STATE_READY == current)
92 ret = tts_add_text(tts, UNAVAILABLE_TEXT, NULL, TTS_VOICE_TYPE_AUTO,
93 TTS_SPEED_AUTO, &u_id);
94 if (TTS_ERROR_NONE != ret)
96 fprintf(stderr, "Fail to add kept text : ret(%d)\n", ret);
100 if (TTS_ERROR_NONE != ret)
102 fprintf(stderr, "Fail to play TTS : ret(%d)\n", ret);
107 static void _tts_init(void)
111 ret = tts_create(&tts);
112 if (TTS_ERROR_NONE != ret)
114 fprintf(stderr, "Fail to get handle : result(%d)", ret);
118 ret = tts_set_state_changed_cb(tts, _tts_state_changed_cb, NULL);
119 if (TTS_ERROR_NONE != ret)
121 fprintf(stderr, "Fail to set callback : result(%d)", ret);
125 ret = tts_set_mode(tts, TTS_MODE_SCREEN_READER);
126 if (TTS_ERROR_NONE != ret)
128 fprintf(stderr, "Fail to set mode : result(%d)", ret);
132 ret = tts_prepare(tts);
133 if (TTS_ERROR_NONE != ret)
135 fprintf(stderr, "Fail to prepare handle : result(%d)", ret);
140 static void _timeout_cb(void *data, Evas_Object *obj, void *event_info)
143 Ecore_X_Window xwin=0;
147 Ecore_Wl_Window *wwin=0;
151 xwin = elm_win_xwindow_get(data);
153 evas_object_del(obj); obj=0;
155 ecore_x_window_prop_card32_set
156 (xwin, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
161 wwin = elm_win_wl_window_get(data);
163 evas_object_del(obj); obj=0;
165 fprintf(stderr, "TODO: workaround: disabled code from "
166 __FILE__ ":%d:", __LINE__);
174 ea_screen_reader_support_set(Evas_Object *win, Eina_Bool support)
179 #elif defined HAVE_WAYLAND
180 Ecore_Wl_Window *w=0;
185 if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &tts_val) != 0)
188 if (!tts_val) return EINA_FALSE;
190 if (!win) return EINA_FALSE;
193 w = elm_win_wl_window_get(win);
195 w = elm_win_xwindow_get(win);
198 if (!w) return EINA_FALSE;
202 elm_config_access_set(EINA_TRUE);
205 ecore_x_window_prop_card32_set
206 (w, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
208 fprintf(stderr, "TODO: workaround: disabled code from "
209 __FILE__ ":%d:", __LINE__);
214 elm_config_access_set(EINA_FALSE);
216 popup = elm_popup_add(win);
217 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
218 elm_object_text_set(popup, UNAVAILABLE_TEXT);
219 elm_popup_timeout_set(popup, 12.0);
220 evas_object_smart_callback_add(popup, "timeout", _timeout_cb, win);
223 evas_object_show(popup);
230 ea_screen_reader_support_get()
232 return elm_config_access_get();