Add seat name to client-connected event

transient-seats
Andri Yngvason 2023-03-25 13:22:51 +00:00
parent c302c20939
commit b927394490
3 changed files with 37 additions and 40 deletions

View File

@ -70,15 +70,11 @@ struct cmd_response* cmd_ok(void);
struct cmd_response* cmd_failed(const char* fmt, ...);
void ctl_server_event_connected(struct ctl*,
const char* client_id,
const char* client_hostname,
const char* client_username,
const struct ctl_server_client_info *info,
int new_connection_count);
void ctl_server_event_disconnected(struct ctl*,
const char* client_id,
const char* client_hostname,
const char* client_username,
const struct ctl_server_client_info *info,
int new_connection_count);
void ctl_server_event_capture_changed(struct ctl*,

View File

@ -856,15 +856,18 @@ struct cmd_response* cmd_failed(const char* fmt, ...)
}
json_t* pack_connection_event_params(
const char* client_id,
const char* client_hostname,
const char* client_username,
const struct ctl_server_client_info *info,
int new_connection_count)
{
return json_pack("{s:s, s:s?, s:s?, s:i}",
"id", client_id,
"hostname", client_hostname,
"username", client_username,
// TODO: Why is the id a string?
char id_str[64];
snprintf(id_str, sizeof(id_str), "%d", info->id);
return json_pack("{s:s, s:s?, s:s?, s:s?, s:i}",
"id", id_str,
"hostname", info->hostname,
"username", info->username,
"seat", info->seat,
"connection_count", new_connection_count);
}
@ -906,34 +909,28 @@ int ctl_server_enqueue_event(struct ctl* self, enum event_type evt_type,
static void ctl_server_event_connect(struct ctl* self,
enum event_type evt_type,
const char* client_id,
const char* client_hostname,
const char* client_username,
const struct ctl_server_client_info *info,
int new_connection_count)
{
json_t* params = pack_connection_event_params(client_id, client_hostname,
client_username, new_connection_count);
json_t* params =
pack_connection_event_params(info, new_connection_count);
ctl_server_enqueue_event(self, evt_type, params);
}
void ctl_server_event_connected(struct ctl* self,
const char* client_id,
const char* client_hostname,
const char* client_username,
const struct ctl_server_client_info *info,
int new_connection_count)
{
ctl_server_event_connect(self, EVT_CLIENT_CONNECTED, client_id,
client_hostname, client_username, new_connection_count);
ctl_server_event_connect(self, EVT_CLIENT_CONNECTED, info,
new_connection_count);
}
void ctl_server_event_disconnected(struct ctl* self,
const char* client_id,
const char* client_hostname,
const char* client_username,
const struct ctl_server_client_info *info,
int new_connection_count)
{
ctl_server_event_connect(self, EVT_CLIENT_DISCONNECTED, client_id,
client_hostname, client_username, new_connection_count);
ctl_server_event_connect(self, EVT_CLIENT_DISCONNECTED, info,
new_connection_count);
}
void ctl_server_event_capture_changed(struct ctl* self,

View File

@ -1053,12 +1053,14 @@ static void on_nvnc_client_cleanup(struct nvnc_client* client)
nvnc_log(NVNC_LOG_DEBUG, "Client disconnected, new client count: %d",
self->nr_clients);
char id[64];
snprintf(id, sizeof(id), "%u", wayvnc_client->id);
ctl_server_event_disconnected(self->ctl, id,
nvnc_client_get_hostname(client),
nvnc_client_get_auth_username(client),
self->nr_clients);
struct ctl_server_client_info info = {
.id = wayvnc_client->id,
.hostname = nvnc_client_get_hostname(client),
.username = nvnc_client_get_auth_username(client),
.seat = wayvnc_client->seat->name,
};
ctl_server_event_disconnected(self->ctl, &info, self->nr_clients);
if (self->nr_clients == 0) {
nvnc_log(NVNC_LOG_INFO, "Stopping screen capture");
@ -1086,12 +1088,14 @@ static void on_nvnc_client_new(struct nvnc_client* client)
nvnc_log(NVNC_LOG_DEBUG, "Client connected, new client count: %d",
self->nr_clients);
char id[64];
snprintf(id, sizeof(id), "%u", wayvnc_client->id);
ctl_server_event_connected(self->ctl, id,
nvnc_client_get_hostname(client),
nvnc_client_get_auth_username(client),
self->nr_clients);
struct ctl_server_client_info info = {
.id = wayvnc_client->id,
.hostname = nvnc_client_get_hostname(client),
.username = nvnc_client_get_auth_username(client),
.seat = wayvnc_client->seat->name,
};
ctl_server_event_connected(self->ctl, &info, self->nr_clients);
}
void parse_keyboard_option(struct wayvnc* self, const char* arg)