From 2e1e2ac4a61784d9cfd072e824d4aafd1d2b2f2a Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Thu, 16 Aug 2018 17:56:23 +0200 Subject: Migration to v3 This makes controller fully compatible with binding v3 and also keeps the compatibility with the Pre-V3 + DYNAPI bindings. Change-Id: Iaa47e51b9cb964bbe2f050784fca355c780673f8 Signed-off-by: Romain Forlot --- ctl-lib/ctl-event.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ctl-lib/ctl-event.c') diff --git a/ctl-lib/ctl-event.c b/ctl-lib/ctl-event.c index 235be28..4174000 100644 --- a/ctl-lib/ctl-event.c +++ b/ctl-lib/ctl-event.c @@ -22,16 +22,19 @@ #include "ctl-config.h" - // Event dynamic API-V3 mode -#ifdef AFB_BINDING_PREV3 +#if defined AFB_BINDING_PREV3 || AFB_BINDING_VERSION == 3 void CtrlDispatchApiEvent (AFB_ApiT apiHandle, const char *evtLabel, struct json_object *eventJ) { int idx = 0; CtlActionT* actions = NULL; AFB_ApiDebug (apiHandle, "Received event=%s, query=%s", evtLabel, json_object_get_string(eventJ)); // retrieve section config from api handle + #ifdef AFB_BINDING_PREV3 CtlConfigT *ctrlConfig = (CtlConfigT*) afb_dynapi_get_userdata(apiHandle); + #elif AFB_BINDING_VERSION == 3 + CtlConfigT *ctrlConfig = (CtlConfigT*) afb_api_get_userdata(apiHandle); + #endif for (idx = 0; ctrlConfig->sections[idx].key != NULL; ++idx) { @@ -67,7 +70,7 @@ void CtrlDispatchV2Event(const char *evtLabel, json_object *eventJ) { int index= ActionLabelToIndex(actions, evtLabel); if (index < 0) { - AFB_WARNING ("CtlDispatchEvent: fail to find uid=%s in action event section", evtLabel); + AFB_WARNING_V2("CtlDispatchEvent: fail to find uid=%s in action event section", evtLabel); return; } -- cgit 1.2.3-korg