Commit 3dfd5ded authored by William Jon McCann's avatar William Jon McCann

migrate gui to new config framework with a chainsaw

svn path=/branches/mccann-gobject/; revision=4947
parent e1a7b7ca
......@@ -79,10 +79,10 @@ get_value (const char *key,
G_TYPE_INVALID);
if (! res) {
if (error != NULL) {
g_warning ("Failed to get value for %s: %s", key, error->message);
g_debug ("Failed to get value for %s: %s", key, error->message);
g_error_free (error);
} else {
g_warning ("Failed to get value for %s", key);
g_debug ("Failed to get value for %s", key);
}
return FALSE;
......@@ -144,6 +144,76 @@ gdm_settings_client_get_string (const char *key,
return ret;
}
gboolean
gdm_settings_client_get_locale_string (const char *key,
const char *locale,
char **value)
{
char *candidate_key;
char *translated_value;
GError *error;
char **languages;
gboolean free_languages = FALSE;
int i;
gboolean ret;
g_return_val_if_fail (key != NULL, FALSE);
candidate_key = NULL;
translated_value = NULL;
error = NULL;
if (locale != NULL) {
languages = g_new (char *, 2);
languages[0] = (char *)locale;
languages[1] = NULL;
free_languages = TRUE;
} else {
languages = (char **) g_get_language_names ();
free_languages = FALSE;
}
for (i = 0; languages[i]; i++) {
gboolean res;
candidate_key = g_strdup_printf ("%s[%s]", key, languages[i]);
res = get_value (candidate_key, &translated_value);
g_free (candidate_key);
if (res) {
break;
}
g_free (translated_value);
translated_value = NULL;
}
/* Fallback to untranslated key
*/
if (translated_value == NULL) {
get_value (key, &translated_value);
}
if (free_languages) {
g_strfreev (languages);
}
if (translated_value != NULL) {
ret = TRUE;
if (value != NULL) {
*value = g_strdup (translated_value);
}
} else {
ret = FALSE;
}
g_free (translated_value);
return ret;
}
gboolean
gdm_settings_client_get_boolean (const char *key,
gboolean *value)
......
......@@ -36,6 +36,9 @@ gboolean gdm_settings_client_get_boolean (const char
gboolean *value);
gboolean gdm_settings_client_get_string (const char *key,
char **value);
gboolean gdm_settings_client_get_locale_string (const char *key,
const char *locale,
char **value);
gboolean gdm_settings_client_set_int (const char *key,
int value);
......
......@@ -78,10 +78,10 @@ get_value (const char *key,
res = gdm_settings_get_value (settings_object, key, &str, &error);
if (! res) {
if (error != NULL) {
g_warning ("Failed to get value for %s: %s", key, error->message);
g_debug ("Failed to get value for %s: %s", key, error->message);
g_error_free (error);
} else {
g_warning ("Failed to get value for %s", key);
g_debug ("Failed to get value for %s", key);
}
return FALSE;
......
......@@ -232,6 +232,8 @@ load_static_servers (GdmManager *manager)
void
gdm_manager_start (GdmManager *manager)
{
g_debug ("GDM starting to manage");
load_static_servers (manager);
/* Start static X servers */
......@@ -405,6 +407,27 @@ gdm_manager_get_property (GObject *object,
}
}
static GObject *
gdm_manager_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GdmManager *manager;
GdmManagerClass *klass;
klass = GDM_MANAGER_CLASS (g_type_class_peek (GDM_TYPE_MANAGER));
manager = GDM_MANAGER (G_OBJECT_CLASS (gdm_manager_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
if (manager->priv->xdmcp_enabled) {
manager->priv->xdmcp_manager = gdm_xdmcp_manager_new (manager->priv->display_store);
}
return G_OBJECT (manager);
}
static void
gdm_manager_class_init (GdmManagerClass *klass)
{
......@@ -412,6 +435,7 @@ gdm_manager_class_init (GdmManagerClass *klass)
object_class->get_property = gdm_manager_get_property;
object_class->set_property = gdm_manager_set_property;
object_class->constructor = gdm_manager_constructor;
object_class->finalize = gdm_manager_finalize;
signals [DISPLAY_ADDED] =
......@@ -459,10 +483,6 @@ gdm_manager_init (GdmManager *manager)
make_global_cookie (manager);
manager->priv->display_store = gdm_display_store_new ();
if (manager->priv->xdmcp_enabled) {
manager->priv->xdmcp_manager = gdm_xdmcp_manager_new (manager->priv->display_store);
}
}
static void
......
......@@ -48,6 +48,7 @@
#include "gdm-settings.h"
#include "gdm-settings-direct.h"
#include "gdm-settings-keys.h"
#include "misc.h"
......@@ -397,10 +398,14 @@ gdm_daemon_change_user (uid_t *uidp,
uid = 0;
gid = 0;
#if 0
gdm_daemon_config_get_string_for_id (daemon_config, GDM_ID_USER, &username);
gdm_daemon_config_get_string_for_id (daemon_config, GDM_ID_GROUP, &groupname);
#endif
gdm_settings_direct_get_string (GDM_KEY_USER, &username);
gdm_settings_direct_get_string (GDM_KEY_GROUP, &groupname);
if (username == NULL || groupname == NULL) {
return;
}
g_debug ("Changing user:group to %s:%s", username, groupname);
/* Lookup user and groupid for the GDM user */
pwent = getpwnam (username);
......
......@@ -5035,6 +5035,27 @@ homogeneous="bool">
If no item node has "background" property set, then the
background is not modified when greeter exits.
</para>
<para>
To use a different background for login transition than the one
used for login, insert a "item" node with "background" property set to "true" to draw login transition background before "item&quote; node (without any "background" property) used for greeter background. For instance :
</para>
<screen>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE greeter SYSTEM "greeter.dtd"&gt;
&lt;greeter&gt;
&lt;item type="rect" background="true"&gt;
&lt;normal file="background_for_login.svg"/&gt;
&lt;pos x="0" y="0" width="100%" height="100%"/&gt;
&lt;/item&gt;
&lt;item type="rect"&gt;
&lt;normal file="background_for_greeter.svg"/&gt;
&lt;pos x="0" y="0" width="100%" height="100%"/&gt;
&lt;/item&gt;
[...]
&lt;/greeter&gt;
</screen>
</sect3>
<sect3 id="positionnodes">
......
......@@ -39,20 +39,14 @@ noinst_LIBRARIES = libgdmwm.a libgdmcommon.a
libexec_PROGRAMS = \
@GDMCHOOSER@ \
gdmlogin
sbin_PROGRAMS = \
gdmsetup
$(NULL)
bin_PROGRAMS = \
gdmphotosetup \
@GDMXNESTCHOOSER@ \
gdmflexiserver \
gdmdynamic
EXTRA_PROGRAMS = gdmchooser gdmXnestchooser
gdmflexiserver \
$(NULL)
gdmphotosetup_SOURCES = \
gdmphotosetup.c
EXTRA_PROGRAMS = gdmchooser gdmXnestchooser
gdmXnestchooser_SOURCES = \
gdmXnestchooser.c
......@@ -60,9 +54,6 @@ gdmXnestchooser_SOURCES = \
gdmflexiserver_SOURCES = \
gdmflexiserver.c
gdmdynamic_SOURCES = \
gdmdynamic.c
libgdmwm_a_SOURCES = \
gdmwm.c \
gdmwm.h
......@@ -76,10 +67,6 @@ libgdmcommon_a_SOURCES = \
gdmsession.h \
misc.c \
misc.h \
gdmcomm.c \
gdmcomm.h \
gdmconfig.c \
gdmconfig.h \
gdmcommon.c \
gdmcommon.h \
$(NULL)
......@@ -90,12 +77,6 @@ gdmchooser_SOURCES = \
misc.h \
$(NULL)
gdmlogin_SOURCES = \
gdmlogin.c
gdmsetup_SOURCES = \
gdmsetup.c
gdmchooser_LDFLAGS = -export-dynamic
gdmchooser_LDADD = \
$(EXTRA_CHOOSER_LIBS) \
......@@ -104,6 +85,7 @@ gdmchooser_LDADD = \
$(GUIGLADE_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS) \
$(DBUS_LIBS) \
$(GOBJECT_LIBS) \
$(PANGO_LIBS) \
$(GDK_LIBS) \
......@@ -116,65 +98,12 @@ gdmchooser_LDADD = \
-lX11 \
$(NULL)
gdmlogin_LDADD = \
$(EXTRA_GREETER_LIBS) \
libgdmwm.a \
libgdmcommon.a \
$(GUING_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS) \
$(GOBJECT_LIBS) \
$(GDK_LIBS) \
$(PANGO_LIBS) \
$(GDKPIXBUF_LIBS) \
$(top_builddir)/common/libgdmcommon.a \
$(X_EXTRA_LIBS) \
$(XINERAMA_LIBS) \
$(X_LIBS) \
-lX11 \
$(NULL)
# LIBGNOMEUI should be removed from gdmsetup at some point.
# It is needed because it uses gnome_help_display_uri(), which
# should be replaced at some point.
#
gdmsetup_CFLAGS = $(LIBGNOMEUI_CFLAGS)
gdmsetup_LDFLAGS = -export-dynamic
gdmsetup_LDADD = \
libgdmcommon.a \
$(GUI_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS) \
$(GOBJECT_LIBS) \
$(PANGO_LIBS) \
$(GDK_LIBS) \
$(GDKPIXBUF_LIBS) \
$(EXTRA_SETUP_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(top_builddir)/common/libgdmcommon.a \
$(X_LIBS) \
-lXau \
-lX11 \
$(NULL)
gdmphotosetup_LDADD = \
libgdmcommon.a \
$(GUI_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS) \
$(GOBJECT_LIBS) \
$(GDK_LIBS) \
$(GDKPIXBUF_LIBS) \
$(INTLLIBS) \
-lX11 \
$(top_builddir)/common/libgdmcommon.a \
$(NULL)
gdmXnestchooser_LDADD = \
libgdmcommon.a \
$(GUI_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS) \
$(DBUS_LIBS) \
$(GOBJECT_LIBS) \
$(GDK_LIBS) \
$(top_builddir)/common/libgdmcommon.a \
......@@ -189,6 +118,7 @@ gdmflexiserver_LDADD = \
$(GUI_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS) \
$(DBUS_LIBS) \
$(GOBJECT_LIBS) \
$(GDK_LIBS) \
$(top_builddir)/common/libgdmcommon.a \
......@@ -198,46 +128,27 @@ gdmflexiserver_LDADD = \
-lXau \
$(NULL)
gdmdynamic_LDADD = \
libgdmcommon.a \
$(GUI_LIBS) \
$(INTLLIBS) \
$(GLIB_LIBS) \
$(GOBJECT_LIBS) \
$(GDK_LIBS) \
$(top_builddir)/common/libgdmcommon.a \
$(EXTRA_DYNAMIC_LIBS) \
$(X_LIBS) \
-lX11 \
-lXau \
$(NULL)
Settingsdir = $(datadir)/applications
Settings_files = gdmphotosetup.desktop
Settings_in_files = gdmphotosetup.desktop.in
Settings_DATA = $(Settings_in_files:.desktop.in=.desktop)
Systemdir = $(datadir)/applications
System_files = \
gdmsetup.desktop \
gdmflexiserver.desktop \
gdmflexiserver-xnest.desktop
System_dist_files = \
gdmsetup.desktop.in.in \
gdmflexiserver.desktop.in \
gdmflexiserver-xnest.desktop.in.in
System_DATA = $(System_files)
CLEANFILES = gdmsetup.desktop gdmsetup.desktop.in gdmflexiserver.desktop gdmflexiserver-xnest.desktop gdmflexiserver-xnest.desktop.in gdmphotosetup.desktop
gdmsetup.desktop.in: $(srcdir)/gdmsetup.desktop.in.in
sed -e 's,[@]sbindir[@],$(sbindir),g' <$(srcdir)/gdmsetup.desktop.in.in \
>gdmsetup.desktop.in
CLEANFILES = \
gdmflexiserver.desktop \
gdmflexiserver-xnest.desktop \
gdmflexiserver-xnest.desktop.in \
$(NULL)
@INTLTOOL_DESKTOP_RULE@
Gladedir = $(datadir)/gdm
Glade_DATA = gdmsetup.glade gdmchooser.glade gdmphotosetup.glade
Glade_DATA = \
gdmchooser.glade \
$(NULL)
Iconsdir = $(datadir)/pixmaps
......
......@@ -2,27 +2,27 @@
*
* GDM - The GNOME Display Manager
* Copyright (c) 2001 Queen of England
*
*
* GDMXnestChooser - run X nest with a chooser using xdmcp
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include "config.h"
#include <glib/gi18n.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
......@@ -39,13 +39,14 @@
#include <X11/Xlib.h>
#include <X11/Xauth.h>
#include <glib/gi18n.h>
#include "gdm.h"
#include "gdmcomm.h"
#include "gdmcommon.h"
#include "gdmconfig.h"
#include "gdm-common.h"
#include "gdm-daemon-config-keys.h"
#include "gdm-settings-client.h"
#include "gdm-settings-keys.h"
static gchar **args_remaining;
static pid_t xnest_pid = 0;
......@@ -399,13 +400,14 @@ setup_cookie (int disp)
FILE *af;
Xauth *xa;
const char *filename = XauFileName ();
if (filename == NULL)
return;
if (XauLockAuth (filename, 3, 3, 0) != LOCK_SUCCESS)
return;
cookie = gdmcomm_get_a_cookie (TRUE /* binary */);
cookie = gdm_common_get_a_cookie (TRUE /* binary */);
if (cookie == NULL) {
XauUnlockAuth (filename);
return;
......@@ -500,16 +502,16 @@ main (int argc, char *argv[])
host = args_remaining[0];
g_strfreev (args_remaining);
/* Read config data in bulk */
gdmcomm_comm_bulk_start ();
if (! gdm_settings_client_init (GDMCONFDIR "/gdm.schemas", "/")) {
exit (1);
}
xdmcp_enabled = gdm_config_get_bool (GDM_KEY_XDMCP);
honor_indirect = gdm_config_get_bool (GDM_KEY_INDIRECT);
pidfile = GDM_PID_FILE;
xnest = gdm_config_get_string (GDM_KEY_XNEST);
gdm_settings_client_get_boolean (GDM_KEY_XDMCP, &xdmcp_enabled);
gdm_settings_client_get_boolean (GDM_KEY_INDIRECT, &honor_indirect);
xnest = NULL;
gdm_settings_client_get_string (GDM_KEY_XNEST, &xnest);
/* At this point we are done using the socket, so close it */
gdmcomm_comm_bulk_stop ();
pidfile = GDM_PID_FILE;
/* complex and wonderous way to get the exec vector */
execvec = make_us_an_exec_vector (xnest);
......
This diff is collapsed.
This diff is collapsed.
/*
* GDM - THe GNOME Display Manager
* Copyright (C) 2001 Queen of England, (c)2002 George Lebl
*
* GDMcommunication routines
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef GDMCOMM_H
#define GDMCOMM_H
void gdmcomm_set_debug (gboolean enable);
void gdmcomm_set_quiet_errors (gboolean enable);
char * gdmcomm_call_gdm (const char *command,
const char *auth_cookie,
const char *min_version,
int tries);
gboolean gdmcomm_did_connection_fail (void);
void gdmcomm_set_allow_sleep (gboolean val);
void gdmcomm_comm_bulk_start (void);
void gdmcomm_comm_bulk_stop (void);
const char * gdmcomm_get_display (void);
/* This just gets a cookie of MIT-MAGIC-COOKIE-1 type */
char * gdmcomm_get_a_cookie (gboolean binary);
/* get the gdm auth cookie */
char * gdmcomm_get_auth_cookie (void);
gboolean gdmcomm_check (gboolean show_dialog);
const char * gdmcomm_get_error_message (const char *ret,
gboolean use_xnest);
#endif /* GDMCOMM_H */
......@@ -36,19 +36,130 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <X11/Xauth.h>
#include "gdm.h"
#include "gdmcommon.h"
#include "gdmcomm.h"
#include "gdmconfig.h"
#include "gdm-common.h"
#include "gdm-log.h"
#include "gdm-socket-protocol.h"
#include "gdm-daemon-config-keys.h"
#include "gdm-settings-client.h"
#include "gdm-settings-keys.h"
gint gdm_timed_delay = 0;
static Atom AT_SPI_IOR;
static const char *
gdm_common_get_display (void)
{
static char *display = NULL;
if (display == NULL) {
char *p;
display = gdk_get_display ();
if (display == NULL) {
display = g_strdup (g_getenv ("DISPLAY"));
if (display == NULL) /*eek!*/ {
display = g_strdup (":0");
}
}
/* whack screen part, GDM doesn't like those */
p = strchr (display, '.');
if (p != NULL)
*p = '\0';
}
return display;
}
static char *
get_dispnum (void)
{
static char *number = NULL;
if (number == NULL) {
char *p;
number = g_strdup (gdm_common_get_display ());
/* whee! handles even DECnet */
number = strchr (number, ':');
if (number != NULL) {
while (*number == ':') {
number++;
}
p = strchr (number, '.');
if (p != NULL)
*p = '\0';
} else {
number = "0";
}
}
return number;
}
/* This just gets a cookie of MIT-MAGIC-COOKIE-1 type */
char *
gdm_common_get_a_cookie (gboolean binary)
{
FILE *fp;
char *number;
char *cookie = NULL;
Xauth *xau;
VE_IGNORE_EINTR (fp = fopen (XauFileName (), "r"));
if (fp == NULL) {
return NULL;
}
number = get_dispnum ();
cookie = NULL;
while ((xau = XauReadAuth (fp)) != NULL) {
/* Just find the FIRST magic cookie, that's what gdm uses */
if (xau->number_length != strlen (number) ||
strncmp (xau->number, number, xau->number_length) != 0 ||
/* gdm sends MIT-MAGIC-COOKIE-1 cookies of length 16,
* so just do those */
xau->data_length != 16 ||
xau->name_length != strlen ("MIT-MAGIC-COOKIE-1") ||
strncmp (xau->name, "MIT-MAGIC-COOKIE-1",
xau->name_length) != 0) {
XauDisposeAuth (xau);
continue;
}
if (binary) {
cookie = g_new0 (char, 16);
memcpy (cookie, xau->data, 16);
} else {
int i;
GString *str;
str = g_string_new (NULL);
for (i = 0; i < xau->data_length; i++) {
g_string_append_printf
(str, "%02x",
(guint)(guchar)xau->data[i]);
}
cookie = g_string_free (str, FALSE);
}
XauDisposeAuth (xau);
break;
}
VE_IGNORE_EINTR (fclose (fp));
return cookie;
}
/*
* Some slaves want to send output to syslog and others (such as
* gdmflexiserver and gdmdynamic send error messages to stdout.
......@@ -412,57 +523,22 @@ gdm_common_text_to_escaped_utf8 (const char *text)
gchar *
gdm_common_get_config_file (void)
{
gchar *result;
gchar *config_file;
/* Get config file */
result = gdmcomm_call_gdm ("GET_CONFIG_FILE", NULL /* auth cookie */, "2.8.0.2", 5);
if (! result)
return NULL;
if (ve_string_empty (result) ||
strncmp (result, "OK ", 3) != 0) {
g_free (result);
return NULL;
}
/* skip the "OK " */
config_file = g_strdup (result + 3);
g_free (result);
return config_file;
return NULL;
}
gchar *
gdm_common_get_custom_config_file (void)
{
gchar *result;
gchar *config_file;
/* Get config file */
result = gdmcomm_call_gdm ("GET_CUSTOM_CONFIG_FILE", NULL /* auth cookie */, "2.8.0.2", 5);
if (! result)
return NULL;
if (ve_string_empty (result) ||
strncmp (result, "OK ", 3) != 0) {
g_free (result);
return NULL;
}
/* skip the "OK " */
config_file = g_strdup (result + 3);