X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=bindings%2Fsamples%2FHelloWorld.c;h=fef87d2dc771d17bdc11ce44d586c5c81d213419;hb=refs%2Fchanges%2F19%2F14319%2F1;hp=4125e77f17aca5f779fcfd6b6155ebc202376546;hpb=85bca06fe0ee2923421f013da3e9f53abbfff673;p=src%2Fapp-framework-binder.git diff --git a/bindings/samples/HelloWorld.c b/bindings/samples/HelloWorld.c index 4125e77f..fef87d2d 100644 --- a/bindings/samples/HelloWorld.c +++ b/bindings/samples/HelloWorld.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015, 2016, 2017 "IoT.bzh" + * Copyright (C) 2015-2018 "IoT.bzh" * Author "Fulup Ar Foll" * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -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; } @@ -421,6 +421,19 @@ static void hasperm (afb_req request) 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"); @@ -460,6 +473,8 @@ static const afb_verb_v2 verbs[]= { { .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} };