summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2018-01-11 14:37:55 +1300
committerRobert Ancell <robert.ancell@canonical.com>2018-01-15 13:36:47 +1300
commit7c0ccdb836965d1610e4276cef275ab37ac5d6c4 (patch)
treec55c85a233f998a4e2dc82ccc48083400d06bef6
parent558cd2782496d5e7e727b015b29a7ba44b0c9c2a (diff)
downloadlightdm-git-7c0ccdb836965d1610e4276cef275ab37ac5d6c4.tar.gz
Set names for XDMCP and VNC seats
-rw-r--r--src/lightdm.c35
-rw-r--r--src/seat.c14
-rw-r--r--src/seat.h4
3 files changed, 43 insertions, 10 deletions
diff --git a/src/lightdm.c b/src/lightdm.c
index 610c5aee..d15a86fb 100644
--- a/src/lightdm.c
+++ b/src/lightdm.c
@@ -43,7 +43,9 @@ static gboolean debug = FALSE;
static DisplayManager *display_manager = NULL;
static XDMCPServer *xdmcp_server = NULL;
+static guint xdmcp_client_count = 0;
static VNCServer *vnc_server = NULL;
+static guint vnc_client_count = 0;
static guint bus_id = 0;
static GDBusConnection *bus = NULL;
static guint reg_id = 0;
@@ -218,6 +220,19 @@ display_manager_stopped_cb (DisplayManager *display_manager)
g_main_loop_quit (loop);
}
+static Seat *
+create_seat (const gchar *module_name, const gchar *name)
+{
+ Seat *seat;
+
+ seat = seat_new (module_name);
+ if (!seat)
+ return NULL;
+
+ seat_set_name (seat, name);
+ return seat;
+}
+
static void
display_manager_seat_removed_cb (DisplayManager *display_manager, Seat *seat)
{
@@ -237,7 +252,7 @@ display_manager_seat_removed_cb (DisplayManager *display_manager, Seat *seat)
if (!next_seat)
{
- next_seat = seat_new (*iter, seat_get_name (seat));
+ next_seat = create_seat (*iter, seat_get_name (seat));
g_string_assign (next_types, *iter);
}
else
@@ -354,7 +369,7 @@ handle_display_manager_call (GDBusConnection *connection,
g_debug ("Adding local X seat :%d", display_number);
- seat = seat_new ("xremote", "xremote0"); // FIXME: What to use for a name?
+ seat = create_seat ("xremote", "xremote0"); // FIXME: What to use for a name?
if (seat)
{
gchar *display_number_string;
@@ -761,8 +776,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);
@@ -774,8 +795,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);
@@ -1020,7 +1047,7 @@ add_login1_seat (Login1Seat *login1_seat)
g_list_free_full (config_sections, g_free);
for (type = types; !seat && type && *type; type++)
- seat = seat_new (*type, seat_name);
+ seat = create_seat (*type, seat_name);
g_strfreev (types);
if (seat)
@@ -1538,7 +1565,7 @@ main (int argc, char **argv)
types = config_get_string_list (config_get_instance (), "Seat:*", "type");
for (type = types; type && *type; type++)
{
- seat = seat_new (*type, "seat0");
+ seat = create_seat (*type, "seat0");
if (seat)
break;
}
diff --git a/src/seat.c b/src/seat.c
index eb40ef52..d4a46319 100644
--- a/src/seat.c
+++ b/src/seat.c
@@ -106,9 +106,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);
@@ -118,10 +117,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
diff --git a/src/seat.h b/src/seat.h
index 3c5b3ee9..8f6fb1b9 100644
--- a/src/seat.h
+++ b/src/seat.h
@@ -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);