X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=plugins%2Fsamples%2FHelloWorld.c;h=946f4b01171b0a717e81bdc430579e18c319aaf6;hb=e7cd169beafdcdb7f268184b0d8d75dff2c82e9c;hp=fd780e20981fafb38e2d1f60c44e141e7ff13a25;hpb=fc19b7d7974f9c64dffc40e180464d595a9805cd;p=src%2Fapp-framework-binder.git diff --git a/plugins/samples/HelloWorld.c b/plugins/samples/HelloWorld.c index fd780e20..946f4b01 100644 --- a/plugins/samples/HelloWorld.c +++ b/plugins/samples/HelloWorld.c @@ -23,33 +23,18 @@ #include "afb-plugin.h" #include "afb-req-itf.h" -static int fillargs(json_object *args, struct afb_arg arg) -{ - json_object *obj; - - obj = json_object_new_object(); - json_object_object_add (obj, "value", json_object_new_string(arg.value)); - json_object_object_add (obj, "path", json_object_new_string(arg.path)); - json_object_object_add (obj, "size", json_object_new_int64((int64_t)arg.size)); - json_object_object_add (args, arg.name && *arg.name ? arg.name : "", obj); - return 1; /* continue to iterate */ -} - // Sample Generic Ping Debug API -static void ping(struct afb_req request, json_object *jresp) +static void ping(struct afb_req request, json_object *jresp, const char *tag) { static int pingcount = 0; - json_object *query; - - query = json_object_new_object(); - afb_req_iterate(request, (void*)fillargs, query); + json_object *query = afb_req_json(request); - afb_req_success_f(request, jresp, "Ping Binder Daemon count=%d query=%s", ++pingcount, json_object_to_json_string(query)); + afb_req_success_f(request, jresp, "Ping Binder Daemon tag=%s count=%d query=%s", tag, ++pingcount, json_object_to_json_string(query)); } static void pingSample (struct afb_req request) { - ping(request, json_object_new_string ("Some String")); + ping(request, json_object_new_string ("Some String"), "pingSample"); } static void pingFail (struct afb_req request) @@ -59,12 +44,12 @@ static void pingFail (struct afb_req request) static void pingNull (struct afb_req request) { - ping(request, NULL); + ping(request, NULL, "pingNull"); } static void pingBug (struct afb_req request) { - pingNull((struct afb_req){NULL,NULL,NULL}); + ping((struct afb_req){NULL,NULL,NULL}, NULL, "pingBug"); } @@ -82,7 +67,7 @@ static void pingJson (struct afb_req request) { json_object_object_add(jresp,"eobj", embed); - ping(request, jresp); + ping(request, jresp, "pingJson"); } // NOTE: this sample does not use session to keep test a basic as possible