Back to index

lightdm  1.3.2
seat-xdmcp-session.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 <string.h>
00013 
00014 #include "seat-xdmcp-session.h"
00015 #include "xserver-remote.h"
00016 #include "xsession.h"
00017 
00018 struct SeatXDMCPSessionPrivate
00019 {
00020     /* Session being serviced */
00021     XDMCPSession *session;
00022 };
00023 
00024 G_DEFINE_TYPE (SeatXDMCPSession, seat_xdmcp_session, SEAT_TYPE);
00025 
00026 SeatXDMCPSession *
00027 seat_xdmcp_session_new (XDMCPSession *session)
00028 {
00029     SeatXDMCPSession *seat;
00030 
00031     seat = g_object_new (SEAT_XDMCP_SESSION_TYPE, NULL);
00032     seat->priv->session = g_object_ref (session);
00033 
00034     return seat;
00035 }
00036 
00037 static DisplayServer *
00038 seat_xdmcp_session_create_display_server (Seat *seat)
00039 {
00040     XAuthority *authority;
00041     gchar *host;
00042     XServerRemote *xserver;
00043 
00044     authority = xdmcp_session_get_authority (SEAT_XDMCP_SESSION (seat)->priv->session);
00045     host = g_inet_address_to_string (xdmcp_session_get_address (SEAT_XDMCP_SESSION (seat)->priv->session));
00046     xserver = xserver_remote_new (host, xdmcp_session_get_display_number (SEAT_XDMCP_SESSION (seat)->priv->session), authority);
00047     g_free (host);
00048 
00049     return DISPLAY_SERVER (xserver);
00050 }
00051 
00052 static Session *
00053 seat_xdmcp_session_create_session (Seat *seat, Display *display)
00054 {
00055     XServerRemote *xserver;
00056     XSession *session;
00057 
00058     xserver = XSERVER_REMOTE (display_get_display_server (display));
00059 
00060     session = xsession_new (XSERVER (xserver));
00061     session_set_remote_host_name (SESSION (session), xserver_get_hostname (XSERVER (xserver)));
00062 
00063     return SESSION (session);
00064 }
00065 
00066 static void
00067 seat_xdmcp_session_display_removed (Seat *seat, Display *display)
00068 {
00069    seat_stop (seat);
00070 }
00071 
00072 static void
00073 seat_xdmcp_session_init (SeatXDMCPSession *seat)
00074 {
00075     seat->priv = G_TYPE_INSTANCE_GET_PRIVATE (seat, SEAT_XDMCP_SESSION_TYPE, SeatXDMCPSessionPrivate);
00076 }
00077 
00078 static void
00079 seat_xdmcp_session_finalize (GObject *object)
00080 {
00081     SeatXDMCPSession *self;
00082 
00083     self = SEAT_XDMCP_SESSION (object);
00084 
00085     g_object_unref (self->priv->session);
00086 
00087     G_OBJECT_CLASS (seat_xdmcp_session_parent_class)->finalize (object);
00088 }
00089 
00090 static void
00091 seat_xdmcp_session_class_init (SeatXDMCPSessionClass *klass)
00092 {
00093     SeatClass *seat_class = SEAT_CLASS (klass);
00094     GObjectClass *object_class = G_OBJECT_CLASS (klass);
00095 
00096     seat_class->create_display_server = seat_xdmcp_session_create_display_server;
00097     seat_class->create_session = seat_xdmcp_session_create_session;
00098     seat_class->display_removed = seat_xdmcp_session_display_removed;
00099     object_class->finalize = seat_xdmcp_session_finalize;
00100 
00101     g_type_class_add_private (klass, sizeof (SeatXDMCPSessionPrivate));
00102 }