]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Fix configuration
authorRobert Ancell <robert.ancell@canonical.com>
Wed, 20 Jul 2011 06:55:01 +0000 (16:55 +1000)
committerRobert Ancell <robert.ancell@canonical.com>
Wed, 20 Jul 2011 06:55:01 +0000 (16:55 +1000)
16 files changed:
src/Makefile.am
src/display-manager.c
src/display.c
src/seat-local.c [deleted file]
src/seat-xdmcp-client.c [deleted file]
src/seat-xdmcp-client.h [deleted file]
src/seat-xdmcp-session.c
src/seat-xdmcp-session.h
src/seat-xlocal.c [new file with mode: 0644]
src/seat-xlocal.h [moved from src/seat-local.h with 56% similarity]
src/seat.c
src/seat.h
src/xdisplay.c
src/xdisplay.h
src/xserver-local.c
src/xserver-local.h

index cab0239132fd2329a783719ce787f5d803b83ff0..11d769e3b39698b312d68ca65f2ceef55214dc5e 100644 (file)
@@ -32,12 +32,10 @@ lightdm_SOURCES = \
        process.h \
        seat.c \
        seat.h \
-       seat-local.c \
-       seat-local.h \
-       seat-xdmcp-client.c \
-       seat-xdmcp-client.h \
        seat-xdmcp-session.c \
        seat-xdmcp-session.h \
+       seat-xlocal.c \
+       seat-xlocal.h \
        session.c \
        session.h \
        user.c \
index babec1a5c95eeed2b8bee30d3f51202d0d84d8bf..29eff545d20f4a66cf639a560f90e74682c695b6 100644 (file)
@@ -19,8 +19,7 @@
 #include "configuration.h"
 #include "display.h"
 #include "xdmcp-server.h"
-#include "seat-local.h"
-#include "seat-xdmcp-client.h"
+#include "seat-xlocal.h"
 #include "seat-xdmcp-session.h"
 #include "plymouth.h"
 
@@ -80,7 +79,7 @@ xdmcp_session_cb (XDMCPServer *server, XDMCPSession *session, DisplayManager *ma
     SeatXDMCPSession *seat;
     gboolean result;
 
-    seat = seat_xdmcp_session_new ("XDMCPServer", session);
+    seat = seat_xdmcp_session_new (session);
     result = add_seat (manager, SEAT (seat));
     g_object_unref (seat);
   
@@ -96,7 +95,7 @@ display_manager_start (DisplayManager *manager)
     g_return_if_fail (manager != NULL);
 
     /* Load the seat modules */
-    seat_register_module ("xlocal", SEAT_LOCAL_TYPE);
+    seat_register_module ("xlocal", SEAT_XLOCAL_TYPE);
 
     /* Load the static display entries */
     seats = config_get_string (config_get_instance (), "LightDM", "seats");
@@ -131,7 +130,7 @@ display_manager_start (DisplayManager *manager)
             g_object_unref (seat);
         }
         else
-            g_debug ("Unknown seat type %s", type);        
+            g_debug ("Unknown seat type %s", type);
     }
     g_strfreev (tokens);
 
index dd9bd557e3f015d1e40504bcaca74e1709b8c941..aab3b4f47c91b6518812b6be0bff733cc2566923 100644 (file)
@@ -117,6 +117,7 @@ display_load_config (Display *display, const gchar *config_section)
         display->priv->greeter_user = config_get_string (config_get_instance (), config_section, "greeter-user");
     if (!display->priv->greeter_user)
         display->priv->greeter_user = config_get_string (config_get_instance (), "SeatDefaults", "greeter-user");
+
     if (config_section)
         display->priv->greeter_session = config_get_string (config_get_instance (), config_section, "greeter-session");
     if (!display->priv->greeter_session)
@@ -437,7 +438,6 @@ create_session (Display *display, PAMSession *pam_session, const gchar *session_
 
     filename = g_strdup_printf ("%s.desktop", session_name);
     path = g_build_filename (sessions_dir, filename, NULL);
-    g_free (sessions_dir);
     g_free (filename);
 
     session_desktop_file = g_key_file_new ();
diff --git a/src/seat-local.c b/src/seat-local.c
deleted file mode 100644 (file)
index 1e8a0e4..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Robert Ancell.
- * Author: Robert Ancell <robert.ancell@canonical.com>
- * 
- * 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 3 of the License, or (at your option) any later
- * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
- * license.
- */
-
-#include <string.h>
-
-#include "seat-local.h"
-#include "configuration.h"
-#include "xdisplay.h"
-#include "xserver-local.h"
-#include "vt.h"
-
-struct SeatLocalPrivate
-{
-    /* The section in the config for this seat */
-    gchar *config_section;
-};
-
-G_DEFINE_TYPE (SeatLocal, seat_local, SEAT_TYPE);
-
-SeatLocal *
-seat_local_new (const gchar *config_section)
-{
-    SeatLocal *seat;
-
-    seat = g_object_new (SEAT_LOCAL_TYPE, NULL);
-    seat->priv->config_section = g_strdup (config_section);
-    seat_load_config (SEAT (seat), config_section);
-    seat_set_can_switch (SEAT (seat), TRUE);
-
-    return seat;
-}
-
-static Display *
-seat_local_add_display (Seat *seat)
-{
-    XServerLocal *xserver;
-    XAuthority *authority = NULL;
-    gchar *number;
-    gchar hostname[1024];
-    XDisplay *display;
-
-    g_debug ("Starting display");
-
-    xserver = xserver_local_new (SEAT_LOCAL (seat)->priv->config_section);
-    number = g_strdup_printf ("%d", xserver_get_display_number (XSERVER (xserver)));
-    gethostname (hostname, 1024);
-    authority = xauth_new_cookie (XAUTH_FAMILY_LOCAL, hostname, number);
-    g_free (number);
-
-    xserver_set_authority (XSERVER (xserver), authority);
-    g_object_unref (authority);
-
-    display = xdisplay_new (SEAT_LOCAL (seat)->priv->config_section, XSERVER (xserver));
-    g_object_unref (xserver);
-
-    return DISPLAY (display);
-}
-
-static void
-seat_local_set_active_display (Seat *seat, Display *display)
-{
-    gint number = xserver_local_get_vt (XSERVER_LOCAL (XSERVER (display_get_display_server (display))));
-    if (number >= 0)
-        vt_set_active (number);
-}
-
-static void
-seat_local_init (SeatLocal *seat)
-{
-    seat->priv = G_TYPE_INSTANCE_GET_PRIVATE (seat, SEAT_LOCAL_TYPE, SeatLocalPrivate);
-}
-
-static void
-seat_local_finalize (GObject *object)
-{
-    SeatLocal *self;
-
-    self = SEAT_LOCAL (object);
-
-    g_free (self->priv->config_section);
-
-    G_OBJECT_CLASS (seat_local_parent_class)->finalize (object);
-}
-
-static void
-seat_local_class_init (SeatLocalClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-    SeatClass *seat_class = SEAT_CLASS (klass);
-
-    seat_class->add_display = seat_local_add_display;
-    seat_class->set_active_display = seat_local_set_active_display;
-    object_class->finalize = seat_local_finalize;
-
-    g_type_class_add_private (klass, sizeof (SeatLocalPrivate));
-}
diff --git a/src/seat-xdmcp-client.c b/src/seat-xdmcp-client.c
deleted file mode 100644 (file)
index 5304965..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Robert Ancell.
- * Author: Robert Ancell <robert.ancell@canonical.com>
- * 
- * 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 3 of the License, or (at your option) any later
- * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
- * license.
- */
-
-#include <string.h>
-
-#include "seat-xdmcp-client.h"
-#include "xdisplay.h"
-#include "configuration.h"
-#include "xserver-local.h"
-
-struct SeatXDMCPClientPrivate
-{
-    /* The section in the config for this seat */  
-    gchar *config_section;
-
-    /* The display we are running */
-    XDisplay *display;
-};
-
-G_DEFINE_TYPE (SeatXDMCPClient, seat_xdmcp_client, SEAT_TYPE);
-
-SeatXDMCPClient *
-seat_xdmcp_client_new (const gchar *config_section)
-{
-    SeatXDMCPClient *seat;
-
-    seat = g_object_new (SEAT_XDMCP_CLIENT_TYPE, NULL);
-    seat->priv->config_section = g_strdup (config_section);
-    seat_load_config (SEAT (seat), config_section);
-
-    return seat;
-}
-
-static Display *
-seat_xdmcp_client_add_display (Seat *seat)
-{
-    XServerLocal *xserver;
-    XAuthority *authority = NULL;
-    gchar *xdmcp_manager;
-    gint port;
-    //gchar *key;
-  
-    g_assert (SEAT_XDMCP_CLIENT (seat)->priv->display == NULL);
-
-    g_debug ("Starting seat %s", SEAT_XDMCP_CLIENT (seat)->priv->config_section);
-
-    xserver = xserver_local_new (SEAT_XDMCP_CLIENT (seat)->priv->config_section);
-
-    xdmcp_manager = config_get_string (config_get_instance (), "SeatDefaults", "xdmcp-manager");
-    if (!xdmcp_manager)
-        xdmcp_manager = config_get_string (config_get_instance (), SEAT_XDMCP_CLIENT (seat)->priv->config_section, "xdmcp-manager");
-    xserver_local_set_xdmcp_server (xserver, xdmcp_manager);
-    g_free (xdmcp_manager);
-
-    if (config_has_key (config_get_instance (), "SeatDefaults", "xdmcp-port"))
-        port = config_get_integer (config_get_instance (), "SeatDefaults", "xdmcp-port");
-    else
-        port = config_get_integer (config_get_instance (), SEAT_XDMCP_CLIENT (seat)->priv->config_section, "xdmcp-port");
-    if (port > 0)
-        xserver_local_set_xdmcp_port (xserver, port);
-    /*FIXME key = config_get_string (config_get_instance (), SEAT_XDMCP_CLIENT (seat)->priv->config_section, "key");
-    if (key)
-    {
-        guint8 data[8];
-
-        string_to_xdm_auth_key (key, data);
-        xserver_set_authentication (xserver, "XDM-AUTHENTICATION-1", data, 8);
-        authority = xauth_new (XAUTH_FAMILY_WILD, "", "", "XDM-AUTHORIZATION-1", data, 8);
-    }*/
-
-    xserver_set_authority (XSERVER (xserver), authority);
-    g_object_unref (authority);
-
-    SEAT_XDMCP_CLIENT (seat)->priv->display = g_object_ref (xdisplay_new (SEAT_XDMCP_CLIENT (seat)->priv->config_section, XSERVER (xserver)));
-    g_object_unref (xserver);
-
-    return DISPLAY (SEAT_XDMCP_CLIENT (seat)->priv->display);
-}
-
-static void
-seat_xdmcp_client_init (SeatXDMCPClient *seat)
-{
-    seat->priv = G_TYPE_INSTANCE_GET_PRIVATE (seat, SEAT_XDMCP_CLIENT_TYPE, SeatXDMCPClientPrivate);
-}
-
-static void
-seat_xdmcp_client_finalize (GObject *object)
-{
-    SeatXDMCPClient *self;
-
-    self = SEAT_XDMCP_CLIENT (object);
-
-    g_free (self->priv->config_section);
-
-    G_OBJECT_CLASS (seat_xdmcp_client_parent_class)->finalize (object);
-}
-
-static void
-seat_xdmcp_client_class_init (SeatXDMCPClientClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-    SeatClass *seat_class = SEAT_CLASS (klass);
-
-    seat_class->add_display = seat_xdmcp_client_add_display;
-    object_class->finalize = seat_xdmcp_client_finalize;
-
-    g_type_class_add_private (klass, sizeof (SeatXDMCPClientPrivate));
-}
diff --git a/src/seat-xdmcp-client.h b/src/seat-xdmcp-client.h
deleted file mode 100644 (file)
index 347e0d1..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Robert Ancell.
- * Author: Robert Ancell <robert.ancell@canonical.com>
- * 
- * 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 3 of the License, or (at your option) any later
- * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
- * license.
- */
-
-#ifndef _SEAT_XDMCP_CLIENT_H_
-#define _SEAT_XDMCP_CLIENT_H_
-
-#include "seat.h"
-
-G_BEGIN_DECLS
-
-#define SEAT_XDMCP_CLIENT_TYPE (seat_xdmcp_client_get_type())
-#define SEAT_XDMCP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAT_XDMCP_CLIENT_TYPE, SeatXDMCPClient))
-
-typedef struct SeatXDMCPClientPrivate SeatXDMCPClientPrivate;
-
-typedef struct
-{
-    Seat                    parent_instance;
-    SeatXDMCPClientPrivate *priv;
-} SeatXDMCPClient;
-
-typedef struct
-{
-    SeatClass parent_class;
-} SeatXDMCPClientClass;
-
-GType seat_xdmcp_client_get_type (void);
-
-SeatXDMCPClient *seat_xdmcp_client_new (const gchar *config_section);
-
-G_END_DECLS
-
-#endif /* _SEAT_XDMCP_CLIENT_H_ */
index dab258d5d871188c2d51d716ce928cbc94254fcb..189220df7b680ca71f19059d74b65d408d2b9985 100644 (file)
@@ -17,9 +17,6 @@
 
 struct SeatXDMCPSessionPrivate
 {
-    /* The section in the config for this seat */
-    gchar *config_section;
-
     /* Session being serviced */
     XDMCPSession *session;
 };
@@ -27,13 +24,12 @@ struct SeatXDMCPSessionPrivate
 G_DEFINE_TYPE (SeatXDMCPSession, seat_xdmcp_session, SEAT_TYPE);
 
 SeatXDMCPSession *
-seat_xdmcp_session_new (const gchar *config_section, XDMCPSession *session)
+seat_xdmcp_session_new (XDMCPSession *session)
 {
     SeatXDMCPSession *seat;
 
     seat = g_object_new (SEAT_XDMCP_SESSION_TYPE, NULL);
     seat->priv->session = g_object_ref (session);
-    seat_load_config (SEAT (seat), config_section);
 
     return seat;
 }
@@ -49,7 +45,7 @@ seat_xdmcp_session_add_display (Seat *seat)
     xserver = xserver_remote_new (xauth_get_address (authority), xdmcp_session_get_display_number (SEAT_XDMCP_SESSION (seat)->priv->session));
     xserver_set_authority (XSERVER (xserver), authority);
 
-    display = xdisplay_new (SEAT_XDMCP_SESSION (seat)->priv->config_section, XSERVER (xserver));
+    display = xdisplay_new (XSERVER (xserver));
     g_object_unref (xserver);
 
     return DISPLAY (display);
@@ -61,26 +57,12 @@ seat_xdmcp_session_init (SeatXDMCPSession *seat)
     seat->priv = G_TYPE_INSTANCE_GET_PRIVATE (seat, SEAT_XDMCP_SESSION_TYPE, SeatXDMCPSessionPrivate);
 }
 
-static void
-seat_xdmcp_session_finalize (GObject *object)
-{
-    SeatXDMCPSession *self;
-
-    self = SEAT_XDMCP_SESSION (object);
-
-    g_free (self->priv->config_section);
-
-    G_OBJECT_CLASS (seat_xdmcp_session_parent_class)->finalize (object);
-}
-
 static void
 seat_xdmcp_session_class_init (SeatXDMCPSessionClass *klass)
 {
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
     SeatClass *seat_class = SEAT_CLASS (klass);
 
     seat_class->add_display = seat_xdmcp_session_add_display;
-    object_class->finalize = seat_xdmcp_session_finalize;
 
     g_type_class_add_private (klass, sizeof (SeatXDMCPSessionPrivate));
 }
index 0b84cbf059704600f04fd7bcd188ef28ada9b542..9c8dba278b30a8c3902506abdf2bc2979e8cf996 100644 (file)
@@ -35,7 +35,7 @@ typedef struct
 
 GType seat_xdmcp_session_get_type (void);
 
-SeatXDMCPSession *seat_xdmcp_session_new (const gchar *config_section, XDMCPSession *session);
+SeatXDMCPSession *seat_xdmcp_session_new (XDMCPSession *session);
 
 G_END_DECLS
 
diff --git a/src/seat-xlocal.c b/src/seat-xlocal.c
new file mode 100644 (file)
index 0000000..57695d6
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2010-2011 Robert Ancell.
+ * Author: Robert Ancell <robert.ancell@canonical.com>
+ * 
+ * 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 3 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <string.h>
+
+#include "seat-xlocal.h"
+#include "configuration.h"
+#include "xdisplay.h"
+#include "xserver-local.h"
+#include "vt.h"
+
+G_DEFINE_TYPE (SeatXLocal, seat_xlocal, SEAT_TYPE);
+
+static void
+seat_xlocal_setup (Seat *seat)
+{
+    seat_set_can_switch (seat, TRUE);
+    SEAT_CLASS (seat_xlocal_parent_class)->setup (seat);
+}
+
+static Display *
+seat_xlocal_add_display (Seat *seat)
+{
+    XServerLocal *xserver;
+    XAuthority *authority = NULL;
+    gchar *number;
+    gchar hostname[1024];
+    XDisplay *display;
+    const gchar *config_section;
+    gchar *command = NULL, *layout = NULL, *config_file = NULL, *xdmcp_manager = NULL;
+    gint port = 0;
+
+    g_debug ("Starting Local X Display");
+  
+    xserver = xserver_local_new ();
+
+    config_section = seat_get_config_section (seat);
+
+    /* If running inside an X server use Xephyr instead */
+    if (g_getenv ("DISPLAY"))
+        command = g_strdup ("Xephyr");
+    if (!command && config_section)
+        command = config_get_string (config_get_instance (), config_section, "xserver-command");
+    if (!command)
+        command = config_get_string (config_get_instance (), "SeatDefaults", "xserver-command");
+    if (command)
+        xserver_local_set_command (xserver, command);
+    g_free (command);
+
+    if (config_section)
+        layout = config_get_string (config_get_instance (), config_section, "xserver-layout");
+    if (!layout)
+        layout = config_get_string (config_get_instance (), "SeatDefaults", "layout");
+    if (layout)
+        xserver_local_set_layout (xserver, layout);
+    g_free (layout);
+
+    if (config_section)
+        config_file = config_get_string (config_get_instance (), config_section, "xserver-config");
+    if (!config_file)
+        config_file = config_get_string (config_get_instance (), "SeatDefaults", "xserver-config");
+    if (config_file)
+        xserver_local_set_config (xserver, config_file);
+    g_free (config_file);
+
+    if (config_section)
+        xdmcp_manager = config_get_string (config_get_instance (), config_section, "xdmcp-manager");
+    if (!xdmcp_manager)
+        xdmcp_manager = config_get_string (config_get_instance (), "SeatDefaults", "xdmcp-manager");
+    if (xdmcp_manager)
+        xserver_local_set_xdmcp_server (xserver, xdmcp_manager);
+    g_free (xdmcp_manager);
+
+    if (config_section && config_has_key (config_get_instance (), config_section, "xdmcp-port"))
+        port = config_get_integer (config_get_instance (), config_section, "xdmcp-port");
+    else if (config_has_key (config_get_instance (), "SeatDefaults", "xdmcp-port"))
+        port = config_get_integer (config_get_instance (), "SeatDefaults", "xdmcp-port");
+    if (port > 0)
+        xserver_local_set_xdmcp_port (xserver, port);
+    /*FIXME key = config_get_string (config_get_instance (), config_section, "key");
+    if (key)
+    {
+        guint8 data[8];
+
+        string_to_xdm_auth_key (key, data);
+        xserver_set_authentication (xserver, "XDM-AUTHENTICATION-1", data, 8);
+        authority = xauth_new (XAUTH_FAMILY_WILD, "", "", "XDM-AUTHORIZATION-1", data, 8);
+    }*/
+
+    number = g_strdup_printf ("%d", xserver_get_display_number (XSERVER (xserver)));
+    gethostname (hostname, 1024);
+    authority = xauth_new_cookie (XAUTH_FAMILY_LOCAL, hostname, number);
+    g_free (number);
+    xserver_set_authority (XSERVER (xserver), authority);
+    g_object_unref (authority);
+
+    display = xdisplay_new (XSERVER (xserver));
+    g_object_unref (xserver);
+
+    return DISPLAY (display);
+}
+
+static void
+seat_xlocal_set_active_display (Seat *seat, Display *display)
+{
+    gint number = xserver_local_get_vt (XSERVER_LOCAL (XSERVER (display_get_display_server (display))));
+    if (number >= 0)
+        vt_set_active (number);
+}
+
+static void
+seat_xlocal_init (SeatXLocal *seat)
+{
+}
+
+static void
+seat_xlocal_class_init (SeatXLocalClass *klass)
+{
+    SeatClass *seat_class = SEAT_CLASS (klass);
+
+    seat_class->setup = seat_xlocal_setup;
+    seat_class->add_display = seat_xlocal_add_display;
+    seat_class->set_active_display = seat_xlocal_set_active_display;
+}
similarity index 56%
rename from src/seat-local.h
rename to src/seat-xlocal.h
index 3fda1687520d9e08abc816e2f3b81a352f2aaf74..3956494d90b6a80ce4918f0f8d67272ba1b46c72 100644 (file)
@@ -9,34 +9,29 @@
  * license.
  */
 
-#ifndef _SEAT_LOCAL_H_
-#define _SEAT_LOCAL_H_
+#ifndef _SEAT_XLOCAL_H_
+#define _SEAT_XLOCAL_H_
 
 #include <glib-object.h>
 #include "seat.h"
 
 G_BEGIN_DECLS
 
-#define SEAT_LOCAL_TYPE (seat_local_get_type())
-#define SEAT_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAT_LOCAL_TYPE, SeatLocal))
-
-typedef struct SeatLocalPrivate SeatLocalPrivate;
+#define SEAT_XLOCAL_TYPE (seat_xlocal_get_type())
+#define SEAT_XLOCAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAT_XLOCAL_TYPE, SeatXLocal))
 
 typedef struct
 {
-    Seat         parent_instance;
-    SeatLocalPrivate *priv;
-} SeatLocal;
+    Seat parent_instance;
+} SeatXLocal;
 
 typedef struct
 {
     SeatClass parent_class;
-} SeatLocalClass;
-
-GType seat_local_get_type (void);
+} SeatXLocalClass;
 
-SeatLocal *seat_local_new (const gchar *config_section);
+GType seat_xlocal_get_type (void);
 
 G_END_DECLS
 
-#endif /* _SEAT_LOCAL_H_ */
+#endif /* _SEAT_XLOCAL_H_ */
index 53aafab520ba0e6c2a299cd55624ce3073234053..90476ce16863569e90419def97bfecb8207ee449 100644 (file)
@@ -28,6 +28,9 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 struct SeatPrivate
 {
+    /* Configuration for this seat */
+    gchar *config_section;
+
     /* True if able to switch users */
     gboolean can_switch;
 
@@ -80,27 +83,16 @@ seat_new (const gchar *module, const gchar *config_section)
         return NULL;
 
     seat = g_object_new (m->type, NULL);
+    seat->priv->config_section = g_strdup (config_section);
 
     return seat;
 }
 
-void
-seat_load_config (Seat *seat, const gchar *config_section)
+const gchar *
+seat_get_config_section (Seat *seat)
 {
-    if (config_section && config_has_key (config_get_instance (), config_section, "autologin-guest"))
-        seat->priv->autologin_guest = config_get_boolean (config_get_instance (), config_section, "autologin-guest");
-    else if (config_has_key (config_get_instance (), "SeatDefaults", "autologin-guest"))
-        seat->priv->autologin_guest = config_get_boolean (config_get_instance (), "SeatDefaults", "autologin-guest");
-    if (config_section)
-        seat->priv->autologin_username = config_get_string (config_get_instance (), config_section, "autologin-user");
-    if (!seat->priv->autologin_username)
-        seat->priv->autologin_username = config_get_string (config_get_instance (), "SeatDefaults", "autologin-user");
-    if (config_section && config_has_key (config_get_instance (), config_section, "autologin-user-timeout"))
-        seat->priv->autologin_timeout = config_get_integer (config_get_instance (), config_section, "autologin-user-timeout");
-    else
-        seat->priv->autologin_timeout = config_get_integer (config_get_instance (), "SeatDefaults", "autologin-user-timeout");
-    if (seat->priv->autologin_timeout < 0)
-        seat->priv->autologin_timeout = 0;
+    g_return_val_if_fail (seat != NULL, NULL);
+    return seat->priv->config_section;
 }
 
 void
@@ -115,6 +107,8 @@ gboolean
 seat_start (Seat *seat)
 {
     g_return_val_if_fail (seat != NULL, FALSE);
+  
+    SEAT_GET_CLASS (seat)->setup (seat);
     return SEAT_GET_CLASS (seat)->start (seat);
 }
 
@@ -194,6 +188,7 @@ add_display (Seat *seat)
     Display *display;
 
     display = SEAT_GET_CLASS (seat)->add_display (seat);
+    display_load_config (DISPLAY (display), seat->priv->config_section);
     g_signal_connect (display, "activate-user", G_CALLBACK (display_activate_user_cb), seat);
     g_signal_connect (display, "stopped", G_CALLBACK (display_stopped_cb), seat);
     seat->priv->displays = g_list_append (seat->priv->displays, g_object_ref (display));
@@ -298,6 +293,25 @@ seat_stop (Seat *seat)
     SEAT_GET_CLASS (seat)->stop (seat);
 }
 
+static void
+seat_real_setup (Seat *seat)
+{
+    if (seat->priv->config_section && config_has_key (config_get_instance (), seat->priv->config_section, "autologin-guest"))
+        seat->priv->autologin_guest = config_get_boolean (config_get_instance (), seat->priv->config_section, "autologin-guest");
+    else if (config_has_key (config_get_instance (), "SeatDefaults", "autologin-guest"))
+        seat->priv->autologin_guest = config_get_boolean (config_get_instance (), "SeatDefaults", "autologin-guest");
+    if (seat->priv->config_section)
+        seat->priv->autologin_username = config_get_string (config_get_instance (), seat->priv->config_section, "autologin-user");
+    if (!seat->priv->autologin_username)
+        seat->priv->autologin_username = config_get_string (config_get_instance (), "SeatDefaults", "autologin-user");
+    if (seat->priv->config_section && config_has_key (config_get_instance (), seat->priv->config_section, "autologin-user-timeout"))
+        seat->priv->autologin_timeout = config_get_integer (config_get_instance (), seat->priv->config_section, "autologin-user-timeout");
+    else
+        seat->priv->autologin_timeout = config_get_integer (config_get_instance (), "SeatDefaults", "autologin-user-timeout");
+    if (seat->priv->autologin_timeout < 0)
+        seat->priv->autologin_timeout = 0;
+}
+
 static gboolean
 seat_real_start (Seat *seat)
 {
@@ -352,6 +366,7 @@ seat_finalize (GObject *object)
 
     self = SEAT (object);
 
+    g_free (self->priv->config_section);
     g_list_free_full (self->priv->displays, g_object_unref);
 
     G_OBJECT_CLASS (seat_parent_class)->finalize (object);
@@ -362,6 +377,7 @@ seat_class_init (SeatClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
+    klass->setup = seat_real_setup;
     klass->start = seat_real_start;
     klass->add_display = seat_real_add_display;
     klass->set_active_display = seat_real_set_active_display;
index 4cefa9e5f950189c0b99fcf5e4842e15c355b4ff..9a9c2f482ffb43bea66632c3af0fbd3c4cdfb88a 100644 (file)
@@ -34,6 +34,7 @@ typedef struct
 {
     GObjectClass parent_class;
 
+    void (*setup)(Seat *seat);    
     gboolean (*start)(Seat *seat);
     Display *(*add_display)(Seat *seat);
     void (*set_active_display)(Seat *seat, Display *display);
@@ -51,7 +52,7 @@ void seat_register_module (const gchar *name, GType type);
 
 Seat *seat_new (const gchar *module, const gchar *config_section);
 
-void seat_load_config (Seat *seat, const gchar *config_section);
+const gchar *seat_get_config_section (Seat *seat);
 
 void seat_set_can_switch (Seat *seat, gboolean can_switch);
 
index 899e7539f98ac8903a71b60508fbdf2b3da23b34..7c4f09c234422ba50efcaba9ce6fc8f4d7d927cd 100644 (file)
 G_DEFINE_TYPE (XDisplay, xdisplay, DISPLAY_TYPE);
 
 XDisplay *
-xdisplay_new (const gchar *config_section, XServer *server)
+xdisplay_new (XServer *server)
 {
     XDisplay *self = g_object_new (XDISPLAY_TYPE, NULL);
 
     g_return_val_if_fail (server != NULL, NULL);
 
-    display_load_config (DISPLAY (self), config_section);
     display_set_display_server (DISPLAY (self), DISPLAY_SERVER (server));
 
     return self;
index 87d099f98fb7d4e707d7fa5f13529be0c6585dca..bf365bc70350f311cd2ad20ef92fc957574cda1a 100644 (file)
@@ -32,7 +32,7 @@ typedef struct
 
 GType xdisplay_get_type (void);
 
-XDisplay *xdisplay_new (const gchar *config_section, XServer *server);
+XDisplay *xdisplay_new (XServer *server);
 
 G_END_DECLS
 
index 06c282469b6ba9b5535ca9de9f3abfb788b79523..cfe679b26eeb1d6cdef3118ad616d4c0a23c23fb 100644 (file)
@@ -24,7 +24,7 @@ struct XServerLocalPrivate
 
     /* Path of file to log to */
     gchar *log_file;
-
+  
     /* Command to run the X server */
     gchar *command;
 
@@ -75,29 +75,11 @@ release_display_number (guint number)
 }
 
 XServerLocal *
-xserver_local_new (const gchar *config_section)
+xserver_local_new (void)
 {
     XServerLocal *self = g_object_new (XSERVER_LOCAL_TYPE, NULL);
 
     xserver_set_display_number (XSERVER (self), get_free_display_number ());
-
-    /* If running inside an X server use Xephyr instead */
-    if (g_getenv ("DISPLAY"))
-        self->priv->command = g_strdup ("Xephyr");
-    if (!self->priv->command && config_section)
-        self->priv->command = config_get_string (config_get_instance (), config_section, "xserver-command");
-    if (!self->priv->command)
-        self->priv->command = config_get_string (config_get_instance (), "SeatDefaults", "xserver-command");
-
-    if (config_section)
-        self->priv->layout = config_get_string (config_get_instance (), config_section, "xserver-layout");
-    if (!self->priv->layout)
-        self->priv->layout = config_get_string (config_get_instance (), "SeatDefaults", "layout");
-
-    if (config_section)
-        self->priv->config_file = config_get_string (config_get_instance (), config_section, "xserver-config");
-    if (!self->priv->config_file)
-        self->priv->config_file = config_get_string (config_get_instance (), "SeatDefaults", "xserver-config");
   
     /* Replace Plymouth if it is running */
     if (plymouth_get_is_active () && plymouth_has_active_vt ())
@@ -119,6 +101,30 @@ xserver_local_new (const gchar *config_section)
     return self;
 }
 
+void
+xserver_local_set_command (XServerLocal *server, const gchar *command)
+{
+    g_return_if_fail (server != NULL);
+    g_free (server->priv->command);
+    server->priv->command = g_strdup (command);
+}
+
+void
+xserver_local_set_config (XServerLocal *server, const gchar *path)
+{
+    g_return_if_fail (server != NULL);
+    g_free (server->priv->config_file);
+    server->priv->config_file = g_strdup (path);
+}
+
+void
+xserver_local_set_layout (XServerLocal *server, const gchar *layout)
+{
+    g_return_if_fail (server != NULL);
+    g_free (server->priv->layout);
+    server->priv->layout = g_strdup (layout);
+}
+
 void
 xserver_local_set_xdmcp_server (XServerLocal *server, const gchar *hostname)
 {
@@ -375,6 +381,7 @@ xserver_local_init (XServerLocal *server)
 {
     server->priv = G_TYPE_INSTANCE_GET_PRIVATE (server, XSERVER_LOCAL_TYPE, XServerLocalPrivate);
     server->priv->vt = -1;
+    server->priv->command = g_strdup ("X");
 }
 
 static void
index dee0c5791dadda5b1fad80f14f0159afa22a622d..2a07c3f6da3d58a5e4f47ff098e351bf43db5adf 100644 (file)
@@ -37,7 +37,13 @@ typedef struct
 
 GType xserver_local_get_type (void);
 
-XServerLocal *xserver_local_new (const gchar *config_section);
+XServerLocal *xserver_local_new (void);
+
+void xserver_local_set_command (XServerLocal *server, const gchar *command);
+
+void xserver_local_set_config (XServerLocal *server, const gchar *path);
+
+void xserver_local_set_layout (XServerLocal *server, const gchar *layout);
 
 void xserver_local_set_xdmcp_server (XServerLocal *server, const gchar *hostname);