X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-dbus.c;h=4689ad1f7c0695979566ec1a801a08c68da824bc;hb=db01090e1f869965c07b12d9480fa6f3d2e7b1b0;hp=b8ec3d0273edf7705283b44d7d4abbd5e0fc02c8;hpb=03f863dd080d32f71c4a0755c02e23c72e4cb342;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-dbus.c b/src/afb-api-dbus.c index b8ec3d02..4689ad1f 100644 --- a/src/afb-api-dbus.c +++ b/src/afb-api-dbus.c @@ -19,6 +19,7 @@ #define NO_PLUGIN_VERBOSE_MACRO #include +#include #include #include #include @@ -32,8 +33,9 @@ #include "afb-session.h" #include "afb-msg-json.h" -#include "afb-apis.h" -#include "afb-api-so.h" +#include "afb-api.h" +#include "afb-apiset.h" +#include "afb-api-dbus.h" #include "afb-context.h" #include "afb-cred.h" #include "afb-evt.h" @@ -69,6 +71,7 @@ struct api_dbus struct sd_bus_slot *slot_call; struct afb_evt_listener *listener; /* listener for broadcasted events */ struct origin *origins; + struct afb_apiset *apiset; } server; }; }; @@ -110,7 +113,7 @@ static struct api_dbus *make_api_dbus_3(int system, const char *path, size_t pat goto error2; } api->api++; - if (!afb_apis_is_valid_api_name(api->api)) { + if (!afb_api_is_valid_name(api->api)) { errno = EINVAL; goto error2; } @@ -358,19 +361,6 @@ end: sd_bus_message_unref(msg); } -static int api_dbus_service_start(void *closure, int share_session, int onneed) -{ - struct api_dbus *api = closure; - - /* 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 broadcasted events */ static int api_dbus_client_on_broadcast_event(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { @@ -578,12 +568,11 @@ static int api_dbus_client_on_manage_event(sd_bus_message *m, void *userdata, sd } static struct afb_api_itf dbus_api_itf = { - .call = api_dbus_client_call, - .service_start = api_dbus_service_start + .call = api_dbus_client_call }; /* adds a afb-dbus-service client api */ -int afb_api_dbus_add_client(const char *path) +int afb_api_dbus_add_client(const char *path, struct afb_apiset *apiset) { int rc; struct api_dbus *api; @@ -621,7 +610,7 @@ int afb_api_dbus_add_client(const char *path) /* record it as an API */ afb_api.closure = api; afb_api.itf = &dbus_api_itf; - if (afb_apis_add(api->api, afb_api) < 0) + if (afb_apiset_add(apiset, api->api, afb_api) < 0) goto error2; return 0; @@ -756,7 +745,7 @@ static void afb_api_dbus_server_listener_free(struct listener *listener) free(listener); } -static struct listener *afb_api_dbus_server_listerner_get(struct api_dbus *api, const char *sender, struct afb_session *session) +static struct listener *afb_api_dbus_server_listener_get(struct api_dbus *api, const char *sender, struct afb_session *session) { int rc; struct listener *listener; @@ -982,7 +971,7 @@ static int api_dbus_server_on_object_called(sd_bus_message *message, void *userd session = dreq->xreq.context.session; /* get the listener */ - listener = afb_api_dbus_server_listerner_get(api, sd_bus_message_get_sender(message), session); + listener = afb_api_dbus_server_listener_get(api, sd_bus_message_get_sender(message), session); if (listener == NULL) goto out_of_memory; @@ -997,8 +986,7 @@ static int api_dbus_server_on_object_called(sd_bus_message *message, void *userd dreq->listener = listener; dreq->xreq.api = api->api; dreq->xreq.verb = method; - afb_apis_call(&dreq->xreq); - afb_xreq_unref(&dreq->xreq); + afb_xreq_process(&dreq->xreq, api->server.apiset); return 1; out_of_memory: @@ -1009,7 +997,7 @@ error: } /* create the service */ -int afb_api_dbus_add_server(const char *path) +int afb_api_dbus_add_server(const char *path, struct afb_apiset *apiset) { int rc; struct api_dbus *api; @@ -1037,6 +1025,7 @@ int afb_api_dbus_add_server(const char *path) INFO("afb service over dbus installed, name %s, path %s", api->name, api->path); api->server.listener = afb_evt_listener_create(&evt_broadcast_itf, api); + api->server.apiset = afb_apiset_addref(apiset); return 0; error3: sd_bus_release_name(api->sdbus, api->name);