-static DBusHandlerResult incoming_call(DBusConnection *connection, DBusMessage *message, struct jbus *jbus)
-{
- struct jservice *srv;
- struct jreq *jreq;
- const char *str;
- const char *method;
- struct json_object *query;
-
- /* search for the service */
- if (!matchitf(jbus, message))
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- method = dbus_message_get_member(message);
- if (method == NULL)
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- srv = jbus->services;
- while(srv != NULL && strcmp(method, srv->method))
- srv = srv->next;
- if (srv == NULL)
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
- /* handle the message */
- jreq = malloc(sizeof * jreq);
- if (jreq == NULL)
- return DBUS_HANDLER_RESULT_NEED_MEMORY;
- jreq->request = dbus_message_ref(message);
- jreq->connection = dbus_connection_ref(jbus->connection);
-
- /* retrieve the string value */
- if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID))
- return reply_invalid_request(jreq);
- if (srv->oncall_s) {
- /* handling strings only */
- srv->oncall_s(jreq, str);
- }
- else {
- /* handling json only */
- query = json_tokener_parse(str);
- if (query == NULL)
- return reply_invalid_request(jreq);
- srv->oncall_j(jreq, query);
- json_object_put(query);
+ rc = sd_bus_call_method_async(jbus->sdbus, NULL, jbus->name, jbus->path, jbus->name, method, (void*)on_reply, resp, "s", query);
+ if (rc < 0) {
+ errno = -rc;
+ goto error2;