summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2015-02-03 17:13:51 -0500
committerRay Strode <rstrode@redhat.com>2015-02-16 23:36:02 -0500
commita6eaa8d635b8c6d3e17939883ad52be23aca96cc (patch)
treefe18133a27cf3e2052b8b01e756b2580ce35afb3
parentca3d6483a64d08612c7a880c17524de6f28bb1fc (diff)
downloadgdm-a6eaa8d635b8c6d3e17939883ad52be23aca96cc.tar.gz
display: get rid of more simple slave code.
This commit moves GdmServer to GdmLocalDisplay, and XDMCP connection retries to GdmXdmcpDisplay.
-rw-r--r--daemon/gdm-display.c9
-rw-r--r--daemon/gdm-local-display.c107
-rw-r--r--daemon/gdm-simple-slave.c182
-rw-r--r--daemon/gdm-xdmcp-display.c35
4 files changed, 143 insertions, 190 deletions
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
index f479edc5..a845aee8 100644
--- a/daemon/gdm-display.c
+++ b/daemon/gdm-display.c
@@ -928,12 +928,6 @@ _gdm_display_set_launch_environment (GdmDisplay *self,
g_clear_object (&self->priv->launch_environment);
self->priv->launch_environment = g_object_ref (launch_environment);
-
- g_object_bind_property (launch_environment,
- "session-id",
- self,
- "session-id",
- G_BINDING_SYNC_CREATE);
}
static void
@@ -1575,8 +1569,7 @@ on_launch_environment_session_opened (GdmLaunchEnvironment *launch_environment,
g_debug ("GdmDisplay: Greeter session opened");
session_id = gdm_launch_environment_get_session_id (launch_environment);
-
- g_object_set (GDM_SLAVE (self), "session-id", session_id, NULL);
+ _gdm_display_set_session_id (self, session_id);
g_free (session_id);
}
diff --git a/daemon/gdm-local-display.c b/daemon/gdm-local-display.c
index 112a7cd2..505a1b3a 100644
--- a/daemon/gdm-local-display.c
+++ b/daemon/gdm-local-display.c
@@ -41,12 +41,17 @@
#include "gdm-launch-environment.h"
#include "gdm-local-display.h"
#include "gdm-local-display-glue.h"
+#include "gdm-server.h"
+#include "gdm-settings-direct.h"
+#include "gdm-settings-keys.h"
#define GDM_LOCAL_DISPLAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_LOCAL_DISPLAY, GdmLocalDisplayPrivate))
struct GdmLocalDisplayPrivate
{
GdmDBusLocalDisplay *skeleton;
+
+ GdmServer *server;
};
static void gdm_local_display_class_init (GdmLocalDisplayClass *klass);
@@ -79,6 +84,7 @@ gdm_local_display_finalize (GObject *object)
GdmLocalDisplay *display = GDM_LOCAL_DISPLAY (object);
g_clear_object (&display->priv->skeleton);
+ g_clear_object (&display->priv->server);
G_OBJECT_CLASS (gdm_local_display_parent_class)->finalize (object);
}
@@ -120,6 +126,106 @@ gdm_local_display_prepare (GdmDisplay *display)
}
static void
+on_server_ready (GdmServer *server,
+ GdmLocalDisplay *self)
+{
+ gboolean ret;
+
+ ret = gdm_display_connect (GDM_DISPLAY (self));
+
+ if (!ret) {
+ g_debug ("GdmDisplay: could not connect to display");
+ gdm_display_unmanage (GDM_DISPLAY (self));
+ } else {
+ g_debug ("GdmDisplay: connected to display");
+ g_object_set (G_OBJECT (self), "status", GDM_DISPLAY_MANAGED, NULL);
+ }
+}
+
+static void
+on_server_exited (GdmServer *server,
+ int exit_code,
+ GdmDisplay *self)
+{
+ g_debug ("GdmDisplay: server exited with code %d\n", exit_code);
+
+ gdm_display_unmanage (GDM_DISPLAY (self));
+}
+
+static void
+on_server_died (GdmServer *server,
+ int signal_number,
+ GdmDisplay *self)
+{
+ g_debug ("GdmDisplay: server died with signal %d, (%s)",
+ signal_number,
+ g_strsignal (signal_number));
+
+ gdm_display_unmanage (GDM_DISPLAY (self));
+}
+
+static void
+gdm_local_display_manage (GdmDisplay *display)
+{
+ GdmLocalDisplay *self = GDM_LOCAL_DISPLAY (display);
+ char *display_name;
+ char *auth_file;
+ char *seat_id;
+ gboolean is_initial;
+ gboolean res;
+ gboolean disable_tcp;
+
+ g_object_get (G_OBJECT (self),
+ "x11-display-name", &display_name,
+ "x11-authority-file", &auth_file,
+ "seat-id", &seat_id,
+ "is-initial", &is_initial,
+ NULL);
+
+ self->priv->server = gdm_server_new (display_name, seat_id, auth_file, is_initial);
+
+ g_free (display_name);
+ g_free (auth_file);
+ g_free (seat_id);
+
+ disable_tcp = TRUE;
+ if (gdm_settings_direct_get_boolean (GDM_KEY_DISALLOW_TCP, &disable_tcp)) {
+ g_object_set (self->priv->server,
+ "disable-tcp", disable_tcp,
+ NULL);
+ }
+
+ g_signal_connect (self->priv->server,
+ "exited",
+ G_CALLBACK (on_server_exited),
+ self);
+ g_signal_connect (self->priv->server,
+ "died",
+ G_CALLBACK (on_server_died),
+ self);
+ g_signal_connect (self->priv->server,
+ "ready",
+ G_CALLBACK (on_server_ready),
+ self);
+
+ res = gdm_server_start (self->priv->server);
+ if (! res) {
+ g_warning (_("Could not start the X "
+ "server (your graphical environment) "
+ "due to an internal error. "
+ "Please contact your system administrator "
+ "or check your syslog to diagnose. "
+ "In the meantime this display will be "
+ "disabled. Please restart GDM when "
+ "the problem is corrected."));
+ gdm_display_unmanage (GDM_DISPLAY (self));
+ }
+
+ g_debug ("GdmDisplay: Started X server");
+
+}
+
+static void
gdm_local_display_class_init (GdmLocalDisplayClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -129,6 +235,7 @@ gdm_local_display_class_init (GdmLocalDisplayClass *klass)
object_class->finalize = gdm_local_display_finalize;
display_class->prepare = gdm_local_display_prepare;
+ display_class->manage = gdm_local_display_manage;
g_type_class_add_private (klass, sizeof (GdmLocalDisplayPrivate));
}
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index 693f7236..e5c88740 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -51,199 +51,17 @@
#include "gdm-settings-direct.h"
#include "gdm-settings-keys.h"
-#define GDM_SIMPLE_SLAVE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SIMPLE_SLAVE, GdmSimpleSlavePrivate))
-
-#define MAX_CONNECT_ATTEMPTS 10
-#define DEFAULT_PING_INTERVAL 15
-
-#define INITIAL_SETUP_USERNAME "gnome-initial-setup"
-#define GNOME_SESSION_SESSIONS_PATH DATADIR "/gnome-session/sessions"
-
-struct GdmSimpleSlavePrivate
-{
- GPid pid;
- char *username;
-
- int ping_interval;
-
- guint connection_attempts;
-
- GdmServer *server;
-};
-
-enum {
- PROP_0,
-};
-
static void gdm_simple_slave_class_init (GdmSimpleSlaveClass *klass);
static void gdm_simple_slave_init (GdmSimpleSlave *simple_slave);
G_DEFINE_TYPE (GdmSimpleSlave, gdm_simple_slave, GDM_TYPE_SLAVE)
static void
-setup_server (GdmSimpleSlave *slave)
-{
-}
-
-static gboolean
-idle_connect_to_display (GdmSimpleSlave *slave)
-{
- gboolean res;
-
- slave->priv->connection_attempts++;
-
- res = gdm_slave_connect_to_x11_display (GDM_SLAVE (slave));
- if (res) {
- setup_server (slave);
- } else {
- if (slave->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
- g_warning ("Unable to connect to display after %d tries - bailing out", slave->priv->connection_attempts);
- exit (1);
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-on_server_ready (GdmServer *server,
- GdmSimpleSlave *slave)
-{
- g_idle_add ((GSourceFunc)idle_connect_to_display, slave);
-}
-
-static void
-on_server_exited (GdmServer *server,
- int exit_code,
- GdmSimpleSlave *slave)
-{
- g_debug ("GdmSimpleSlave: server exited with code %d\n", exit_code);
-
- gdm_slave_stop (GDM_SLAVE (slave));
-}
-
-static void
-on_server_died (GdmServer *server,
- int signal_number,
- GdmSimpleSlave *slave)
-{
- g_debug ("GdmSimpleSlave: server died with signal %d, (%s)",
- signal_number,
- g_strsignal (signal_number));
-
- gdm_slave_stop (GDM_SLAVE (slave));
-}
-
-static gboolean
-gdm_simple_slave_run (GdmSimpleSlave *slave)
-{
- char *display_name;
- char *auth_file;
- char *seat_id;
- gboolean display_is_local;
- gboolean display_is_initial;
-
- g_object_get (slave,
- "display-is-local", &display_is_local,
- "display-name", &display_name,
- "display-seat-id", &seat_id,
- "display-x11-authority-file", &auth_file,
- "display-is-initial", &display_is_initial,
- NULL);
-
- /* if this is local display start a server if one doesn't
- * exist */
- if (display_is_local) {
- gboolean res;
- gboolean disable_tcp;
-
- slave->priv->server = gdm_server_new (display_name, seat_id, auth_file, display_is_initial);
-
- disable_tcp = TRUE;
- if (gdm_settings_direct_get_boolean (GDM_KEY_DISALLOW_TCP, &disable_tcp)) {
- g_object_set (slave->priv->server,
- "disable-tcp", disable_tcp,
- NULL);
- }
-
- g_signal_connect (slave->priv->server,
- "exited",
- G_CALLBACK (on_server_exited),
- slave);
- g_signal_connect (slave->priv->server,
- "died",
- G_CALLBACK (on_server_died),
- slave);
- g_signal_connect (slave->priv->server,
- "ready",
- G_CALLBACK (on_server_ready),
- slave);
-
- res = gdm_server_start (slave->priv->server);
- if (! res) {
- g_warning (_("Could not start the X "
- "server (your graphical environment) "
- "due to an internal error. "
- "Please contact your system administrator "
- "or check your syslog to diagnose. "
- "In the meantime this display will be "
- "disabled. Please restart GDM when "
- "the problem is corrected."));
- exit (1);
- }
-
- g_debug ("GdmSimpleSlave: Started X server");
- } else {
- g_timeout_add (500, (GSourceFunc)idle_connect_to_display, slave);
- }
-
- g_free (display_name);
- g_free (auth_file);
-
- return TRUE;
-}
-
-static gboolean
-gdm_simple_slave_start (GdmSlave *slave)
-{
- GDM_SLAVE_CLASS (gdm_simple_slave_parent_class)->start (slave);
-
- gdm_simple_slave_run (GDM_SIMPLE_SLAVE (slave));
-
- return TRUE;
-}
-
-static gboolean
-gdm_simple_slave_stop (GdmSlave *slave)
-{
- GdmSimpleSlave *self = GDM_SIMPLE_SLAVE (slave);
-
- g_debug ("GdmSimpleSlave: Stopping simple_slave");
-
- GDM_SLAVE_CLASS (gdm_simple_slave_parent_class)->stop (slave);
-
- if (self->priv->server != NULL) {
- gdm_server_stop (self->priv->server);
- g_clear_object (&self->priv->server);
- }
-
- return TRUE;
-}
-
-static void
gdm_simple_slave_class_init (GdmSimpleSlaveClass *klass)
{
- GdmSlaveClass *slave_class = GDM_SLAVE_CLASS (klass);
-
- slave_class->start = gdm_simple_slave_start;
- slave_class->stop = gdm_simple_slave_stop;
-
- g_type_class_add_private (klass, sizeof (GdmSimpleSlavePrivate));
}
static void
gdm_simple_slave_init (GdmSimpleSlave *slave)
{
- slave->priv = GDM_SIMPLE_SLAVE_GET_PRIVATE (slave);
}
diff --git a/daemon/gdm-xdmcp-display.c b/daemon/gdm-xdmcp-display.c
index 27f7ee5e..7241cafe 100644
--- a/daemon/gdm-xdmcp-display.c
+++ b/daemon/gdm-xdmcp-display.c
@@ -52,6 +52,7 @@ struct GdmXdmcpDisplayPrivate
{
GdmAddress *remote_address;
gint32 session_number;
+ guint connection_attempts;
};
enum {
@@ -60,6 +61,8 @@ enum {
PROP_SESSION_NUMBER,
};
+#define MAX_CONNECT_ATTEMPTS 10
+
static void gdm_xdmcp_display_class_init (GdmXdmcpDisplayClass *klass);
static void gdm_xdmcp_display_init (GdmXdmcpDisplay *xdmcp_display);
@@ -174,6 +177,37 @@ gdm_xdmcp_display_prepare (GdmDisplay *display)
return GDM_DISPLAY_CLASS (gdm_xdmcp_display_parent_class)->prepare (display);
}
+static gboolean
+idle_connect_to_display (GdmXdmcpDisplay *self)
+{
+ gboolean res;
+
+ self->priv->connection_attempts++;
+
+ res = gdm_display_connect (GDM_DISPLAY (self));
+ if (res) {
+ } else {
+ if (self->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
+ g_warning ("Unable to connect to display after %d tries - bailing out", self->priv->connection_attempts);
+ gdm_display_unmanage (GDM_DISPLAY (self));
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+gdm_xdmcp_display_manage (GdmDisplay *display)
+{
+ GdmXdmcpDisplay *self = GDM_XDMCP_DISPLAY (display);
+
+ g_timeout_add (500, (GSourceFunc)idle_connect_to_display, self);
+
+ GDM_DISPLAY_CLASS (gdm_xdmcp_display_parent_class)->manage (display);
+}
+
static void
gdm_xdmcp_display_class_init (GdmXdmcpDisplayClass *klass)
{
@@ -184,6 +218,7 @@ gdm_xdmcp_display_class_init (GdmXdmcpDisplayClass *klass)
object_class->set_property = gdm_xdmcp_display_set_property;
display_class->prepare = gdm_xdmcp_display_prepare;
+ display_class->manage = gdm_xdmcp_display_manage;
g_type_class_add_private (klass, sizeof (GdmXdmcpDisplayPrivate));