From: José Bollo Date: Wed, 18 Dec 2019 09:42:15 +0000 (+0100) Subject: afb-evt: Improve name of listening functions X-Git-Tag: 8.99.5~4 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;ds=sidebyside;h=refs%2Fchanges%2F37%2F23537%2F1;p=src%2Fapp-framework-binder.git afb-evt: Improve name of listening functions Some more improvement on the road of the following bug: Bug-AGL: SPEC-3069 Signed-off-by: José Bollo Change-Id: I5ad6439fa6051566ab2caf271345eda1efcef398 --- diff --git a/src/afb-api-dbus.c b/src/afb-api-dbus.c index 04943c6e..f2145301 100644 --- a/src/afb-api-dbus.c +++ b/src/afb-api-dbus.c @@ -851,7 +851,7 @@ static int dbus_req_subscribe(struct afb_xreq *xreq, struct afb_event_x2 *event) uint64_t msgid; int rc; - rc = afb_evt_event_x2_add_watch(dreq->listener->listener, event); + rc = afb_evt_listener_watch_x2(dreq->listener->listener, event); sd_bus_message_get_cookie(dreq->message, &msgid); afb_api_dbus_server_event_send(dreq->listener->origin, 'S', afb_evt_event_x2_fullname(event), afb_evt_event_x2_id(event), "", msgid); return rc; @@ -865,7 +865,7 @@ static int dbus_req_unsubscribe(struct afb_xreq *xreq, struct afb_event_x2 *even sd_bus_message_get_cookie(dreq->message, &msgid); afb_api_dbus_server_event_send(dreq->listener->origin, 'U', afb_evt_event_x2_fullname(event), afb_evt_event_x2_id(event), "", msgid); - rc = afb_evt_event_x2_remove_watch(dreq->listener->listener, event); + rc = afb_evt_listener_unwatch_x2(dreq->listener->listener, event); return rc; } diff --git a/src/afb-evt.c b/src/afb-evt.c index 1c8798fd..400f8fbe 100644 --- a/src/afb-evt.c +++ b/src/afb-evt.c @@ -818,7 +818,7 @@ void afb_evt_listener_unref(struct afb_evt_listener *listener) * Makes the 'listener' watching 'evtid' * Returns 0 in case of success or else -1. */ -int afb_evt_watch_add_evtid(struct afb_evt_listener *listener, struct afb_evtid *evtid) +int afb_evt_listener_watch_evt(struct afb_evt_listener *listener, struct afb_evtid *evtid) { struct afb_evt_watch *watch; @@ -870,7 +870,7 @@ found: * Avoids the 'listener' to watch 'evtid' * Returns 0 in case of success or else -1. */ -int afb_evt_watch_sub_evtid(struct afb_evt_listener *listener, struct afb_evtid *evtid) +int afb_evt_listener_unwatch_evt(struct afb_evt_listener *listener, struct afb_evtid *evtid) { struct afb_evt_watch *watch; @@ -898,7 +898,7 @@ int afb_evt_watch_sub_evtid(struct afb_evt_listener *listener, struct afb_evtid * Avoids the 'listener' to watch 'eventid' * Returns 0 in case of success or else -1. */ -int afb_evt_watch_sub_eventid(struct afb_evt_listener *listener, uint16_t eventid) +int afb_evt_listener_unwatch_id(struct afb_evt_listener *listener, uint16_t eventid) { struct afb_evt_watch *watch; struct afb_evtid *evtid; @@ -991,7 +991,7 @@ uint16_t afb_evt_event_x2_id(struct afb_event_x2 *eventid) * Makes the 'listener' watching 'eventid' * Returns 0 in case of success or else -1. */ -int afb_evt_event_x2_add_watch(struct afb_evt_listener *listener, struct afb_event_x2 *eventid) +int afb_evt_listener_watch_x2(struct afb_evt_listener *listener, struct afb_event_x2 *eventid) { struct afb_evtid *evtid = afb_evt_event_x2_to_evtid(eventid); @@ -1002,14 +1002,14 @@ int afb_evt_event_x2_add_watch(struct afb_evt_listener *listener, struct afb_eve } /* search the existing watch for the listener */ - return afb_evt_watch_add_evtid(listener, evtid); + return afb_evt_listener_watch_evt(listener, evtid); } /* * Avoids the 'listener' to watch 'eventid' * Returns 0 in case of success or else -1. */ -int afb_evt_event_x2_remove_watch(struct afb_evt_listener *listener, struct afb_event_x2 *eventid) +int afb_evt_listener_unwatch_x2(struct afb_evt_listener *listener, struct afb_event_x2 *eventid) { struct afb_evtid *evtid = afb_evt_event_x2_to_evtid(eventid); @@ -1020,7 +1020,7 @@ int afb_evt_event_x2_remove_watch(struct afb_evt_listener *listener, struct afb_ } /* search the existing watch */ - return afb_evt_watch_sub_evtid(listener, evtid); + return afb_evt_listener_unwatch_evt(listener, evtid); } int afb_evt_event_x2_push(struct afb_event_x2 *eventid, struct json_object *object) diff --git a/src/afb-evt.h b/src/afb-evt.h index 3392ee3d..88308aaa 100644 --- a/src/afb-evt.h +++ b/src/afb-evt.h @@ -58,10 +58,9 @@ extern int afb_evt_evtid_push(struct afb_evtid *evtid, struct json_object *obj); extern int afb_evt_evtid_broadcast(struct afb_evtid *evtid, struct json_object *object); -extern int afb_evt_watch_add_evtid(struct afb_evt_listener *listener, struct afb_evtid *evtid); -extern int afb_evt_watch_sub_evtid(struct afb_evt_listener *listener, struct afb_evtid *evtid); -extern int afb_evt_watch_sub_eventid(struct afb_evt_listener *listener, uint16_t eventid); - +extern int afb_evt_listener_watch_evt(struct afb_evt_listener *listener, struct afb_evtid *evtid); +extern int afb_evt_listener_unwatch_evt(struct afb_evt_listener *listener, struct afb_evtid *evtid); +extern int afb_evt_listener_unwatch_id(struct afb_evt_listener *listener, uint16_t eventid); extern struct afb_event_x2 *afb_evt_event_x2_create(const char *fullname); extern struct afb_event_x2 *afb_evt_event_x2_create2(const char *prefix, const char *name); @@ -73,8 +72,8 @@ extern void afb_evt_event_x2_unref(struct afb_event_x2 *eventid); extern int afb_evt_event_x2_push(struct afb_event_x2 *eventid, struct json_object *object); extern int afb_evt_event_x2_unhooked_push(struct afb_event_x2 *eventid, struct json_object *object); -extern int afb_evt_event_x2_add_watch(struct afb_evt_listener *listener, struct afb_event_x2 *eventid); -extern int afb_evt_event_x2_remove_watch(struct afb_evt_listener *listener, struct afb_event_x2 *eventid); +extern int afb_evt_listener_watch_x2(struct afb_evt_listener *listener, struct afb_event_x2 *eventid); +extern int afb_evt_listener_unwatch_x2(struct afb_evt_listener *listener, struct afb_event_x2 *eventid); extern struct afb_evtid *afb_evt_event_x2_to_evtid(struct afb_event_x2 *eventid); extern struct afb_event_x2 *afb_evt_event_x2_from_evtid(struct afb_evtid *evtid); diff --git a/src/afb-export.c b/src/afb-export.c index 33891d31..4ad31cc0 100644 --- a/src/afb-export.c +++ b/src/afb-export.c @@ -1937,12 +1937,12 @@ void afb_export_undeclare(struct afb_export *export) int afb_export_subscribe(struct afb_export *export, struct afb_event_x2 *event) { - return afb_evt_event_x2_add_watch(export->listener, event); + return afb_evt_listener_watch_x2(export->listener, event); } int afb_export_unsubscribe(struct afb_export *export, struct afb_event_x2 *event) { - return afb_evt_event_x2_remove_watch(export->listener, event); + return afb_evt_listener_unwatch_x2(export->listener, event); } void afb_export_process_xreq(struct afb_export *export, struct afb_xreq *xreq) diff --git a/src/afb-stub-ws.c b/src/afb-stub-ws.c index b7e3c946..197d4cdc 100644 --- a/src/afb-stub-ws.c +++ b/src/afb-stub-ws.c @@ -167,7 +167,7 @@ static int server_req_subscribe_cb(struct afb_xreq *xreq, struct afb_event_x2 *e int rc; struct server_req *wreq = CONTAINER_OF_XREQ(struct server_req, xreq); - rc = afb_evt_event_x2_add_watch(wreq->stubws->listener, event); + rc = afb_evt_listener_watch_x2(wreq->stubws->listener, event); if (rc >= 0) rc = afb_proto_ws_call_subscribe(wreq->call, afb_evt_event_x2_id(event)); if (rc < 0) @@ -181,7 +181,7 @@ static int server_req_unsubscribe_cb(struct afb_xreq *xreq, struct afb_event_x2 struct server_req *wreq = CONTAINER_OF_XREQ(struct server_req, xreq); rc = afb_proto_ws_call_unsubscribe(wreq->call, afb_evt_event_x2_id(event)); - rc2 = afb_evt_event_x2_remove_watch(wreq->stubws->listener, event); + rc2 = afb_evt_listener_unwatch_x2(wreq->stubws->listener, event); if (rc >= 0 && rc2 < 0) rc = rc2; if (rc < 0) @@ -499,7 +499,7 @@ static void server_on_event_unexpected_cb(void *closure, uint16_t eventid) { struct afb_stub_ws *stubws = closure; - afb_evt_watch_sub_eventid(stubws->listener, eventid); + afb_evt_listener_unwatch_id(stubws->listener, eventid); } static void server_on_call_cb(void *closure, struct afb_proto_ws_call *call, const char *verb, struct json_object *args, uint16_t sessionid, uint16_t tokenid, const char *user_creds) diff --git a/src/afb-ws-json1.c b/src/afb-ws-json1.c index ec22e1ed..54d18785 100644 --- a/src/afb-ws-json1.c +++ b/src/afb-ws-json1.c @@ -279,13 +279,13 @@ static int wsreq_subscribe(struct afb_xreq *xreq, struct afb_event_x2 *event) { struct afb_wsreq *wsreq = CONTAINER_OF_XREQ(struct afb_wsreq, xreq); - return afb_evt_event_x2_add_watch(wsreq->aws->listener, event); + return afb_evt_listener_watch_x2(wsreq->aws->listener, event); } static int wsreq_unsubscribe(struct afb_xreq *xreq, struct afb_event_x2 *event) { struct afb_wsreq *wsreq = CONTAINER_OF_XREQ(struct afb_wsreq, xreq); - return afb_evt_event_x2_remove_watch(wsreq->aws->listener, event); + return afb_evt_listener_unwatch_x2(wsreq->aws->listener, event); }