X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-dbus.c;h=13cbf7dbd0e891d4fdcd813d83f70a2be30d4a0f;hb=d69860c79a93845b78bbeafafbf04d12c60e63fa;hp=593232b93c851cd803c6b8919f3b183d44f0ae44;hpb=a05138e6bf1257b0e7b1ad90c974fb9e12f1d040;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-dbus.c b/src/afb-api-dbus.c index 593232b9..13cbf7db 100644 --- a/src/afb-api-dbus.c +++ b/src/afb-api-dbus.c @@ -756,7 +756,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; @@ -808,9 +808,9 @@ struct dbus_req { }; /* decrement the reference count of the request and free/release it on falling to null */ -static void dbus_req_destroy(void *closure) +static void dbus_req_destroy(struct afb_xreq *xreq) { - struct dbus_req *dreq = closure; + struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq); afb_context_disconnect(&dreq->xreq.context); json_object_put(dreq->json); @@ -819,9 +819,9 @@ static void dbus_req_destroy(void *closure) } /* get the object of the request */ -static struct json_object *dbus_req_json(void *closure) +static struct json_object *dbus_req_json(struct afb_xreq *xreq) { - struct dbus_req *dreq = closure; + struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq); return dreq->json; } @@ -836,25 +836,25 @@ static void dbus_req_reply(struct dbus_req *dreq, uint8_t type, const char *firs ERROR("sending the reply failed"); } -static void dbus_req_success(void *closure, struct json_object *obj, const char *info) +static void dbus_req_success(struct afb_xreq *xreq, struct json_object *obj, const char *info) { - struct dbus_req *dreq = closure; + struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq); dbus_req_reply(dreq, RETOK, json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN), info); } -static void dbus_req_fail(void *closure, const char *status, const char *info) +static void dbus_req_fail(struct afb_xreq *xreq, const char *status, const char *info) { - struct dbus_req *dreq = closure; + struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq); dbus_req_reply(dreq, RETERR, status, info); } static void afb_api_dbus_server_event_send(struct origin *origin, char order, const char *event, int eventid, const char *data, uint64_t msgid); -static int dbus_req_subscribe(void *closure, struct afb_event event) +static int dbus_req_subscribe(struct afb_xreq *xreq, struct afb_event event) { - struct dbus_req *dreq = closure; + struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq); uint64_t msgid; int rc; @@ -864,9 +864,9 @@ static int dbus_req_subscribe(void *closure, struct afb_event event) return rc; } -static int dbus_req_unsubscribe(void *closure, struct afb_event event) +static int dbus_req_unsubscribe(struct afb_xreq *xreq, struct afb_event event) { - struct dbus_req *dreq = closure; + struct dbus_req *dreq = CONTAINER_OF_XREQ(struct dbus_req, xreq); uint64_t msgid; int rc; @@ -976,12 +976,13 @@ static int api_dbus_server_on_object_called(sd_bus_message *message, void *userd } /* connect to the context */ + afb_xreq_init(&dreq->xreq, &afb_api_dbus_xreq_itf); if (afb_context_connect(&dreq->xreq.context, uuid, NULL) < 0) goto out_of_memory; 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; @@ -994,9 +995,6 @@ static int api_dbus_server_on_object_called(sd_bus_message *message, void *userd dreq->json = json_object_new_string(dreq->request); } dreq->listener = listener; - dreq->xreq.refcount = 1; - dreq->xreq.query = dreq; - dreq->xreq.queryitf = &afb_api_dbus_xreq_itf; dreq->xreq.api = api->api; dreq->xreq.verb = method; afb_apis_call(&dreq->xreq);