X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-monitor.c;h=369c5bf5d4ab7fb7adbe157a2d0d42fa0909b8c1;hb=017a0f3080978c1de1c1ed2342c10878be1614aa;hp=b361be79aac2b1b5fd0bc46b2f6deeec76ccb5dd;hpb=2c0d6171441fc3612c3cf60fda70a1d90b18be64;p=src%2Fapp-framework-binder.git diff --git a/src/afb-monitor.c b/src/afb-monitor.c index b361be79..369c5bf5 100644 --- a/src/afb-monitor.c +++ b/src/afb-monitor.c @@ -21,6 +21,7 @@ #include #include + #include #include "afb-api.h" @@ -28,6 +29,7 @@ #include "afb-api-so-v2.h" #include "afb-ditf.h" #include "afb-xreq.h" +#include "afb-trace.h" #include "verbose.h" #include "wrap-json.h" @@ -237,14 +239,10 @@ static struct json_object *get_verbosity(struct json_object *spec) static void get_one_api(struct json_object *resu, const char *name, struct json_object *spec) { struct json_object *o; - struct afb_api api; - int rc; - rc = afb_apiset_lookup(main_apiset, name, &api); - if (!rc) { - o = api.itf->describe ? api.itf->describe(api.closure) : NULL; + o = afb_apiset_describe(main_apiset, name); + if (o || afb_apiset_has(main_apiset, name)) json_object_object_add(resu, name, o); - } } /** @@ -324,18 +322,36 @@ static void f_set(struct afb_req req) afb_req_success(req, NULL, NULL); } -#if 0 -static void f_hook(struct afb_xreq *xreq) +static void *context_create() { - struct json_object *o, *v; + return afb_trace_create(&datav2.daemon, NULL); +} - o = afb_xreq_json(xreq); - if (json_object_object_get_ex(o, _verbosity_, &v)) { - set_verbosity(v); - } +static void context_destroy(void *pointer) +{ + struct afb_trace *trace = pointer; + afb_trace_unref(trace); +} - if (!xreq->replied) - afb_xreq_success(xreq, NULL, NULL); +static void f_trace(struct afb_req req) +{ + int rc; + struct json_object *add = NULL; + struct json_object *drop = NULL; + struct afb_trace *trace; + + trace = afb_req_context(req, context_create, context_destroy); + wrap_json_unpack(afb_req_json(req), "{s?o s?o}", "add", &add, "drop", &drop); + if (add) { + rc = afb_trace_add(req, add, trace); + if (rc) + return; + } + if (drop) { + rc = afb_trace_drop(req, drop, trace); + if (rc) + return; + } + afb_req_success(req, NULL, NULL); } -#endif