+ } catch (DBusException | IOException e) {
+ logger.error("Dbus command failed", e);
+ throw new UnexpectedErrorException("Dbus command failed", e);
+ }
+ }
+
+ @Override
+ public void handleCommand(
+ final Namespace ns, final List<Manager> managers, final SignalCreator c, final OutputWriter outputWriter
+ ) throws CommandException {
+ boolean ignoreAttachments = Boolean.TRUE.equals(ns.getBoolean("ignore-attachments"));
+
+ DBusConnection.DBusBusType busType;
+ if (Boolean.TRUE.equals(ns.getBoolean("system"))) {
+ busType = DBusConnection.DBusBusType.SYSTEM;
+ } else {
+ busType = DBusConnection.DBusBusType.SESSION;
+ }
+
+ try (var conn = DBusConnection.getConnection(busType)) {
+ final var signalControl = new DbusSignalControlImpl(c, m -> {
+ try {
+ final var objectPath = DbusConfig.getObjectPath(m.getSelfNumber());
+ return run(conn, objectPath, m, outputWriter, ignoreAttachments);
+ } catch (DBusException e) {
+ logger.error("Failed to export object", e);
+ return null;
+ }
+ }, DbusConfig.getObjectPath());
+ conn.exportObject(signalControl);
+
+ for (var m : managers) {
+ signalControl.addManager(m);