X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=bindings%2Fintrinsics%2Fafb-dbus-binding.c;h=04bbad009445d3ee8d0d0384b7ceee2704205826;hb=65353dce81a629e042800bb7b86fcd869a76727e;hp=a5b7d788f0f689461919e7d8f4eaa92cc3c1bd10;hpb=24d000c2290126abf88204089d132229d63f9a05;p=src%2Fapp-framework-binder.git diff --git a/bindings/intrinsics/afb-dbus-binding.c b/bindings/intrinsics/afb-dbus-binding.c index a5b7d788..04bbad00 100644 --- a/bindings/intrinsics/afb-dbus-binding.c +++ b/bindings/intrinsics/afb-dbus-binding.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2017, 2018 "IoT.bzh" + * Copyright (C) 2015-2020 "IoT.bzh" * Author José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,14 +23,9 @@ #include #include -#define AFB_BINDING_VERSION 1 +#define AFB_BINDING_VERSION 3 #include -/* - * the interface to afb-daemon - */ -const struct afb_binding_interface *afbitf; - /* * union of possible dbus values */ @@ -371,7 +366,7 @@ static int packsingle(struct sd_bus_message *msg, const char *signature, struct goto error; if (json_object_is_type(item, json_type_array)) { /* Is an array! */ - count = json_object_array_length(item); + count = (int)json_object_array_length(item); index = 0; while(index < count) { rc = packsingle(msg, subsig, json_object_array_get_idx(item, index++)); @@ -466,7 +461,7 @@ static int packlist(struct sd_bus_message *msg, const char *signature, struct js } /* iterate over elements */ - count = json_object_array_length(list); + count = (int)json_object_array_length(list); index = 0; for (;;) { /* check state */ @@ -497,7 +492,7 @@ error: /* * handle the reply */ -static int on_rawcall_reply(sd_bus_message *msg, struct afb_req *req, sd_bus_error *ret_error) +static int on_rawcall_reply(sd_bus_message *msg, afb_req_t *req, sd_bus_error *ret_error) { struct json_object *obj = NULL; int rc; @@ -532,7 +527,7 @@ static int on_rawcall_reply(sd_bus_message *msg, struct afb_req *req, sd_bus_err * "arguments": "ARRAY of arguments" * } */ -static void rawcall(struct afb_req req) +static void rawcall(afb_req_t req) { struct json_object *obj; struct json_object *args; @@ -569,9 +564,9 @@ static void rawcall(struct afb_req req) /* get bus */ busname = strval(obj, "bus"); if (busname != NULL && !strcmp(busname, "system")) - bus = afb_daemon_get_system_bus(afbitf->daemon); + bus = afb_api_get_system_bus(req->api); else - bus = afb_daemon_get_user_bus(afbitf->daemon); + bus = afb_api_get_user_bus(req->api); /* creates the message */ rc = sd_bus_message_new_method_call(bus, &msg, destination, path, interface, member); @@ -601,32 +596,19 @@ cleanup: /* * array of the verbs exported to afb-daemon */ -static const struct afb_verb_desc_v1 binding_verbs[] = { +static const struct afb_verb_v3 binding_verbs[] = { /* VERB'S NAME SESSION MANAGEMENT FUNCTION TO CALL SHORT DESCRIPTION */ - { .name= "rawcall", .session= AFB_SESSION_NONE, .callback= rawcall, .info= "raw call to dbus method" }, - { .name= NULL } /* marker for end of the array */ + { .verb= "rawcall", .session= AFB_SESSION_NONE, .callback= rawcall, .info= "raw call to dbus method" }, + { .verb= NULL } /* marker for end of the array */ }; /* * description of the binding for afb-daemon */ -static const struct afb_binding binding_description = +const struct afb_binding_v3 afbBindingV3 = { - /* description conforms to VERSION 1 */ - .type= AFB_BINDING_VERSION_1, - .v1= { /* fills the v1 field of the union when AFB_BINDING_VERSION_1 */ - .prefix= "dbus", /* the API name (or binding name or prefix) */ - .info= "raw dbus binding", /* short description of of the binding */ + .api = "dbus", /* the API name (or binding name or prefix) */ + .info = "raw dbus binding", /* short description of of the binding */ .verbs = binding_verbs /* the array describing the verbs of the API */ - } }; -/* - * activation function for registering the binding called by afb-daemon - */ -const struct afb_binding *afbBindingV1Register(const struct afb_binding_interface *itf) -{ - afbitf = itf; /* records the interface for accessing afb-daemon */ - return &binding_description; /* returns the description of the binding */ -} -