diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2018-01-11 14:37:55 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2018-01-15 11:30:36 +1300 |
commit | 190551d461c54cfbaaf62efc308e7ac2bbd657c2 (patch) | |
tree | 5027b674b49c93d76124f53eb228881a9fe446a5 | |
parent | a3f049cf857c110d747b9fd6b57d3fe8233669c3 (diff) | |
download | lightdm-git-190551d461c54cfbaaf62efc308e7ac2bbd657c2.tar.gz |
Set names for XDMCP and VNC seats
-rw-r--r-- | src/lightdm.c | 27 | ||||
-rw-r--r-- | src/seat.c | 14 | ||||
-rw-r--r-- | src/seat.h | 4 |
3 files changed, 36 insertions, 9 deletions
diff --git a/src/lightdm.c b/src/lightdm.c index 0ad438f6..5f1af7d3 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -45,7 +45,9 @@ static gboolean debug = FALSE; static DisplayManager *display_manager = NULL; static DisplayManagerService *display_manager_service = NULL; static XDMCPServer *xdmcp_server = NULL; +static guint xdmcp_client_count = 0; static VNCServer *vnc_server = NULL; +static guint vnc_client_count = 0; static gint exit_code = EXIT_SUCCESS; static gboolean update_login1_seat (Login1Seat *login1_seat); @@ -200,12 +202,19 @@ display_manager_stopped_cb (DisplayManager *display_manager) static Seat * create_seat (const gchar *module_name, const gchar *name) { + Seat *seat; + if (strcmp (module_name, "xlocal") == 0) { g_warning ("Seat type 'xlocal' is deprecated, use 'type=local' instead"); - return seat_new ("local", name); + module_name = "local"; } - else - return seat_new (module_name, name); + + seat = seat_new (module_name); + if (!seat) + return NULL; + + seat_set_name (seat, name); + return seat; } static Seat * @@ -293,8 +302,14 @@ xdmcp_session_cb (XDMCPServer *server, XDMCPSession *session) { SeatXDMCPSession *seat; gboolean result; + gchar *name; + + name = g_strdup_printf ("xdmcp%d", xdmcp_client_count); + xdmcp_client_count++; seat = seat_xdmcp_session_new (session); + seat_set_name (SEAT (seat), name); + g_free (name); set_seat_properties (SEAT (seat), NULL); result = display_manager_add_seat (display_manager, SEAT (seat)); g_object_unref (seat); @@ -306,8 +321,14 @@ static void vnc_connection_cb (VNCServer *server, GSocket *connection) { SeatXVNC *seat; + gchar *name; + + name = g_strdup_printf ("vnc%d", vnc_client_count); + vnc_client_count++; seat = seat_xvnc_new (connection); + seat_set_name (SEAT (seat), name); + g_free (name); set_seat_properties (SEAT (seat), NULL); display_manager_add_seat (display_manager, SEAT (seat)); g_object_unref (seat); @@ -114,9 +114,8 @@ seat_register_module (const gchar *name, GType type) } Seat * -seat_new (const gchar *module_name, const gchar *name) +seat_new (const gchar *module_name) { - Seat *seat; SeatModule *m = NULL; g_return_val_if_fail (module_name != NULL, NULL); @@ -126,10 +125,15 @@ seat_new (const gchar *module_name, const gchar *name) if (!m) return NULL; - seat = g_object_new (m->type, NULL); - seat->priv->name = g_strdup (name); + return g_object_new (m->type, NULL); +} - return seat; +void +seat_set_name (Seat *seat, const gchar *name) +{ + g_return_if_fail (seat != NULL); + g_free (seat->priv->name); + seat->priv->name = g_strdup (name); } void @@ -65,7 +65,9 @@ GType seat_get_type (void); void seat_register_module (const gchar *name, GType type); -Seat *seat_new (const gchar *module_name, const gchar *name); +Seat *seat_new (const gchar *module_name); + +void seat_set_name (Seat *seat, const gchar *name); void seat_set_property (Seat *seat, const gchar *name, const gchar *value); |