Back to index

lightdm  1.3.2
xsession.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010-2011 Robert Ancell.
00003  * Author: Robert Ancell <robert.ancell@canonical.com>
00004  * 
00005  * This program is free software: you can redistribute it and/or modify it under
00006  * the terms of the GNU General Public License as published by the Free Software
00007  * Foundation, either version 3 of the License, or (at your option) any later
00008  * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
00009  * license.
00010  */
00011 
00012 #include <errno.h>
00013 #include <string.h>
00014 #include <fcntl.h>
00015 #include <sys/stat.h>
00016 
00017 #include "xsession.h"
00018 #include "configuration.h"
00019 #include "privileges.h"
00020 
00021 struct XSessionPrivate
00022 {
00023     /* X server connected to */
00024     XServer *xserver;
00025 };
00026 
00027 G_DEFINE_TYPE (XSession, xsession, SESSION_TYPE);
00028 
00029 XSession *
00030 xsession_new (XServer *xserver)
00031 {
00032     XSession *session;
00033     XAuthority *authority;
00034 
00035     session = g_object_new (XSESSION_TYPE, NULL);
00036     session->priv->xserver = g_object_ref (xserver);
00037 
00038     session_set_env (SESSION (session), "DISPLAY", xserver_get_address (xserver));
00039     session_set_tty (SESSION (session), xserver_get_address (xserver));
00040     session_set_xdisplay (SESSION (session), xserver_get_address (xserver));
00041     authority = xserver_get_authority (xserver);
00042     if (authority)
00043         session_set_xauthority (SESSION (session), authority, config_get_boolean (config_get_instance (), "LightDM", "user-authority-in-system-dir"));
00044     session_set_log_file (SESSION (session), ".xsession-errors");
00045 
00046     return session;
00047 }
00048 
00049 static void
00050 xsession_init (XSession *session)
00051 {
00052     session->priv = G_TYPE_INSTANCE_GET_PRIVATE (session, XSESSION_TYPE, XSessionPrivate);
00053 }
00054 
00055 static void
00056 xsession_finalize (GObject *object)
00057 {
00058     XSession *self;
00059 
00060     self = XSESSION (object);
00061 
00062     if (self->priv->xserver)
00063         g_object_unref (self->priv->xserver);
00064 
00065     G_OBJECT_CLASS (xsession_parent_class)->finalize (object);
00066 }
00067 
00068 static void
00069 xsession_class_init (XSessionClass *klass)
00070 {
00071     GObjectClass *object_class = G_OBJECT_CLASS (klass);
00072 
00073     object_class->finalize = xsession_finalize;
00074 
00075     g_type_class_add_private (klass, sizeof (XSessionPrivate));
00076 }