Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,25 @@ if ENABLE_DOC
SUBDIRS += doc
endif

EXTRA_DIST= config.rpath COPYING.LGPL COPYING.GPL-2 COPYING.GPL-3 ANNOUNCE BUGS FAQ README.md README.packagers README.translators README.overview.md README.style.md build.sh speech-dispatcherd.service.in speech-dispatcher.socket speech-dispatcher.service.in po/Makevars.in po/README
# Keep sorted in byte order, as "LC_ALL=C sort" does.
EXTRA_DIST = \
ANNOUNCE \
BUGS \
COPYING.GPL-2 \
COPYING.GPL-3 \
COPYING.LGPL \
FAQ \
README.md \
README.overview.md \
README.packagers \
README.style.md \
README.translators \
build.sh \
config.rpath \
po/Makevars.in \
po/README \
speech-dispatcher.service.in \
speech-dispatcherd.service.in

CLEANFILES=
DISTCLEANFILES=
Expand Down
16 changes: 16 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,21 @@ AC_SUBST([LIB_SPD_AGE])
GETTEXT_PACKAGE=speech-dispatcher
AC_SUBST([GETTEXT_PACKAGE])

# Default location of the per-user server socket, shared by the
# server, libspeechd, the Python client and the systemd user socket:
# <runtime dir>/<spd_socket_path>, in the server's directory
# <runtime dir>/<spd_runtime_subdir>
spd_runtime_subdir=speech-dispatcher
spd_socket_path=$spd_runtime_subdir/speechd.sock
AC_DEFINE_UNQUOTED([SPD_RUNTIME_SUBDIR], ["$spd_runtime_subdir"],
[Directory of the server in the user's runtime directory])
AC_DEFINE_UNQUOTED([SPD_SOCKET_PATH], ["$spd_socket_path"],
[Default server socket, relative to the user's runtime directory])
AC_DEFINE([SPD_BUILD_SOCKET_PATH(runtime_dir)],
[g_build_filename((runtime_dir), SPD_SOCKET_PATH, NULL)],
[Default server socket in runtime_dir, as a string to free with g_free])
AC_SUBST([spd_socket_path])

# Paths for configuration files:
spdconfdir='${sysconfdir}/speech-dispatcher'
AC_SUBST([spdconfdir])
Expand Down Expand Up @@ -718,6 +733,7 @@ AC_CONFIG_FILES([Makefile
run-speechd
run-spd-say
speech-dispatcher.pc
speech-dispatcher.socket
config/Makefile
config/clients/Makefile
config/modules/Makefile
Expand Down
2 changes: 1 addition & 1 deletion speech-dispatcher.socket → speech-dispatcher.socket.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Description=Speech Dispatcher Socket

[Socket]
ListenStream=%t/speech-dispatcher/speechd.sock
ListenStream=%t/@spd_socket_path@

[Install]
WantedBy=sockets.target
11 changes: 1 addition & 10 deletions src/api/c/libspeechd.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,7 @@ char *get_line(SPDConnection * conn, int *n)
/* Determine address for the unix socket */
static char *_get_default_unix_socket_name(void)
{
GString *socket_filename;
char *h;
const char *rundir = g_get_user_runtime_dir();
socket_filename = g_string_new("");
g_string_printf(socket_filename, "%s/speech-dispatcher/speechd.sock",
rundir);
// Do not return glib string, but glibc string...
h = strdup(socket_filename->str);
g_string_free(socket_filename, 1);
return h;
return SPD_BUILD_SOCKET_PATH(g_get_user_runtime_dir());
}

void SPDConnectionAddress__free(SPDConnectionAddress * address)
Expand Down
1 change: 1 addition & 0 deletions src/api/python/speechd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ speechd_python_PYTHON = __init__.py _test.py client.py
nodist_speechd_python_PYTHON = paths.py

edit = sed \
-e 's:@spd_socket_path[@]:$(spd_socket_path):g' \
-e 's:@bindir[@]:$(bindir):g'

all: paths.py
Expand Down
2 changes: 1 addition & 1 deletion src/api/python/speechd/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ class SSIPClient(object):
"""Default host for server connections."""
DEFAULT_PORT = 6560
"""Default port number for server connections."""
DEFAULT_SOCKET_PATH = "speech-dispatcher/speechd.sock"
DEFAULT_SOCKET_PATH = paths.DEFAULT_SOCKET_PATH
"""Default name of the communication unix socket"""

def __init__(self, name, component='default', user='unknown', address=None,
Expand Down
1 change: 1 addition & 0 deletions src/api/python/speechd/paths.py.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SPD_SPAWN_CMD = "@bindir@/speech-dispatcher"
DEFAULT_SOCKET_PATH = "@spd_socket_path@"
15 changes: 3 additions & 12 deletions src/server/speechd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ int main(int argc, char *argv[])

/* Setup a speechd-dispatcher directory or create a new one */
SpeechdOptions.runtime_speechd_dir =
g_strdup_printf("%s/speech-dispatcher", user_runtime_dir);
g_build_filename(user_runtime_dir, SPD_RUNTIME_SUBDIR, NULL);
MSG(4, "Trying to find %s", SpeechdOptions.runtime_speechd_dir);
g_mkdir_with_parents(SpeechdOptions.runtime_speechd_dir,
S_IRWXU);
Expand Down Expand Up @@ -1271,18 +1271,9 @@ int main(int argc, char *argv[])
if (!strcmp(SpeechdOptions.socket_path, "default")) {
/* This code cannot be moved above next to conf_dir and pidpath resolution because
we need to also consider the DotConf configuration, which is read in speechd_init() */
GString *socket_filename;
socket_filename = g_string_new("");
if (SpeechdOptions.runtime_speechd_dir) {
g_string_printf(socket_filename, "%s/speechd.sock",
SpeechdOptions.runtime_speechd_dir);
} else {
FATAL
("Socket name file not set and user has no runtime directory");
}
g_free(SpeechdOptions.socket_path);
SpeechdOptions.socket_path = g_strdup(socket_filename->str);
g_string_free(socket_filename, 1);
SpeechdOptions.socket_path =
SPD_BUILD_SOCKET_PATH(g_get_user_runtime_dir());
}

/* Check if the communication method corresponds to the spawn request */
Expand Down
4 changes: 1 addition & 3 deletions src/tests/run_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ void set_socket_path(struct sockaddr_un *address)

path = g_getenv("SPEECHD_SOCKET");
if (path == NULL || path[0] == '\0') {
pathcopy = g_build_filename(g_get_user_runtime_dir(),
"speech-dispatcher",
"speechd.sock", NULL);
pathcopy = SPD_BUILD_SOCKET_PATH(g_get_user_runtime_dir());
path = pathcopy;
}

Expand Down
Loading