/* creates the message */
msg = NULL;
- rc = sd_bus_message_new_method_call(api->sdbus, &msg, api->name, api->path, api->name, xreq->verb);
+ rc = sd_bus_message_new_method_call(api->sdbus, &msg, api->name, api->path, api->name, xreq->request.verb);
if (rc < 0)
goto error;
struct dbus_event *ev;
ev = api->client.events;
- while (ev != NULL && (ev->id != id || 0 != strcmp(afb_evt_event_fullname(ev->eventid), name)))
+ while (ev != NULL && (ev->id != id || 0 != strcmp(afb_evt_eventid_fullname(ev->eventid), name)))
ev = ev->next;
return ev;
/* no conflict, try to add it */
ev = malloc(sizeof *ev);
if (ev != NULL) {
- ev->eventid = afb_evt_create_event(name);
+ ev->eventid = afb_evt_eventid_create(name);
if (ev->eventid == NULL)
free(ev);
else {
*prv = ev->next;
/* destroys the event */
- afb_evt_event_unref(ev->eventid);
+ afb_evt_eventid_unref(ev->eventid);
free(ev);
}
/* destroys the event */
object = json_tokener_parse(data);
- afb_evt_push(ev->eventid, object);
+ afb_evt_eventid_push(ev->eventid, object);
}
/* subscribes an event */
uint64_t msgid;
int rc;
- rc = afb_evt_add_watch(dreq->listener->listener, eventid);
+ rc = afb_evt_eventid_add_watch(dreq->listener->listener, eventid);
sd_bus_message_get_cookie(dreq->message, &msgid);
- afb_api_dbus_server_event_send(dreq->listener->origin, 'S', afb_evt_event_fullname(eventid), afb_evt_event_id(eventid), "", msgid);
+ afb_api_dbus_server_event_send(dreq->listener->origin, 'S', afb_evt_eventid_fullname(eventid), afb_evt_eventid_id(eventid), "", msgid);
return rc;
}
int rc;
sd_bus_message_get_cookie(dreq->message, &msgid);
- afb_api_dbus_server_event_send(dreq->listener->origin, 'U', afb_evt_event_fullname(eventid), afb_evt_event_id(eventid), "", msgid);
- rc = afb_evt_remove_watch(dreq->listener->listener, eventid);
+ afb_api_dbus_server_event_send(dreq->listener->origin, 'U', afb_evt_eventid_fullname(eventid), afb_evt_eventid_id(eventid), "", msgid);
+ rc = afb_evt_eventid_remove_watch(dreq->listener->listener, eventid);
return rc;
}
+static void dbus_req_subcall(
+ struct afb_xreq *xreq,
+ const char *api,
+ const char *verb,
+ struct json_object *args,
+ void (*callback)(void*, int, struct json_object*),
+ void *cb_closure)
+{
+ ERROR("DBUS API doesn't support subcalls, info: %s/%s(%s)", api, verb, json_object_to_json_string(args));
+ callback(cb_closure, 1, afb_msg_json_reply_error("error", "subcall isn't supported", NULL, NULL));
+ json_object_put(args);
+}
+
const struct afb_xreq_query_itf afb_api_dbus_xreq_itf = {
.json = dbus_req_json,
.success = dbus_req_success,
.fail = dbus_req_fail,
.unref = dbus_req_destroy,
.subscribe = dbus_req_subscribe,
- .unsubscribe = dbus_req_unsubscribe
+ .unsubscribe = dbus_req_unsubscribe,
+ .subcall = dbus_req_subcall
};
/******************* server part **********************************/
dreq->json = json_object_new_string(dreq->request);
}
dreq->listener = listener;
- dreq->xreq.api = api->api;
- dreq->xreq.verb = method;
+ dreq->xreq.request.api = api->api;
+ dreq->xreq.request.verb = method;
afb_xreq_process(&dreq->xreq, api->server.apiset);
return 1;