Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnome-session/configure.in,v
retrieving revision 1.391
diff -u -r1.391 configure.in
--- configure.in	10 Jun 2002 06:02:37 -0000	1.391
+++ configure.in	12 Jun 2002 21:04:36 -0000
@@ -19,15 +19,31 @@
 dnl If you add a version number here, you *must* add an AC_SUBST line for
 dnl it too, or it will never make it into the spec file!
 
+AUDIOFILE_REQUIRED=0.2.3
+ESOUND_REQUIRED=0.2.26
 LIBGNOMECANVAS_REQUIRED=2.0.0
 LIBGNOMEUI_REQUIRED=2.0.0
 
 AC_SUBST(LIBGNOMECANVAS_REQUIRED)
 AC_SUBST(LIBGNOMEUI_REQUIRED)
+AC_SUBST(AUDIOFILE_REQUIRED)
+AC_SUBST(ESOUND_REQUIRED)
 
 dnl pkg-config dependency checks
 
-PKG_CHECK_MODULES(GNOME_SESSION, libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED)
+dnl We first check for esound and audiofile (which has conditional
+dnl support built in)
+
+AUDIOFILE_MODULE="audiofile >= $AUDIOFILE_REQUIRED_VERSION"
+ESOUND_MODULE="esound >= $ESOUND_REQUIRED_VERSION"
+PKG_CHECK_MODULES(SOUND_TEST, $ESOUND_MODULE $AUDIOFILE_MODULE, [
+	AC_DEFINE(HAVE_ESD)
+],[
+	AUDIOFILE_MODULE=""
+	ESOUND_MODULE=""
+])
+
+PKG_CHECK_MODULES(GNOME_SESSION, libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED $AUDIOFILE_MODULE $ESOUND_MODULE)
 AC_SUBST(GNOME_SESSION_CFLAGS)
 AC_SUBST(GNOME_SESSION_LIBS)
 
@@ -216,6 +232,7 @@
 LIBS="$oLIBS"
 dnl -----------------------------------------------------------
 
+AC_CHECK_FUNCS(usleep)
 
 dnl Build Flags
 
@@ -245,9 +262,10 @@
 [  --with-reboot-command=COMMAND
 			  Specify the command for rebooting the system],[
     REBOOT_COMMAND="$with_reboot_command"], [
-    AC_PATH_PROGS(REBOOT_COMMAND, reboot, [
-	AC_MSG_ERROR([The reboot command was not found. Please use the --with-reboot-command option.])
-    ])
+    AC_PATH_PROGS(REBOOT_COMMAND, reboot)
+    if test x$REBOOT_COMMAND = x ; then
+	AC_MSG_WARN([The reboot command was not found. Restarting from the logout dialog will be disabled.])
+    fi
 ])
 AC_SUBST(REBOOT_COMMAND)
 
@@ -255,9 +273,10 @@
 [  --with-halt-command=COMMAND
 			  Specify the command for halting the system],[
     HALT_COMMAND="$with_halt_command"], [
-    AC_PATH_PROGS(HALT_COMMAND, poweroff halt, [
-	AC_MSG_ERROR([The halt command was not found. Please use the --with-halt-command option.])
-    ])
+    AC_PATH_PROGS(HALT_COMMAND, [poweroff halt])
+    if test x$HALT_COMMAND = x ; then
+	AC_MSG_WARN([The halt command was not found. Shutting down from the logout dialog will be disabled.])
+    fi
 ])
 AC_SUBST(HALT_COMMAND)
 
Index: gnome-session/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/Makefile.am,v
retrieving revision 1.80
diff -u -r1.80 Makefile.am
--- gnome-session/Makefile.am	6 Jun 2002 22:36:06 -0000	1.80
+++ gnome-session/Makefile.am	12 Jun 2002 21:04:36 -0000
@@ -71,6 +71,8 @@
 	splash.h		\
 	gsm-protocol.c		\
 	gsm-protocol.h		\
+	gsm-sound.c		\
+	gsm-sound.h		\
 	gsm-typebuiltins.c	\
 	gsm-typebuiltins.h	\
 	headers.h		\
Index: gnome-session/gsm-sound.c
===================================================================
RCS file: gnome-session/gsm-sound.c
diff -N gnome-session/gsm-sound.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnome-session/gsm-sound.c	12 Jun 2002 21:04:36 -0000
@@ -0,0 +1,153 @@
+#include <config.h>
+
+#include "gsm-sound.h"
+
+#ifdef HAVE_ESD /* almost whole file */
+#include <libgnome/libgnome.h>
+#include <gconf/gconf-client.h>
+#include <esd.h>
+
+static void
+start_esd (void) 
+{
+  GError *err = NULL;
+  time_t starttime;
+	
+  if (!g_spawn_command_line_async ("esd -nobeeps", &err))
+    {
+      g_warning ("Could not start esd: %s\n", err->message);
+      g_error_free (err);
+      return;
+    }
+
+  starttime = time (NULL);
+  gnome_sound_init (NULL);
+
+  while (gnome_sound_connection_get () < 0
+	 && ((time(NULL) - starttime) < 4)) 
+    {
+#ifdef HAVE_USLEEP
+      usleep(200);
+#endif
+      gnome_sound_init(NULL);
+    }  
+}
+
+static gboolean
+load_login_sample_from (const char *file)
+{
+  char *key;
+  char *sample_file;
+  int sample_id;
+
+  if (!file)
+    return FALSE;
+
+  key = g_strconcat ("=", file, "=login/file", NULL);
+  sample_file = gnome_config_get_string (key);
+  g_free (key);
+
+  if (sample_file && *sample_file && *sample_file != '/')
+    {
+      char *tmp_sample_file;
+      tmp_sample_file = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_SOUND, sample_file, TRUE, NULL);
+      g_free (sample_file);
+      sample_file = tmp_sample_file;
+    }
+
+  if (!(sample_file && *sample_file))
+    {
+      g_free (sample_file);
+      return FALSE;
+    }
+
+  sample_id = esd_sample_getid (gnome_sound_connection_get (), "gnome-2/login");
+  if (sample_id >= 0)
+    esd_sample_free (gnome_sound_connection_get (), sample_id);
+
+  sample_id = gnome_sound_sample_load ("gnome-2/login", sample_file);
+
+  if (sample_id < 0)
+    {
+      g_warning ("Couldn't load sound file %s\n", sample_file);
+      return FALSE;
+    }
+
+  g_free (sample_file);
+
+  return TRUE;
+}
+
+#define SOUND_EVENT_FILE "sound/events/gnome-2.soundlist"
+static gboolean
+load_login_sample (void)
+{
+  char *s;
+  gboolean loaded;
+
+  s = gnome_util_home_file (SOUND_EVENT_FILE);
+  loaded = load_login_sample_from (s);
+  g_free (s);
+
+  if (loaded)
+    return TRUE;
+
+  s = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_CONFIG, SOUND_EVENT_FILE, TRUE, NULL);
+  loaded = load_login_sample_from (s);
+  g_free (s);
+
+  return loaded;
+}
+
+static gboolean
+sound_init (void)
+{
+  GConfClient *client;
+  gboolean enable_esd;
+  gboolean event_sounds;
+
+  client = gconf_client_get_default ();
+
+  enable_esd   = gconf_client_get_bool (client, "/desktop/gnome/sound/enable_esd", NULL);
+  event_sounds = gconf_client_get_bool (client, "/desktop/gnome/sound/event_sounds", NULL);
+
+  if (!(enable_esd && event_sounds))
+    return FALSE;
+
+  if (gnome_sound_connection_get () < 0)
+    start_esd ();
+
+  if (gnome_sound_connection_get () < 0)
+    {
+      g_warning ("Esound failed to start.\n");
+      return FALSE;
+    }
+
+  return load_login_sample ();
+}
+
+static void
+play_trigger (const char *trigger)
+{
+  const char *supinfo[3] = { "gnome-2" };
+  supinfo[1] = trigger;
+  gnome_triggers_vdo ("", NULL, supinfo);
+}
+#endif /* HAVE_ESD */
+
+void 
+gsm_sound_login (void)
+{
+#ifdef HAVE_ESD
+  if (sound_init ())
+    play_trigger ("login");
+#endif /* HAVE_ESD */
+}
+
+void 
+gsm_sound_logout (void)
+{
+#ifdef HAVE_ESD
+  play_trigger ("logout");
+#endif
+}
Index: gnome-session/gsm-sound.h
===================================================================
RCS file: gnome-session/gsm-sound.h
diff -N gnome-session/gsm-sound.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnome-session/gsm-sound.h	12 Jun 2002 21:04:36 -0000
@@ -0,0 +1,7 @@
+#ifndef GSM_SOUND_H
+#define GSM_SOUND_H
+
+void gsm_sound_login (void);
+void gsm_sound_logout (void);
+
+#endif /* GSM_SOUND_H */
Index: gnome-session/main.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/main.c,v
retrieving revision 1.42
diff -u -r1.42 main.c
--- gnome-session/main.c	5 Jun 2002 22:25:16 -0000	1.42
+++ gnome-session/main.c	12 Jun 2002 21:04:36 -0000
@@ -40,6 +40,7 @@
 #include "command.h"
 #include "splash.h"
 #include "util.h"
+#include "gsm-sound.h"
 
 /* Flag indicating autosave - user won't be prompted on logout to 
  * save the session */
@@ -264,12 +265,16 @@
   putenv (session_name_env);
   the_session = read_session (session_name);
 
+  gsm_sound_login ();
+
   if (splashing)
     start_splash (49.0);
 
   start_session (the_session);
 
   gtk_main ();
+
+  gsm_sound_logout ();
 
   clean_ice ();
 
