X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-so-v2.c;h=2d939fbcb17d7c1018427499b1dba766261172be;hb=c82c7a70449d31e2fc05c486e9959cb68b371e8e;hp=12b83aca6a7e954711c0b948801cf65df7fcd729;hpb=b529ded85a3e50a1aa6529e870b2e2f43e377ca2;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-so-v2.c b/src/afb-api-so-v2.c index 12b83aca..2d939fbc 100644 --- a/src/afb-api-so-v2.c +++ b/src/afb-api-so-v2.c @@ -24,7 +24,8 @@ #include -#include "afb-apis.h" +#include "afb-api.h" +#include "afb-apiset.h" #include "afb-svc.h" #include "afb-ditf.h" #include "afb-evt.h" @@ -68,10 +69,10 @@ static void call_cb(void *closure, struct afb_xreq *xreq) if (!verb) afb_xreq_fail_f(xreq, "unknown-verb", "verb %s unknown within api %s", xreq->verb, desc->binding->api); else - afb_xreq_call(xreq, verb->session, verb->callback); + afb_xreq_so_call(xreq, verb->session, verb->callback); } -static int service_start_cb(void *closure, int share_session, int onneed) +static int service_start_cb(void *closure, int share_session, int onneed, struct afb_apiset *apiset) { int (*start)(const struct afb_binding_interface *interface, struct afb_service service); void (*onevent)(const char *event, struct json_object *object); @@ -103,7 +104,7 @@ static int service_start_cb(void *closure, int share_session, int onneed) /* get the event handler if any */ onevent = desc->binding->onevent; - desc->service = afb_svc_create_v2(share_session, onevent, start, &desc->ditf.interface); + desc->service = afb_svc_create_v2(apiset, share_session, onevent, start, &desc->ditf.interface); if (desc->service == NULL) { /* starting error */ ERROR("Starting service %s failed", desc->binding->api); @@ -119,7 +120,27 @@ static void update_hooks_cb(void *closure) afb_ditf_update_hook(&desc->ditf); } -int afb_api_so_v2_add(const char *path, void *handle) +static int get_verbosity_cb(void *closure) +{ + struct api_so_v2 *desc = closure; + return desc->ditf.interface.verbosity; +} + +static void set_verbosity_cb(void *closure, int level) +{ + struct api_so_v2 *desc = closure; + desc->ditf.interface.verbosity = level; +} + +static struct afb_api_itf so_v2_api_itf = { + .call = call_cb, + .service_start = service_start_cb, + .update_hooks = update_hooks_cb, + .get_verbosity = get_verbosity_cb, + .set_verbosity = set_verbosity_cb +}; + +int afb_api_so_v2_add(const char *path, void *handle, struct afb_apiset *apiset) { int rc; struct api_so_v2 *desc; @@ -138,7 +159,7 @@ int afb_api_so_v2_add(const char *path, void *handle) ERROR("binding [%s] bad api name...", path); goto error; } - if (!afb_apis_is_valid_api_name(binding->api)) { + if (!afb_api_is_valid_name(binding->api)) { ERROR("binding [%s] invalid api name...", path); goto error; } @@ -177,10 +198,8 @@ int afb_api_so_v2_add(const char *path, void *handle) /* records the binding */ afb_api.closure = desc; - afb_api.call = call_cb; - afb_api.service_start = service_start_cb; - afb_api.update_hooks = update_hooks_cb; - if (afb_apis_add(binding->api, afb_api) < 0) { + afb_api.itf = &so_v2_api_itf; + if (afb_apiset_add(apiset, binding->api, afb_api) < 0) { ERROR("binding [%s] can't be registered...", path); goto error2; }