- return sbus_call_sync(jbus->sbus, jbus->name, jbus->path, jbus->name,
- method, query);
+ sd_bus_message *smsg = NULL;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ char *result = NULL;
+ const char *reply;
+
+ /* makes the call */
+ if (mkerrno(sd_bus_call_method(jbus->sdbus, jbus->name, jbus->path, jbus->name, method, &error, &smsg, "s", query)) < 0)
+ goto error;
+
+ /* check if error */
+ if (sd_bus_message_is_method_error(smsg, NULL))
+ goto error;
+
+ /* check the returned type */
+ if (!sd_bus_message_has_signature(smsg, "s")
+ || sd_bus_message_read_basic(smsg, 's', &reply) < 0)
+ goto error;
+
+ /* get the result */
+ result = strdup(reply);
+
+error:
+ sd_bus_message_unref(smsg);
+ sd_bus_error_free(&error);
+ return result;