- busType = DBusConnection.DBusBusType.SESSION;
- }
- try (var dBusConn = DBusConnection.getConnection(busType)) {
- var ts = dBusConn.getRemoteObject(DbusConfig.getBusname(),
- DbusConfig.getObjectPath(username),
- Signal.class);
-
- handleCommand(command, ts, dBusConn, outputWriter);
- }
- } catch (DBusException | IOException e) {
- logger.error("Dbus client failed", e);
- throw new UnexpectedErrorException("Dbus client failed", e);
- }
- }
-
- private void handleCommand(
- Command command, Signal ts, DBusConnection dBusConn, OutputWriter outputWriter
- ) throws CommandException {
- if (command instanceof ExtendedDbusCommand) {
- ((ExtendedDbusCommand) command).handleCommand(ns, ts, dBusConn, outputWriter);
- } else if (command instanceof LocalCommand) {
- try {
- ((LocalCommand) command).handleCommand(ns, new DbusManagerImpl(ts, dBusConn), outputWriter);
- } catch (UnsupportedOperationException e) {
- throw new UserErrorException("Command is not yet implemented via dbus", e);
- } catch (DBusExecutionException e) {
- throw new UnexpectedErrorException(e.getMessage(), e);