X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-evt.c;h=8ae31cc5f810aa0bd980cac52e13f7f5ca60522e;hb=8d322ebdd04d6de2d5649626bbc23aae0d0ed556;hp=4924b8cb2b642bee647cc99b786176405463bf85;hpb=d8ef25780bffa6f91f013ef71b1ede908325e59d;p=src%2Fapp-framework-binder.git diff --git a/src/afb-evt.c b/src/afb-evt.c index 4924b8cb..8ae31cc5 100644 --- a/src/afb-evt.c +++ b/src/afb-evt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015, 2016 "IoT.bzh" + * Copyright (C) 2015, 2016, 2017 "IoT.bzh" * Author "Fulup Ar Foll" * Author José Bollo * @@ -94,12 +94,14 @@ struct afb_evt_watch { static int evt_broadcast(struct afb_evt_event *evt, struct json_object *obj); static int evt_push(struct afb_evt_event *evt, struct json_object *obj); static void evt_destroy(struct afb_evt_event *evt); +static const char *evt_name(struct afb_evt_event *evt); /* the interface for events */ static struct afb_event_itf afb_evt_event_itf = { .broadcast = (void*)evt_broadcast, .push = (void*)evt_push, - .drop = (void*)evt_destroy + .drop = (void*)evt_destroy, + .name = (void*)evt_name }; /* head of the list of listeners */ @@ -144,8 +146,8 @@ int afb_evt_broadcast(const char *event, struct json_object *object) } /* - * Broadcasts the event 'evt' with its 'object' - * 'object' is released (like json_object_put) + * Pushes the event 'evt' with 'obj' to its listeners + * 'obj' is released (like json_object_put) * Returns the count of listener taht received the event. */ static int evt_push(struct afb_evt_event *evt, struct json_object *obj) @@ -168,6 +170,14 @@ static int evt_push(struct afb_evt_event *evt, struct json_object *obj) return result; } +/* + * Returns the name associated to the event 'evt'. + */ +static const char *evt_name(struct afb_evt_event *evt) +{ + return evt->name; +} + /* * remove the 'watch' */