2 * Copyright (C) 2010-2011 Robert Ancell.
3 * Author: Robert Ancell <robert.ancell@canonical.com>
5 * This program is free software: you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option) any later
8 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
14 #include "seat-xdmcp-session.h"
15 #include "x-server-remote.h"
17 struct SeatXDMCPSessionPrivate
19 /* Session being serviced */
20 XDMCPSession *session;
23 G_DEFINE_TYPE (SeatXDMCPSession, seat_xdmcp_session, SEAT_TYPE);
26 seat_xdmcp_session_new (XDMCPSession *session)
28 SeatXDMCPSession *seat;
30 seat = g_object_new (SEAT_XDMCP_SESSION_TYPE, NULL);
31 seat->priv->session = g_object_ref (session);
36 static DisplayServer *
37 seat_xdmcp_session_create_display_server (Seat *seat, Session *session)
39 XAuthority *authority;
41 XServerRemote *x_server;
43 if (strcmp (session_get_session_type (session), "x") != 0)
46 authority = xdmcp_session_get_authority (SEAT_XDMCP_SESSION (seat)->priv->session);
47 host = g_inet_address_to_string (xdmcp_session_get_address (SEAT_XDMCP_SESSION (seat)->priv->session));
48 x_server = x_server_remote_new (host, xdmcp_session_get_display_number (SEAT_XDMCP_SESSION (seat)->priv->session), authority);
51 return DISPLAY_SERVER (x_server);
55 seat_xdmcp_session_init (SeatXDMCPSession *seat)
57 seat->priv = G_TYPE_INSTANCE_GET_PRIVATE (seat, SEAT_XDMCP_SESSION_TYPE, SeatXDMCPSessionPrivate);
61 seat_xdmcp_session_finalize (GObject *object)
63 SeatXDMCPSession *self = SEAT_XDMCP_SESSION (object);
65 g_clear_object (&self->priv->session);
67 G_OBJECT_CLASS (seat_xdmcp_session_parent_class)->finalize (object);
71 seat_xdmcp_session_class_init (SeatXDMCPSessionClass *klass)
73 SeatClass *seat_class = SEAT_CLASS (klass);
74 GObjectClass *object_class = G_OBJECT_CLASS (klass);
76 seat_class->create_display_server = seat_xdmcp_session_create_display_server;
77 object_class->finalize = seat_xdmcp_session_finalize;
79 g_type_class_add_private (klass, sizeof (SeatXDMCPSessionPrivate));