[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] server - More tightly integrate the server into a user session
From: |
Luke Yelavich |
Subject: |
[PATCH] server - More tightly integrate the server into a user session |
Date: |
Wed, 15 Jul 2009 16:32:35 +1000 |
From: Luke Yelavich <address@hidden>
To: address@hidden
This commit allows for tighter integration of the speech server into a user's
session. When the user logs in, the SPEECHD_PORT environment variable is set
to a unique port number, which is the base port set in intl/def.h, plus the
user's UID. When the server gets loaded, it then checks for the presence of
the SPEECHD_PORT environment variable, and uses that port for communication
if found. The environment variable will overwrite any setting in the config
file, but will not override the port command-line flag.
This integration is disabled by default, but can be enabled at compile time
with the --enable-session-integration command-line flag given to the
configure script. You can also set in which directory the shell fragment
gets placed, to allow it to be run at user login. This is set using the
--with-bash-profile-dir command-line flag. The default is
$sysconfdir/profile.d.
---
configure.in | 20 +++++++++++++++++++-
src/Makefile.am | 4 ++--
src/server/Makefile.am | 4 ++++
src/server/speechd.c | 13 +++++++++++++
src/session/Makefile.in | 32 ++++++++++++++++++++++++++++++++
src/session/speechd-user-port.sh.in | 1 +
6 files changed, 71 insertions(+), 3 deletions(-)
create mode 100644 src/session/Makefile.in
create mode 100644 src/session/speechd-user-port.sh.in
diff --git a/configure.in b/configure.in
index 287a06b..3c0ab6a 100644
--- a/configure.in
+++ b/configure.in
@@ -242,6 +242,24 @@ AC_SUBST(gthread_libs)
AC_SUBST(datadir)
+AC_ARG_ENABLE([session-integration],
+ AC_HELP_STRING([--enable-session-integration],
+ [build with user session integration support]),
+ msg_session_integration=$enableval,
+ msg_session_integration=no)
+ if test "x$enable_session_integration" != "xyes"; then
+ msg_session_integration=no
+ fi
+AM_CONDITIONAL(ENABLE_SESSION, test "$msg_session_integration" = "yes")
+
+AC_ARG_WITH([bash-profile-dir],
+ AC_HELP_STRING([--with-bash-profile-dir=PATH],
+ [choose directory for session integration shell
file (default=SYSCONFDIR/profile.d)]),
+ with_bash_profile_dir=$withval,
+ with_bash_profile_dir=$sysconfdir/profile.d)
+BASH_PROFILE_DIR=$with_bash_profile_dir
+AC_SUBST(BASH_PROFILE_DIR)
+
spdconfdir='${sysconfdir}/speech-dispatcher'
AC_SUBST(spdconfdir)
moduleconfdir='${spdconfdir}/modules'
@@ -285,5 +303,5 @@ AC_SUBST(LIB_SPD_CURRENT)
AC_SUBST(LIB_SPD_REVISION)
AC_SUBST(LIB_SPD_AGE)
-AC_OUTPUT([Makefile src/Makefile src/server/Makefile src/modules/Makefile
src/c/Makefile src/c/api/Makefile src/c/clients/Makefile
src/c/clients/say/Makefile src/c/clients/spdsend/Makefile src/tests/Makefile
src/audio/Makefile config/Makefile config/modules/Makefile
config/clients/Makefile doc/Makefile src/python/Makefile])
+AC_OUTPUT([Makefile src/Makefile src/server/Makefile src/modules/Makefile
src/c/Makefile src/c/api/Makefile src/c/clients/Makefile
src/c/clients/say/Makefile src/c/clients/spdsend/Makefile src/tests/Makefile
src/audio/Makefile config/Makefile config/modules/Makefile
config/clients/Makefile doc/Makefile src/python/Makefile src/session/Makefile])
diff --git a/src/Makefile.am b/src/Makefile.am
index 19f0c08..32e9bfa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,8 +8,8 @@ EXTRA_DIST = cl/ChangeLog cl/README cl/*.lisp cl/*.asd \
guile/ChangeLog guile/Makefile guile/README guile/*.in guile/*.c guile/*.h \
python/*.py python/speechd/*.py python/Makefile.in python/speechd_config/*.py \
python/speechd_config/spd-conf python/speechd_config/test.wav \
-python/speechd_config/speechd.desktop
+python/speechd_config/speechd.desktop session/Makefile.in
session/speechd-user-port.sh.in
-SUBDIRS= server audio c modules tests python
+SUBDIRS= server audio c modules tests python session
diff --git a/src/server/Makefile.am b/src/server/Makefile.am
index fcbcfd9..1d45ae0 100644
--- a/src/server/Makefile.am
+++ b/src/server/Makefile.am
@@ -7,3 +7,7 @@ speech_dispatcher_LDFLAGS = -rdynamic
inc_local = -I$(top_srcdir)/intl/
localedir = $(datadir)/locale
AM_CFLAGS = -Wall $(inc_local) -I$(localedir) @glib_include@
-DSYS_CONF=\"@address@hidden" -DSND_DATA=\"@address@hidden"
-DMODULEBINDIR=\"@address@hidden" -DVERSION=\"@address@hidden"
-DPACKAGE=\"@address@hidden" -DPIDPATH=\"@address@hidden"
+
+if ENABLE_SESSION
+AM_CFLAGS += -DENABLE_SESSION
+endif
diff --git a/src/server/speechd.c b/src/server/speechd.c
index 530fdbc..a9ed391 100644
--- a/src/server/speechd.c
+++ b/src/server/speechd.c
@@ -766,6 +766,19 @@ main(int argc, char *argv[])
options_parse(argc, argv);
+#ifdef ENABLE_SESSION
+ /* Get the server port from the SPEECHD_PORT environment variable. */
+ char *tail_ptr;
+ int val;
+ if (getenv("SPEECHD_PORT") && !SpeechdOptions.port_set){
+ SpeechdOptions.port_set = 1;
+ val = strtol(getenv("SPEECHD_PORT"), &tail_ptr, 10);
+ if (tail_ptr != getenv("SPEECHD_PORT")){
+ SpeechdOptions.port = val;
+ }
+ }
+#endif
+
MSG(1, "Speech Dispatcher "VERSION" starting");
/* Check if there is .speech-dispatcher directory
diff --git a/src/session/Makefile.in b/src/session/Makefile.in
new file mode 100644
index 0000000..7304fe7
--- /dev/null
+++ b/src/session/Makefile.in
@@ -0,0 +1,32 @@
+prefix = @prefix@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+datarootdir = @datarootdir@
+bash_profile_dir = @BASH_PROFILE_DIR@
+speechd_default_port = $(shell grep SPEECHD_DEFAULT_PORT ../../intl/def.h |
awk '{print $$3}')
+
+all:
+ifneq ($(ENABLE_SESSION_TRUE), "")
+ sed -e "s/@SPEECHD_DEFAULT_PORT@/$(speechd_default_port)/"
speechd-user-port.sh.in > speechd-user-port.sh
+endif
+
+install:
+ifneq ($(ENABLE_SESSION_TRUE), "")
+ install -d -o root -m 755 $(DESTDIR)/$(bash_profile_dir)
+ install -o root -m 644 speechd-user-port.sh
$(DESTDIR)/$(bash_profile_dir)
+endif
+
+uninstall:
+ rm -f $(DESTDIR)/$(bash_profile_dir)/speechd-user-port.sh
+
+clean:
+ rm -f speechd-user-port.sh
+
+distclean: clean
+
+maintainer-clean: clean
+
+distdir:
+
+check:
+
diff --git a/src/session/speechd-user-port.sh.in
b/src/session/speechd-user-port.sh.in
new file mode 100644
index 0000000..70e185d
--- /dev/null
+++ b/src/session/speechd-user-port.sh.in
@@ -0,0 +1 @@
+export SPEECHD_PORT=$(expr @SPEECHD_DEFAULT_PORT@ + $(getent passwd $USER |
cut -f 3 -d :))
--
1.6.3.3
- [PATCH] server - More tightly integrate the server into a user session,
Luke Yelavich <=