]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - src/seat-unity.c
Launchpad automatic translations update.
[sojka/lightdm.git] / src / seat-unity.c
1 /*
2  * Copyright (C) 2012-2013 Robert Ancell.
3  * Author: Robert Ancell <robert.ancell@canonical.com>
4  *
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
9  * license.
10  */
11
12 #include <string.h>
13 #include <fcntl.h>
14 #include <errno.h>
15 #include <glib/gstdio.h>
16
17 #include "seat-unity.h"
18 #include "configuration.h"
19 #include "x-server-local.h"
20 #include "mir-server.h"
21 #include "vt.h"
22 #include "plymouth.h"
23
24 typedef enum
25 {
26    USC_MESSAGE_PING = 0,
27    USC_MESSAGE_PONG = 1,
28    USC_MESSAGE_READY = 2,
29    USC_MESSAGE_SESSION_CONNECTED = 3,
30    USC_MESSAGE_SET_ACTIVE_SESSION = 4
31 } USCMessageID;
32
33 struct SeatUnityPrivate
34 {
35     /* VT we are running on */
36     gint vt;
37
38     /* File to log to */
39     gchar *log_file;
40
41     /* Filename of Mir socket */
42     gchar *mir_socket_filename;
43
44     /* Pipes to communicate with compositor */
45     int to_compositor_pipe[2];
46     int from_compositor_pipe[2];
47
48     /* IO channel listening on for messages from the compositor */
49     GIOChannel *from_compositor_channel;
50
51     /* TRUE when the compositor indicates it is ready */
52     gboolean compositor_ready;
53
54     /* Buffer reading from channel */
55     guint8 *read_buffer;
56     gsize read_buffer_length;
57     gsize read_buffer_n_used;
58
59     /* Compositor process */
60     Process *compositor_process;
61
62     /* Timeout when waiting for compositor to start */
63     guint compositor_timeout;
64
65     /* Next Mir ID to use for a compositor client */
66     gint next_id;
67
68     /* TRUE if using VT switching fallback */
69     gboolean use_vt_switching;
70
71     /* The currently visible session */
72     Session *active_session;
73     DisplayServer *active_display_server;
74 };
75
76 G_DEFINE_TYPE (SeatUnity, seat_unity, SEAT_TYPE);
77
78 static gboolean
79 seat_unity_get_start_local_sessions (Seat *seat)
80 {
81     return !seat_get_string_property (seat, "xdmcp-manager");
82 }
83
84 static void
85 seat_unity_setup (Seat *seat)
86 {
87     seat_set_can_switch (seat, TRUE);
88     SEAT_CLASS (seat_unity_parent_class)->setup (seat);
89 }
90
91 static void
92 compositor_stopped_cb (Process *process, SeatUnity *seat)
93 {
94     if (seat->priv->compositor_timeout != 0)
95         g_source_remove (seat->priv->compositor_timeout);
96     seat->priv->compositor_timeout = 0;
97
98     /* Finished with the VT */
99     vt_unref (seat->priv->vt);
100     seat->priv->vt = -1;
101
102     if (seat_get_is_stopping (SEAT (seat)))
103     {
104         SEAT_CLASS (seat_unity_parent_class)->stop (SEAT (seat));
105         return;
106     }
107
108     /* If stopped before it was ready, then revert to VT mode */
109     if (!seat->priv->compositor_ready)
110     {
111         l_debug (seat, "Compositor failed to start, switching to VT mode");
112         seat->priv->use_vt_switching = TRUE;
113         SEAT_CLASS (seat_unity_parent_class)->start (SEAT (seat));
114         return;
115     }
116
117     l_debug (seat, "Stopping Unity seat, compositor terminated");
118
119     seat_stop (SEAT (seat));
120 }
121
122 static void
123 compositor_run_cb (Process *process, SeatUnity *seat)
124 {
125     int fd;
126
127     /* Make input non-blocking */
128     fd = open ("/dev/null", O_RDONLY);
129     dup2 (fd, STDIN_FILENO);
130     close (fd);
131
132     /* Redirect output to logfile */
133     if (seat->priv->log_file)
134     {
135          int fd;
136          gchar *old_filename;
137
138          /* Move old file out of the way */
139          old_filename = g_strdup_printf ("%s.old", seat->priv->log_file);
140          rename (seat->priv->log_file, old_filename);
141          g_free (old_filename);
142
143          /* Create new file and log to it */
144          fd = g_open (seat->priv->log_file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
145          if (fd < 0)
146              l_warning (seat, "Failed to open log file %s: %s", seat->priv->log_file, g_strerror (errno));
147          else
148          {
149              dup2 (fd, STDOUT_FILENO);
150              dup2 (fd, STDERR_FILENO);
151              close (fd);
152          }
153     }
154 }
155
156 static void
157 write_message (SeatUnity *seat, guint16 id, const guint8 *payload, guint16 payload_length)
158 {
159     guint8 *data;
160     gsize data_length = 4 + payload_length;
161
162     data = g_malloc (data_length);
163     data[0] = id >> 8;
164     data[1] = id & 0xFF;
165     data[2] = payload_length >> 8;
166     data[3] = payload_length & 0xFF;
167     memcpy (data + 4, payload, payload_length);
168
169     errno = 0;
170     if (write (seat->priv->to_compositor_pipe[1], data, data_length) != data_length)
171         l_warning (seat, "Failed to write to compositor: %s", strerror (errno));
172 }
173
174 static gboolean
175 read_cb (GIOChannel *source, GIOCondition condition, gpointer data)
176 {
177     SeatUnity *seat = data;
178     gsize n_to_read = 0;
179     guint16 id, payload_length;
180     /*guint8 *payload;*/
181   
182     if (condition == G_IO_HUP)
183     {
184         l_debug (seat, "Compositor closed communication channel");
185         return FALSE;
186     }
187
188     /* Work out how much required for a message */
189     if (seat->priv->read_buffer_n_used < 4)
190         n_to_read = 4 - seat->priv->read_buffer_n_used;
191     else
192     {
193         payload_length = seat->priv->read_buffer[2] << 8 | seat->priv->read_buffer[3];
194         n_to_read = 4 + payload_length - seat->priv->read_buffer_n_used;
195     }
196
197     /* Read from compositor */
198     if (n_to_read > 0)
199     {
200         gsize n_total, n_read = 0;
201         GIOStatus status;
202         GError *error = NULL;
203
204         n_total = seat->priv->read_buffer_n_used + n_to_read;
205         if (seat->priv->read_buffer_length < n_total)
206             seat->priv->read_buffer = g_realloc (seat->priv->read_buffer, n_total);
207
208         status = g_io_channel_read_chars (source,
209                                           (gchar *)seat->priv->read_buffer + seat->priv->read_buffer_n_used,
210                                           n_to_read,
211                                           &n_read,
212                                           &error);
213         if (error)
214             l_warning (seat, "Failed to read from compositor: %s", error->message);
215         if (status != G_IO_STATUS_NORMAL)
216             return TRUE;
217         g_clear_error (&error);
218         seat->priv->read_buffer_n_used += n_read;
219     }
220
221     /* Read header */
222     if (seat->priv->read_buffer_n_used < 4)
223          return TRUE;
224     id = seat->priv->read_buffer[0] << 8 | seat->priv->read_buffer[1];
225     payload_length = seat->priv->read_buffer[2] << 8 | seat->priv->read_buffer[3];
226
227     /* Read payload */
228     if (seat->priv->read_buffer_n_used < 4 + payload_length)
229         return TRUE;
230     /*payload = seat->priv->read_buffer + 4;*/
231
232     switch (id)
233     {
234     case USC_MESSAGE_PING:
235         l_debug (seat, "PING!");
236         write_message (seat, USC_MESSAGE_PONG, NULL, 0);
237         break;
238     case USC_MESSAGE_PONG:
239         l_debug (seat, "PONG!");
240         break;
241     case USC_MESSAGE_READY:
242         l_debug (seat, "READY");
243         if (!seat->priv->compositor_ready)
244         {
245             seat->priv->compositor_ready = TRUE;
246             l_debug (seat, "Compositor ready");
247             g_source_remove (seat->priv->compositor_timeout);
248             seat->priv->compositor_timeout = 0;
249             SEAT_CLASS (seat_unity_parent_class)->start (SEAT (seat));
250         }
251         break;
252     case USC_MESSAGE_SESSION_CONNECTED:
253         l_debug (seat, "SESSION CONNECTED");
254         break;
255     default:
256         l_warning (seat, "Ignoring unknown message %d with %d octets from system compositor", id, payload_length);
257         break;
258     }
259
260     /* Clear buffer */
261     seat->priv->read_buffer_n_used = 0;
262
263     return TRUE;
264 }
265
266 static gchar *
267 get_absolute_command (const gchar *command)
268 {
269     gchar **tokens;
270     gchar *absolute_binary, *absolute_command = NULL;
271
272     tokens = g_strsplit (command, " ", 2);
273
274     absolute_binary = g_find_program_in_path (tokens[0]);
275     if (absolute_binary)
276     {
277         if (tokens[1])
278             absolute_command = g_strjoin (" ", absolute_binary, tokens[1], NULL);
279         else
280             absolute_command = g_strdup (absolute_binary);
281         g_free (absolute_binary);
282     }
283     else
284         absolute_command = g_strdup (command);
285
286     g_strfreev (tokens);
287
288     return absolute_command;
289 }
290
291 static gboolean
292 compositor_timeout_cb (gpointer data)
293 {
294     SeatUnity *seat = data;
295
296     /* Stop the compositor - it is not working */
297     process_stop (seat->priv->compositor_process);
298
299     return TRUE;
300 }
301
302 static gboolean
303 seat_unity_start (Seat *seat)
304 {
305     const gchar *compositor_command;
306     gchar *command, *absolute_command, *dir;
307     gboolean result;
308     int timeout;
309
310     /* Replace Plymouth if it is running */
311     if (plymouth_get_is_active () && plymouth_has_active_vt ())
312     {
313         gint active_vt = vt_get_active ();
314         if (active_vt >= vt_get_min ())
315         {
316             SEAT_UNITY (seat)->priv->vt = active_vt;
317             plymouth_quit (TRUE);
318         }
319         else
320             l_debug (seat, "Plymouth is running on VT %d, but this is less than the configured minimum of %d so not replacing it", active_vt, vt_get_min ());
321     }
322     if (plymouth_get_is_active ())
323         plymouth_quit (FALSE);
324     if (SEAT_UNITY (seat)->priv->vt < 0)
325         SEAT_UNITY (seat)->priv->vt = vt_get_unused ();
326     if (SEAT_UNITY (seat)->priv->vt < 0)
327     {
328         l_debug (seat, "Failed to get a VT to run on");
329         return FALSE;
330     }
331     vt_ref (SEAT_UNITY (seat)->priv->vt);
332
333     /* Create pipes to talk to compositor */
334     if (pipe (SEAT_UNITY (seat)->priv->to_compositor_pipe) < 0 || pipe (SEAT_UNITY (seat)->priv->from_compositor_pipe) < 0)
335     {
336         l_debug (seat, "Failed to create compositor pipes: %s", g_strerror (errno));
337         return FALSE;
338     }
339
340     /* Don't allow the daemon end of the pipes to be accessed in the compositor */
341     fcntl (SEAT_UNITY (seat)->priv->to_compositor_pipe[1], F_SETFD, FD_CLOEXEC);
342     fcntl (SEAT_UNITY (seat)->priv->from_compositor_pipe[0], F_SETFD, FD_CLOEXEC);
343
344     /* Listen for messages from the compositor */
345     SEAT_UNITY (seat)->priv->from_compositor_channel = g_io_channel_unix_new (SEAT_UNITY (seat)->priv->from_compositor_pipe[0]);
346     g_io_add_watch (SEAT_UNITY (seat)->priv->from_compositor_channel, G_IO_IN | G_IO_HUP, read_cb, seat);
347
348     /* Setup logging */
349     dir = config_get_string (config_get_instance (), "LightDM", "log-directory");
350     SEAT_UNITY (seat)->priv->log_file = g_build_filename (dir, "unity-system-compositor.log", NULL);
351     l_debug (seat, "Logging to %s", SEAT_UNITY (seat)->priv->log_file);
352     g_free (dir);
353
354     SEAT_UNITY (seat)->priv->mir_socket_filename = g_strdup ("/tmp/mir_socket"); // FIXME: Use this socket by default as XMir is hardcoded to this
355     timeout = seat_get_integer_property (seat, "unity-compositor-timeout");
356     compositor_command = seat_get_string_property (seat, "unity-compositor-command");
357     command = g_strdup_printf ("%s --from-dm-fd %d --to-dm-fd %d --vt %d", compositor_command, SEAT_UNITY (seat)->priv->to_compositor_pipe[0], SEAT_UNITY (seat)->priv->from_compositor_pipe[1], SEAT_UNITY (seat)->priv->vt);
358
359     absolute_command = get_absolute_command (command);
360     g_free (command);
361
362     /* Start the compositor */
363     process_set_command (SEAT_UNITY (seat)->priv->compositor_process, absolute_command);
364     g_free (absolute_command);
365     g_signal_connect (SEAT_UNITY (seat)->priv->compositor_process, "stopped", G_CALLBACK (compositor_stopped_cb), seat);
366     g_signal_connect (SEAT_UNITY (seat)->priv->compositor_process, "run", G_CALLBACK (compositor_run_cb), seat);
367     result = process_start (SEAT_UNITY (seat)->priv->compositor_process, FALSE);
368
369     /* Close compostor ends of the pipes */
370     close (SEAT_UNITY (seat)->priv->to_compositor_pipe[0]);
371     SEAT_UNITY (seat)->priv->to_compositor_pipe[0] = 0;
372     close (SEAT_UNITY (seat)->priv->from_compositor_pipe[1]);
373     SEAT_UNITY (seat)->priv->from_compositor_pipe[1] = 0;
374
375     if (!result)
376         return FALSE;
377
378     /* Connect to the compositor */
379     timeout = seat_get_integer_property (seat, "unity-compositor-timeout");
380     if (timeout <= 0)
381         timeout = 60;
382     l_debug (seat, "Waiting for system compositor for %ds", timeout);
383     SEAT_UNITY (seat)->priv->compositor_timeout = g_timeout_add (timeout * 1000, compositor_timeout_cb, seat);
384
385     return TRUE;
386 }
387
388 static DisplayServer *
389 create_x_server (Seat *seat)
390 {
391     XServerLocal *x_server;
392     const gchar *command = NULL, *layout = NULL, *config_file = NULL, *xdmcp_manager = NULL, *key_name = NULL;
393     gboolean allow_tcp;
394     gint port = 0;
395
396     l_debug (seat, "Starting X server on Unity compositor");
397
398     x_server = x_server_local_new ();
399
400     command = seat_get_string_property (seat, "xserver-command");
401     if (command)
402         x_server_local_set_command (x_server, command);
403
404     if (SEAT_UNITY (seat)->priv->use_vt_switching)
405         x_server_local_set_vt (x_server, vt_get_unused ());
406     else
407     {
408         gchar *id;
409
410         id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id);
411         SEAT_UNITY (seat)->priv->next_id++;
412         x_server_local_set_mir_id (x_server, id);
413         x_server_local_set_mir_socket (x_server, SEAT_UNITY (seat)->priv->mir_socket_filename);
414         g_free (id);
415     }
416
417     layout = seat_get_string_property (seat, "xserver-layout");
418     if (layout)
419         x_server_local_set_layout (x_server, layout);
420
421     config_file = seat_get_string_property (seat, "xserver-config");
422     if (config_file)
423         x_server_local_set_config (x_server, config_file);
424
425     allow_tcp = seat_get_boolean_property (seat, "xserver-allow-tcp");
426     x_server_local_set_allow_tcp (x_server, allow_tcp);
427
428     xdmcp_manager = seat_get_string_property (seat, "xdmcp-manager");
429     if (xdmcp_manager)
430         x_server_local_set_xdmcp_server (x_server, xdmcp_manager);
431
432     port = seat_get_integer_property (seat, "xdmcp-port");
433     if (port > 0)
434         x_server_local_set_xdmcp_port (x_server, port);
435
436     key_name = seat_get_string_property (seat, "xdmcp-key");
437     if (key_name)
438     {
439         gchar *dir, *path;
440         GKeyFile *keys;
441         gboolean result;
442         GError *error = NULL;
443
444         dir = config_get_string (config_get_instance (), "LightDM", "config-directory");
445         path = g_build_filename (dir, "keys.conf", NULL);
446         g_free (dir);
447
448         keys = g_key_file_new ();
449         result = g_key_file_load_from_file (keys, path, G_KEY_FILE_NONE, &error);
450         if (error)
451             l_debug (seat, "Error getting key %s", error->message);
452         g_clear_error (&error);
453
454         if (result)
455         {
456             gchar *key = NULL;
457
458             if (g_key_file_has_key (keys, "keyring", key_name, NULL))
459                 key = g_key_file_get_string (keys, "keyring", key_name, NULL);
460             else
461                 l_debug (seat, "Key %s not defined", key_name);
462
463             if (key)
464                 x_server_local_set_xdmcp_key (x_server, key);
465             g_free (key);
466         }
467
468         g_free (path);
469         g_key_file_free (keys);
470     }
471
472     return DISPLAY_SERVER (x_server);
473 }
474
475 static DisplayServer *
476 create_mir_server (Seat *seat)
477 {
478     MirServer *mir_server;
479
480     mir_server = mir_server_new ();
481     mir_server_set_parent_socket (mir_server, SEAT_UNITY (seat)->priv->mir_socket_filename);
482
483     if (SEAT_UNITY (seat)->priv->use_vt_switching)
484         mir_server_set_vt (mir_server, vt_get_unused ());
485     else
486     {
487         gchar *id;
488
489         id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id);
490         SEAT_UNITY (seat)->priv->next_id++;
491         mir_server_set_id (mir_server, id);
492         mir_server_set_parent_socket (mir_server, SEAT_UNITY (seat)->priv->mir_socket_filename);
493         g_free (id);
494     }   
495
496     return DISPLAY_SERVER (mir_server);
497 }
498
499 static DisplayServer *
500 seat_unity_create_display_server (Seat *seat, const gchar *session_type)
501 {  
502     if (strcmp (session_type, "x") == 0)
503         return create_x_server (seat);
504     else if (strcmp (session_type, "mir") == 0)
505         return create_mir_server (seat);
506     else
507     {
508         l_warning (seat, "Can't create unsupported display server '%s'", session_type);
509         return NULL;
510     }
511 }
512
513 static Greeter *
514 seat_unity_create_greeter_session (Seat *seat)
515 {
516     Greeter *greeter_session;
517     const gchar *xdg_seat;
518
519     greeter_session = SEAT_CLASS (seat_unity_parent_class)->create_greeter_session (seat);
520     xdg_seat = "seat0";
521     l_debug (seat, "Setting XDG_SEAT=%s", xdg_seat);
522     session_set_env (SESSION (greeter_session), "XDG_SEAT", xdg_seat);
523     if (!SEAT_UNITY (seat)->priv->use_vt_switching)
524     {
525         gchar *value = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->vt);
526         l_debug (seat, "Setting XDG_VTNR=%s", value);
527         session_set_env (SESSION (greeter_session), "XDG_VTNR", value);
528         g_free (value);
529     }
530     else
531         l_debug (seat, "Not setting XDG_VTNR");
532
533     return greeter_session;
534 }
535
536 static Session *
537 seat_unity_create_session (Seat *seat)
538 {
539     Session *session;
540     const gchar *xdg_seat;
541
542     session = SEAT_CLASS (seat_unity_parent_class)->create_session (seat);
543     xdg_seat = "seat0";
544     l_debug (seat, "Setting XDG_SEAT=%s", xdg_seat);
545     session_set_env (session, "XDG_SEAT", xdg_seat);
546     if (!SEAT_UNITY (seat)->priv->use_vt_switching)
547     {
548         gchar *value = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->vt);
549         l_debug (seat, "Setting XDG_VTNR=%s", value);
550         session_set_env (SESSION (session), "XDG_VTNR", value);
551         g_free (value);
552     }
553     else
554         l_debug (seat, "Not setting XDG_VTNR");
555
556     return session;
557 }
558
559 static void
560 seat_unity_set_active_session (Seat *seat, Session *session)
561 {
562     DisplayServer *display_server;
563
564     /* If no compositor, have to use VT switching */
565     if (SEAT_UNITY (seat)->priv->use_vt_switching)
566     {
567         gint vt = display_server_get_vt (session_get_display_server (session));
568         if (vt >= 0)
569             vt_set_active (vt);
570
571         SEAT_CLASS (seat_unity_parent_class)->set_active_session (seat, session);
572         return;
573     }
574
575     if (session == SEAT_UNITY (seat)->priv->active_session)
576         return;
577     SEAT_UNITY (seat)->priv->active_session = g_object_ref (session);
578
579     display_server = session_get_display_server (session);
580     if (SEAT_UNITY (seat)->priv->active_display_server != display_server)
581     {
582         const gchar *id = NULL;
583
584         SEAT_UNITY (seat)->priv->active_display_server = g_object_ref (display_server);
585
586         if (IS_X_SERVER_LOCAL (display_server))
587             id = x_server_local_get_mir_id (X_SERVER_LOCAL (display_server));
588         else if (IS_MIR_SERVER (display_server))
589             id = mir_server_get_id (MIR_SERVER (display_server));
590
591         if (id)
592         {
593             l_debug (seat, "Switching to Mir session %s", id);
594             write_message (SEAT_UNITY (seat), USC_MESSAGE_SET_ACTIVE_SESSION, (const guint8 *) id, strlen (id));
595         }
596         else
597             l_warning (seat, "Failed to work out session ID");
598     }
599
600     SEAT_CLASS (seat_unity_parent_class)->set_active_session (seat, session);
601 }
602
603 static Session *
604 seat_unity_get_active_session (Seat *seat)
605 {
606     if (SEAT_UNITY (seat)->priv->use_vt_switching)
607     {
608         gint vt;
609         GList *link;
610         vt = vt_get_active ();
611         if (vt < 0)
612             return NULL;
613
614         for (link = seat_get_sessions (seat); link; link = link->next)
615         {
616             Session *session = link->data;
617             if (display_server_get_vt (session_get_display_server (session)) == vt)
618                 return session;
619         }
620
621         return NULL;
622     }
623
624     return SEAT_UNITY (seat)->priv->active_session;
625 }
626
627 static void
628 seat_unity_run_script (Seat *seat, DisplayServer *display_server, Process *script)
629 {
630     const gchar *path;
631     XServerLocal *x_server;
632
633     x_server = X_SERVER_LOCAL (display_server);
634     path = x_server_local_get_authority_file_path (x_server);
635     process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
636     process_set_env (script, "XAUTHORITY", path);
637
638     SEAT_CLASS (seat_unity_parent_class)->run_script (seat, display_server, script);
639 }
640
641 static void
642 seat_unity_stop (Seat *seat)
643 {
644     /* Stop the compositor first */
645     if (process_get_is_running (SEAT_UNITY (seat)->priv->compositor_process))
646     {
647         process_stop (SEAT_UNITY (seat)->priv->compositor_process);
648         return;
649     }
650
651     SEAT_CLASS (seat_unity_parent_class)->stop (seat);
652 }
653
654 static void
655 seat_unity_init (SeatUnity *seat)
656 {
657     seat->priv = G_TYPE_INSTANCE_GET_PRIVATE (seat, SEAT_UNITY_TYPE, SeatUnityPrivate);
658     seat->priv->vt = -1;
659     seat->priv->compositor_process = process_new ();
660 }
661
662 static void
663 seat_unity_finalize (GObject *object)
664 {
665     SeatUnity *seat = SEAT_UNITY (object);
666
667     if (seat->priv->vt >= 0)
668         vt_unref (seat->priv->vt);
669     g_free (seat->priv->log_file);
670     g_free (seat->priv->mir_socket_filename);
671     close (seat->priv->to_compositor_pipe[0]);
672     close (seat->priv->to_compositor_pipe[1]);
673     close (seat->priv->from_compositor_pipe[0]);
674     close (seat->priv->from_compositor_pipe[1]);
675     g_io_channel_unref (seat->priv->from_compositor_channel);
676     g_free (seat->priv->read_buffer);
677     g_object_unref (seat->priv->compositor_process);
678     if (seat->priv->active_session)
679         g_object_unref (seat->priv->active_session);
680     if (seat->priv->active_display_server)
681         g_object_unref (seat->priv->active_display_server);
682
683     G_OBJECT_CLASS (seat_unity_parent_class)->finalize (object);
684 }
685
686 static void
687 seat_unity_class_init (SeatUnityClass *klass)
688 {
689     GObjectClass *object_class = G_OBJECT_CLASS (klass);
690     SeatClass *seat_class = SEAT_CLASS (klass);
691
692     object_class->finalize = seat_unity_finalize;
693     seat_class->get_start_local_sessions = seat_unity_get_start_local_sessions;
694     seat_class->setup = seat_unity_setup;
695     seat_class->start = seat_unity_start;
696     seat_class->create_display_server = seat_unity_create_display_server;
697     seat_class->create_greeter_session = seat_unity_create_greeter_session;
698     seat_class->create_session = seat_unity_create_session;
699     seat_class->set_active_session = seat_unity_set_active_session;
700     seat_class->get_active_session = seat_unity_get_active_session;
701     seat_class->run_script = seat_unity_run_script;
702     seat_class->stop = seat_unity_stop;
703
704     g_type_class_add_private (klass, sizeof (SeatUnityPrivate));
705 }