]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blobdiff - src/seat-xvnc.c
Releasing 1.20.0
[sojka/lightdm.git] / src / seat-xvnc.c
index 2f4ecf7500fd4042e558dfbfe13723971a695664..6026859e8582a5f3372c4cc59b7b63b73b5f908e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2010-2011 Robert Ancell.
  * Author: Robert Ancell <robert.ancell@canonical.com>
- * 
+ *
  * This program is free software: you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
  * Foundation, either version 3 of the License, or (at your option) any later
@@ -34,23 +34,27 @@ SeatXVNC *seat_xvnc_new (GSocket *connection)
 }
 
 static DisplayServer *
-seat_xvnc_create_display_server (Seat *seat, const gchar *session_type)
+seat_xvnc_create_display_server (Seat *seat, Session *session)
 {
     XServerXVNC *x_server;
+    gchar *number;
+    XAuthority *cookie;
     const gchar *command = NULL;
 
-    if (strcmp (session_type, "x") != 0)
-    {
-        g_warning ("XVNC seat only supports X display servers, not '%s'", session_type);
+    if (strcmp (session_get_session_type (session), "x") != 0)
         return NULL;
-    }
-  
+
     x_server = x_server_xvnc_new ();
+    number = g_strdup_printf ("%d", x_server_get_display_number (X_SERVER (x_server)));
+    cookie = x_authority_new_local_cookie (number);
+    x_server_set_authority (X_SERVER (x_server), cookie);
+    g_free (number);
+    g_object_unref (cookie);
     x_server_xvnc_set_socket (x_server, g_socket_get_fd (SEAT_XVNC (seat)->priv->connection));
 
     command = config_get_string (config_get_instance (), "VNCServer", "command");
     if (command)
-        x_server_xvnc_set_command (x_server, command);
+        x_server_local_set_command (X_SERVER_LOCAL (x_server), command);
 
     if (config_has_key (config_get_instance (), "VNCServer", "width") &&
         config_has_key (config_get_instance (), "VNCServer", "height"))
@@ -84,7 +88,7 @@ seat_xvnc_run_script (Seat *seat, DisplayServer *display_server, Process *script
 
     address = G_INET_SOCKET_ADDRESS (g_socket_get_remote_address (SEAT_XVNC (seat)->priv->connection, NULL));
     hostname = g_inet_address_to_string (g_inet_socket_address_get_address (address));
-    path = x_server_xvnc_get_authority_file_path (x_server);
+    path = x_server_local_get_authority_file_path (X_SERVER_LOCAL (x_server));
 
     process_set_env (script, "REMOTE_HOST", hostname);
     process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
@@ -102,13 +106,11 @@ seat_xvnc_init (SeatXVNC *seat)
 }
 
 static void
-seat_xdmcp_session_finalize (GObject *object)
+seat_xvnc_session_finalize (GObject *object)
 {
-    SeatXVNC *self;
-
-    self = SEAT_XVNC (object);
+    SeatXVNC *self = SEAT_XVNC (object);
 
-    g_object_unref (self->priv->connection);
+    g_clear_object (&self->priv->connection);
 
     G_OBJECT_CLASS (seat_xvnc_parent_class)->finalize (object);
 }
@@ -121,7 +123,7 @@ seat_xvnc_class_init (SeatXVNCClass *klass)
 
     seat_class->create_display_server = seat_xvnc_create_display_server;
     seat_class->run_script = seat_xvnc_run_script;
-    object_class->finalize = seat_xdmcp_session_finalize;
+    object_class->finalize = seat_xvnc_session_finalize;
 
     g_type_class_add_private (klass, sizeof (SeatXVNCPrivate));
 }