X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-dbus.c;h=3d9da07f4d5d13de920b438ad6589cdb6050a9cc;hb=5b5a2e4412eea806451c016da9fb285bc09c17ab;hp=905c723d75f1942165938cd4bb8cd9e77a536518;hpb=6518887513840471ea9c5af7e534787717e6bd82;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-dbus.c b/src/afb-api-dbus.c index 905c723d..3d9da07f 100644 --- a/src/afb-api-dbus.c +++ b/src/afb-api-dbus.c @@ -32,6 +32,7 @@ #include "afb-common.h" #include "session.h" +#include "afb-msg-json.h" #include "afb-apis.h" #include "afb-api-so.h" #include "afb-context.h" @@ -295,6 +296,17 @@ static void api_dbus_client_call(struct api_dbus *api, struct afb_req req, struc } } +static int api_dbus_service_start(struct api_dbus *api, int share_session, int onneed) +{ + /* not an error when onneed */ + if (onneed != 0) + return 0; + + /* already started: it is an error */ + ERROR("The Dbus binding %s is not a startable service", api->name); + return -1; +} + /* receives events */ static int api_dbus_client_on_event(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { @@ -342,6 +354,7 @@ int afb_api_dbus_add_client(const char *path) /* record it as an API */ afb_api.closure = api; afb_api.call = (void*)api_dbus_client_call; + afb_api.service_start = (void*)api_dbus_service_start; if (afb_apis_add(api->api, afb_api) < 0) goto error2; @@ -400,19 +413,7 @@ static struct json_object *dbus_req_json(struct dbus_req *dreq) /* get the argument of the request of 'name' */ static struct afb_arg dbus_req_get(struct dbus_req *dreq, const char *name) { - struct afb_arg arg; - struct json_object *value, *root; - - root = dbus_req_json(dreq); - if (root != NULL && json_object_object_get_ex(root, name, &value)) { - arg.name = name; - arg.value = json_object_get_string(value); - } else { - arg.name = NULL; - arg.value = NULL; - } - arg.path = NULL; - return arg; + return afb_msg_json_get_arg(dbus_req_json(dreq), name); } static void dbus_req_reply(struct dbus_req *dreq, uint8_t type, const char *first, const char *second)