Show seat in client list

transient-seats
Andri Yngvason 2023-03-25 10:33:10 +00:00
parent 75173ea838
commit 0414e1fd87
3 changed files with 12 additions and 0 deletions

View File

@ -25,6 +25,7 @@ struct ctl_server_vnc_client {
char id[64]; char id[64];
char hostname[256]; char hostname[256];
char username[256]; char username[256];
char seat[256];
}; };
struct ctl_server_output { struct ctl_server_output {

View File

@ -343,6 +343,8 @@ static struct cmd_response* generate_vnc_client_list(struct ctl* self)
if (clients[i].username[0] != '\0') if (clients[i].username[0] != '\0')
json_object_set_new(packed, "username", json_object_set_new(packed, "username",
json_string(clients[i].username)); json_string(clients[i].username));
json_object_set_new(packed, "seat",
json_string(clients[i].seat));
json_array_append_new(response->data, packed); json_array_append_new(response->data, packed);
} }
free(clients); free(clients);

View File

@ -515,24 +515,33 @@ static int get_client_list(struct ctl* ctl,
*clients = NULL; *clients = NULL;
return 0; return 0;
} }
*clients = calloc(self->nr_clients, sizeof(**clients)); *clients = calloc(self->nr_clients, sizeof(**clients));
struct nvnc_client* nvnc_client = nvnc_client_first(self->nvnc); struct nvnc_client* nvnc_client = nvnc_client_first(self->nvnc);
for (int i = 0; i < self->nr_clients && nvnc_client; ++i) { for (int i = 0; i < self->nr_clients && nvnc_client; ++i) {
struct wayvnc_client* client = nvnc_get_userdata(nvnc_client); struct wayvnc_client* client = nvnc_get_userdata(nvnc_client);
struct ctl_server_vnc_client* ctl_client =&(*clients)[i]; struct ctl_server_vnc_client* ctl_client =&(*clients)[i];
snprintf(ctl_client->id, sizeof(ctl_client->id), "%u", snprintf(ctl_client->id, sizeof(ctl_client->id), "%u",
client->id); client->id);
const char* hostname = nvnc_client_get_hostname(nvnc_client); const char* hostname = nvnc_client_get_hostname(nvnc_client);
if (hostname) if (hostname)
strlcpy(ctl_client->hostname, hostname, strlcpy(ctl_client->hostname, hostname,
sizeof(ctl_client->hostname)); sizeof(ctl_client->hostname));
const char* username = nvnc_client_get_auth_username(nvnc_client); const char* username = nvnc_client_get_auth_username(nvnc_client);
if (username) if (username)
strlcpy(ctl_client->username, username, strlcpy(ctl_client->username, username,
sizeof(ctl_client->username)); sizeof(ctl_client->username));
strlcpy(ctl_client->seat, client->seat->name,
sizeof(ctl_client->seat));
nvnc_client = nvnc_client_next(nvnc_client); nvnc_client = nvnc_client_next(nvnc_client);
} }
return self->nr_clients; return self->nr_clients;
} }