summaryrefslogtreecommitdiff
path: root/src/modules/access_output
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2011-08-19 11:07:42 +0000
committerCarsten Haitzler <raster@rasterman.com>2011-08-19 11:07:42 +0000
commitc264466f3bd6f352d9aba93ea998e9edf9b59a08 (patch)
tree13bd5c37b274c4b125bde08beccf74d8c57f4dad /src/modules/access_output
parent20236447bb926f0c1503a6ed8a50ad335ab7565d (diff)
this is... the beginning of accessibility supportin elm. it's direct
as in elm manages it itself - all it needs is a module to send text to. one is provided here that just execs espeak and handles a stream of things for it to say. this is only a start and is still being fleshed out. SVN revision: 62585
Diffstat (limited to 'src/modules/access_output')
-rw-r--r--src/modules/access_output/Makefile.am33
-rw-r--r--src/modules/access_output/mod.c116
2 files changed, 149 insertions, 0 deletions
diff --git a/src/modules/access_output/Makefile.am b/src/modules/access_output/Makefile.am
new file mode 100644
index 000000000..0cf21873d
--- /dev/null
+++ b/src/modules/access_output/Makefile.am
@@ -0,0 +1,33 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I. \
6-I$(top_builddir) \
7-I$(top_srcdir) \
8-I$(top_srcdir)/src/lib \
9-I$(top_builddir)/src/lib \
10-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
11-DPACKAGE_LIB_DIR=\"$(libdir)\" \
12@ELEMENTARY_CFLAGS@ \
13@ELEMENTARY_X_CFLAGS@ \
14@ELEMENTARY_FB_CFLAGS@ \
15@ELEMENTARY_WIN32_CFLAGS@ \
16@ELEMENTARY_WINCE_CFLAGS@ \
17@ELEMENTARY_EDBUS_CFLAGS@ \
18@ELEMENTARY_EFREET_CFLAGS@ \
19@ELEMENTARY_ETHUMB_CFLAGS@ \
20@ELEMENTARY_EMAP_CFLAGS@
21
22if ELEMENTARY_WINDOWS_BUILD
23AM_CPPFLAGS += -DELEMENTARY_BUILD
24endif
25
26pkgdir = $(libdir)/elementary/modules/access_output/$(MODULE_ARCH)
27pkg_LTLIBRARIES = module.la
28
29module_la_SOURCES = mod.c
30
31module_la_LIBADD = $(top_builddir)/src/lib/libelementary.la
32module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
33module_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/src/modules/access_output/mod.c b/src/modules/access_output/mod.c
new file mode 100644
index 000000000..79e97990d
--- /dev/null
+++ b/src/modules/access_output/mod.c
@@ -0,0 +1,116 @@
1#include <Elementary.h>
2#ifdef HAVE_CONFIG_H
3# include "elementary_config.h"
4#endif
5
6/* to enable this module
7export ELM_MODULES="access_output>access/api"
8 */
9
10static void (*cb_func) (void *data);
11static void *cb_data;
12static Ecore_Exe *espeak = NULL;
13static Ecore_Event_Handler *exe_exit_handler = NULL;
14static char *tmpf = NULL;
15static int tmpfd = -1;
16
17static Eina_Bool
18_exe_del(void *data __UNUSED__, int type __UNUSED__, void *event)
19{
20 Ecore_Exe_Event_Del *ev = event;
21
22 if ((espeak) && (ev->exe == espeak))
23 {
24 if (tmpf)
25 {
26 unlink(tmpf);
27 free(tmpf);
28 tmpf = NULL;
29 close(tmpfd);
30 }
31 espeak = NULL;
32 if (cb_func) cb_func(cb_data);
33 }
34 return ECORE_CALLBACK_RENEW;
35}
36
37// module api funcs needed
38EAPI int
39elm_modapi_init(void *m __UNUSED__)
40{
41 exe_exit_handler =
42 ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
43 _exe_del, NULL);
44 return 1; // succeed always
45}
46
47EAPI int
48elm_modapi_shutdown(void *m __UNUSED__)
49{
50 if (exe_exit_handler)
51 {
52 ecore_event_handler_del(exe_exit_handler);
53 exe_exit_handler = NULL;
54 }
55 return 1; // succeed always
56}
57
58// module fucns for the specific module type
59EAPI void
60out_read(const char *txt)
61{
62 if (!tmpf)
63 {
64 char buf[PATH_MAX];
65
66 snprintf(buf, sizeof(buf), "/tmp/.elm-speak-XXXXXX");
67 tmpfd = mkstemp(buf);
68 if (tmpfd >= 0) tmpf = strdup(buf);
69 else return;
70 }
71 if (write(tmpfd, txt, strlen(txt)) < 0) perror("write to tmpfile (espeak)");
72}
73
74EAPI void
75out_read_done(void)
76{
77 char buf[PATH_MAX];
78
79 if (espeak)
80 {
81 ecore_exe_interrupt(espeak);
82 espeak = NULL;
83 }
84 if (tmpf)
85 {
86 close(tmpfd);
87 snprintf(buf, sizeof(buf), "espeak -m -a 20 -f %s", tmpf);
88 espeak = ecore_exe_pipe_run(buf,
89 ECORE_EXE_NOT_LEADER,
90 NULL);
91 }
92}
93
94EAPI void
95out_cancel(void)
96{
97 if (espeak)
98 {
99 ecore_exe_interrupt(espeak);
100 espeak = NULL;
101 }
102 if (tmpf)
103 {
104 unlink(tmpf);
105 free(tmpf);
106 tmpf = NULL;
107 close(tmpfd);
108 }
109}
110
111EAPI void
112out_done_callback_set(void (*func) (void *data), const void *data)
113{
114 cb_func = func;
115 cb_data = (void *)data;
116}