X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-svc.c;h=74f32eceb5585c3e981b7efc3c1a56bad80ca9c1;hb=7c7d610ccbd7e30204501622ebee6690aef5af0c;hp=03ff4b84b830ccb7a8853968ec49e1b2653a9b0b;hpb=5b5a2e4412eea806451c016da9fb285bc09c17ab;p=src%2Fapp-framework-binder.git diff --git a/src/afb-svc.c b/src/afb-svc.c index 03ff4b84..74f32ece 100644 --- a/src/afb-svc.c +++ b/src/afb-svc.c @@ -64,7 +64,7 @@ struct svc_req }; /* functions for services */ -static void svc_on_event(struct afb_svc *svc, const char *event, struct json_object *object); +static void svc_on_event(struct afb_svc *svc, const char *event, int eventid, struct json_object *object); static void svc_call(struct afb_svc *svc, const char *api, const char *verb, struct json_object *args, void (*callback)(void*, int, struct json_object*), void *closure); @@ -73,6 +73,12 @@ static const struct afb_service_itf service_itf = { .call = (void*)svc_call }; +/* the interface for events */ +static const struct afb_evt_itf evt_itf = { + .broadcast = (void*)svc_on_event, + .push = (void*)svc_on_event +}; + /* functions for requests of services */ static void svcreq_addref(struct svc_req *svcreq); static void svcreq_unref(struct svc_req *svcreq); @@ -127,10 +133,11 @@ struct afb_svc *afb_svc_create(int share_session, int (*init)(struct afb_service } /* initialises the listener if needed */ + svc->on_event = on_event; if (on_event == NULL) svc->listener = NULL; else { - svc->listener = afb_evt_listener_create((void*)svc_on_event, svc); + svc->listener = afb_evt_listener_create(&evt_itf, svc); if (svc->listener == NULL) goto error3; } @@ -156,9 +163,10 @@ error: /* * Propagates the event to the service */ -static void svc_on_event(struct afb_svc *svc, const char *event, struct json_object *object) +static void svc_on_event(struct afb_svc *svc, const char *event, int eventid, struct json_object *object) { svc->on_event(event, object); + json_object_put(object); } /*