X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=bindings%2Fsamples%2FHelloWorld.c;h=134ea6207c8d540963c9225d064806a442a14056;hb=d559a044b7d6daa62437a38ff81161505b2e58b8;hp=002c4721720dcc159dd312af87793a8073f98add;hpb=bdff72f45e1d02f596595f6229d5bccf7c0827c2;p=src%2Fapp-framework-binder.git diff --git a/bindings/samples/HelloWorld.c b/bindings/samples/HelloWorld.c index 002c4721..134ea620 100644 --- a/bindings/samples/HelloWorld.c +++ b/bindings/samples/HelloWorld.c @@ -59,7 +59,7 @@ static int event_del(const char *tag) *p = e->next; /* destroys */ - afb_event_drop(e->event); + afb_event_unref(e->event); free(e); return 0; } @@ -412,6 +412,28 @@ static void broadcast(afb_req request) json_object_put(object); } +static void hasperm (afb_req request) +{ + const char *perm = afb_req_value(request, "perm"); + if (afb_req_has_permission(request, perm)) + afb_req_success_f(request, NULL, "permission %s granted", perm?:"(null)"); + else + afb_req_fail_f(request, "not-granted", "permission %s NOT granted", perm?:"(null)"); +} + +static void appid (afb_req request) +{ + char *aid = afb_req_get_application_id(request); + afb_req_success_f(request, aid ? json_object_new_string(aid) : NULL, "application is %s", aid?:"?"); + free(aid); +} + +static void uid (afb_req request) +{ + int uid = afb_req_get_uid(request); + afb_req_success_f(request, json_object_new_int(uid), "uid is %d", uid); +} + static int preinit() { AFB_NOTICE("hello binding comes to live"); @@ -450,6 +472,9 @@ static const afb_verb_v2 verbs[]= { { .verb="callsync", .callback=callsync }, { .verb="verbose", .callback=verbose }, { .verb="broadcast", .callback=broadcast }, + { .verb="hasperm", .callback=hasperm }, + { .verb="appid", .callback=appid }, + { .verb="uid", .callback=uid }, { .verb="exit", .callback=exitnow }, { .verb=NULL} };