Commit 5e57744d authored by Brian Cameron's avatar Brian Cameron Committed by Brian Cameron

Happy holidays. Some bug fixes.

2005-12-24  Brian Cameron  <brian.cameron@sun.com>

        Happy holidays.  Some bug fixes.

        * daemon/gdm.h, daemon/gdmconfig.c, daemon/slave.c,
          gui/gdmlogin.c, gui/greeter/greeter_item_timed.c:
          Fix so that timed/automatic enable is checked and
          automatic/timed login is only turned on if they are
          enabled.  Fix so greeters restart if timed login is
          changed in gdmsetup.  Fixes bug #324337.
        * gui/gdmcommon.c, gui/gdmlogin.c, gui/greeter/greeter.c,
          gui/greeter/greeter_item.c, gui/greeter/greeter_parser.c:
          Now gdmlogin and gdmcommon use the same character sequences
          with Welcome/RemoteWelcome messages.  Fixes bug #322711.
        * docs/C/gdm.xml: Document how character sequences work with text
          labels and Welcome/RemoteWelcome messages.
        * gui/gdmcommon.[ch], gui/gdmchooser.c,
          gui/greeter/greeter_canvas_item.c, gui/greeter/greeter_geometry.c:
          Rename functions so all common functions have prefix gdm_common.
parent bef4ad35
2005-12-24 Brian Cameron <brian.cameron@sun.com>
Happy holidays. Some bug fixes.
* daemon/gdm.h, daemon/gdmconfig.c, daemon/slave.c,
gui/gdmlogin.c, gui/greeter/greeter_item_timed.c:
Fix so that timed/automatic enable is checked and
automatic/timed login is only turned on if they are
enabled. Fix so greeters restart if timed login is
changed in gdmsetup. Fixes bug #324337.
* gui/gdmcommon.c, gui/gdmlogin.c, gui/greeter/greeter.c,
gui/greeter/greeter_item.c, gui/greeter/greeter_parser.c:
Now gdmlogin and gdmcommon use the same character sequences
with Welcome/RemoteWelcome messages. Fixes bug #322711.
* docs/C/gdm.xml: Document how character sequences work with text
labels and Welcome/RemoteWelcome messages.
* gui/gdmcommon.[ch], gui/gdmchooser.c,
gui/greeter/greeter_canvas_item.c, gui/greeter/greeter_geometry.c:
Rename functions so all common functions have prefix gdm_common.
2005-12-22 Brian Cameron <brian.cameron@sun.com>
* daemon/auth.c, daemon/display.c, daemon/errorgui.c,
......
......@@ -180,10 +180,7 @@ enum {
/* Configuration constants */
#define GDM_KEY_CHOOSER "daemon/Chooser=" EXPANDED_LIBEXECDIR "/gdmchooser"
/* This defaults to true for backward compatibility,
* it will not actually do automatic login since the AutomaticLogin defaults
* to nothing */
#define GDM_KEY_AUTOMATIC_LOGIN_ENABLE "daemon/AutomaticLoginEnable=true"
#define GDM_KEY_AUTOMATIC_LOGIN_ENABLE "daemon/AutomaticLoginEnable=false"
#define GDM_KEY_AUTOMATIC_LOGIN "daemon/AutomaticLogin="
/* The SDTLOGIN feature is Solaris specific, and causes the Xserver to be
* run with user permissionsinstead of as root, which adds security but
......@@ -229,10 +226,7 @@ enum {
#define GDM_KEY_DISPLAY_LAST_LOGIN "daemon/DisplayLastLogin=false"
/* This defaults to true for backward compatibility,
* it will not actually do timed login since the TimedLogin defaults
* to nothing */
#define GDM_KEY_TIMED_LOGIN_ENABLE "daemon/TimedLoginEnable=true"
#define GDM_KEY_TIMED_LOGIN_ENABLE "daemon/TimedLoginEnable=false"
#define GDM_KEY_TIMED_LOGIN "daemon/TimedLogin="
#define GDM_KEY_TIMED_LOGIN_DELAY "daemon/TimedLoginDelay=30"
......@@ -699,6 +693,7 @@ void gdm_final_cleanup (void);
#define GDM_NOTIFY_REMOTE_GREETER "RemoteGreeter" /* <greeter binary> */
#define GDM_NOTIFY_TIMED_LOGIN "TimedLogin" /* <login> */
#define GDM_NOTIFY_TIMED_LOGIN_DELAY "TimedLoginDelay" /* <seconds> */
#define GDM_NOTIFY_TIMED_LOGIN_ENABLE "TimedLoginEnable" /* <true/false as int> */
#define GDM_NOTIFY_DISALLOW_TCP "DisallowTCP" /* <true/false as int> */
#define GDM_NOTIFY_SOUND_ON_LOGIN_FILE "SoundOnLoginFile" /* <sound file> */
#define GDM_NOTIFY_SOUND_ON_LOGIN_SUCCESS_FILE "SoundOnLoginSuccessFile" /* <sound file> */
......
......@@ -777,8 +777,6 @@ notify_displays_string (const gchar *key, const gchar *val)
}
}
/* TODO - Need to fix so notification happens for TIMED_LOGIN */
/**
* _gdm_set_value_string
* _gdm_set_value_bool
......@@ -963,6 +961,8 @@ _gdm_set_value_string (gchar *key, gchar *value_in, gboolean doing_update)
notify_displays_string (GDM_NOTIFY_SOUND_ON_LOGIN_FAILURE_FILE, *setting);
else if (is_key (key, GDM_KEY_GTK_MODULES_LIST))
notify_displays_string (GDM_NOTIFY_GTK_MODULES_LIST, *setting);
else if (is_key (key, GDM_KEY_TIMED_LOGIN))
notify_displays_string (GDM_NOTIFY_TIMED_LOGIN, *setting);
}
if (setting_copy != NULL)
......@@ -1048,6 +1048,8 @@ _gdm_set_value_bool (gchar *key, gboolean value, gboolean doing_update)
notify_displays_int (GDM_NOTIFY_DISALLOW_TCP, *setting);
else if (is_key (key, GDM_KEY_ADD_GTK_MODULES))
notify_displays_int (GDM_NOTIFY_ADD_GTK_MODULES, *setting);
else if (is_key (key, GDM_KEY_TIMED_LOGIN_ENABLE))
notify_displays_int (GDM_NOTIFY_TIMED_LOGIN_ENABLE, *setting);
}
if (*setting)
......
......@@ -1317,13 +1317,15 @@ gdm_slave_run (GdmDisplay *display)
char *automaticlogin = gdm_get_value_string (GDM_KEY_AUTOMATIC_LOGIN);
char *timedlogin = gdm_get_value_string (GDM_KEY_TIMED_LOGIN);
if ( ! ve_string_empty (automaticlogin)) {
if (gdm_get_value_bool (GDM_KEY_AUTOMATIC_LOGIN_ENABLE) &&
! ve_string_empty (automaticlogin)) {
g_free (ParsedAutomaticLogin);
ParsedAutomaticLogin = gdm_parse_enriched_login (automaticlogin,
display);
}
if ( ! ve_string_empty (timedlogin)) {
if (gdm_get_value_bool (GDM_KEY_TIMED_LOGIN_ENABLE) &&
! ve_string_empty (timedlogin)) {
g_free (ParsedTimedLogin);
ParsedTimedLogin = gdm_parse_enriched_login (timedlogin,
display);
......@@ -5343,10 +5345,14 @@ gdm_slave_handle_notify (const char *msg)
}
}
}
} else if (strncmp (msg, GDM_NOTIFY_TIMED_LOGIN " ",
strlen (GDM_NOTIFY_TIMED_LOGIN) + 1) == 0) {
} else if ((strncmp (msg, GDM_NOTIFY_TIMED_LOGIN " ",
strlen (GDM_NOTIFY_TIMED_LOGIN) + 1) == 0) ||
(strncmp (msg, GDM_NOTIFY_TIMED_LOGIN_DELAY " ",
strlen (GDM_NOTIFY_TIMED_LOGIN_DELAY) + 1) == 0) ||
(strncmp (msg, GDM_NOTIFY_TIMED_LOGIN_ENABLE " ",
strlen (GDM_NOTIFY_TIMED_LOGIN_ENABLE) + 1) == 0)) {
do_restart_greeter = TRUE;
/* FIXME: this is fairly nasty, we should handle this nicer */
/* FIXME: this is fairly nasty, we should handle this nicer */
/* FIXME: can't handle flexi servers without going all cranky */
if (d->type == TYPE_STATIC || d->type == TYPE_XDMCP) {
if ( ! d->logged_in) {
......@@ -5355,10 +5361,6 @@ gdm_slave_handle_notify (const char *msg)
remanage_asap = TRUE;
}
}
} else if (sscanf (msg, GDM_NOTIFY_TIMED_LOGIN_DELAY " %d", &val) == 1) {
gdm_set_value_int (GDM_KEY_TIMED_LOGIN_DELAY, val);
if (d->greetpid > 1)
kill (d->greetpid, SIGHUP);
} else if (strncmp (msg, GDM_NOTIFY_SOUND_ON_LOGIN_FILE " ",
strlen (GDM_NOTIFY_SOUND_ON_LOGIN_FILE) + 1) == 0) {
gdm_set_value_string (GDM_KEY_SOUND_ON_LOGIN_FILE,
......
......@@ -2871,7 +2871,9 @@ XKeepsCrashing
<filename>RemoteWelcome</filename>. This value is translated
into the appropriate language for the user. If set to false,
the <filename>RemoteWelcome</filename> setting is used.
false, the <filename>Welcome</filename> setting is used.
This string can use the same special character sequences as
explained in the "Text Node" section of the "Themed Greeter"
chapter. This explains the meaning of "%n".
</para>
</listitem>
</varlistentry>
......@@ -2884,6 +2886,9 @@ XKeepsCrashing
Controls which text to display next to the logo image in the
greeter for remote XDMCP sessions. The same expansion is
done here as in the <filename>Welcome</filename> string.
This string can use the same special character sequences as
explained in the "Text Node" section of the "Themed Greeter"
chapter.
</para>
</listitem>
</varlistentry>
......@@ -5097,7 +5102,7 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
<term>clock</term>
<listitem>
<para>
Label the displays the date and time.
Label that displays the date and time.
</para>
</listitem>
</varlistentry>
......@@ -5106,7 +5111,7 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
<term>pam-prompt</term>
<listitem>
<para>
Label the displays PAM prompt. This is the prompt that PAM
Label that displays the PAM prompt. This is the prompt that PAM
uses to ask for username, password, etc...
</para>
</listitem>
......@@ -5116,7 +5121,7 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
<term>pam-error</term>
<listitem>
<para>
Label the displays PAM/GDM error messages. Such as when user
Label that displayst PAM/GDM error messages. Such as when user
can't log in.
</para>
</listitem>
......@@ -5126,7 +5131,7 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
<term>pam-message</term>
<listitem>
<para>
Label the displays PAM message. These are messages that
Label that displays the PAM message. These are messages that
PAM/GDM gives about state of the account, help about the
prompts and other information.
</para>
......@@ -5142,7 +5147,7 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
</listitem>
</varlistentry>
</variablelist>
<para>
Rectangles can have id values as follows:
</para>
......@@ -5474,6 +5479,61 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
<screen>&lt;text"&gt;foo&amp;lt;sup&amp;gt;bar&amp;lt;/sup&amp;gt;&lt;/text&gt;</screen>
</para>
<para>
Text nodes can contain the following special character sequences which
will be translated as follows:
</para>
<para>
%% - A literal % character
</para>
<para>
%c - Clock time. Only labels with the "clock" id will update
automatically every second. Other labels will contain a static
timestamp.
</para>
<para>
%d - Display name (DISPLAY environment variable)
</para>
<para>
%h - Hostname (gethostname output)
</para>
<para>
%m - Machine name (uname.machine output)
</para>
<para>
%n - Node name (uname.nodename output)
</para>
<para>
%o - Domain name (getdomainname output)
</para>
<para>
%r - Release name (uname.release output)
</para>
<para>
%s - System name (uname.sysname output)
</para>
<para>
%t - Current timed delay value from configuration file (0 if off)
followed by the word "seconds" if value is greater than 1 or
the word "second" if the value is 1. This character sequence is
intended to be only used internally to display the "timed-label"
message, which is automatically updated every second.
</para>
<para>
%u - Timed username value from configuration file (empty if off)
This character sequence is intended to be only used internally to
display the "timed-label" message, which is automatically updated
every second.
</para>
<para>
\n - Carriage return
</para>
<para>
_ - An underscore causes the following character to be underlined.
If it precedes a % character sequence, the string that replaces the
character sequence is underlined.
</para>
</sect3>
<sect3 id="stocklabels">
......@@ -5524,14 +5584,13 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
<filename>system</filename>, _("_Actions") (Formerly "S_ystem")
</para>
<para>
<filename>timed-label</filename>,
_("User %s will login in %d seconds")
<filename>timed-label</filename>, _("User %u will login in %t")
</para>
<para>
<filename>username-label</filename>, _("Username:")
</para>
<para>
<filename>welcome-label</filename>, _("Welcome to %h")
<filename>welcome-label</filename>, _("Welcome to %n")
</para>
<para>
......
This diff is collapsed.
......@@ -1345,7 +1345,7 @@ XKeepsCrashing
<term>DefaultRemoteWelcome</term>
<listitem>
<synopsis>DefaultRemoteWelcome=true</synopsis>
<para>If set to true, the value "Welcome to %n" is used for the <filename>RemoteWelcome</filename>. This value is translated into the appropriate language for the user. If set to false, the <filename>RemoteWelcome</filename> setting is used. false, the <filename>Welcome</filename> setting is used.</para>
<para>If set to true, the value "Welcome to %n" is used for the <filename>RemoteWelcome</filename>. This value is translated into the appropriate language for the user. If set to false, the <filename>RemoteWelcome</filename> setting is used. This string can use the same special character sequences as explained in the "Text Node" section of the "Themed Greeter" chapter. This explains the meaning of "%n".</para>
</listitem>
</varlistentry>
......@@ -1353,7 +1353,7 @@ XKeepsCrashing
<term>RemoteWelcome</term>
<listitem>
<synopsis>RemoteWelcome=Welcome to n</synopsis>
<para>Controls which text to display next to the logo image in the greeter for remote XDMCP sessions. The same expansion is done here as in the <filename>Welcome</filename> string.</para>
<para>Controls which text to display next to the logo image in the greeter for remote XDMCP sessions. The same expansion is done here as in the <filename>Welcome</filename> string. This string can use the same special character sequences as explained in the "Text Node" section of the "Themed Greeter" chapter.</para>
</listitem>
</varlistentry>
......@@ -2837,28 +2837,28 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
<varlistentry>
<term>reloj</term>
<listitem>
<para>Etiqueta que muesta la fecha y la hora.</para>
<para>Label that displays the date and time.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pam-prompt</term>
<listitem>
<para>Label the displays PAM prompt. This is the prompt that PAM uses to ask for username, password, etc...</para>
<para>Label that displays the PAM prompt. This is the prompt that PAM uses to ask for username, password, etc...</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pam-error</term>
<listitem>
<para>Label the displays PAM/GDM error messages. Such as when user can't log in.</para>
<para>Label that displayst PAM/GDM error messages. Such as when user can't log in.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>pam-message</term>
<listitem>
<para>Label the displays PAM message. These are messages that PAM/GDM gives about state of the account, help about the prompts and other information.</para>
<para>Label that displays the PAM message. These are messages that PAM/GDM gives about state of the account, help about the prompts and other information.</para>
</listitem>
</varlistentry>
......@@ -2869,7 +2869,7 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
</listitem>
</varlistentry>
</variablelist>
<para>Rectangles can have id values as follows:</para>
<variablelist>
......@@ -3040,6 +3040,21 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
<para>You can include pango markup in the text nodes for labels, however you must encode it. So for example to have the label of "foo&lt;sup&gt;bar&lt;/sup&gt;", you must type: <screen>&lt;text"&gt;foo&amp;lt;sup&amp;gt;bar&amp;lt;/sup&amp;gt;&lt;/text&gt;</screen></para>
<para>Text nodes can contain the following special character sequences which will be translated as follows:</para>
<para>%% - A literal % character</para>
<para>%c - Clock time. Only labels with the "clock" id will update automatically every second. Other labels will contain a static timestamp.</para>
<para>%d - Display name (DISPLAY environment variable)</para>
<para>%h - Hostname (gethostname output)</para>
<para>%m - Machine name (uname.machine output)</para>
<para>%n - Node name (uname.nodename output)</para>
<para>%o - Domain name (getdomainname output)</para>
<para>%r - Release name (uname.release output)</para>
<para>%s - System name (uname.sysname output)</para>
<para>%t - Current timed delay value from configuration file (0 if off) followed by the word "seconds" if value is greater than 1 or the word "second" if the value is 1. This character sequence is intended to be only used internally to display the "timed-label" message, which is automatically updated every second.</para>
<para>%u - Timed username value from configuration file (empty if off) This character sequence is intended to be only used internally to display the "timed-label" message, which is automatically updated every second.</para>
<para>\n - Carriage return</para>
<para>_ - An underscore causes the following character to be underlined. If it precedes a % character sequence, the string that replaces the character sequence is underlined.</para>
</sect3>
<sect3 id="stocklabels">
......@@ -3059,9 +3074,9 @@ ypadding="num" spacing="num" homogeneous="bool"&gt;
<para><filename>session</filename>, _("_Session")</para>
<para><filename>suspend</filename>, _("Sus_pend")</para>
<para><filename>system</filename>, _("_Actions") (Formerly "S_ystem")</para>
<para><filename>timed-label</filename>, _("User %s will login in %d seconds")</para>
<para><filename>timed-label</filename>, _("User %u will login in %t")</para>
<para><filename>username-label</filename>, _("Username:")</para>
<para><filename>welcome-label</filename>, _("Welcome to %h")</para>
<para><filename>welcome-label</filename>, _("Welcome to %n")</para>
<para>For example: <screen>&lt;stock type="welcome-label"/&gt;</screen></para>
</sect3>
......
......@@ -1812,7 +1812,7 @@ gdm_reread_config (int sig, gpointer data)
gdm_config_reload_int (GDM_KEY_BACKGROUND_TYPE)) {
if (gdm_config_get_int (GDM_KEY_BACKGROUND_TYPE) != GDM_BACKGROUND_NONE)
setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
gdm_common_setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
}
return TRUE;
......@@ -1969,7 +1969,7 @@ main (int argc, char *argv[])
/* but just in case */
if (RUNNING_UNDER_GDM) {
if (gdm_config_get_int (GDM_KEY_BACKGROUND_TYPE) != GDM_BACKGROUND_NONE)
setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
gdm_common_setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
gdm_common_setup_cursor (GDK_WATCH);
}
......
......@@ -28,6 +28,7 @@
#include <locale.h>
#include <string.h>
#include <syslog.h>
#include <sys/utsname.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
......@@ -37,6 +38,8 @@
#include "gdmcomm.h"
#include "gdmconfig.h"
gint gdm_timed_delay = 0;
void
gdm_common_abort (const gchar *format, ...)
{
......@@ -305,7 +308,7 @@ gdm_common_select_time_format (void)
/* Not to look too shaby on Xinerama setups */
void
setup_background_color (gchar *bg_color)
gdm_common_setup_background_color (gchar *bg_color)
{
GdkColormap *colormap;
GdkColor color;
......@@ -338,7 +341,7 @@ setup_background_color (gchar *bg_color)
}
gchar *
gdm_get_welcomemsg (void)
gdm_common_get_welcomemsg (void)
{
gchar *welcomemsg;
gchar *tempstr;
......@@ -416,7 +419,7 @@ post_display_run (gpointer data)
}
void
gdm_post_display_launch (void)
gdm_common_post_display_launch (void)
{
if (! post_display_prog_get_path ())
return;
......@@ -424,3 +427,179 @@ gdm_post_display_launch (void)
g_idle_add (post_display_run, NULL);
}
/*
* Returns the string version of the time that the user
* will need to free. Requires the user pass in the
* the_tm structure to be used. This way the caller
* has access to the time data as well.
*/
gchar *
gdm_common_get_clock (struct tm **the_tm)
{
char *str;
time_t the_time;
time (&the_time);
*the_tm = localtime (&the_time);
if (gdm_common_select_time_format ()) {
str = ve_strftime (*the_tm, _("%a %b %d, %H:%M"));
} else {
/* Translators: You should translate time part as
%H:%M if your language does not have AM and PM
equivalent. Note: %l is a strftime option for
12-hour clock format */
str = ve_strftime (*the_tm, _("%a %b %d, %l:%M %p"));
}
return str;
}
char *
gdm_common_expand_text (const gchar *text)
{
GString *str;
const char *p;
gchar *clock, *display;
int r, i, n_chars;
gboolean underline = FALSE;
gchar buf[256];
struct utsname name;
struct tm *the_tm;
str = g_string_sized_new (strlen (text));
p = text;
n_chars = g_utf8_strlen (text, -1);
i = 0;
while (i < n_chars)
{
gunichar ch;
ch = g_utf8_get_char (p);
/* Backslash commands */
if (ch == '\\')
{
p = g_utf8_next_char (p);
i++;
ch = g_utf8_get_char (p);
if (i >= n_chars || ch == '\0')
{
g_warning ("Unescaped \\ at end of text\n");
goto bail;
}
else if (ch == 'n')
g_string_append_unichar (str, '\n');
else
g_string_append_unichar (str, ch);
}
else if (ch == '%')
{
p = g_utf8_next_char (p);
i++;
ch = g_utf8_get_char (p);
if (i >= n_chars || ch == '\0')
{
g_warning ("Unescaped %% at end of text\n");
goto bail;
}
switch (ch)
{
case '%':
g_string_append (str, "%");
break;
case 'c':
clock = gdm_common_get_clock (&the_tm);
g_string_append (str, clock);
g_free (clock);
break;
case 'd':
display = g_strdup (g_getenv ("DISPLAY"));
g_string_append (str, display);
break;
case 'h':
buf[sizeof (buf) - 1] = '\0';
r = gethostname (buf, sizeof (buf) - 1);
if (r)
g_string_append (str, "localhost");
else
g_string_append (str, buf);
break;
case 'm':
uname (&name);
g_string_append (str, name.machine);
break;
case 'n':
uname (&name);
g_string_append (str, name.nodename);
break;
case 'o':
buf[sizeof (buf) - 1] = '\0';
r = getdomainname (buf, sizeof (buf) - 1);
if (r)
g_string_append (str, "localdomain");
else
g_string_append (str, buf);
break;
case 'r':
uname (&name);
g_string_append (str, name.release);
break;
case 's':
uname (&name);
g_string_append (str, name.sysname);
break;
case 't':
g_string_append_printf (str, "%d", gdm_timed_delay);
if (gdm_timed_delay != 1)
g_string_append (str, _(" seconds"));
else
g_string_append (str, _(" second"));
break;
case 'u':
g_string_append (str, ve_sure_string (gdm_config_get_string (GDM_KEY_TIMED_LOGIN)));
break;
default:
if (ch < 127)
g_warning ("unknown escape code %%%c in text\n", (char)ch);
else
g_warning ("unknown escape code %%(U%x) in text\n", (int)ch);
}
}
else if (ch == '_')
{
/*
* Could be true if an underscore was put right before a special
* character like % or /
*/
if (underline == FALSE) {
underline = TRUE;
g_string_append (str, "<u>");
}
}
else
{
g_string_append_unichar (str, ch);
if (underline)
{
underline = FALSE;
g_string_append (str, "</u>");
}
}
p = g_utf8_next_char (p);
i++;
}
bail:
if (underline)
g_string_append (str, "</u>");
return g_string_free (str, FALSE);
}
......@@ -55,8 +55,10 @@ GdkPixbuf *gdm_common_get_face (const char *filename,
guint max_height);
gchar* gdm_common_get_config_file (void);
gboolean gdm_common_select_time_format (void);
void setup_background_color (gchar *bg_color);
gchar* gdm_get_welcomemsg (void);
void gdm_post_display_launch (void);
void gdm_common_setup_background_color (gchar *bg_color);
gchar* gdm_common_get_welcomemsg (void);
void gdm_common_post_display_launch (void);
gchar* gdm_common_expand_text (const gchar *text);
gchar* gdm_common_get_clock (struct tm **the_tm);
#endif /* GDM_COMMON_H */
......@@ -41,7 +41,6 @@
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <pwd.h>
#include <sys/utsname.h>
#if HAVE_PAM
#include <security/pam_appl.h>
......@@ -128,7 +127,6 @@ static const gchar *curlang = NULL;
static gchar *curuser = NULL;
static gchar *session = NULL;
static gchar *language = NULL;
static gint curdelay = 0;
static gint savesess = GTK_RESPONSE_NO;
static gint savelang = GTK_RESPONSE_NO;
......@@ -161,6 +159,7 @@ extern GHashTable *sessnames;
extern gchar *default_session;
extern const gchar *current_session;
extern gboolean session_dir_whacked_out;
extern gint gdm_timed_delay;
static void login_window_resize (gboolean force);
......@@ -413,35 +412,31 @@ back_prog_stop (void)
}
}
/*
* Timed Login: Timer
*/
static gboolean
gdm_timer (gpointer data)
{
curdelay --;
if ( curdelay <= 0 ) {
if (gdm_timed_delay <= 0) {
/* timed interruption */
printf ("%c%c%c\n", STX, BEL, GDM_INTERRUPT_TIMED_LOGIN);
fflush (stdout);
} else {
gchar *autologin_msg;
if (curdelay > 1)
autologin_msg = g_strdup_printf (
_("User %s will login in %d seconds"),
gdm_config_get_string (GDM_KEY_TIMED_LOGIN), curdelay);
else
autologin_msg = g_strdup_printf (
_("User %s will login in %d second"),
gdm_config_get_string (GDM_KEY_TIMED_LOGIN), curdelay);
/* Note that this message is not handled the same way as in
* the greeter, we don't parse it through the enriched text.
*/
autologin_msg = gdm_common_expand_text (
_("User %u will login in %t"));
gtk_label_set_text (GTK_LABEL (auto_timed_msg), autologin_msg);
gtk_widget_show (GTK_WIDGET (auto_timed_msg));
g_free (autologin_msg);
login_window_resize (FALSE /* force */);
}
gdm_timed_delay--;
return TRUE;
}
......@@ -455,10 +450,10 @@ gdm_timer_up_delay (GSignalInvocationHint *ihint,
const GValue *param_values,
gpointer data)
{
if (curdelay < 30)
curdelay = 30;
if (curdelay < gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY))
curdelay = gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY);
if (gdm_timed_delay < 30)
gdm_timed_delay = 30;
if (gdm_timed_delay < gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY))
gdm_timed_delay = gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY);
return TRUE;
}
......@@ -637,104 +632,6 @@ set_screen_to_pos (int x, int y)
}
}
/* I *really* need to rewrite this */
static gchar *
gdm_parse_enriched_string (const char *pre, const gchar *s, const char *post)
{
gchar hostbuf[1023] = "";
gchar *hostname, *display;
struct utsname name;
GString *str;
if (s == NULL)
return (NULL);
hostbuf[sizeof (hostbuf) - 1] = '\0';
if (gethostname (hostbuf, sizeof (hostbuf) - 1) < 0)
hostname = g_strdup ("GNOME");
else
hostname = g_strdup (hostbuf);
display = g_strdup (g_getenv ("DISPLAY"));
uname (&name);
if (strlen (s) > 2048) {
char *buffer;
syslog (LOG_ERR, _("%s: String too long!"), "gdm_parse_enriched_string");
g_free (display);
buffer = g_strdup_printf (_("%sWelcome to %s%s"),
pre, name.nodename, post);
g_free (hostname);
return buffer;
}
str = g_string_new (pre);
while (s[0] != '\0') {
/* Backslash commands */
if (s[0] == '\\' && s[1] != '\0') {
char cmd = s[1];
s++;
switch (cmd) {
case 'n':
g_string_append_c (str, '\n');
break;
default:
g_string_append_c (str, cmd);
}
/* Percent commands */
} else if (s[0] == '%' && s[1] != 0) {
char cmd = s[1];
s++;
switch (cmd) {
case 'h':
g_string_append (str, hostname);