Back to index

lightdm  1.3.2
seat-xremote.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-xremote.h"
00015 #include "configuration.h"
00016 #include "xserver-remote.h"
00017 #include "xsession.h"
00018 
00019 G_DEFINE_TYPE (SeatXRemote, seat_xremote, SEAT_TYPE);
00020 
00021 static void
00022 seat_xremote_setup (Seat *seat)
00023 {
00024     seat_set_can_switch (seat, FALSE);
00025     SEAT_CLASS (seat_xremote_parent_class)->setup (seat);
00026 }
00027 
00028 static DisplayServer *
00029 seat_xremote_create_display_server (Seat *seat)
00030 {
00031     XServerRemote *xserver;
00032     const gchar *hostname;
00033     gint number;
00034 
00035     hostname = seat_get_string_property (seat, "xserver-hostname");
00036     if (!hostname)
00037         hostname = "localhost";
00038     number = seat_get_integer_property (seat, "xserver-display-number");
00039 
00040     g_debug ("Starting remote X display %s:%d", hostname, number);
00041 
00042     xserver = xserver_remote_new (hostname, number, NULL);
00043 
00044     return DISPLAY_SERVER (xserver);
00045 }
00046 
00047 static Session *
00048 seat_xremote_create_session (Seat *seat, Display *display)
00049 {
00050     XServerRemote *xserver;
00051     XSession *session;
00052 
00053     xserver = XSERVER_REMOTE (display_get_display_server (display));
00054 
00055     session = xsession_new (XSERVER (xserver));
00056     session_set_remote_host_name (SESSION (session), xserver_get_hostname (XSERVER (xserver)));
00057 
00058     return SESSION (session);
00059 }
00060 
00061 static void
00062 seat_xremote_run_script (Seat *seat, Display *display, Process *script)
00063 {
00064     XServerRemote *xserver;
00065 
00066     xserver = XSERVER_REMOTE (display_get_display_server (display));
00067     process_set_env (script, "DISPLAY", xserver_get_address (XSERVER (xserver)));  
00068     process_set_env (script, "REMOTE_HOST", xserver_get_hostname (XSERVER (xserver)));
00069 
00070     SEAT_CLASS (seat_xremote_parent_class)->run_script (seat, display, script);
00071 }
00072 
00073 static void
00074 seat_xremote_display_removed (Seat *seat, Display *display)
00075 {
00076     /* Can't restart the display, so remove this seat */
00077     seat_stop (seat);
00078 }
00079 
00080 static void
00081 seat_xremote_init (SeatXRemote *seat)
00082 {
00083 }
00084 
00085 static void
00086 seat_xremote_class_init (SeatXRemoteClass *klass)
00087 {
00088     SeatClass *seat_class = SEAT_CLASS (klass);
00089 
00090     seat_class->setup = seat_xremote_setup;
00091     seat_class->create_display_server = seat_xremote_create_display_server;
00092     seat_class->create_session = seat_xremote_create_session;
00093     seat_class->run_script = seat_xremote_run_script;
00094     seat_class->display_removed = seat_xremote_display_removed;
00095 }