diff options
author | Brian Cameron <Brian.Cameron@sun.com> | 2005-11-22 07:49:43 +0000 |
---|---|---|
committer | Brian Cameron <bcameron@src.gnome.org> | 2005-11-22 07:49:43 +0000 |
commit | b68ffea6d293f7c453fb9b42c6c8b637d17ea326 (patch) | |
tree | f352faccc11772611193fe7fec8e8fa5ceeea8a9 /gui/gdmflexiserver.c | |
parent | b370db3d95e3df789286f5c44b8c0014d1c653ca (diff) | |
download | gdm-b68ffea6d293f7c453fb9b42c6c8b637d17ea326.tar.gz |
This further improves GDM configuration so that now only the GDM daemon
2005-11-21 Brian Cameron <Brian.Cameron@sun.com>
This further improves GDM configuration so that
now only the GDM daemon parses and manages the
configuration file. Most client programs use
the GET_CONFIG command to access needed data.
This simplifies the configuration logic and
puts all configuration parsing in one place
and gets rid of a lot of global variables that
were making the code look messy. This also
gets rid of several places where gnome_config
deprecated functions were being used. I have
cleaned up the code so that the vicious-extensions
code is more localized in gui/gdmconfig.[ch].
Some work is left to do: gdmflexiserver still
uses gnome_config functions and gdmconfig should
use the new functions for reading from the
configuration file. Some compile issues fixed
as highlghted by dmacks@netspace.org to fix
bug #322083.
* NEWS: Fixed comment.
* daemon/gdm.h: Further cleanup of #define's so
that they better match the names of the config
keys.
* daemon/gdm.c: Now GET_CONFIG returns "OK" if
the key is valid but has no value when it
is a string. Now free return value from
gdm_config_to_string.
* daemon/Makefile.am, gui/greeter/Makefile.am:
Now the daemon validates the greeter's theme
directory, so pass the default value into the
daemon and not the greeter.
* daemon/gdmconfig.h: Added gdm_is_valid_key
and corrected prototype for
gdm_set_user_session_lang.
* daemon/slave.c: Fix warning and compile errors.
* daemon/gdmconfig.c: Further fleshed out.
Now it supports a few additional keys I
overlooked. It now validates all keys used
by the slaves. Now handles translated string.
Further refactored the code.
* gui/Makefile.am: Added gdmconfig.[ch] to
common library.
* gui/gdmconfig.[ch]: New functions for
accessing configuration data for slaves.
* gui/gdmXnestchooser.c, gui/gdmlanguages.c,
gui/gdmsession.h, gui/gdmuser.h, gui/gdmwm.c,
gui/misc.c, gui/greeter/greeter_item_capslock.c:
gui/greeter/greeter_item_pam.c: No longer include
vicious.h/viciousui.h, instead gdmconfig.h.
* gui/gdmcomm.c: Fix gdm_check_comm to no
longer require passing in the config file
name.
* gui/gdmcommon.[ch]: Get rid of old
gdm_common_*_same functions that are
replaced with new gui/gdmconfig logic.
Now functions that access config data
use the new functions.
* gui/gdmflexiserver.c: Now displays the
localized string when you use GET_CONFIG
to access a translatable string.
* gui/gdmconfig.c: Now calls update_key in
addition to update_greeters when updating
greeter config data, since the daemon needs
to update the values now when they change.
* gui/gdmchooser.c, gui/gdmdynamic.c,
gui/gdmlogin.c, gui/gdmphotosetup.c,
gui/gdmsession.c, gui/gdmuser.c,
gui/gdm/gdmXnestchooser.c,
gui/greeter/greeter.c,
gui/greeter/greeter_action_language.c,
gui/greeter/greeter_canvas_item.c,
gui/greeter/greeter_item.c,
gui/greeter/greeter_item_customlist.c,
gui/greeter/greeter_item_timed.c,
gui/greeter/greeter_item_list.c,
gui/greeter/greeter_parser.c,
gui/greeter/greeter_session.c,
gui/greeter/greeter_system.c: Updated to
use new configuration functions.
* vicious-extensions/glade-helper.c: Now
include stdlib.h to avoid compiler warnings.
* gui/greeter/greeter.c: Remove unused
gdm_kill_thingies function.
Diffstat (limited to 'gui/gdmflexiserver.c')
-rw-r--r-- | gui/gdmflexiserver.c | 78 |
1 files changed, 69 insertions, 9 deletions
diff --git a/gui/gdmflexiserver.c b/gui/gdmflexiserver.c index 8a81fb5f..3ddcd838 100644 --- a/gui/gdmflexiserver.c +++ b/gui/gdmflexiserver.c @@ -39,11 +39,11 @@ #include <libgnome/libgnome.h> /* for gnome_config */ #include <libgnomeui/libgnomeui.h> /* for gnome_program */ -#include <viciousui.h> - #include "gdm.h" #include "gdmcomm.h" #include "gdmcommon.h" +#include "gdmconfig.h" +#include "gdmconfig.h" static GSList *xservers = NULL; static gboolean got_standard = FALSE; @@ -672,6 +672,42 @@ choose_server (void) return NULL; } +/** + * is_key + * + * Since GDM keys sometimes have default values defined in the gdm.h header + * file (e.g. key=value), this function strips off the "=value" from both + * keys passed in to do a comparison. + */ +static gboolean +is_key (const gchar *key1, const gchar *key2) +{ + gchar *key1d, *key2d, *p; + + key1d = g_strdup (key1); + key2d = g_strdup (key2); + + g_strstrip (key1d); + p = strchr (key1d, '='); + if (p != NULL) + *p = '\0'; + + g_strstrip (key2d); + p = strchr (key2d, '='); + if (p != NULL) + *p = '\0'; + + if (strcmp (key1d, key2d) == 0) { + g_free (key1d); + g_free (key2d); + return TRUE; + } else { + g_free (key1d); + g_free (key2d); + return FALSE; + } +} + static void calc_pi (void) { @@ -740,22 +776,46 @@ main (int argc, char *argv[]) if (args != NULL && args[0] != NULL) server = args[0]; + if ( ! gdmcomm_check (TRUE)) { + return 1; + } + config_file = gdm_common_get_config_file (); if (config_file == NULL) { g_print (_("Could not access GDM configuration file.\n")); exit (0); } - if ( ! gdmcomm_check (config_file, TRUE /* gui_bitching */)) { - g_free (config_file); - return 1; - } - if (send_command != NULL) { if (authenticate) auth_cookie = gdmcomm_get_auth_cookie (); - ret = gdmcomm_call_gdm (send_command, auth_cookie, - "2.2.4.0", 5); + + /* + * If asking for a translatable config value, then try to get + * the translated value first. If this fails, then go ahead + * and call the normal sockets command. + */ + if (strncmp (send_command, GDM_SUP_GET_CONFIG " ", + strlen (GDM_SUP_GET_CONFIG " ")) == 0) { + gchar *value = NULL; + const char *key = &send_command[strlen (GDM_SUP_GET_CONFIG " ")]; + + if (is_key (GDM_KEY_WELCOME, key) || + is_key (GDM_KEY_REMOTE_WELCOME, key)) { + value = gdm_config_get_translated_string ((gchar *)key); + if (value != NULL) { + ret = g_strdup_printf ("OK %s", value); + g_free (value); + } + } + if (value == NULL) + ret = gdmcomm_call_gdm (send_command, auth_cookie, + "2.2.4.0", 5); + } else { + ret = gdmcomm_call_gdm (send_command, auth_cookie, + "2.2.4.0", 5); + } + if (ret != NULL) { g_print ("%s\n", ret); g_free (config_file); |