diff --git a/proto/ei.proto b/proto/ei.proto index 8ba87d0..1ed2904 100644 --- a/proto/ei.proto +++ b/proto/ei.proto @@ -191,7 +191,7 @@ message ClientMessage { TouchMotion touch_motion = 15; TouchUp touch_up = 16; ConfigureName configure_name = 17; - ConfigureCapabilities configure_caps = 18; + ConfigureCapabilities configure_capabilities = 18; Frame frame = 19; StartEmulating start_emulating = 20; StopEmulating stop_emulating = 21; diff --git a/src/libei-proto.c b/src/libei-proto.c index bf63271..7f8be38 100644 --- a/src/libei-proto.c +++ b/src/libei-proto.c @@ -171,7 +171,7 @@ log_wire_message(struct ei *ei, const ClientMessage *msg, int error) MSG_STRING_CASE(TOUCH_MOTION); MSG_STRING_CASE(TOUCH_UP); MSG_STRING_CASE(CONFIGURE_NAME); - MSG_STRING_CASE(CONFIGURE_CAPS); + MSG_STRING_CASE(CONFIGURE_CAPABILITIES); MSG_STRING_CASE(FRAME); MSG_STRING_CASE(PROPERTY); } diff --git a/src/libeis-proto.c b/src/libeis-proto.c index 2d391d3..e086cf9 100644 --- a/src/libeis-proto.c +++ b/src/libeis-proto.c @@ -405,11 +405,11 @@ eis_proto_handle_message(struct eis_client *client, rc = call(configure_name, client, proto->configure_name->name); break; - case CLIENT_MESSAGE__MSG_CONFIGURE_CAPS: + case CLIENT_MESSAGE__MSG_CONFIGURE_CAPABILITIES: rc = call(configure_capabilities, client, - proto->configure_caps->policy_is_allow, - proto->configure_caps->allowed_capabilities, - proto->configure_caps->denied_capabilities); + proto->configure_capabilities->policy_is_allow, + proto->configure_capabilities->allowed_capabilities, + proto->configure_capabilities->denied_capabilities); break; case CLIENT_MESSAGE__MSG_FRAME: rc = call(frame, client, proto->frame->deviceid); diff --git a/src/libreis.c b/src/libreis.c index 952a258..fcbc764 100644 --- a/src/libreis.c +++ b/src/libreis.c @@ -77,16 +77,18 @@ reis_new(void) return reis; } +#define prepare_msg(_type, _struct, _field) \ + ClientMessage msg = CLIENT_MESSAGE__INIT; \ + _struct _field = _type##__INIT; \ + msg.msg_case = CLIENT_MESSAGE__MSG_##_type; \ + msg._field = &_field + _public_ int reis_apply(struct reis *reis, int eisfd) { if (reis->name) { - ConfigureName n = CONFIGURE_NAME__INIT; - n.name = reis->name; - - ClientMessage msg = CLIENT_MESSAGE__INIT; - msg.configure_name = &n; - msg.msg_case = CLIENT_MESSAGE__MSG_CONFIGURE_NAME; + prepare_msg(CONFIGURE_NAME, ConfigureName, configure_name); + configure_name.name = reis->name; int rc = send_msg(eisfd, &msg); if (rc) @@ -94,14 +96,10 @@ reis_apply(struct reis *reis, int eisfd) } if (!reis->policy_is_allow || reis->allow || reis->deny) { - ConfigureCapabilities c = CONFIGURE_CAPABILITIES__INIT; - c.policy_is_allow = reis->policy_is_allow; - c.allowed_capabilities = reis->allow; - c.denied_capabilities = reis->deny; - - ClientMessage msg = CLIENT_MESSAGE__INIT; - msg.configure_caps = &c; - msg.msg_case = CLIENT_MESSAGE__MSG_CONFIGURE_CAPS; + prepare_msg(CONFIGURE_CAPABILITIES, ConfigureCapabilities, configure_capabilities); + configure_capabilities.policy_is_allow = reis->policy_is_allow; + configure_capabilities.allowed_capabilities = reis->allow; + configure_capabilities.denied_capabilities = reis->deny; int rc = send_msg(eisfd, &msg); if (rc)