mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-06-14 07:08:28 +02:00
libeis: unify the wire message logging in one place
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
6c823b1308
commit
325622ed7c
1 changed files with 27 additions and 8 deletions
|
|
@ -143,9 +143,36 @@ eis_client_get_context(struct eis_client *client)
|
|||
return eis_client_parent(client);
|
||||
}
|
||||
|
||||
static inline void
|
||||
log_wire_message(struct eis *eis, const ServerMessage *msg)
|
||||
{
|
||||
const char *message = NULL;
|
||||
|
||||
#define MSG_STRING_CASE(_name) \
|
||||
case SERVER_MESSAGE__MSG_##_name: message = #_name; break;
|
||||
|
||||
switch (msg->msg_case) {
|
||||
case SERVER_MESSAGE__MSG__NOT_SET:
|
||||
abort();
|
||||
MSG_STRING_CASE(CONNECTED);
|
||||
MSG_STRING_CASE(DISCONNECTED);
|
||||
MSG_STRING_CASE(ADDED);
|
||||
MSG_STRING_CASE(REMOVED);
|
||||
break;
|
||||
default:
|
||||
assert(!"Unimplemented message type");
|
||||
break;
|
||||
}
|
||||
log_debug(eis, "sending wire message %s\n", message);
|
||||
|
||||
#undef MSG_STRING_CASE
|
||||
}
|
||||
|
||||
static int
|
||||
client_send_msg(struct eis_client *client, const ServerMessage *msg)
|
||||
{
|
||||
log_wire_message(eis_client_get_context(client), msg);
|
||||
|
||||
size_t msglen = server_message__get_packed_size(msg);
|
||||
Frame frame = FRAME__INIT;
|
||||
frame.length = msglen;
|
||||
|
|
@ -163,8 +190,6 @@ client_send_disconnect(struct eis_client *client)
|
|||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
Disconnected disconnected = DISCONNECTED__INIT;
|
||||
|
||||
log_debug(eis_client_get_context(client), "sending disconnect\n");
|
||||
|
||||
msg.disconnected = &disconnected;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_DISCONNECTED;
|
||||
|
||||
|
|
@ -177,8 +202,6 @@ client_send_connect(struct eis_client *client)
|
|||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
Connected connected = CONNECTED__INIT;
|
||||
|
||||
log_debug(eis_client_get_context(client), "sending connect\n");
|
||||
|
||||
msg.connected = &connected;
|
||||
msg.msg_case = SERVER_MESSAGE__MSG_CONNECTED;
|
||||
|
||||
|
|
@ -191,8 +214,6 @@ client_send_added(struct eis_client *client, struct eis_device *device)
|
|||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
Added added = ADDED__INIT;
|
||||
|
||||
log_debug(eis_client_get_context(client), "sending added\n");
|
||||
|
||||
added.deviceid = device->id;
|
||||
added.capabilities = device->capabilities;
|
||||
|
||||
|
|
@ -208,8 +229,6 @@ client_send_removed(struct eis_client *client, struct eis_device *device)
|
|||
ServerMessage msg = SERVER_MESSAGE__INIT;
|
||||
Removed removed = REMOVED__INIT;
|
||||
|
||||
log_debug(eis_client_get_context(client), "sending removed\n");
|
||||
|
||||
removed.deviceid = device->id;
|
||||
|
||||
msg.removed = &removed;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue