Commit 1f539686 authored by William Jon McCann's avatar William Jon McCann

Add x11-display property to display. Move

remote-hostname from xdmcp display to parent class.
Set some defaults in slave so greeter and server start.

svn path=/branches/mccann-gobject/; revision=4916
parent b961c279
......@@ -47,8 +47,9 @@ static guint32 display_serial = 1;
struct GdmDisplayPrivate
{
char *id;
char *name;
char *remote_hostname;
int number;
char *x11_display;
int status;
time_t creation_time;
char *cookie;
......@@ -64,8 +65,9 @@ struct GdmDisplayPrivate
enum {
PROP_0,
PROP_ID,
PROP_NAME,
PROP_REMOTE_HOSTNAME,
PROP_NUMBER,
PROP_X11_DISPLAY,
PROP_COOKIE,
PROP_BINARY_COOKIE,
PROP_AUTHORITY_FILE,
......@@ -149,6 +151,34 @@ gdm_display_create_authority (GdmDisplay *display)
return ret;
}
gboolean
gdm_display_get_remote_hostname (GdmDisplay *display,
char **hostname,
GError **error)
{
g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
if (hostname != NULL) {
*hostname = g_strdup (display->priv->remote_hostname);
}
return TRUE;
}
gboolean
gdm_display_get_number (GdmDisplay *display,
int *number,
GError **error)
{
g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
if (number != NULL) {
*number = display->priv->number;
}
return TRUE;
}
static gboolean
gdm_display_real_manage (GdmDisplay *display)
{
......@@ -226,28 +256,14 @@ gdm_display_get_id (GdmDisplay *display,
}
gboolean
gdm_display_get_name (GdmDisplay *display,
char **name,
gdm_display_get_x11_display (GdmDisplay *display,
char **x11_display,
GError **error)
{
g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
if (name != NULL) {
*name = g_strdup (display->priv->name);
}
return TRUE;
}
gboolean
gdm_display_get_number (GdmDisplay *display,
int *number,
GError **error)
{
g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
if (number != NULL) {
*number = display->priv->number;
if (x11_display != NULL) {
*x11_display = g_strdup (display->priv->x11_display);
}
return TRUE;
......@@ -276,11 +292,26 @@ _gdm_display_set_id (GdmDisplay *display,
}
static void
_gdm_display_set_name (GdmDisplay *display,
const char *name)
_gdm_display_set_remote_hostname (GdmDisplay *display,
const char *hostname)
{
g_free (display->priv->name);
display->priv->name = g_strdup (name);
g_free (display->priv->remote_hostname);
display->priv->remote_hostname = g_strdup (hostname);
}
static void
_gdm_display_set_number (GdmDisplay *display,
int num)
{
display->priv->number = num;
}
static void
_gdm_display_set_x11_display (GdmDisplay *display,
const char *x11_display)
{
g_free (display->priv->x11_display);
display->priv->x11_display = g_strdup (x11_display);
}
static void
......@@ -307,13 +338,6 @@ _gdm_display_set_authority_file (GdmDisplay *display,
display->priv->authority_file = g_strdup (file);
}
static void
_gdm_display_set_number (GdmDisplay *display,
int num)
{
display->priv->number = num;
}
static void
_gdm_display_set_is_local (GdmDisplay *display,
gboolean is_local)
......@@ -335,8 +359,14 @@ gdm_display_set_property (GObject *object,
case PROP_ID:
_gdm_display_set_id (self, g_value_get_string (value));
break;
case PROP_NAME:
_gdm_display_set_name (self, g_value_get_string (value));
case PROP_REMOTE_HOSTNAME:
_gdm_display_set_remote_hostname (self, g_value_get_string (value));
break;
case PROP_NUMBER:
_gdm_display_set_number (self, g_value_get_int (value));
break;
case PROP_X11_DISPLAY:
_gdm_display_set_x11_display (self, g_value_get_string (value));
break;
case PROP_COOKIE:
_gdm_display_set_cookie (self, g_value_get_string (value));
......@@ -347,9 +377,6 @@ gdm_display_set_property (GObject *object,
case PROP_AUTHORITY_FILE:
_gdm_display_set_authority_file (self, g_value_get_string (value));
break;
case PROP_NUMBER:
_gdm_display_set_number (self, g_value_get_int (value));
break;
case PROP_IS_LOCAL:
_gdm_display_set_is_local (self, g_value_get_boolean (value));
break;
......@@ -373,8 +400,14 @@ gdm_display_get_property (GObject *object,
case PROP_ID:
g_value_set_string (value, self->priv->id);
break;
case PROP_NAME:
g_value_set_string (value, self->priv->name);
case PROP_REMOTE_HOSTNAME:
g_value_set_string (value, self->priv->remote_hostname);
break;
case PROP_NUMBER:
g_value_set_int (value, self->priv->number);
break;
case PROP_X11_DISPLAY:
g_value_set_string (value, self->priv->x11_display);
break;
case PROP_COOKIE:
g_value_set_string (value, self->priv->cookie);
......@@ -385,9 +418,6 @@ gdm_display_get_property (GObject *object,
case PROP_AUTHORITY_FILE:
g_value_set_string (value, self->priv->authority_file);
break;
case PROP_NUMBER:
g_value_set_int (value, self->priv->number);
break;
case PROP_IS_LOCAL:
g_value_set_boolean (value, self->priv->is_local);
break;
......@@ -468,10 +498,26 @@ gdm_display_class_init (GdmDisplayClass *klass)
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_NAME,
g_param_spec_string ("name",
"name",
"name",
PROP_REMOTE_HOSTNAME,
g_param_spec_string ("remote-hostname",
"remote-hostname",
"remote-hostname",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_NUMBER,
g_param_spec_int ("number",
"number",
"number",
-1,
G_MAXINT,
-1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_X11_DISPLAY,
g_param_spec_string ("x11-display",
"x11-display",
"x11-display",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
......@@ -495,15 +541,6 @@ gdm_display_class_init (GdmDisplayClass *klass)
"authority file",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_NUMBER,
g_param_spec_int ("number",
"number",
"number",
-1,
G_MAXINT,
-1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_IS_LOCAL,
......
......@@ -83,11 +83,14 @@ gboolean gdm_display_unmanage (GdmDisplay *disp
gboolean gdm_display_get_id (GdmDisplay *display,
char **id,
GError **error);
gboolean gdm_display_get_remote_hostname (GdmDisplay *display,
char **hostname,
GError **error);
gboolean gdm_display_get_number (GdmDisplay *display,
int *number,
GError **error);
gboolean gdm_display_get_name (GdmDisplay *display,
char **name,
gboolean gdm_display_get_x11_display (GdmDisplay *display,
char **x11_display,
GError **error);
gboolean gdm_display_is_local (GdmDisplay *display,
gboolean *local,
......
......@@ -4,12 +4,9 @@
<method name="GetId">
<arg name="id" direction="out" type="o"/>
</method>
<method name="GetName">
<method name="GetX11Display">
<arg name="name" direction="out" type="s"/>
</method>
<method name="GetNumber">
<arg name="number" direction="out" type="i"/>
</method>
<method name="IsLocal">
<arg name="local" direction="out" type="b"/>
</method>
......
......@@ -206,8 +206,7 @@ load_static_displays_from_file (GdmManager *manager)
g_debug ("Loading display for '%d' %s", xserver->number, xserver->id);
display = gdm_static_display_new (xserver->number,
xserver->id);
display = gdm_static_display_new (xserver->number);
if (display == NULL) {
g_warning ("Unable to create display: %d %s", xserver->number, xserver->id);
......
......@@ -327,6 +327,8 @@ server_child_setup (GdmServer *server)
logfile = gdm_make_filename (server->priv->log_dir,
server->priv->display_name,
".log");
g_debug ("Opening logfile for server %s", logfile);
VE_IGNORE_EINTR (g_unlink (logfile));
VE_IGNORE_EINTR (logfd = open (logfile, O_CREAT|O_TRUNC|O_WRONLY|O_EXCL, 0644));
......@@ -678,6 +680,8 @@ gdm_server_init (GdmServer *server)
server->priv = GDM_SERVER_GET_PRIVATE (server);
server->priv->pid = -1;
server->priv->command = g_strdup ("/usr/bin/Xorg");
server->priv->log_dir = g_strdup (LOGDIR);
}
static void
......
......@@ -504,9 +504,7 @@ get_script_environment (GdmSlave *slave,
static gboolean
gdm_slave_exec_script (GdmSlave *slave,
const char *dir,
const char *login,
struct passwd *pwent,
gboolean pass_stdout)
const char *login)
{
char *script;
char **argv;
......@@ -516,6 +514,9 @@ gdm_slave_exec_script (GdmSlave *slave,
gboolean res;
gboolean ret;
g_assert (dir != NULL);
g_assert (login != NULL);
script = g_build_filename (dir, slave->priv->display_name, NULL);
if (g_access (script, R_OK|X_OK) != 0) {
g_free (script);
......@@ -691,9 +692,7 @@ gdm_slave_run (GdmSlave *slave)
/* Run the init script. gdmslave suspends until script has terminated */
gdm_slave_exec_script (slave,
GDMCONFDIR"/Init",
NULL,
NULL,
FALSE /* pass_stdout */);
"gdm");
slave->priv->greeter = gdm_greeter_new (slave->priv->display_name);
gdm_greeter_start (slave->priv->greeter);
......@@ -772,7 +771,7 @@ gdm_slave_start (GdmSlave *slave)
error = NULL;
res = dbus_g_proxy_call (slave->priv->display_proxy,
"GetName",
"GetX11Display",
&error,
G_TYPE_INVALID,
G_TYPE_STRING, &slave->priv->display_name,
......@@ -788,24 +787,6 @@ gdm_slave_start (GdmSlave *slave)
return FALSE;
}
error = NULL;
res = dbus_g_proxy_call (slave->priv->display_proxy,
"GetNumber",
&error,
G_TYPE_INVALID,
G_TYPE_STRING, &slave->priv->display_number,
G_TYPE_INVALID);
if (! res) {
if (error != NULL) {
g_warning ("Failed to get value: %s", error->message);
g_error_free (error);
} else {
g_warning ("Failed to get value");
}
return FALSE;
}
gdm_slave_run (slave);
return TRUE;
......
......@@ -161,15 +161,17 @@ gdm_static_display_finalize (GObject *object)
}
GdmDisplay *
gdm_static_display_new (int number,
const char *name)
gdm_static_display_new (int display_number)
{
GObject *object;
char *x11_display;
x11_display = g_strdup_printf (":%d", display_number);
object = g_object_new (GDM_TYPE_STATIC_DISPLAY,
"number", number,
"name", name,
"number", display_number,
"x11-display", x11_display,
NULL);
g_free (x11_display);
return GDM_DISPLAY (object);
}
......@@ -52,8 +52,7 @@ typedef struct
} GdmStaticDisplayClass;
GType gdm_static_display_get_type (void);
GdmDisplay * gdm_static_display_new (int number,
const char *name);
GdmDisplay * gdm_static_display_new (int display_number);
G_END_DECLS
......
......@@ -49,14 +49,12 @@
struct GdmXdmcpDisplayPrivate
{
char *remote_hostname;
GdmAddress *remote_address;
gint32 session_number;
};
enum {
PROP_0,
PROP_REMOTE_HOSTNAME,
PROP_REMOTE_ADDRESS,
PROP_SESSION_NUMBER,
};
......@@ -75,20 +73,6 @@ gdm_xdmcp_display_get_session_number (GdmXdmcpDisplay *display)
return display->priv->session_number;
}
gboolean
gdm_xdmcp_display_get_remote_hostname (GdmXdmcpDisplay *display,
char **hostname,
GError **error)
{
g_return_val_if_fail (GDM_IS_XDMCP_DISPLAY (display), FALSE);
if (hostname != NULL) {
*hostname = g_strdup (display->priv->remote_hostname);
}
return TRUE;
}
GdmAddress *
gdm_xdmcp_display_get_remote_address (GdmXdmcpDisplay *display)
{
......@@ -200,9 +184,6 @@ gdm_xdmcp_display_set_property (GObject *object,
self = GDM_XDMCP_DISPLAY (object);
switch (prop_id) {
case PROP_REMOTE_HOSTNAME:
self->priv->remote_hostname = g_value_dup_string (value);
break;
case PROP_REMOTE_ADDRESS:
self->priv->remote_address = g_value_get_boxed (value);
break;
......@@ -226,9 +207,6 @@ gdm_xdmcp_display_get_property (GObject *object,
self = GDM_XDMCP_DISPLAY (object);
switch (prop_id) {
case PROP_REMOTE_HOSTNAME:
g_value_set_string (value, self->priv->remote_hostname);
break;
case PROP_REMOTE_ADDRESS:
g_value_set_boxed (value, self->priv->remote_address);
break;
......@@ -257,13 +235,6 @@ gdm_xdmcp_display_class_init (GdmXdmcpDisplayClass *klass)
g_type_class_add_private (klass, sizeof (GdmXdmcpDisplayPrivate));
g_object_class_install_property (object_class,
PROP_REMOTE_HOSTNAME,
g_param_spec_string ("remote-hostname",
"remote-hostname",
"remote-hostname",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_REMOTE_ADDRESS,
g_param_spec_boxed ("remote-address",
......@@ -308,22 +279,24 @@ gdm_xdmcp_display_finalize (GObject *object)
}
GdmDisplay *
gdm_xdmcp_display_new (int number,
const char *name,
const char *hostname,
gdm_xdmcp_display_new (const char *hostname,
int number,
GdmAddress *address,
gint32 session_number)
{
GObject *object;
char *x11_display;
x11_display = g_strdup_printf ("%s:%d", hostname, number);
object = g_object_new (GDM_TYPE_XDMCP_DISPLAY,
"is-local", FALSE,
"number", number,
"name", name,
"remote-hostname", hostname,
"number", number,
"x11-display", x11_display,
"is-local", FALSE,
"remote-address", address,
"session-number", session_number,
NULL);
g_free (x11_display);
return GDM_DISPLAY (object);
}
......@@ -56,9 +56,8 @@ typedef struct
GType gdm_xdmcp_display_get_type (void);
GdmDisplay * gdm_xdmcp_display_new (int number,
const char *name,
const char *hostname,
GdmDisplay * gdm_xdmcp_display_new (const char *hostname,
int number,
GdmAddress *addr,
gint32 serial_number);
......@@ -66,12 +65,6 @@ gint32 gdm_xdmcp_display_get_session_number (GdmXdmcpDi
GdmAddress * gdm_xdmcp_display_get_remote_address (GdmXdmcpDisplay *display);
/* exported */
gboolean gdm_xdmcp_display_get_remote_hostname (GdmXdmcpDisplay *display,
char **hostname,
GError **error);
G_END_DECLS
#endif /* __GDM_XDMCP_DISPLAY_H */
......@@ -1659,7 +1659,7 @@ remove_host (const char *id,
return FALSE;
}
gdm_xdmcp_display_get_remote_hostname (GDM_XDMCP_DISPLAY (display), &hostname, NULL);
gdm_display_get_remote_hostname (display, &hostname, NULL);
gdm_display_get_number (display, &disp_num, NULL);
if (disp_num == data->display_num &&
......@@ -1754,15 +1754,9 @@ gdm_xdmcp_display_alloc (GdmXdmcpManager *manager,
int displaynum)
{
GdmDisplay *display;
char *name;
name = g_strdup_printf ("%s:%d",
hostname,
displaynum);
display = gdm_xdmcp_display_new (displaynum,
name,
hostname,
display = gdm_xdmcp_display_new (hostname,
displaynum,
address,
get_next_session_serial (manager));
if (display == NULL) {
......@@ -1779,7 +1773,6 @@ gdm_xdmcp_display_alloc (GdmXdmcpManager *manager,
manager->priv->num_pending_sessions++;
out:
g_free (name);
return display;
}
......@@ -2226,7 +2219,7 @@ gdm_xdmcp_handle_manage (GdmXdmcpManager *manager,
char *name;
name = NULL;
gdm_display_get_name (display, &name, NULL);
gdm_display_get_x11_display (display, &name, NULL);
g_debug ("gdm_xdmcp_handle_manage: Looked up %s", name);
g_free (name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment